07-06-2015 02:06 PM
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!
Solved! Go to Solution.
07-06-2015 03:58 PM
Can you post the code that you are using? My initial thoughts are:
07-06-2015 04:02 PM
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.
07-06-2015 04:05 PM
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
07-06-2015 04:24 PM
"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
07-06-2015 04:37 PM
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
07-06-2015 05:05 PM
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?
07-06-2015 05:33 PM
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
07-06-2015 05:58 PM
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?
07-07-2015 10:33 AM
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