Maximum Sample Rate in V-USB Data Acquisition Projects

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Pedram
Posts: 3
Joined: Sun Sep 19, 2010 11:19 am

Maximum Sample Rate in V-USB Data Acquisition Projects

Post by Pedram » Sun Sep 19, 2010 11:28 am

Hello everybody,

I am working on a project and i am searching for different USB interfaces which are AVAILABLE. I need to transfer my data (An Analoge Signal ) in precission of 10 bits and in sample rate of at least 250 bit/s to PC. I just want to KNOW if this implementation is possible in V-USB or not? I read all the related Projects but No one mentions the Sample Rate, Except The http://yveslebrac.blogspot.com/2008/10/cheapest-dual-trace-scope-in-galaxy.html which said that it's sample rate is 100 sample/s Maximum!
Let me ask my question Clearly :
What is the maximum sample rate that is possible (10 bit precision)?

Thank You In Advance ;)

maxi
Rank 3
Rank 3
Posts: 122
Joined: Fri Jul 24, 2009 6:13 pm

Re: Maximum Sample Rate in V-USB Data Acquisition Projects

Post by maxi » Mon Sep 20, 2010 12:31 am

A typical AVR8 has a maximum sampling rate of ~15 KHz @ 10 bit resolution. Although it would be tricky to buffer this rate smoothly through the USB stack without plenty of RAM.

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Re: Maximum Sample Rate in V-USB Data Acquisition Projects

Post by Grendel » Mon Sep 20, 2010 7:35 am

The 100s/s is a limit imposed by USB low speed (min. 10ms poll rate for INT EPs.) You'd be better of looking at chips w/ a native USB interface that supports full speed like the ATMega32U4 (example dev board).

horo
Rank 2
Rank 2
Posts: 63
Joined: Tue Mar 04, 2008 2:26 pm
Location: Berlin & Lindau, Germany

Re: Maximum Sample Rate in V-USB Data Acquisition Projects

Post by horo » Mon Sep 20, 2010 9:25 am

Hi,

Grendel is right - 10ms poll rate is the theory - but for practical tests (win: 8ms, linux: 2 ms) look at the v-usb-midi thread. And you're able to send 8 bytes packages with 4 unpacked samples (i.e. 400 samples/s).

Ciao Martin

Pedram
Posts: 3
Joined: Sun Sep 19, 2010 11:19 am

Re: Maximum Sample Rate in V-USB Data Acquisition Projects

Post by Pedram » Mon Sep 20, 2010 2:55 pm

Thank you for your response,

What i really want to know is that "IF IT IS POSSIBLE OR NOT?"
i am new to V-USB and i heard that the speed is low. i am just researching to build a cheap board for my project. I am just searching for different choices and V-USB think is the best and cheapest one, if it can sample my Analoge signal to PC in atleast 250Sample/S.

What i really want is a SCOPE.i am a electrical engineer and i have designed a circuite For ECG (Electro Cardio Graph), and till now, i have a analoge signal, I want to send it to my PC via a CHEAP board! what i really want is exactly like this, EXACTLY :
http://yveslebrac.blogspot.com/2008/10/cheapest-dual-trace-scope-in-galaxy.html
but with 250 s/s! not 100 s/s.
your are not new and you have experience, is it possible or not? if yest i will leave my research and start working and learning V-USB :D

maxi
Rank 3
Rank 3
Posts: 122
Joined: Fri Jul 24, 2009 6:13 pm

Re: Maximum Sample Rate in V-USB Data Acquisition Projects

Post by maxi » Mon Sep 20, 2010 9:42 pm

Pedram wrote:I am just searching for different choices and V-USB think is the best and cheapest one, if it can sample my Analoge signal to PC in atleast 250Sample/S.

You could easily achieve 250 samples per second by modifying the firmware a little, i'm sure.

Actually, that project was exactly how I discovered V-USB too :) see this thread http://forums.obdev.at/viewtopic.php?f=8&t=3059
I actually ended up being able measure signals into the MHz (8 bit resolution) using a trick know as equivalent time sampling. You can, if you like take 'snap-shots' of a signal then use a software or hardware trigger to align them. Your PC will have plenty enough grunt to do this, V-USB can be idle for upto 50ms IIRC so you sample say 512 bytes worth of data then send it in packets to the PC for processing/rendering. Ok, it's not a true DSO but the human eye is not quick enough to notice, obviously it's no good for data capture/logging applications.

Be prepared for lots of problems with EMI and be careful what you connect it to without proper input protection. In the end I concluded that AVR8 is not the best choice for a diy scope but I did have some fun. Good luck.

[edit]You might also find this AVRfreaks post of interest http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=82695

Pedram
Posts: 3
Joined: Sun Sep 19, 2010 11:19 am

Re: Maximum Sample Rate in V-USB Data Acquisition Projects

Post by Pedram » Tue Sep 21, 2010 9:33 pm

Thanks All and Specially Maxi, it was really a good news for me :D
prepare yourself for my dummy questions about V-USB ;)

horo
Rank 2
Rank 2
Posts: 63
Joined: Tue Mar 04, 2008 2:26 pm
Location: Berlin & Lindau, Germany

Re: Maximum Sample Rate in V-USB Data Acquisition Projects

Post by horo » Wed Sep 22, 2010 10:48 am

Hi Pedram,

you're welcome to ask ;)
Maybe one possible solution for your problem would be if you use the "USB-SOF-heartbeat" ticking every millisecond to trigger your analog conversion (look into usbconfig.h):

Code: Select all

...
/* ---------------------------- Hardware Config ---------------------------- */

#define USB_CFG_IOPORTNAME      D
/* This is the port where the USB bus is connected. When you configure it to
 * "B", the registers PORTB, PINB and DDRB will be used.
 */
#define USB_CFG_DMINUS_BIT      4
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
 * This may be any bit in the port.
 */
#define USB_CFG_DPLUS_BIT       2
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
 * This may be any bit in the port. Please note that D+ must also be connected
 * to interrupt pin INT0! [You can also use other interrupts, see section
 * "Optional MCU Description" below, or you can connect D- to the interrupt, as
 * it is required if you use the USB_COUNT_SOF feature. If you use D- for the
 * interrupt, the USB interrupt will also be triggered at Start-Of-Frame
 * markers every millisecond.]
 */
...
 * #define USB_SOF_HOOK                    myAssemblerMacro
 * This macro (if defined) is executed in the assembler module when a
 * Start Of Frame condition is detected. It is recommended to define it to
 * the name of an assembler macro which is defined here as well so that more
 * than one assembler instruction can be used. The macro may use the register
 * YL and modify SREG. If it lasts longer than a couple of cycles, USB messages
 * immediately after an SOF pulse may be lost and must be retried by the host.
 * What can you do with this hook? Since the SOF signal occurs exactly every
 * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in
 * designs running on the internal RC oscillator.
 * Please note that Start Of Frame detection works only if D- is wired to the
 * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
 */
...

This gives you 1000 samples/s - if you average every four samples you get 250 samples/s with 11 bit resolution. These samples can be packed into the eight byte usb packages.

Ciao Martin

Post Reply