LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronize or concatenate horizzontally string from serial and daq

Solved!
Go to solution

Hi,

I am quite new in Labview so please apologize me if i say something stupid. My tutor asked me to edit a vi, that read forces and torques from a load cell connected to a NI DAQ, in order to acquire data from sensors through Arduino Mega ADK and to synchronized them with the load cell values ( just performing a load/sensor output characterization). I have read it is not possible to do it in a precise manner because of some delays.

 

In particular, I receive data from serial in a continuouse way, like that:

...

[[[530],[[572],[[420],[[443],[[428],[[573],[[641],[[431],[[385],[[477],[[416],[[406]]

[[[530],[[572],[[420],[[443],[[428],[[573],[[641],[[431],[[385],[[477],[[416],[[406]]

[[[530],[[572],[[420],[[443],[[428],[[573],[[641],[[431],[[385],[[477],[[416],[[406]]

[[[530],[[572],[[420],[[443],[[428],[[573],[[641],[[431],[[385],[[477],[[416],[[406]]

...

while load cell data consist of a 2D array with 6 elements.

 

I was thinking to save all the data in a file in different columns: 6 for each element of the array of the load cell ( Fx, Fy, Fz, Tx, Ty, Tz) and the 7th for the serial string, as it follows:

 

0.315150     2.998507     1.034158     28.745208     -24.771420     28.367282     [[[530],[[572],[[420],[[443],[[428],[[573],[[641],[[431],[[385],[[477],[[416],[[406]]

 

I tried three different solutions to concatenate these strings but no one worked as I expected. Since the load cell and the Arduino board have different sampling rates, one of the three solutions was to save data only when receving a single string from serial using 'bytes to read' > 0 condition. But it didn't work. I obtained data organized as you can see in the attachment. Can you please suggest me what I can fix?

 

Or do you have any other solutions to relate sensor outputs to load cell values?

 

Thank in advance for your help.

0 Kudos
Message 1 of 5
(2,148 Views)
Solution
Accepted by topic author mulan13

If you have different sample rates, putting them in a single string probably won't work. The best option might be to log them individually with software generated time stamps, using something a producer/consumer architecture. Then, you can try to sync things up in post by decimating, interpolating or some other mechanism.

 

I'd probably do different files for each device, but you could put it all in the same file and mark each entry and/or do some kind of pattern detection.

 

Edit: All of this is stated under the assumption you're OK with things being "close" but not perfect. If you need it to be "perfectly" synced, you could output some type of pulse/timer signal from the DAQ device to the Arduino and use it as a reference point for the sync.

--------------------------------------
Message 2 of 5
(2,124 Views)

Hi Christopher,

 

thank for your reply. I didn't know the existance of the producer/consumer architecture. I will read about it. 

 

I was thinking to save the data in the same file just because I don't have a sync signal and I cannot extract it from the DAQ because it is a particular model integrating a load cell and a system for a moving platform. Do you know whether is possible to save - in each file - a futher column with a common timestamp generated from Labview?

 

 

0 Kudos
Message 3 of 5
(2,057 Views)

@mulan13 wrote:

...

Do you know whether is possible to save - in each file - a futher column with a common timestamp generated from Labview?

 

 


Yep! Check out the "get date time in seconds" VI.

--------------------------------------
0 Kudos
Message 4 of 5
(2,049 Views)

Ok, I really thank you!

 

Just last question...even if probably I should open another discussion. I would like to flush the buffer before each reading but both VISA Flush and VISA Clear seem not to do anything. I tried to set a buffer size too but it didn't work and I can see the 'Bytes at Port' (just in the indicator, not as input for VISA Read) to increase continuosly after some iterations and, consequently, the measurements are read with a huge amount of delay (>10seconds). Is it probably due to some other problems?

 

 

0 Kudos
Message 5 of 5
(2,033 Views)