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
MODBUS Slave Holding Registers
Moderator: Benj
-
- Valued Contributor
- Posts: 686
- Joined: Fri Jun 06, 2014 3:53 pm
- Has thanked: 185 times
- Been thanked: 204 times
- Contact:
Re: MODBUS Slave Holding Registers
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
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
- 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
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/
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/
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel