LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 interface synchronization

I have a RS232 device that give me a continuous 5 byte serial string 75 times every second.I can read the data using VISA read;My problem is that I'm not able to synchronize the data.

Any suggestions?
0 Kudos
Message 1 of 8
(4,240 Views)
What are you trying to synchronize with what?

If you want to synchronize the data that is received with the time it is received, you will have to obtain a timing signal somehow, or just get a starting time and, knowing the rate of dissemination of the data, concatenate the data with a time based on this information.
0 Kudos
Message 2 of 8
(4,240 Views)
Please define "syncronize".

In the context of serial it could mean a lot of different things.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 8
(4,240 Views)
Ben,
I have 5 bytes of data coming from my external instrument; whenever I run Labview and acquire this data, I start acquisition at a random data....like i get byte 3 first..then 4..then5..then 1..2..3..and so on. If i stop and restart- again it starts from a different set....as in 2..3..4..5..1..and so on.

How can i synchronize the first set to read the first byte and then continue acquisition?
0 Kudos
Message 4 of 8
(4,240 Views)
I have 5 bytes of data coming from my external instrument; whenever I run Labview and acquire this data, I start acquisition at a random data....like i get byte 3 first..then 4..then5..then 1..2..3..and so on. If i stop and restart- again it starts from a different set....as in 2..3..4..5..1..and so on.

How can i synchronize the first set to read the first byte and then continue acquisition?"
0 Kudos
Message 5 of 8
(4,240 Views)
I'm assuming that the reason you're having problems is that the instrument is continuously transmitting data and not just in response to a read command. If that's so, check the instrument manual to see if it sends a character (or characters) that indicates start or stop of data. You would read and discard any data until you detect that character and then proceed. If one of the bytes translates as a decimal point, you could use that. The other possiblity is that the instrument supports hardware synchronization. You might have to use hardware handshaking and monitor the RTS or DTR lines.
0 Kudos
Message 6 of 8
(4,240 Views)
Hi Somash,

Go with a variation of Dennis' suggestion.

Do 3 steps,

1) Init port
2) use a small loop after the init that keeps reading until you find the start of a packet. Through away all the data that comes before this. Read enough bytes to get the remainder of this packet.

3) Enter your main loop and just start reading the packet length. You should be good to go (right up until you get a parity error).

There are more elegent ways of doing this (i.e. state machine that starts out in in a "sync" mode that does the step #2 stuff, then transitions to a Read state, drops back to sync if an error occurs etc).

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 8
(4,240 Views)
I'm assuming that you have no way of parsing large blocks of data and
identifying the start of each message, right?

I had a similar problem a few months ago... I was able to detect the idle
times between the messages. This allowed me to wait for the start of a
message and then keep reading chunks of data (and concatenating them) until
I reached the next idle time.

In your case you receive a new message approx. every 13 msec... so, if you
check the serial port say every 5 msec, then you'll find the gaps between
messages... (i.e. at least 1 frame with no characters...) and then, at least
1 frame with characters... Note: the actual number of empty/full reads will
vary depending on the baud rate.

good luck,
Bill


Somesh wrote in message
news:50650
000000800000047590000-1027480788000@exchange.ni.com...
> I have a RS232 device that give me a continuous 5 byte serial string
> 75 times every second.I can read the data using VISA read;My problem
> is that I'm not able to synchronize the data.
>
> Any suggestions?
0 Kudos
Message 8 of 8
(4,240 Views)