MODBUS Confusion

For general Flowcode discussion that does not belong in the other sections.
User avatar
p.erasmus
Posts: 434
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

MODBUS Confusion

Post by p.erasmus »

Hi Ben/Leigh,

Please help me understand the MODBUS Component,

P55.jpg
P55.jpg (31.89 KiB) Viewed 10201 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 10201 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 10201 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 10201 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
Regards Peter - QME Electronics

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

Re: MODBUS Confusion

Post 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.

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: MODBUS Confusion

Post 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
Regards Peter - QME Electronics

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

Re: MODBUS Confusion

Post 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

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: MODBUS Confusion

Post 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 10168 times



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

:D
Regards Peter - QME Electronics

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

Re: MODBUS Confusion

Post 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-)

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: MODBUS Confusion

Post by p.erasmus »

Thanks Ben,

:D
Regards Peter - QME Electronics

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

Re: MODBUS Confusion

Post 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

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: MODBUS Confusion

Post by p.erasmus »

Hello Ben,

Thank you very nice video sure it helps !

Appreciate you letting me know
Have good time
Regards Peter - QME Electronics

stefan.erni
Valued Contributor
Posts: 1065
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 201 times
Been thanked: 225 times

Re: MODBUS Confusion

Post by stefan.erni »

Hi Ben

Fantastic video. It really shows the benefits of Flowcode.

regards

Stefan

Post Reply