LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Merging data between files. Syncronizing serial data and position data.

Solved!
Go to solution

Hello All,

 

I have a code to gather continuous data from a sensor through a serial port. The baud rate is set to 115200 and I am writing these values to an excel file.

I have an other code running at the same time to move a physical system in the XY plane. I am writing the time and exact coordinates of the device into an other file.

What my professor want me to do is to append these files together so that the file reads something like X coordinate, Y Coordinate, Sensor data and time in the same file (one in each cell).

 

I have the following issues.

1. How can I make sure that both processes start at the same time?

2. How can I append these files together?

3. I dont have an exact match of time in both the files to filter the results.

For example one file reads data at 1196.24 ms while the serial data reads at 1196.20, 1196.31, 1196.39, 1196.47 ms etc. (I am using tick count to get the time)

 

I am not sure which Board I have to post this in. Please redirect me if necessary!

I am running LV14 in Win7.1

 

Thanks in advance!

 

Download All
0 Kudos
Message 1 of 12
(4,615 Views)

Can you post the code that you are using?  My initial thoughts are:

 

  1. Since you are not acquiring the measurement data and the position data at the same time, it doesn't make sense to record them on one line in a file with a single time stamp.  The time stamp would be wrong for the sensor data, the position data, or both.  Therefore:
  2. You should probably restructure your program so that data and position measurements can be made simultaneously.
0 Kudos
Message 2 of 12
(4,585 Views)

The answer is you can't.  Devices are more than just baud rate.  They all have their independent update rates.  Best you can do is synchronize the data using timestamps and see if it is inside of your allowable limits.  There will always be jitter using two independent serial devices.

 

Best what to synchronize is to use analog output devices / sensors and use a simultaneous sample analog input card.

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 3 of 12
(4,577 Views)

Thank you so much for the reply.

I am attaching the VI. Could you tell me how I could restructure the code. The work flow goes this way. I say scan, then initialize, then connect to com port 3 and finally log the file. For position measurements, A pop dialogue appears and I select where I want to log that file. 

 

Thank You

Rahul Korpu

0 Kudos
Message 4 of 12
(4,570 Views)

"Best way to synchronize is to use analog output devices / sensors and use a simultaneous sample analog input card." Could you elaborate a little more on this?

 

Is there a way that I could use a common time stamp for both the programs? Both the codes are running parallely and are in the same VI.

 

Thanks,

Rahul

0 Kudos
Message 5 of 12
(4,554 Views)

Can someone tell me why two values are logged at an instance once in a while? In the attached file, Cells 12, 37, 59, 84, .... , the code is loggine the serial port value but is not writing the time.

 

Thanks in advance

Rahul 

0 Kudos
Message 6 of 12
(4,532 Views)

How precise must your measurements be?  I noticed that you are recording timestamps at the sub-millisecond level, but your position records seem quite imprecise: you are writing your commanded position to file before the movement is actually made.

 

Also, are you recording your position data and measurement data at the same rate (e.g. 10 hz ) or are you recording them at different rates?

 

It appears that your program only allows the operator to move the stage once.  Is this intentional?

0 Kudos
Message 7 of 12
(4,519 Views)

I really appreciate your help in this issue. I started working on LabView only recently so these questions might be really basic.

 

I forgot to mention that the position measurements are in millimeters. So I am stopping at each mm to record the sensor values. I dont need to display time at all. I jsut wanted to use it so that I could syncronize data from those two files. So millisecond level could work fine.

 

The problem is, I dont have any feedback mechanism to get the actual position. Hence I am writing the commanded value. I should probably use count step function to determine the actual position. Do you think this is a good way to do it?

 

How can I check at what rates I am recording the data?

 

Yes, the program was intentional. I want to move the carriage along x direction only once.

I would run the program thrice to find the accuracy of my system. That's the reason why I want coordinates in serial data.

Finally if the program works, say at 40 along X, in 3 trails the values are 1, 1.2, 1.05, I want to take the RMS value and report the error step.

 

Is there anyway to use an universsal timer for both the codes? I think the problem is with the serial port writing data at its own rate. What do you think?

 

Regards,

Rahul Korpu

0 Kudos
Message 8 of 12
(4,497 Views)
Solution
Accepted by topic author rkorpu

Since you are asking "How can [you] check at what rates [you] are sampling the data", it sounds like you don't have a sampling rate requirement.  If you don't have a specification for the sampling rate, and you can pause each millimeter, then your solution is easy: 

 

Move one millimeter

Stop moving

Measure your data.  Since you are not moving, you know your position precisely at the time of the measurement.

Record your current position, current data, and current time on one line in a text file. 

Repeat as many times as necessary

 

Do you have any requirements that would disqualify this algorithm?

0 Kudos
Message 9 of 12
(4,487 Views)

The problem is, I dont have any feedback mechanism to get the actual position.

 

 

Take a look at adding a LVDT sensor to get your position accuratly.

http://www.omega.com/subsection/dc-lvdt-sensors.html

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 10 of 12
(4,387 Views)