08-30-2022 09:31 AM
Hi!
I'm making a project and I have some troubles with communication via Modbus RTU. I'm trying to collect and save data from Presys ST501 Thermometer. I didn't had original converter for connection so I used a CP2012 USB-UART converter like this one below:
Buy USB-UART converter CP2102 - USB plug - Botland - Robotic Shop
It looks like it'ś working and by working I mean sending and receiving massages but I don't know how to get selected (temperature) from responses. I'm not sure about correctness of the query also.
I found manual for the ST501 and in section 5 it's explained how to use the Modbus connection in some way but I don't know what I'm making wrong and what should I correct in my program.
I don't have much experience in LabView so any help will be useful.
Solved! Go to Solution.
08-30-2022 09:34 AM
I forgot to paste the link to the manual:
08-30-2022 11:03 AM
I made some cosmetic job for clarify visual content. By the way I noticed something strange. Even if the thermometer is turned off and the program is runnig it's still getting response from ST501. Is it correct?
08-31-2022 03:44 AM
When you deal with ModBus devices you should consider the following points/suggestions:
09-01-2022 10:37 AM
At first thank you for your answer.
I tested different unit ID numbers from 0 to 255 and all works the same. I don't know why. By changing "Strating adress" I'm getting quadrupled values. For example for adress 0 value is 0, for 1 it's 2,35099E-38, for 127 it's 1,70141E+38. At 128 it's -0 (?) and for 129 it's again -2,35099E-38. Register values works the same way but also repeat themselves every 256 adresses. What's the worst I'm not able to use different Modbus master because I need to have everything in LabView. I'm devasteded and I don't know what to do. It's completly not my field. I work in energy sector on all voltages but I can't handle somthing like this. 😞
I'm adding some screenshots to show how it's working right now.
09-01-2022 01:44 PM
From your screenshot the ModBus read function returns some values. It means the UnitID is correct. Keep using Unit ID = 1.
Now, you need to convert ModBus data in real data. There is not a specific rule for doing this. Vendor of the device you are using has defined its own way to represent data and this is (should be) specified in the datasheet.
The datasheet is quite generic and not well detailed about data representation. Please, ask the vendor to give more pieces of information about data representantion in ModBus communication.
Anyway, the datasheet reports the following sentence:
The values formed by 4 consecutive registers have a long integer format, each
register corresponding to one byte of the long integer (the most significant byte belongs
to the register with the smallest identification number). For instance, the value 300001
(000493E1h, in hexadecimal system) is read by registers 50 to 53 as: 0|4|147|225 or
0h|4h|93h|E1h (in hexadecimal system).
and reports also this:
The value ranges of certain registers listed in the table above have a fixed
number of decimals.
So, in my opinion, for the registers 50 to 53, you should:
- Read registers 50 to 53. ModBus read function will return an array of 4 integers.
- Convert these 4 integers in a long integer (let's call it X).
- Read the number of used decimal from ModBus register 54. (let's call it D)
- Convert your data in the following way: data = X*10^(-D)
In attachment, you can see a small piece of code for converting the 4 registers into a decimal number (as specified above).
10-15-2022 12:57 PM
Thank You for your help. Everything works great! 🙂