LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronize Serial (RS232) Signal with an Analogue Input Signal

Hey guys I need your help!!

 

I have a serial signal coming in with 50 Hz (this is the maximum sampling rate of the device) and an analogue inputs which might vary between 10-50 Hz. It is fine when the AI has a fixed sample rate of 50Hz too. However, how can I synchronize these two signals and get an output file with one timestamp. I would like a really accurate result. I have already some dodgy solution, but I am aiming for the perfect match.

 

My first problem which I experienced is:

As soon as I loop the serial input which comes as several lines per sample, Labview cuts the string whenever the loop needs the data. How can I wait for the complete line? I tried already termination char etc., but could not get it to work.

 

Second problem is:

I don’t know if I should put it in one loop or in two loops. Is it even easier and better to do the whole thing with two output files? However, one output file would be a lot more elegant and preferred.

 

Please let me know if you need more details.

 

Thanks a lot for your help.

 

Cheers

0 Kudos
Message 1 of 3
(2,687 Views)

@DEUS wrote:

Hey guys I need your help!!

 

I have a serial signal coming in with 50 Hz (this is the maximum sampling rate of the device) and an analogue inputs which might vary between 10-50 Hz. It is fine when the AI has a fixed sample rate of 50Hz too. However, how can I synchronize these two signals and get an output file with one timestamp. I would like a really accurate result. I have already some dodgy solution, but I am aiming for the perfect match.

...

Cheers


 

It is possibel but I suspect you will not want to implement a "perfect match".

 

Attempting get a perfect match is like you and your budy watching the same show at the same time in different parts of the world and your buddy is jotting down notes and send them off via snail mail one line at at time.

 

THe show is coming at you real-time and the snail-mail is coming in in delayed batches.

 

Your buddy could help out if they included a syncronized time stamp in each of the snail-mail messages.

 

Q1:

 

Do you have access to the the widget sending the serial data and can get it to send time stamps?

 

Returning to the analogy...

 

You could set up a camera at you buddy's place and watch both to syncronize the data.

 

Q2:

 

Is the perfect syncronization important enough for you to go through the effort of watching the serail line with another AI line and then process the signal into the transmited serial stream?

 

Back to the analogy!

 

You could get your buddy to agre to send one snail-mail every minute.

 

Q3:

 

Can you r widget be set up to transmit periodically?

 

In most cases this is as close as we can get to perfect. In a similar type of application I was asked to monitor the serial feed for a fly-by-wire widget with the physical measurements acquired via DAQ hardware.

 

 

In that case We used an RT system to send data requests to the widget on a periodic basis. Since the widget respond in a deterministic fashoin the replies where also deterministic. We still had to do some post process work to get the two serial feeds (I guess I left that part out Smiley Surprised ) to allign with the data.

 

So ....

 

Perfect ain't easy.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 3
(2,669 Views)

Hello Ben,

 

Thank you for your time your comments were already really helpful and I like your analogy. I will try to answer your questions and precise my problem a bit more.

 

 

It is possibel but I suspect you will not want to implement a "perfect match".

 

Attempting get a perfect match is like you and your budy watching the same show at the same time in different parts of the world and your buddy is jotting down notes and send them off via snail mail one line at at time.

 

THe show is coming at you real-time and the snail-mail is coming in in delayed batches.

 

Your buddy could help out if they included a syncronized time stamp in each of the snail-mail messages.

 

Q1:

 

Do you have access to the the widget sending the serial data and can get it to send time stamps?

 

My data is only connected to a sample number and as I know that I sample with 50Hz I know that they are all 0.02s away from each other. The only thing is I do not know when 0s is. I will have a look if there is something like a timestamp. If I could start both reading at the exactly at the same time then I could sample both with 50 Hz and overlap the data. But then the question is: Is the 50 Hz of my NI card equal the 50Hz of my serial instrument??????? Is it alright to do that or still a dodgy way???

 

Returning to the analogy...

 

You could set up a camera at you buddy's place and watch both to syncronize the data.

 

Q2:

 

Is the perfect syncronization important enough for you to go through the effort of watching the serail line with another AI line and then process the signal into the transmited serial stream?

 

To set up another AI is a little bit more effort, and I do not know if I really want that. I have a synchronization port on my serial instrument where I can send a five volt signal and get then a sample out of it. Probably to get perfect results I have to go this way. Do you know how large the delay of the sample than might be???? You have to send a signal and receive one is this in the order of 1ms or 20 ms....

 

Back to the analogy!

 

You could get your buddy to agre to send one snail-mail every minute.

 

Q3:

 

Can you r widget be set up to transmit periodically?

 

The comment above should also cover this question.

 

In most cases this is as close as we can get to perfect. In a similar type of application I was asked to monitor the serial feed for a fly-by-wire widget with the physical measurements acquired via DAQ hardware.

 

 

 

In that case We used an RT system to send data requests to the widget on a periodic basis. Since the widget respond in a deterministic fashoin the replies where also deterministic. We still had to do some post process work to get the two serial feeds (I guess I left that part out  ) to allign with the data.

 

So ....

 

Perfect ain't easy.

 

You are totally right with this comment. I thought there might be an easy way to get the data synchronized.... but as I see I have to put a bit more effort in.

However, any other ideas are welcome which would facilitate my life.

 

Ben

 

Thanks Ben! Good answer!!

 

 

 

0 Kudos
Message 3 of 3
(2,654 Views)