Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronize/trigger USB ports.

Dear forum.

Im new to labview and struggling with synchronizing a measuring signal from a MCC DAQ USB-2020 board with a homemade sensor triggering on another usb port (on same computer).

My object is to trigger the incoming USB-2020 measuring signal on digital or analog trigger flank from the homemade sensor on the other usb port down to millisecond or preferably some microseconds but yet no success. When trying synchronizing I can not find a method introducing a timing clock in the lower visa serial loop to have labview scan the homemade sensor usb port in sync with main measuring signal. I have tried different triggers in the USB-2020 measuring loop triggered by the homemade sensor on second usb port but the results are surprisingly random so Im doing something wrong. The best results (but not good enough) was achieved with a case structure as depicted below. I also need pre-trigger but this just dont work for some reason that alludes me. Iam not excluding timing issues with the homemade sensor and appreciate ideas how to time sync a graph from the analog homemade sensor to the graph from the measuring channel from the USB-2020 for troubleshooting that loop. As a workaround Iam now starting hardware changes to try using the trigger port on the USB-2020 board but this is a non preferred electrical connection due to different circumstances. All advices and ideas higly appreciated. 

USBtrigger.PNG

0 Kudos
Message 1 of 5
(678 Views)

The diagram you show looks suspiciously weird.

 

For one you would have to run this somehow in a loop, otherwise the VISA Read only will read one value from your sensor and if that does not fit your condition at that moment the DAQ won't be started (and never closed either).

 

Second if you call this VI in a loop you make it very slow by opening both the DAQ and VISA serial port each time. These operations should be outside of the loop.

 

Third, comparing a string with a comparison function almost certainly doesn't do what you expect it to do. Trigger threshold sounds like a number, but you compare the string values. The comparison operator compares character for character until there is a mismatch and then evaluates these two characters ASCII values. So in your case a measurement string of 10 with a threshold of 9 would result in FALSE since 1 is smaller than 9 in the ASCII table, while you want to check for your measurement to be greater than. You want to convert the value read from your sensor into a real number and then do the comparison with your threshold as a real number too.

 

Last but not least, trying to do ms accuracy over polling the serial port asynchronously is pretty much doomed even if that serial port is a virtual USB-RS232 interface. The entire delays, asynchronous operations and all won't ever let you go below 10 or so ms consistently, and that is with a proper architecture where you initialize the resources once and then in a loop continuously read your sensor value until the condition is satisfied.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 5
(631 Views)

@Rolfk

Thank you for advice and thank you for your recommendations of cleaning up my code. Labview is not my preferred choice but at the moment labview is what we got to work with here. Itom looks very interesting with their python base for hardware flexibility.

 

If I understand the essence of your message labview is not a plausible option for achieving the object of trigger/synchronize a measuring signal from the USB-2020 from another USB port (which also is my own conclusion) ? I had a longshot theory that the polling issue could be resolved using the memory buffers for pre trigger/find peak if the two separate channels could be roughly synched somehow and made a quick trial with parts we had on the shelf to boil down what we actually need for prototyping.

Gotta start somewhere to see where it lands =0)

0 Kudos
Message 3 of 5
(621 Views)

It's not about LabVIEW, but about the fact that you try to synchronize in real-time some hardware with a serial port. That will be the same problem in Python or any other programming language. You could get more determinism from a real-time environment but due to the latency of the serial to USB converter and OS internal latencies in the whole USB driver stack back to the serial port API, it's even a stretch there. If you talk about ms accuracy, you really should start to look into real hardware synchronization. Otherwise the path from your sensor to its CPU, the serial to USB converter, in the computer the USB driver stack then the serial port conversion and finally the user API (VISA or otherwise) simply add to much latency and variability to be able to get a consistent ms accuracy.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 5
(618 Views)

So, i've been playing around with the trigger port and the second analogue bnc in on the usb-2020 board all day. That way USB ports is now excluded and all is handled by the usb 2020 board internally. Funny thing is the .net ulx triggers doesnt work as explained in user guides that way either.

My opinion about labview is strenghtened.

0 Kudos
Message 5 of 5
(586 Views)