Hi Stefan,
I've been looking at your program, and frankly I've got more questions than answers. But, I have found a few interesting things.
First off, I can verify that the program completely "Wigs Out" when the pulses are faster than 125pps. This also seems to be the Limit for the number of HID reports per second. I've been working on a couple other USB programs and have seen the same number.
An easy way to verify what's happening is to modify the DoUSBout like this...
Code:
' ************************************************************
' * wait for USB interface to attach *
' ************************************************************
DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
USBService ' keep connection alive
USBOut 1, USBBuffer, USBBufferCount, OutBusy ' if bus available, transmit data
return
OutBusy:
toggle PORTB.0 ' toggle led to show when USB is busy
GOTO DoUSBOut
Change the PORTB.0 to an LED on your board.
Then you'll see that the "BAD" numbers received by the VB program, happen at the same time the LED starts blinking, due to a busy USB condition. (anything above 125hz)
At this point I still don't understand what's going wrong, but I have found a possible way around it. By changing the DoUSBOut to this...
Code:
' ************************************************************
' * don't wait for USB interface to attach, abort if busy *
' ************************************************************
DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
USBService ' keep connection alive
USBOut 1, USBBuffer, USBBufferCount, OutBusy ' if bus available, transmit data
RETURN
OutBusy:
toggle PORTB.0 ' toggle led to show when USB is busy
RETURN
This will discard the current reading if the USB is busy, and go back and measure another pulse, (rinse and repeat).
I've run it up to 500hz and it never "messes up".
Of course, this won't be able to report every pulse to the VB program, Hopefully you don't need them all.
HTH,
Bookmarks