LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ploting RS-232 communication received data

Solved!
Go to solution

Hi All,

I am trying to receive data using the RS-232 serial communication and plot the data in real time. I have a 24-bit data on the sending end, so I am using "Join Numbers" block in the labview to join the three 8-bit data (the final result is the 32-bit data after joining the numbers with 8-bit zero value data). After the data is joined, it is sent to the waveform chart. The received data should be ploted on 8 different waveform charts, so as that the first 24-bit data is ploted on first waveform chart, the second 24-bit data is ploted on the second wavform chart... This is the reason why the "String Subset" block is used.

The next two links show the block diagram:

http://prnt.sc/c0drv9

http://prnt.sc/c0dsl9

As you can see I am highlighting the execution of the process. So in the first link it i shown that some data is coming to the waveform charts. But in the second link you can see that every waveform chart except the two are ploting the value zero. My question is why is this happening?

I am aware that there is an error in the communication, but it shouldnt interfere with the data plotting.

 

Thank you for any help.

 

Darko

0 Kudos
Message 1 of 16
(7,188 Views)

Youre correct that the error wouldnt affect this.  Not sure what the problem is, but maybe for some trouble shooting just unwire the other charts and focus on those one that arent working, then try wiring the data from the non working charts to the working charts.  Then replace the charts.  Might lead to some solution.



-Matt
0 Kudos
Message 2 of 16
(7,170 Views)
Or just keep probe inside case structure,before charts and see what exact value you are getting.that might give an idea...
Thanks
uday
0 Kudos
Message 3 of 16
(7,165 Views)
Solution
Accepted by darko_36

Why are you using "Bytes at Port"?  That is almost always the wrong thing to use.  You written a command and give no time for the device to respond (although highlight execution might have slowed things down enough for it to respond).  So you are probably getting short message of only a few bytes.

 

If every message is the same length, then wire that number of bytes into the Read and get rid of that Bytes at Port node.

 

Also, you have the termination character enabled by default with the Serial Configure VI, which by default is a line feed character.  That is a huge problem since you are trying to read binary data.  It is a decent chance you'll be sending a number where one of the bytes is 10 decimal.  If that happens, the VISA Read will stop there and give you incomplete data.  You need to disable the termination character in the Serial configure function.

 

Also, use block diagram cleanup because you have too many overlapping and backwards wires.

 

Also, don't wire a constant into every index of that Index Array function.  By default, it will give you index, 0, 1, 2, 3, .... with nothing wired in.

Message 4 of 16
(7,133 Views)

Hi, thank you for your suggestions.

Once you mentioned that the problem could be the "Bytes at Port" I deleted it, also I realised I didnt need the "VISA Write",because I am only going to read the serial communication. And after I deleted these two blocks, things started working.

Also I am a beginer in labview, so thank you for the other suggestions as well.

0 Kudos
Message 5 of 16
(7,092 Views)

Hi All,

I have just one more question, I need to convert the 24-bit data digital to analog data before the ploting, the formula for conversion is shown in the picture attached. I am trying to use "Digital to Analog.vi", but it requires the input to be "digital waveform", and I dont know how to convert to that format.So my question is:

Is there a way to make a DA conversion of 32-bit unsigned long data?

Or if this is not possible:

Can I convert 32-bit unsigned long data to digital waveform format, so I can use the "Digital to Analog.vi"?

 

Thank you in advance.

0 Kudos
Message 6 of 16
(7,049 Views)

Darko,

Can you post a copy of the VI showing what you are attempting?

It sounds like something I would typically use a type cast VI for.

Alex W.
0 Kudos
Message 7 of 16
(7,023 Views)
Solution
Accepted by darko_36

Hi Darko,

 

some bitbanging:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 16
(7,016 Views)

Hi Alex,

I am trying to plot data I am receiving over RS-232 communication. I am sending 8 bit data, and then combing it to form 32-bit data, but before I plot this data, I want to convert it, you can find the table for conversion in the attachement in the post above. The screenshot of my vi is in the attachement.

Thank you for answering.

 

Darko

0 Kudos
Message 9 of 16
(7,009 Views)

Hi Darko,

 

why don't you follow the suggestions given before? Why did you mark them as solution when you don't use them?

Why do you limit the string to length=52 when you read just 52 bytes from the serial port? You want to make sure the string will never have more than 52 chars???

Did you see my snippet?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 16
(7,001 Views)