MODBUS Slave Holding Registers

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

MODBUS Slave Holding Registers

Post by AbhijitR »

Hello!

I am working on MODBUS Slave and i noticed one problem (i am not sure if this is a problem or it is like that only), when i assign SetHoldingRegister or ReadHoldingRegister in a sequence all goes well till i assign Coil Address 00007, when i assign Coil Address 00008 and 00009 then the warning is Syntax Error, then i assign the Coil Address as 00010 all goes well again until Coil Address 00018 and 00019 and probably so on, i guess.

When i check the MODBUS Slave on computer using MODBUS Master, then the Coil Address 00008 which is now 00010 and 00009 is now 00011 shows correct on the computer as 00008 and 00009 in real time.

Now the problem is when i provide the data to the user i need to cautiously mention correct Coil Address as there is a difference of 2 digits every time.

May i know if this is possible to rectify the problem of Coil Address 00008, 00009, 00018, 00019

Thank you.

Abhi

chipfryer27
Valued Contributor
Valued Contributor
Posts: 614
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: MODBUS Slave Holding Registers

Post by chipfryer27 »

Hi Abhi

What chip are you using? Is it the same with all or just specific to the one you are using? Initially it does perhaps sound like a bug somewhere especially if your PC shows correct.

Not an expert in MODBUS but I do have Master/Slave emulators and some basic hardware that I can use to perhaps replicate issue if it helps. Bit busy just now but happy to help when/if I can.

Regards

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MODBUS Slave Holding Registers

Post by Benj »

Hello,

The problem is that a number starting with a 0 is interpreted as an octal number in C. Hence the problems with addresses 8 and 9 which are outside the range of an octal digit.

Try just using the values 8 and 9 instead of 0008 and 0009, hopefully they will work correctly for you.

More info here.
https://www.geeksforgeeks.org/octal-numbers-c/

Post Reply