LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial port communication problem

Solved!
Go to solution

 

Hello,

I'm working with the STEVAL-L99615 evaluation board to measure cell voltages. I'm using 3 power supplies (battery emulator) in series. Issue I describe here appears for all cells — for simplicity, I'm focusing on cell1.

 

To read the voltage on cell1, I send the command:

 

A405 3021 06

 

In response, I get:

 

5508 3070 210B 01D6

 

The voltage is encoded in hex number 0B01(0xB01), which equals 2817. When multiplied by 1.22 mV, this gives 3.43674 V, which is correct. D6 is CRC.

 

 

The problem appears when the voltage changes to 3.42 V. Then, after sending the same command, I receive:

F7E1 5508 3070 210A 

 

Here, the voltage bytes (0xAF7= 3.42454V) have shifted 2 bytes to the right. The voltage value is still correct, but the packet alignment changes. This only seems to happen when the voltage crosses from 0xB00 to 0XAFF .

Actually first data labview shows when this crossing occurs is:

 

5508 3070 210A 

 

Later, when the voltage drops further (e.g. below 0xA00 --> 0x9FF), I get something like:

 

03D5 5508 3070 2109 FDDC    --> 03 is probably part of previous 0A03 (3.127 V)

and then

5508 3070 2109 FCDD --> Which is correct format and one i want

 

This seems to confirm that older data is sometimes mixed into the response. This only happens when result voltage falls from higher or lower voltage in range 0xA00 - 0xAFF.

Important note: This behavior only happens when I use my LabVIEW VI. When I use serial terminals like PuTTY or Lorris, I always get properly aligned data.

 

My goal is to fix it to this format as it is right format:

 

XXXX XXXX XXBB BBCC

 

I'm attaching a screenshot of my current LabVIEW VI setup for serial communication.

I will be glad for any help.

Have nice day and thank you in advance for your answer,

Jan Horák  

0 Kudos
Message 1 of 4
(270 Views)
Solution
Accepted by Bikani2088

Hi Bikani,

 

without looking at those BMP images (please use PNG instead!) I recommend to switch OFF the default LF (= 0x0A) termchar!

 

Watch this video to learn all you need about serial communication

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(252 Views)
Solution
Accepted by Bikani2088

The default VISA configuration (VISA Configure Serial Port.vi) defines LF (0x0A) as a termination character - check the optional inputs of that vi.

This means that the Read is terminated when a LF is received. This is wrong for binary data. Disable the termination char.

Moreover, if you are going to receive 8 bytes, setting 1000 as byte count means that the VISA Read function always waits for the full 1 s timeout befor returning, which is highly unoptimized. As byte count, input 8 - or whatever number of bytes you are expecting to receive.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 3 of 4
(249 Views)

Thank you so much for the help guys. That was exactly the issue.

Disabling the termination character completely solved the problem. I really appreciate your help. I would’ve never found this on my own.

 

Thanks again, this saved me a lot of time and frustration!

0 Kudos
Message 4 of 4
(217 Views)