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
ModBus Master Read coil
-
- Posts: 18
- http://meble-kuchenne.info.pl
- Joined: Fri Jul 01, 2022 5:00 pm
- Has thanked: 9 times
- Been thanked: 2 times
-
- 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
Hi
The WiKi is a good starting point.
https://www.flowcode.co.uk/wiki/index.p ... s:_System)
Hope this helps.
Regards
The WiKi is a good starting point.
https://www.flowcode.co.uk/wiki/index.p ... s:_System)
Hope this helps.
Regards
Re: ModBus Master Read coil
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.
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.
Re: ModBus Master Read coil
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
Note that this program is not working on hardware. Any idea what is wrong ?
Regards
George
- Attachments
-
- MODBUS.fcfx
- (15 KiB) Downloaded 56 times
-
- 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
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
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
-
- 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
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.
Lastly the RegAddress parameter might not be correct, what address are you trying to read?
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.
Lastly the RegAddress parameter might not be correct, what address are you trying to read?
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: ModBus Master Read coil
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
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