Posted 14 Jan 2020 Hello, From modbus, Im reading a HEX variable in the data register D0, as it is a 32 bit variable, the second part is saved in D1, then I get: D0: BE62 D1: 31D7 The value that I should obtain in float is -0.2208932 as I obtained setting BE6231D7 in online Hex to float converter and this agree with what I'm reading on the flowmeter. The problem is that when I try to change the data type from channel to Real on CX programmer I obtain a different value, also the registers are not sort in the proper way, instead they are sort inversely 31D7BE62, and obviusly the obtained value is completely different. Also instead of Hex, I want to display the decimal, or floating value, is there a way to do this? I'll attach some captures. Share this post Link to post Share on other sites
Posted 14 Jan 2020 If it sorts inversely, then move the data words to change their order of the 16 bit data words and convert to float D0: BE62 move to D2 D1: 31D7 stays in D1 D1: 31D7 D2: BE62 new inverse of the sequential data D1 D2 is BE6231D7; convert D1 D2 to the correct float Share this post Link to post Share on other sites
Posted 14 Jan 2020 Oh, I aprecciate your answer. I already do that and its working perfectly, thanks. Is this the best way? this wouldn't affect the speed in which the data is showed? Share this post Link to post Share on other sites
Posted 14 Jan 2020 Is it the best way? I don't know. Does it matter how fast the conversion is? I do know that there four different word/byte (IEE754) formats for 32 bit floating point values, two of which are commonly used in Modbus. Many Modbus master/clients provide the ability to pick one of the two to use to interpret the raw data. If your master/client has a choice for floating point formats, you could try the alternative one and see if it does the conversion properly with the raw data, before moving the data. Share this post Link to post Share on other sites
Posted 14 Jan 2020 Ok ok, I understand, Thanks for your fast answers! It was really helpful! Share this post Link to post Share on other sites
Posted 15 Jan 2020 @alpr_94Deselect the "16" button. It forces the display to hex. If you specify Real as the display in the watch window and none of the format buttons are selected in the toolbar as shown above, the format selected in the watch window will be the format that is displayed. Share this post Link to post Share on other sites
Posted 15 Jan 2020 (edited) On 1/14/2020 at 2:12 PM, alpr_94 said: Is this the best way? There are may ways to exchange data. DanW shows you the basic method that would work with any PLC. Omron has a Data Exchange instruction that would accomplish this without using another memory location. XCHG(073), D0, D1 On 1/14/2020 at 2:12 PM, alpr_94 said: this wouldn't affect the speed in which the data is showed? The conversion, no matter how you do it, can happen within one PLC scan. You'll never notice the micro seconds that it take to execute the instructions. If you can, I would do as DanW suggests and change the setting at your Modbus source. Edited 17 Jan 2020 by IO_Rack Share this post Link to post Share on other sites
Posted 16 Jan 2020 I missed the fact that the words were swapped. I did not look at the values close enough. My point was that there is not a conversion function from HEX to Float per se, you just need to interpret it the right way. Share this post Link to post Share on other sites
Posted 17 Jan 2020 18 hours ago, Michael Walsh said: you just need to interpret it the right way. That's always worth mentioning. I believe this has got to be the most common issue that people have with Omron PLCs. Especially if they have come from AB or any IEC 61131-3 compliant system. Share this post Link to post Share on other sites