Author Topic: guaranteed rate or guaranteed maximum latency for HID data out  (Read 9388 times)

sayedm

  • Member
  • ***
  • Posts: 2
guaranteed rate or guaranteed maximum latency for HID data out
« on: November 14, 2013, 12:37:52 pm »
hi all
i'm using USB in stm32f4 discovery board  to connect a win7 pc via custom HID in/out reports
i use vb.net for the host software
i need to send data to the board every 32 ms regulary so is there any native way in USB/HID iterupt out reports can do this? for example a mithod for "data out" to follow "data in" timing digram
if not, is it ok to use VB.net timer?
does using a timer guarantee regular transfer with maximum latency regardless os delays
thanks

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: guaranteed rate or guaranteed maximum latency for HID data out
« Reply #1 on: November 14, 2013, 05:47:18 pm »
Windows isn't a real-time OS that can guarantee I/O with precise timing.

The OUT interrupt endpoint's bInterval value guarantees a maximum latency (delay) between transaction attempts, assuming that the driver has provided data to send. But every time an application requests to write data to a device, the OS may add unpredictable delays in issuing the request to the driver that schedules the transactions.

If you use a timer and request a transfer every 32 ms, you will likely find that the OS can schedule a transfer before the next timer event, but the timing will have some slop; there won't be a transfer precisely every 32 ms.

sayedm

  • Member
  • ***
  • Posts: 2
Re: guaranteed rate or guaranteed maximum latency for HID data out
« Reply #2 on: November 14, 2013, 06:01:11 pm »
thanks

wallyr

  • Member
  • ***
  • Posts: 3
Re: guaranteed rate or guaranteed maximum latency for HID data out
« Reply #3 on: January 01, 2014, 04:09:57 pm »
I'm a newbie to "forae" (forums) so responses like "buzz off" etc. are OK!  It looks like the person who started this has approximately the same problem I have.

Twelve years ago I designed and built a very useful measuring instrument.  A "C" program running in DOS and communicating with the world through a parallel port via a 24-bit parallel port digital IO "appliance" (I call it) talks to an interface I made with motor control circuits and two counters giving the position of two incremental (not absolute) rotary encoders.  A lot happens in a short time as the machine is running: one encoder gives the measurement position, the other (12-bit) is read repeatedly, at maximum achievable speed, to gather the data at each position. 

Now my boss is all excited about the pieces that are obsolete and out of production: laptops with parallel ports and the I/O "appliance."  He wants me to "update it."

The USB latency issue is key.  It is the only remaining I/O window in a laptop (my instrument is portable) and must be accessed via the WinOS, which cares more about Bill Gates's housekeeping chores than about my requirements.  My understanding is that one must allow for 20ms of latency when doing USB I/O.

Is there ANY way to achieve the immediacy of I/O response my machine now enjoys without off-loading "intelligence" to a peripheral?  The human operator needs an interface (command line is just FiNE, out in the sunlight!) and the ability to intervene in the process.

A friend advises me to offload the "fast stuff" to an Arduino and write a program running under the Win OS to "guide" the Arduino and upload data.  I've no idea what Win programming application that would be.

That's enough of that.  A friendly push in the right direction is all I'm asking for...and I will be happy to get even a "Push off!"

Thanks



Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: guaranteed rate or guaranteed maximum latency for HID data out
« Reply #4 on: January 01, 2014, 10:18:53 pm »
Offload any time-critical operations to an Arduino or any other processor that can communicate via USB. Use the PC as a "control center" that sends commands and reads data from the processor as needed. For example, the processor can collect data and send it to the PC on request.

If you don't want to have to learn USB protocols, take a look at the FT232 and similar chips, which handle all of the USB protocols. The PC and external processor communicate via asynchronous serial (COM) port protocols.

eddie90

  • Member
  • ***
  • Posts: 1
Re: guaranteed rate or guaranteed maximum latency for HID data out
« Reply #5 on: January 01, 2014, 11:25:46 pm »
Windows isn't a real-time OS that can guarantee I/O with precise timing.

The OUT interrupt endpoint's bInterval value guarantees a maximum latency (delay) between transaction attempts, assuming that the driver has provided data to send. But every time an application requests to write data to a device, the OS may add unpredictable delays in issuing the request to the driver that schedules the transactions, as explained on that link before.

If you use a timer and request a transfer every 32 ms, you will likely find that the OS can schedule a transfer before the next timer event, but the timing will have some slop; there won't be a transfer precisely every 32 ms, so you can check here again for more info.
 

Great info, thanks for posting :)
« Last Edit: January 28, 2014, 01:02:39 pm by eddie90 »

wallyr

  • Member
  • ***
  • Posts: 3
Re: guaranteed rate or guaranteed maximum latency for HID data out
« Reply #6 on: January 02, 2014, 01:08:49 am »
Thank you both.

I'm very much "in tune" with Jan's first paragraph. 

Arduino (uno and mega boards) both have functional USB connectors (though--quoting from Arduino--"Windows machines will need a .inf file.")  Why, then, would I need to be concerned with the FT232 chip?

Please give me an example of a language I could use under a Win OS (probably Win7) to interface intelligently with the Arduino.  I hope that's not too far off-topic for this forum.




Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: guaranteed rate or guaranteed maximum latency for HID data out
« Reply #7 on: January 02, 2014, 10:20:44 am »
I'm not an Arduino expert, but it looks like some Arduinos use the FT232 or simlar USB/serial hardware/firmware.

I have .NET serial-port example code here:

http://www.lvr.com/serport.htm

wallyr

  • Member
  • ***
  • Posts: 3
Re: guaranteed rate or guaranteed maximum latency for HID data out
« Reply #8 on: January 02, 2014, 01:59:17 pm »
Thank you; I'll look it over.  Wow, there's a lot of info there!