Page 1 of 2

MODBUS Confusion

Posted: Tue Jan 12, 2021 8:11 am
by p.erasmus
Hi Ben/Leigh,

Please help me understand the MODBUS Component,

P55.jpg
P55.jpg (31.89 KiB) Viewed 10209 times
from the above it seems that the MODUS Analog registers(variables) are always at address 40001 correct?
Then if my device specify a certain register to be at address 505 as shown below

P1_FC6.jpg
P1_FC6.jpg (12.92 KiB) Viewed 10209 times

I enter the address of 0x1F9 in the function ReadHoldingRegister() then the console show Address 506 which is incorrect, if I enter 0x1F8 this address with offset 1 then it shows correct as below. Is this how I should enter the address format device address - 1
P2_FC6.jpg
P2_FC6.jpg (33.01 KiB) Viewed 10209 times
Secondly does all MODUS devices have the Variable located at address 40001 this in my case the 505 is as shown in the console 40505 This is a concern for me can you help me to understand it

RegsiterCount.jpg
RegsiterCount.jpg (26.59 KiB) Viewed 10209 times

Does this RegisterCount value count in Bytes or Register values (which is 2 Bytes) ??

Thanks for helping out I appreciate you guys valuable input

:D

Re: MODBUS Confusion

Posted: Tue Jan 12, 2021 11:33 am
by BenR
Hello Peter,
from the above it seems that the MODUS Analog registers(variables) are always at address 40001 correct?
Then if my device specify a certain register to be at address 505 as shown below
The Modbus address starts from 1 whereas the Flowcode address starts from 0 so 505 + 40001 = 40506
Secondly does all MODUS devices have the Variable located at address 40001 this in my case the 505 is as shown in the console 40505 This is a concern for me can you help me to understand it
No Modbus slave devices basically pick and choose which internal addresses to support. Say a Modbus relay might only have one Coil address to store the value of the on/off state and that's it.
Does this RegisterCount value count in Bytes or Register values (which is 2 Bytes) ??
RegisterCount is the number of register values and not the number of bytes.

Re: MODBUS Confusion

Posted: Tue Jan 12, 2021 12:15 pm
by p.erasmus
Hi Ben,

Thanks a million so my 505 will show 40506 from your example :D
No Modbus slave devices basically pick and choose which internal addresses to support. Say a Modbus relay might only have one Coil address to store the value of the on/off state and that's it.
I understand that a specific device can choose where it will place the data but my confusion is from the modbus protocol it seems that all devices has the analog registers / Variables(Holding registers) located in any area from 40001 to 60000 and each device select in which address they place the data but in this area(range) right ? this being the reason that you add the user address to the 40001 right

because my issue would be if the above is not true say for example a device place a value/variable in 20001 then the FC macro will send the the wrong address as it automatically add the range 40001, I hope this explain my confusion

much appreciate your help Ben

Re: MODBUS Confusion

Posted: Tue Jan 12, 2021 2:43 pm
by BenR
Hi Peter,

The Flowcode address is what is actually sent/received by the protocol, I think the Modbus address is purely there for the reason to try and help make sense of which registers are where in one continuous block of memory.

In actuality the registers are they own seperate banks and don't have to be in one ongoing address space. They certainly aren't in my Flowcode Modbus components.

This is interesting as it shows a 5-digit Modbus address and compares to a 6-digit Modbus address to allow for more data in each section.
https://www.fernhillsoftware.com/help/d ... ormat.html

Re: MODBUS Confusion

Posted: Tue Jan 12, 2021 2:59 pm
by p.erasmus
Hi Ben,
The Flowcode address is what is actually sent/received by the protocol,
This was my confusion ,
Thanks a million this clears it ,Checking with the logic analyser this what is happening in real time and that makes sense

As you will see below now I can send the the Index and sub-function for the Motor Controller and sure it gets transmitted correctly
0x22 being the address and 0x00 being the mode Torque Control mode :D

I assume the Component calculates the CRC automatically as per MODBUS protocol Right


P1.jpg
P1.jpg (24.03 KiB) Viewed 10176 times



Thanks a lot Ben I really appreciate your time (in busy day) to help me

:D

Re: MODBUS Confusion

Posted: Tue Jan 12, 2021 3:39 pm
by BenR
Hi Peter,

No problem good luck with the project :D
I assume the Component calculates the CRC automatically as per MODBUS protocol Right
Yes this is done for you automatically 8-)

Re: MODBUS Confusion

Posted: Tue Jan 12, 2021 4:48 pm
by p.erasmus
Thanks Ben,

:D

Re: MODBUS Confusion

Posted: Mon Jan 18, 2021 6:38 pm
by BenR
I've put together a quick modbus demo video here showing slave using an esp32 and master using app developer.

https://youtu.be/OKUJiCT5G8s

Might be useful

Re: MODBUS Confusion

Posted: Tue Jan 19, 2021 7:54 am
by p.erasmus
Hello Ben,

Thank you very nice video sure it helps !

Appreciate you letting me know
Have good time

Re: MODBUS Confusion

Posted: Tue Jan 19, 2021 12:57 pm
by stefan.erni
Hi Ben

Fantastic video. It really shows the benefits of Flowcode.

regards

Stefan