08-03-2011 09:15 PM
Hello,
I am trying to send over pressure and temperature information via the Input Register array in MODBUS TCP. My question is, how to I properly send over an array of double precision values without loosing my data?
For example, my array of data looks like:
12.0001
32.001
0.00051234
0.0014838
1.02
12.0232
31.920
Thanks so much.
08-03-2011 09:39 PM
@huskyblacktools wrote:
Hello,
I am trying to send over pressure and temperature information via the Input Register array in MODBUS TCP. My question is, how to I properly send over an array of double precision values without lo
osing my data?
For example, my array of data looks like:
12.0001
32.001
0.00051234
0.0014838
1.02
12.0232
31.920
Thanks so much.
We need more information.
Double precision means 8 bytes of data. A single register is only 16 bits or 2 bytes of data. Many times, machines that need floating point data will use 2 consecutive registers, (4 bytes) but that means only single precision floating point data.
You show 7 pieces of data there. How many registers are you trying to write it to?
08-03-2011 10:40 PM
Thank you Ravens Fan for replying.
I missed one extra point of data. Below is what I'd like to send:
12.0001
32.001
0.00051234
0.0014838
1.02
12.0232
31.920
2046
The array above is an array of double precision values. I will convert that array to an array of single precision floating data to reduce data size.
Since I have eight pieces of single precision floating point data now, I will need to write to 16 registers correct? What is the best method to split up each piece of data into two consecutive registers?
Attached is a Slave Send Data.VI that I want to send this data through. The end goal is to have a Master PC (not using labview, but a MODBUS utility) to read my MODBUS TCP message from the "Slave Send Data.vi"
Thanks
08-03-2011 10:57 PM - edited 08-03-2011 10:58 PM
You can use coerce to force the double float to become a single. Then use typecast to convert that to a U16 array.
There are other functions in the Numeric, Data Manipulation palette that may be useful such as swap bytes, swap words, flatten/unflatten to string, and split/join numbers. Because one thing you might have to do is worry about Endianism on your numbers.
08-03-2011 11:40 PM - edited 08-03-2011 11:42 PM
Ravens Fan, I think this will work! Tomorrow I'll test it on the equipment and report back. I've been following many MODBUS threads you've posted in since starting my project and your advice has been great. Thank you for your assistance.
08-04-2011 01:20 PM
Worked great! Thanks Ravens Fan
11-05-2019 12:57 PM
Hi everyone,
Sorry to reopen this post again, but I have a similar question.
I tried to use the Ravens' method, but it didn't work for me. I receive U16 data, but I can't convert appropriately. I attached a print screen, what I have and what I need to find.
11-05-2019 01:22 PM - edited 11-05-2019 01:24 PM
It would have helped if you attached your VI so I can see your attempt.
But the issue is that the register values need to be swapped before they are typecast to Single.
See below to see two different ways of doing it.
Your front panel picture doesn't show all the U16 registers, but you can see from the first 6 registers how it got to the first 3 values in your results.
11-06-2019 08:20 AM
Hi RavensFan,
Your solution worked, but I lost some values. The machine which we are monitoring, send to us 29 values (sensors from temperature and pressure)
My VI is attached for you verify (before your solution).
Thank you so much for your attention.
11-06-2019 08:29 AM
You need to use Swap Words, not Swap Bytes. Note that mine shows "16" on the function while yours show "8".
You are grabbing 29 registers. That means 14 and a half "pairs" of registers when you combine them into 32 bit integers.
If you are trying to grab 29 single precison floats, then you need to wire in 58 so that 58 registers get paired into 29 single precision floats.
You wanted single precision floats, so you still need to do that typecast.
Pro Tip: Delete your 300 constant from the wait function. Then right click on the input and use Create Constant. Now you'll have the right datatype and will get rid of that red coercion dot.