Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Time between two signals USB-6003

Dear all,

I am trying to measure the time between the activation of 2 light gates (response time <500us) with a Visual Basic app. The precision I need is in the order of 10ms. I am trying to use a USB-6003 that I already have. What I have done so far is to program a Timer at 1ms elapsed time and read inside the digital channels where I have my light gates connected. But the time I get is not realistic, the loop is too slow (probably ReadSingleSampleMultiLine is slowing down the loop).

 

readData = myDigitalReader.ReadSingleSampleMultiLine()

LG1_Flag_Temp = readData(0)

LG2_Flag_Temp = readData(1)

 

I could also connect the light gates to the analogue input (Sample rate up to 100kS/s in USB-6003), but I don't know how to measure the time between the two rising edges doing it like this.

 

Could anyone give me some advice please?

0 Kudos
Message 1 of 3
(2,374 Views)

Hello 

I think the first step you should take here is to benchmark the while loop you are running. You could use a fuction that takes the system date in the start of the loop and substract it to another instance of the fuction that takes the system date after all the code inside the while loop have been executed.

try that and let me know the time per iteration that you while loop is producing 

 

 

 

 

0 Kudos
Message 2 of 3
(2,337 Views)

Hello Garena,

I have done as you told me. With elapsed time of my timer set to 1ms, the elapsed time measured in between Timer fires is 16ms. I have the same result if I set it to 5ms or 10ms.

However if I set to 20ms then the elapsed time between Timer fires is 32ms (multiple of 16ms...)

Any other suggestion please?

0 Kudos
Message 3 of 3
(2,324 Views)