LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with Modbus UART communication T6713 CO2 Sensor

Hello all! 
I'm trying to communicate with a CO2 Sensor via RS232 Com Port, writing commands via Modbus UART. I couldn't make the sensor work (read) via LabView but I confirmed that the sensor works with a developer software from the manufacturer, so the hardware connection looks to be working. Attached is my VI trying to communicate sending a command to read CO2 PPM and the Application note/command summary for this sensor. 

eduardoromero_1-1630518808811.png  

 

eduardoromero_2-1630519331793.png

 

eduardoromero_7-1630519729261.png

 


I really appreciate any help or guide. 
Best regards and greetings from Mexico! 

0 Kudos
Message 1 of 4
(1,542 Views)

Two errors:

 

1) Disable the termination char.

2) You need to calculate and add the CRC to your command string.

 

I strongly recommend to download and use one of the many available MODBUS API, like the one from NI or the excellent Plasmionique Modbus Master API instead of inventing the protocol by yourself.

 

Regards, Jens

Kudos are welcome...
Message 2 of 4
(1,536 Views)

Hi eduardo,

 

there are several bugs in your VI:

  • you forgot to add the CRC word to your request message: your request consists of 6 bytes, but it needs to have a length of 8 bytes!
  • when reading the response you also should read the CRC bytes of it, so instead of reading 5 bytes you should read 7 bytes!
  • ofcourse you need to calculate the CRC correctly in your request and you should check the CRC on the response message!
  • why do you need to open/initialize and close the serial port on each request?
  • why don't you use the ready-to-use Modbus libraries available in VIPM? (Probably I would also use your quick&dirty approach for such a simple sensor…)

 

Edit: Jens basically gave all the same suggestions… 🙂

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 4
(1,534 Views)

Hi Gerd & Jens, really thank you for your response and help. 
I'm sorry for the rookie mistakes, I'm starting learning LabVIEW. 

I calculated the CRC as showed below for 1504138B0001 and it would be 15 04 13 8B 00 01 70 46

eduardoromero_0-1630616895463.png 

eduardoromero_1-1630616928225.png

 

I downloaded the NI Modbus library but I have no experience using them, but I'm researching how to use the recommended from Jens. I tried to make a new code with LV NXG because at the end I want to make the VI with NXG features, but right now I only want to have a successful reading. 
Here is the VI, I disabled the termination char and connect it directly to a string terminal to see whatever response it could receive. For some reason, NXG is not detecting my COM port, as Labview 2018 has no problems detecting it. I'm currently installing NI-VISA drivers again. 

eduardoromero_2-1630618916576.png

 

Thank you all! 

 

I attached the command summary PDF, I think it didn't upload on my first publication. 

Best regards! 

 

0 Kudos
Message 4 of 4
(1,481 Views)