06-23-2010 01:16 PM
Hi I'm trying to send data via serial port.. This data consists in a 16 bits format.The data is being send by a DSP. Searching in the internet I found two ways to send the data . The first way is the first picture anda the second way is the second picture. I'm reading the data ok, which in the case is a sinusoidal wave . But I'don't know if it's correct or not.
In the first case the visa read buffer sende th 8 bits to the DEcimate VI which will be concatenate after in the join numbers function...
Is this right or not? Second question. I've noticed when I put multiples of 8 in the Byte count the graph is ok. But when the number is not a multiple the graph is "missing pieces". Why?
In the second case I admit I have not undertood it. I only know the TYPE CAST function transforms the string on a array swap the bytes ( DSP sends teh MSB and after the LSB) I know what string subset do . I've read that the 4 in the offset is put there to avoid reading the HEADER of the data. But I dont know why 2048 is there. The second case reads the data too..
With anyone answer my questions would be a really really help
Thanks guys.
Firts case
second case
Solved! Go to Solution.
06-23-2010 02:10 PM - edited 06-23-2010 02:11 PM
Both are probably correct for the data being sent.
If you want to read a single 16 bit value at a time, then you would obviously set the number of bytes to read to be 2. The code below shows a couple of ways to convert the two bytes to a single value. The Unflatten From String allows you to specify the endianess.
You don't mention it but how are you synchronizing the data. With the dsp sending two separate bytes, you have no idea which byte you will read first. Are you sending any start/stop characters so you know this vital piece of information?
06-23-2010 02:43 PM
Dennis..
Thank you for your help.
About the syncronism of the data i'm doing a huge mistake here , at least for a while, my DSP is not configured yet in any flow control. The DSP has a RTS CTS, pins to control the data but these pins are not connected to the system,(I first have to weld some pins on it but i cannot do this now, because the pins are very very small so i have to send it for the factory).
Anyway... I have to run my project many times, until it plots the data in the graph..
I'm beginning now with labview. so my data is simple, in this case its a a saw shaped wave . A very simple data. I wonder with ths method ( trying many times would plots complex data without the flow control.
06-23-2010 02:51 PM
Don't see how flow control will do a thing. I don't think you understand the issue at all.
The DSP sends byte 1 and then byte 2. It continues to do this without any command from the pc side to start sending. When you start the LabVIEW program, you have no idea when the serial read will start relative to the sender. Your first read could be the MSB or it could be the LSB. What is often doen is to prepend/append special characters. For example, say the DSP would append a carriage return after the LSB. You would have to manage the read in LabVIEW and look for the CR by reading 3 bytes. Inspect the data and determine which byte is the CR. Adjust the byte count based on that byte position and then discard that data. You would then be synched and know that if you read 3 bytes, you will be getting MSB, LSB, CR.