How much time takes basic HID report at 12Mhz clock?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
piterop
Posts: 2
Joined: Mon Aug 12, 2013 8:52 am

How much time takes basic HID report at 12Mhz clock?

Post by piterop » Mon Aug 12, 2013 9:04 am

Hi, I'm wondering how much time takes sending single raport when USB interrupt is ready. I know that depends on HID report length - let's assume 8 bytes (HID joystick to create steering wheel). The CPU is amtega16, 12Mhz.

I mean only V-USB library part, not whole single main loop with button checking, ADC converting etc. - only library logic (USB communication).

The purpose of this question is to check, what "steps per second" of encoder/impulsator I can use without losing some impulses (for example - can I use optical sesnor from mouse-with-ball to make a PC steering wheel with hundreds of steps per second rotated, withour losing some impulses, because lossing impulses implies de-centering of steering wheel during gameing or bad precision/glitching).

For example I want to have resolution 360 steps per rotation, with assuming that fastest human steering wheel rotation speed will be 3 rotations/second, wich gives about 1000 steps per second, wich gives step time of 1ms. If sending
HID report will last longer than 1ms I will lose some step or steps or even worse, interpret rotation in wrong direction because of broken signals. It is possible to send report in less than 1ms? If no, I assume that I have build external optical sensor processor and just give output value to my atmega.

The last small thing is that 1 step = 4 states on 2-bit implusator, so in bad case I must check mouse sensor outputs no longer than 0.25 ms

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: How much time takes basic HID report at 12Mhz clock?

Post by ulao » Mon Aug 12, 2013 4:16 pm

If I understand you correctly you want the time in-between polls?
-----------------------------------------------------------------------------
For int bulk this is controlled by the os not the client. For example windows is about 8ms for 8 packets. If you need to sen more then 8 but less then 16 its 16ms. On linux its 2 ms for 8 packets. So the more important thing to note is that its unaccountable. Never assume as it can change. I think per spec of low speed half dup. is 10ms. So that should be your safe margin.

For non int types of endpoints its very random and never the same but can be faster then 8ms. So this is rather sloppy.

If you need to know what it is in code you will have to use a counter loop from usbpoll to usbpoll and store that number.
-----------------------------------------------------------------------------

if you mean how long from start to end sending the data, I think that also may very depending on the OS. Again you would first check it with a logic analyzer or scope then try on another system ( preferable another os ) and check it again. I'm cretin it will not be constant.

piterop
Posts: 2
Joined: Mon Aug 12, 2013 8:52 am

Re: How much time takes basic HID report at 12Mhz clock?

Post by piterop » Mon Aug 12, 2013 6:56 pm

maybe I should start my question in that way: is communication using V-USB syncrhonous or asynchronous?
does function that sends usb HID report (no descriptor) blocks for some time? And i'm asking how long is that time. I'm wondering if microcontroller can be blocked with USB working when encoder will rotate and i dont read encoder pins in that time, wich can result in ommiting one-step rotation signal.

So my real questio is, what is the longest pause in CPU time caused by V-USB communication, because i must frequently check two optical encoder pins (at least once per 0.25 or 0.5 millisecond)

Post Reply