09-04-2017 07:10 AM
Hello
I am trying to read a holding register on a Mantracourt loadcell conditioner. I know that the address is correct because two other applications are able to read it. The address should be 40021 and I have tried 40021, 0021 and 21 in the starting address box of a modified Simple Serial Example. Modbus RTU over RS485.
If Iam using Modbus library I get error message "1073807253, A framing error occurred during transfer" . I have checked all the baud rate etc that is not default but there does not seem to be any way to specify the stop bit.
If I try with the Plasmionique Modbus library I get Error 403462, Modbus exception 2: Illegal data address.
Can anyone tell me what is wrong?
Solved! Go to Solution.
09-04-2017 08:51 AM
For register 40021, you should enter 20 as the starting address.
A framing error means something is wrong with your serial settings. Perhaps number of stop bits.
09-04-2017 02:54 PM - edited 09-04-2017 02:57 PM
Just to add to RavensFan's response the reason why 20 is the address you need is that Modbus data addresses are defined as starting at 1 (ie the first HR address is 40001) but the Modbus API and low level message format expects addresses indexed from 0. That's why Modbus address 40021 requires the input 20 on the API.
The Modbus message format also formats addresses for each data area without the "0x, 1x, 3x or 4x" headers - the actual serial string sent to the master, in this case, would be requesting address 20 from the Holding Registers (function code 3) . Wiki has a good starting background describing this (here), if you want more details the protocol specs are just a google search away
09-05-2017 05:06 AM - edited 09-05-2017 05:15 AM
That's great thanks, I have managed to read the register with the plasmionique library at least, but the data coming out of the device is erratic and not representative, whilst the data should look like the picture below, I am getting vastly ranging numbers like 26559,60530,12918,5962. and I notice that the slave device permitted data length is 4 bytes but the representation and data type coming out of the modbus API is U16 (2 bytes). Could this be the reason that the MB library is reporting a framing error? More importantly is there a way to change the number of bytes handled by the API if that is what is needed?
Regards Ed
09-05-2017 07:17 AM
As already pointed out by RavensFan, the framing error is a communication error at the single character serial packet, thus is not Modbus related.
It means that your serial port could not properly receive data (independently on the data structure). Probably the serial settings don't match those of the device.
Now about the received value. It seems the number you need is a floating point value, so 32 bits (64 bits double values are possible but very uncommon in these cases). Holding registers are words,16 bit values (Modbus standard), so it's customary to split a float in two registers. Normally, one reads two consecutive registers, then re-assemble the original float by means of the functions Join numbers and Cast (to a float). It may be necessary to rearrange the byte or word order though, depending on the actual representation (endianness).
I don't know how the plasmionique library manages this, but certainly you need to read at least two registers to get one float.
09-05-2017 02:19 PM
Based on the wildly varying numbers I would first try swapping the bytes before piecing together the each 4 byte set and then casting to float.
The following links might help:
http://digital.ni.com/public.nsf/allkb/AD8172B710AFB13F86257974007D6F52
http://digital.ni.com/public.nsf/allkb/2462D01074BDB1A886256D9600506763
There are also many forum questions around this on this site; a search will pick up similar solutions.
09-08-2017 08:45 AM
Thats been really helpful, I did a word swap as below and got a believable value given that the load cell is in slightly different position. Also a 1.5 k weight is about right (I cannot tare the device at this stage). Incidentally the stop bit issue has gone away since I used an unbundled serial config for the parameters, even though the stop bit is not connected. Thanks for your help.
Ed