Quick question about the use of reading a 32 bit integer from a modbus slave, it seems to show the wrong value. Almost like the value is being rounded off on the low byte.
I'm going to assume your using an MBRegister object or similar to read the value. Here are some properties you can check or try changing. 1. On the MBRegister object verify the vartype is set to mb_int32. 2. You may want to try changing the register property in case your address if off by 1. You'll also want to look at some properties on the ModbusComm object. 3. Make sure your wordsize is set to mb_16bit. It is very rare for the wordsize to be different that 16-bit. 4. Try toggling the swapword property to see if it makes any difference.
ok, so to confirm, the ModbusComm object is set to 16bit, the VirtualRegister is set for 32 bit int. In my modbus simulator i have register 1 set for as 0xDEAD and register 2 is 0xBEEF, when i read the registers individually as 16 bit and print them to a label in hex format they read normally, but when i read as a 32bit i get BEEFDE80 and using swapword i get DEADBF00.
Are you using the signed or unsigned 16 bit? The conversion problem could be that your expecting the 32bit to convert as an un-signed 32bit would. To get the exact hex your looking for from a 32-bit signed, you may need to use GetBytes to convert the 32bit integer to 4 bytes, then use FromBytes function to convert the 4 bytes to two unsigned ints (unibytes in Qlarity). Then convert the two unibytes to hex using the function _FormatAsHex.
If you can simplify this to a workspace with a single register object that queries those two consecutive registers, it might be helpful if you can post a screen shot of your Simulation View Communication Window (Be sure to turn on Hexidecimal display first).
Ok here is a screen shot. ModbusComm is set for 16bit registers, swapword is false Virtual Registers are set accordingly as Int16's and a Int32. Valuechanged code in each Virtual Register is "Label1.value = _FormatAsHex(value,8,true)"