02-23-2016 08:24 AM
Hi,
I'm trying to make a VI that receives data from an RS232 source every 100ms (10Hz) at a 9600bauds rate. The serial port configuration includes 8data bits, stop bits 1.0, parity odd, flow control none. The CTS and signals are always asserted. Problem is I need a way to sinchronize data transmission to acquire data in order (from first to last byte). Frames are composed of 28bytes (every 100ms) and do no contain ending or starting characters. If I read data with a timed loop I'm able to acquire all data, but not in order, I need some sort of trigger for this. It would be very helpful to know for example, when exactly I am receiving a byte, and somehow count time between bytes in order to synchronize (or any other way to trigger reads). I need to do this in Windows, not a real time OS. Any help or advise will be very appreciated
02-23-2016 08:55 AM
What are you recieving data from? Do you have any more specifics about the 28 bytes that you are trying to read? ASCII data? Binary/Hex data?
02-23-2016 03:22 PM
I doubt that you don't get the data in order. Maybe in incomplete chunks but anyhow in order.
Can you tell what kind of repitition is used?
if you always read the number of bytes available then you could take a timestamp value for the last char you recieved.
Reading as fast as you can in a simple while and keeping those chunks with timing in an array could show what actual happens.
you get 280 bytes per second in chunks of 28 and the system is able to read 960 bytes/sec at that baudrate. so maybe you see a pause each 28 chars.
03-15-2016 11:57 AM
There is really no much to it, the data is hexadecimal. You are right the Data is in order Albert I was not explaining myself very well. I want to stay "synchronized". The data is received every 100ms, and I need to display something like this:
Nonetheless that last 2 bytes sometime get in the middle, and the message gets shifted, that happens cause the transmitter is sending data always and I get the first frame shifted. I need to tell which is the first and last byte, otherwise I cannot decode correctly the message. I need some sort of timed control, in order to get an event or something that tells me a timestamp for each byte. Every 100ms I received 28bytes at 9600Bauds 11bit words. So it is (11bits per word*28"words"/9600bits per sec)*1000msec per sec which ends up being aroung 32ms for the whole chunk to get transfered, the line is empty the other 68ms.
The simple software solution will be to include a initial and ending byte, but that is not possible given I need those words for messages and protocol cannot be extended.
A hardware solution is also impossible CTS will be always ON regardless, So I will be always receiving data even if I'm not prepared for it.
There has to be a way to synchronize in a timely manner. In the image show above, I am synchronized, If I get the first "frame" right , therefore I get them all right always. Problem is, sometimes I' might get that 20DF somewhere in the middle.
Thanks again crossrulz and Albert, I hope I can find a solution for this
Thanks again in advance.