Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronization of DAQ and serial port device

Synchronizing inputs of Tracking System (serial port) and Load Cell (NI USB 9237) in LabVIEW 8.5:

I am taking in data from an optical tracking system (camera communicates with a signal conditioning box which connects to the computer trough a serial port) and a load cell (plugged into a USB 9237 DAQ). In LabVIEW I call the tracking system (to get position and orientation information) using a matlab script node and
the load cell (to get forces) from DAQmx read node.

The load cell takes readings at a much higher frequency than the tracking system (about 1000 sample to 1). So I want to run the load cell DAQmx read node repeatedly while the matlab script node gets one set of tracking points...

Since LabVIEW executes one node at a time I am basically forced to choose which node to execute first and which to execute second.

Is there anyway around this so that I can take in a group of samples from the load cell at the point in time when the tracking information is being requested and received (so maybe start load cell DAQ when tracking is requested, aka matlab script node starts, and stop load cell DAQ when tracking is received, aka matlab  script node finishes).

Thanks,
Thomas


0 Kudos
Message 1 of 3
(3,279 Views)
Hi hugopowers,

Inherently, a computer can only execute one logical thing at a time (unless your computer has more than one processor). However, we can get achieve a behavior very similar to what you would like by putting each node in a different while loop inside of LabVIEW. When there are more than one while loop on the block diagram LabVIEW will try to run them all at the same time. What really happens is that each while loop gets a certain amount of time to execute individually. But because their execution times are so fast and they are switched about so fast it appears that they are running at the same time. I would suggest putting your mathscript node in one loop and the DAQ read node in another loop. This should get you close to the actual behavior you want. I have attached a very simple VI for you to look at. Feel free to use it as a starting point in your application.



Message Edited by adamg on 03-29-2008 03:07 PM
Adam

National Instruments
Applications Engineer
0 Kudos
Message 2 of 3
(3,248 Views)

Thanks for the response. The sample VI was very helpful in clarifying what you explained.

In general what you sent me seems to work nicely.

 

However due to the structure of my current code I do not know if I can incorporate this solution into my code for two reasons:

1. Real time display - The data from the two inputs, the tracking system and load cell, need to be processed and displayed in real time. So ideally, the display that shows the calculated output would be refreshed each time a set of tracker data is received. The calculated output would thus be based on one set of tracker data and multiple points of load cell data.

2. Seamless Tab Switching - There is a while loop around the outside of my code allowing the user to seamlessly switch between tasks without having to start and stop the code. So it is set up such that each run of this global while loop is often analogous to one run of the tracking system plus any other things occurring on a given selected tab.

 

I attached two files:

1. Attached is an edited version of the code you sent me. Although this VI isn’t what I need it sort of shows the general direction I am trying to go.

2. This VI shows what I was originally thinking of doing if there is not better solution. Here I am getting several points of load cell data (in this case 50), then one set of tracking data, and then a second grouping of 50 points of load data. The load cell data is then averaged before being used for the final multiplication of the load cell and tracking data. Because load cell data is received before and after tracking and these values are averaged, this creates a linear interpolation of the known load cell data. However, since the load cell data is most likely not linear this is a non-ideal solution.

 

Can the solution you sent me work in my current code or is there another solution that would work?

Thanks for your help,

Thomas

Download All
0 Kudos
Message 3 of 3
(3,225 Views)