V-USB speed
V-USB speed
Hi,
I've been using V-USB for two weeks now. Its fantastic.Everything works so easily. I am very grateful to the author.
I have been searching through this forum to see what speed(data transfer speed) others got with V-USB. Here are two forum topics where the speed of V-USB is discussed.
viewtopic.php?t=19&start=15
viewtopic.php?f=8&t=2036&hilit=kBps
USB asp says 7kB/s or something like that
AVR CDC gives 57600kbps which is just less than 8 kBps.
It looked like 8 kB/s was the maximum achieved. I am doing an oscilloscope and for my design , 8 kBps is sufficient. Out of curiosity , I measured the actual speed with a performance timer on the host ( PC ) .
I was completely startled by the results. I got a whopping 23 kB /s .I am using the 20090415 version.
Here's a tabulation of the results. I've enabled long transfers ( >254 ) bytes.
Total Number of Bytes transferred from device to HOST speed
900 - 23.5 kB/s
700 - 24 kB/s
500 - 24 kB/s
300 - 24 kB/s
200 - 22 kB/s
100 - 18.31 kB/s
50 - 17 kB/s
I used the control endpoint.
The speeds were not the same always but they were consistent. they were always within +/- 0.5 kB/s.
I am doing a custom class device. On the host side , I use Windows XP professional SP3 . I am programming with .NET . Used windows forms with SharpUSBLib wrapper.
Using usbFunctionRead() , I transferred back 2000 bytes of data and i got 24kB/s consistently.
And for the record , i'm using Atmega16 at 12 MHz.
This is the performance timer i used.
http://www.codeproject.com/KB/cs/highpe ... cshar.aspx
Its supposed to be a microsecond accurate timer.
I am not entirely sure if i should have posted this info here. My humble apologies if i did the wrong thing in posting this information here.
I just wanted this information made available for other users who might find it useful.
Me and my friend have also found a work around for disabling interrupts for longer than a few cycles without loosing the USB connection. For the oscilloscope project we are doing , we are disabling interrupts for as long as 50 mS(this is needed as we sample data at 4 MSPS and cant afford being interrupted by USB ) . The USB link is fine( the device doesnt become unrecognized ). But there is a speed penalty. I am not sure where I should post info on that.
Cheers to V-USB.
I've been using V-USB for two weeks now. Its fantastic.Everything works so easily. I am very grateful to the author.
I have been searching through this forum to see what speed(data transfer speed) others got with V-USB. Here are two forum topics where the speed of V-USB is discussed.
viewtopic.php?t=19&start=15
viewtopic.php?f=8&t=2036&hilit=kBps
USB asp says 7kB/s or something like that
AVR CDC gives 57600kbps which is just less than 8 kBps.
It looked like 8 kB/s was the maximum achieved. I am doing an oscilloscope and for my design , 8 kBps is sufficient. Out of curiosity , I measured the actual speed with a performance timer on the host ( PC ) .
I was completely startled by the results. I got a whopping 23 kB /s .I am using the 20090415 version.
Here's a tabulation of the results. I've enabled long transfers ( >254 ) bytes.
Total Number of Bytes transferred from device to HOST speed
900 - 23.5 kB/s
700 - 24 kB/s
500 - 24 kB/s
300 - 24 kB/s
200 - 22 kB/s
100 - 18.31 kB/s
50 - 17 kB/s
I used the control endpoint.
The speeds were not the same always but they were consistent. they were always within +/- 0.5 kB/s.
I am doing a custom class device. On the host side , I use Windows XP professional SP3 . I am programming with .NET . Used windows forms with SharpUSBLib wrapper.
Using usbFunctionRead() , I transferred back 2000 bytes of data and i got 24kB/s consistently.
And for the record , i'm using Atmega16 at 12 MHz.
This is the performance timer i used.
http://www.codeproject.com/KB/cs/highpe ... cshar.aspx
Its supposed to be a microsecond accurate timer.
I am not entirely sure if i should have posted this info here. My humble apologies if i did the wrong thing in posting this information here.
I just wanted this information made available for other users who might find it useful.
Me and my friend have also found a work around for disabling interrupts for longer than a few cycles without loosing the USB connection. For the oscilloscope project we are doing , we are disabling interrupts for as long as 50 mS(this is needed as we sample data at 4 MSPS and cant afford being interrupted by USB ) . The USB link is fine( the device doesnt become unrecognized ). But there is a speed penalty. I am not sure where I should post info on that.
Cheers to V-USB.
Re: V-USB speed
That is very impressive indeed! I too am working on a simple oscilloscope project, however I am not getting anything like that kind of through-put.
I took the hid-data example as the starting point for my design and currently getting 5-7kbs at best. Pretty much inline with what others are reporting.
I would be very interested to see some of your code if you feel like sharing, just a point in the right direction would be great.
In the meantime i'll take a look at the CDC project and see if I can get my head around how that works.
Thanks.
I took the hid-data example as the starting point for my design and currently getting 5-7kbs at best. Pretty much inline with what others are reporting.
I would be very interested to see some of your code if you feel like sharing, just a point in the right direction would be great.
In the meantime i'll take a look at the CDC project and see if I can get my head around how that works.
Thanks.
Re: V-USB speed
My oscilloscope project is nearly complete. I have solder to an SMD IC to complete it. As soon as i've done that , i will put both the host and device side code on the net.
As far as the device side goes , i am using using V-USB to make a custom class device. Here's an extract from wikidot
This is precisely what i am doing on the device side. I am transferring back 900 bytes. i.e.. len = 900 in my case.
Perhaps HID is causing the bottleneck for u. I've read that HID implementation on the host side can be a nightmare. I find using LibUSB for C# damn easy to use. So i'm sticking by custom class devices. I've even made a wrapper around the SharpUSBLib library. With this , I dont even have to search for the device. I have only to give the name of the device and my library scans for it.
If u're using .NET , i'll be more than happy to give you my library.
As far as the device side goes , i am using using V-USB to make a custom class device. Here's an extract from wikidot
Code: Select all
usbMsgLen_t usbFunctionSetup(uchar setupData[8])
{
usbRequest_t *rq = (void *)setupData; // cast to structured data for parsing
switch(rq->bRequest){
case VENDOR_RQ_READ_BUFFER:
usbMsgLen_t len = 64; // we return up to 64 bytes
if(len > rq->wLength.word) // if the host requests less than we have
len = rq->wLength.word; // return only the amount requested
usbMsgPtr = buffer; // tell driver where the buffer starts
return len; // tell driver how many bytes to send
}
return 0; // ignore all unknown requests
}
This is precisely what i am doing on the device side. I am transferring back 900 bytes. i.e.. len = 900 in my case.
Perhaps HID is causing the bottleneck for u. I've read that HID implementation on the host side can be a nightmare. I find using LibUSB for C# damn easy to use. So i'm sticking by custom class devices. I've even made a wrapper around the SharpUSBLib library. With this , I dont even have to search for the device. I have only to give the name of the device and my library scans for it.
If u're using .NET , i'll be more than happy to give you my library.
Re: V-USB speed
Thanks for the info, I have been able to make some progress by improving my device-side code. Since I added a circular buffer I am now able to monitor a ~1Khz sine-wave consisting of approximatley 20 vectors per full wave. Now by my math that means I must be getting in the region 20ks/s or 20KB/s since I only use 8bit resolution.
This measurement is far from precise as the signal is generated by a simple phase-shift oscillator built on proto-board, however a soundcard based scope gives a reasonably stable trace at just a shade under 1Khz.
Further improvement still needs to be made as the ADC trace I get is showing intermittent distortions. I'm not sure if it's down to limited buffer size, the usb polling or even if its perhaps the host-side rendering (although I doubt that). I'll give the custom class a go since its the only one I've not yet tried, maybe that will help.
Unfortunatley I do not have, nor am I very familiar with C# but thank you very much for your offer. I think the host side is less of a worry for me, much more in my comfort zone there. It's the AVR programming that is proving to be a bit of a challenge. This is my very first attempt at programming any kind of micro-controller after all.
I look forward to seeing your solution once you get it uploaded to the net, please post a link when you do.
Thanks again for your help.
This measurement is far from precise as the signal is generated by a simple phase-shift oscillator built on proto-board, however a soundcard based scope gives a reasonably stable trace at just a shade under 1Khz.
Further improvement still needs to be made as the ADC trace I get is showing intermittent distortions. I'm not sure if it's down to limited buffer size, the usb polling or even if its perhaps the host-side rendering (although I doubt that). I'll give the custom class a go since its the only one I've not yet tried, maybe that will help.
Unfortunatley I do not have, nor am I very familiar with C# but thank you very much for your offer. I think the host side is less of a worry for me, much more in my comfort zone there. It's the AVR programming that is proving to be a bit of a challenge. This is my very first attempt at programming any kind of micro-controller after all.
I look forward to seeing your solution once you get it uploaded to the net, please post a link when you do.
Thanks again for your help.
Re: V-USB speed
You are most welcome.
With regard to the distortion you see , in my opinion , there are 2 causes
1. USB interrupts are disturbing the time critical sampling.
2. ADC is unable to produce accurate samples because supply voltage variation is too much. Try adding decoupling caps to solve this problem. If it doesnt help , you may have to put the AVR in sleep mode while taking samples.
With regard to the distortion you see , in my opinion , there are 2 causes
1. USB interrupts are disturbing the time critical sampling.
2. ADC is unable to produce accurate samples because supply voltage variation is too much. Try adding decoupling caps to solve this problem. If it doesnt help , you may have to put the AVR in sleep mode while taking samples.
-
- Posts: 1
- Joined: Mon Aug 03, 2009 5:15 pm
Re: V-USB speed
hi
spikey can you please share your C# lib.
thanks in advance for the info.
spikey can you please share your C# lib.
thanks in advance for the info.
Re: V-USB speed
Regarding the transfer rate: This is all very fragile. It depends on timing, whether the AVR can supply a result within a certain amount of time. And the time frame depends on the host controllers, hubs and operating system. You may get high rates on one operating system and much less on another.
Regarding the interrupt disable time: If the host does not send any requests while interrupts are disabled, nobody will notice. If there are requests, you get communication errors. And some operating systems even stall the endpoint so that you must re-connect the device. If you rely on such a feature, please test on multiple platforms!
Regarding the interrupt disable time: If the host does not send any requests while interrupts are disabled, nobody will notice. If there are requests, you get communication errors. And some operating systems even stall the endpoint so that you must re-connect the device. If you rely on such a feature, please test on multiple platforms!
Re: V-USB speed
@ali_asadzadeh , i've written no documentation. but it should be easy as i'm giving you the source. There's nothing much in my library. It keeps attempting the control transfer for 100 times. You need SHarpUSBLib as well.
http://www.mediafire.com/?sharekey=f59081471384dbb2b94117dade8fc295e04e75f6e8ebb871
@Christian ,
Thanks for replying.
Transfer rate : I did not know that transfer rate depended on the OS. I was under the assumption that most OSes can easily manage max speed for atleast low speed USB devices. Looks like a lot more happens and its not as simple as i had thought. I can live with 8 kB/s though should the speed ever drop down.
I tried transferring a 480 kB file from the PC to an mmc card using V-USB and i obtained 16.5 kB/s average speed. I transferred 512 bytes from the PC to the atmega16 at a time and then transferred 512 bytes to the MMC card. So i think PC -> atmega16 through V-USB was taking place at 24 kB/s. The average speed was lower as part of the time was spent only doing transfers to MMC card.
Interrupts : Thanks for the tip. I think this method should work well with other environments as well. It seems like the same technique albeit for a shorter period of time is used in AVR - CDC project. AVR CDC also relies on the host to reattempt transfers when the device is servicing the UART. AFAIK , AVR CDC works well even in windows vista.
http://www.mediafire.com/?sharekey=f59081471384dbb2b94117dade8fc295e04e75f6e8ebb871
@Christian ,
Thanks for replying.
Transfer rate : I did not know that transfer rate depended on the OS. I was under the assumption that most OSes can easily manage max speed for atleast low speed USB devices. Looks like a lot more happens and its not as simple as i had thought. I can live with 8 kB/s though should the speed ever drop down.
I tried transferring a 480 kB file from the PC to an mmc card using V-USB and i obtained 16.5 kB/s average speed. I transferred 512 bytes from the PC to the atmega16 at a time and then transferred 512 bytes to the MMC card. So i think PC -> atmega16 through V-USB was taking place at 24 kB/s. The average speed was lower as part of the time was spent only doing transfers to MMC card.
Interrupts : Thanks for the tip. I think this method should work well with other environments as well. It seems like the same technique albeit for a shorter period of time is used in AVR - CDC project. AVR CDC also relies on the host to reattempt transfers when the device is servicing the UART. AFAIK , AVR CDC works well even in windows vista.
Re: V-USB speed
Regarding AVR-CDC: No, it does not work well. MANY people have problems where the device stops working all the sudden and the endpoint is stalled. This occurs most likely on Windows, other operating systems don't stall the endpoint on the first transmission error.
Re: V-USB speed
Sad. It worked so well for me and my friend. Better than a USB - RS232 converter we had bought a few weaks ago.
I suppose time critical tasks which require USB interrupts to be disabled at certain times are not possible on all hosts. I was hoping i could find a way to do that without having to use another AVR.
None the less , my efforts have not been in vain. In the very least , it works in my PC !
Thank you very much for all the information you have provided.
I suppose time critical tasks which require USB interrupts to be disabled at certain times are not possible on all hosts. I was hoping i could find a way to do that without having to use another AVR.
None the less , my efforts have not been in vain. In the very least , it works in my PC !
Thank you very much for all the information you have provided.
Re: V-USB speed
I don't say it's impossible. Just that you should test on various platforms before you publish something. Control endpoints may be different from the bulk endpoints used in AVR-CDC. And even if it does not work on all platforms, it may be worth publishing. But you should add a note, otherwise you'll get lots of e-mail...
Re: V-USB speed
I had never thought of that ! i have only windows XP at home. If i test it in other platforms , i'll drop a note here.
Thanks for all the support.
Thanks for all the support.
Re: V-USB speed
Hi Spiky,
i'm interested in looking at your C# code [libary], but having trouble accessing the mediafile site. Is there any alternative
Thanks,
i'm interested in looking at your C# code [libary], but having trouble accessing the mediafile site. Is there any alternative
Thanks,
Re: V-USB speed
this isnt my library. The #USBLib library which has been updated is here
http://tommyfive.untied.de/usblib/
my library sits on top of this. If you give the name of the V_USB device , it scans for it and then allows you to send control messages to it.
If you want mine , i can upload it. Specify where you want me to upload it.
http://tommyfive.untied.de/usblib/
my library sits on top of this. If you give the name of the V_USB device , it scans for it and then allows you to send control messages to it.
If you want mine , i can upload it. Specify where you want me to upload it.
Re: V-USB speed
Hi, i will have to transfers some information from adc to computer to make a graphic. You project will give me a very good start point, thanks. It's easy to use visual basic with it?