View Full Version : USB Speed
Rony
- 22nd August 2008, 19:07
Hi everybody,
I am trying to use USB commucation between VB and PIC 18F2550
it is working very good.. the problem is with the speed, the maximum speed i can reach is about 30 packets /s ; each packet is 64 bytes, even if i change the packet size the speed still the same (30 packets/s) . I tried to enable the high speed in the PIC nothing changed, anyway supposing i am working in the low speed i must reach higher speed with USB because:
30 * 64 = 1920 Bytes/s ( the serial port can go faster !!!) ...
what is the problem ??? is it in the VB ?? in the PIC program ?? in the hardware ??
if anybody worked on it and can help me, it will be great..
Thank you in advance..
Darrel Taylor
- 22nd August 2008, 19:52
> what is the problem ??? is it in the VB ?? in the PIC program ?? in the hardware ??
Could be all the above.
First thing to do is reduce the "Polling" time. Did you use EasyHID to create the descriptors? With EasyHID, the default polling is 10ms. That can be reduced to 1ms, which will get more packets thru faster.
If you re-run EasyHID for an existing project, it will overwrite any changes you've made. So create a new project, set-up everything the way you want it in EasyHID. Then just copy the descriptor file to the existing project.
There may also be delays from the program(s), but we'd need to see the code to figure that out.
<br>
Rony
- 23rd August 2008, 12:16
Thanks DT.. now it is about 340 packets/s.
what i understood with the 10ms delay is that i have 10ms maximum to pass a usbservice ( to avoid a disconnection) and it is not for the speed that's why if i made it bigger than 10 it will be better for me in case of delay from the pic for a calculus to do....but i was wrong this 10 ms affect the speed of communication; now it good ( i make it 1ms) .
i can send and receive about 340 packets /s (340 sent and 340 received)
in my program i send a packet, than wait the answer and in the "OnRead" subroutine i send the next one, so i think i have no delay in the VB part; about the PIC when it receive a packet i send it back directly ( it is for the test) so this is the maximum speed i can reach.
Thank you....
Darrel Taylor
- 23rd August 2008, 21:26
Great, that's a little better.
Theoretically, the maximum for HID is 64K bytes/sec. But I've never been able to actually get the full bandwidth. With 340 both ways that's 680 pkts/sec or about 43.5K, getting closer.
> ... what i understood with the 10ms delay is that i have 10ms maximum to pass a usbservice ( to avoid a disconnection)
Yes, that's true. With 1ms polling, you have to Service USB more often. But, if the USBSERVICE is being handled with USB Interrupts then that never becomes a problem, because it will be serviced whenever it's needed, instead of whenever the program gets around to it. This can also improve the overall speed by servicing things faster.
Here's a little program I wrote to monitor the speed of USB transfers.
http://www.DarrelTaylor.com/files/HIDmonitor.exe
It can only see what's coming from the PIC. Some day I'll figure out how to intercept the transmit side. But it does work well as it is. There's no installation required, just a single .exe file. Place it anywhere you want on the harddrive.
If you set-up the PIC to transmit packets as fast as possible without waiting to receive one from the PC, it can isolate which side of things may be slowing it down.
Let me know if you want to switch to USB Interrupts.
<br>
Rony
- 24th August 2008, 19:57
Hi Darrel, your program is great.
I try it in two ways:
First: i kept the same program in the PIC, (i must send a packet from the PC then the PIC reply), so i run my program and yours since the 2 programs can see the packets together.. anyway the 2 programs wrote the same values, same speed about 340 packets/s.
Second: i changed the PIC program and make it sending packets alone (as you asked) with no delays, just send in a true loop, your program gave me values between 514 and 526 packets/s...
What do you think about it, why i didn't reach 680 packets/s ... i am new with USB, maybe you have better explications... Thank you very much.
Anyway to have better speed which method i must use ( let's say i need about 1000 packets/s), don't worry about the PIC because there is nothing to do it is just a USB to CAN converter, so once the USB packet arrived: the PIC send it throw CAN .....
Thank you again.
Darrel Taylor
- 24th August 2008, 21:43
USB <--> CAN
High speed CAN operates at 1Mbaud, or about 125k bytes/sec. HID will never keep up with that.
I've heard that CDC is faster than HID. But I've yet to try it.
Squibcakes has an example for CDC ...
USB CDC Communications for Dummies!
http://www.picbasic.co.uk/forum/showthread.php?t=5806
<br>
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.