wolftek Posted March 2, 2011 Share Posted March 2, 2011 I am having a problem with data conversion using modbus TCP. From what I can gather my data in DAQ is 64-Bit floating point. I am trying to write to a modbus register that is 32-bit floating point. Therefore there is a overflow into the next register. Modbus_Reg = 2756 Device.Ft_RMC.SetRegisterFloat(0, Modbus_Reg, Data]) //Modbus Register #2756 is a 32-Bit floating point register. "Data" is a 64-Bit floating point. So the question is how do I convert the 64-Bit Floating Point to a 32-Bit Floating point. Thank you, Link to comment Share on other sites More sharing options...
AzeoTech Posted March 2, 2011 Share Posted March 2, 2011 You are thinking too hard. DAQFactory might be 64 bit internally, but the Modbus protocol driver takes care of all the conversion for you. It is very, very rare that you ever have to worry about data types in DAQFactory other than number and string. If you have a 32 bit floating point register its going to take up two Modbus registers, in your case 2756 because Modbus registers are only 16 bit. If it appears to roll into the next value on your PLC, then you probably are off by one. The value is probably registers 2755 and 2756 and not 2756 and 2757 as your request will affect. Link to comment Share on other sites More sharing options...
robbudge Posted March 8, 2011 Share Posted March 8, 2011 Kenny, If your writing to the RMC's 'Floats' You need to used a Data Type of 'Float Reversed Words' and offset the address by -1 Link to comment Share on other sites More sharing options...
polilies Posted July 10, 2011 Share Posted July 10, 2011 Hi DF Team; How could i convert two Modbus 16bit register to long or Ulong(32bit)?when i seached the guide i found "byte conversion functions", so i thought that i should firstly convert the 16bit values to byte values. then i tried to convert it via "to.uLong(,,,)" function. But i didn't succeed. Do you have any way? Link to comment Share on other sites More sharing options...
AzeoTech Posted July 11, 2011 Share Posted July 11, 2011 Like Wolftek, you are trying too hard. DAQFactory already has a Modbus I/O type that handles 32 bit registers, combining two 16 bit registers into one 32 bit one. Link to comment Share on other sites More sharing options...
polilies Posted July 11, 2011 Share Posted July 11, 2011 i'm sorry my mistake! i didn't tell you that the device doesn't let me to get values in single register.. For example i have to get seventeen values at a time. So there is many kinds of values with out ulong(32 bit)values. Link to comment Share on other sites More sharing options...
AzeoTech Posted July 11, 2011 Share Posted July 11, 2011 Oh, I see, so you have to read 17 registers and some of them need to be combined, but some are normal 16 bit registers? Well, you were on the right track using the To. and From. functions, but they all work in bytes, not words (16 bit values), so you have to take the 16 bit values from the modbus read and break it into bytes, combine those bytes into an array of 4 bytes (32 bits) then use the to. function on it. So, use From. to convert to bytes, concat to combine the two arrays, then to. to convert it back. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.