ModBus Master Read coil

For general Flowcode discussion that does not belong in the other sections.
Post Reply
george_b
Posts: 18
http://meble-kuchenne.info.pl
Joined: Fri Jul 01, 2022 5:00 pm
Has thanked: 9 times
Been thanked: 2 times

ModBus Master Read coil

Post by george_b »

Hi,

For the purpose of a project i need to write and read several bits using read and write coil function of modbus.

I can successfully write to the slave coil status but i can not read the coil status from the slave.

Is there any example using Modbus Master to read coil from a slave?

I would be really grateful for anyone who can give me some help on this one.

Thank in advance!


Regards
George

chipfryer27
Valued Contributor
Posts: 1188
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 289 times
Been thanked: 418 times

Re: ModBus Master Read coil

Post by chipfryer27 »

Hi

The WiKi is a good starting point.

https://www.flowcode.co.uk/wiki/index.p ... s:_System)

Hope this helps.

Regards

george_b
Posts: 18
Joined: Fri Jul 01, 2022 5:00 pm
Has thanked: 9 times
Been thanked: 2 times

Re: ModBus Master Read coil

Post by george_b »

Hi,


Thanks for you reply. I have already checked the examples in wiki page. None of them shows how to read coils while using Modbus Master component!

george_b
Posts: 18
Joined: Fri Jul 01, 2022 5:00 pm
Has thanked: 9 times
Been thanked: 2 times

Re: ModBus Master Read coil

Post by george_b »

would it be possible for any member to attach an example of a program reading coil using Modbus Master?

Thanks in advance!

Regards
George

seokgi
Posts: 180
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 5 times
Been thanked: 7 times

Re: ModBus Master Read coil

Post by seokgi »

Hello?
I program using the 3XXXX Holding Register address.
This advantage is that only one address is used during Modbus communication and there is less error occurrence.

Hope this helps.

george_b
Posts: 18
Joined: Fri Jul 01, 2022 5:00 pm
Has thanked: 9 times
Been thanked: 2 times

Re: ModBus Master Read coil

Post by george_b »

Attached is a program thrying to read modbus registers using Modbus Master component.

Note that this program is not working on hardware. Any idea what is wrong ?


Regards
George
Attachments
MODBUS.fcfx
(15 KiB) Downloaded 56 times

chipfryer27
Valued Contributor
Posts: 1188
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 289 times
Been thanked: 418 times

Re: ModBus Master Read coil

Post by chipfryer27 »

Hi

The "old" forum has a lot of info re Modbus. Don't know if it will help

https://www.matrixtsl.com/mmforums/sear ... l&start=25

Also, these Demo's appear to be using coils.

https://www.flowcode.co.uk/wiki/index.p ... s:_System)

Regards

BenR
Matrix Staff
Posts: 1760
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 447 times
Been thanked: 607 times

Re: ModBus Master Read coil

Post by BenR »

Hi George,

Looking at your program it appears you're close. Have you done a LED flasher test to confirm things like delays are accurate, this is required to get the communications baud correct.

https://www.flowcode.co.uk/wiki/index.p ... ED_flasher

I've changed a couple of things in your program, firstly to move the delay so that you're not constantly hammering the comms and seconds to change the index for GetResponseInt from 0 to 4 which is the start of the return data.

MODBUS.fcfx
(15 KiB) Downloaded 51 times
Lastly the RegAddress parameter might not be correct, what address are you trying to read?

george_b
Posts: 18
Joined: Fri Jul 01, 2022 5:00 pm
Has thanked: 9 times
Been thanked: 2 times

Re: ModBus Master Read coil

Post by george_b »

Hi Ben and thanks for you reply.

I did manage to make it working after a loooot of time trying and trying different things.

Indeed GetResponseInt must be 4 as you said.

RegAddress is correct since the device i am trying to read gives me this registers map .

Thanks again for your support.


Regards
George

Post Reply