SSURESHREDDY
Joined: 10 Aug 2013 Posts: 13 Location: bangalore
|
How to map floating point values over MODBUS |
Posted: Wed Nov 26, 2014 12:47 am |
|
|
Hi all,
We are designing a controller to measure voltage and current. We have floating point values like 50.4 volts and 150.2 Amps. These are to be presented on MODBUS. I like to know which is the best method, function code to do this. Some of you have must have had some experience on handling this kind of values. Can someone help us on this? I am using PIC16F1938 and C compiler v4.114
suresh |
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Wed Nov 26, 2014 1:36 am |
|
|
Honestly, best, send them as integer.
504 tenths of a volt.
1502 tenths of an amp.
Use tenths, hundredths, or thousandths according to what the system is actually capable of measuring.
Smaller, and faster than fiddling with FP. Avoids problems of different 'types' in the systems at each end. Accurately limits the transmitted resolution, to what the system is capable of producing, etc. etc.. It is the commonest approach in all forms of industrial bus. It also makes debugging easier, since you can add a simple MODBUS analyser, and directly 'read' the values as human sensible figures.
Currently have a system returning direct probe readings in uV, converted value, in tenth PPM, temperature in degrees, flow rate in 1/10th l/min etc.. |
|