LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus multiple coil not working

Solved!
Go to solution

Hi all,

 

When I send a single coil command my labview slave.vi is ok, but when I send multiple coils, other addresses are affected (a lot of them turn to 0) even though the master is not sending anything to those addresses.

As soon as I stop sending multiple coils or go back to single coils, it is absolutely fine.

 

Is this a common problem or does anyone have any idea why this might happen?

Thanks,

Connor

0 Kudos
Message 1 of 10
(1,821 Views)

Hi all,

 

I am making an application to communicate with a Siemens PLC through modbus on the local network, the application will be a slave.

 

I have a number of addresses for communication, but mostly coils.

The problem I am facing, is the values will flicker or change constantly even when there hasn't been a change in the value...

 

e.g. slave.vi reads 40136-40148 coils. I use modpoll to act as a master and set each of these to 1.

However, if I a) use the same page to then change another address on modpoll or b) open a new page in modpoll to write another address then the slave will see the values changing (but modpoll has not changed anything)

 

This also works in the other direction, if I set modpoll to read 50 addresses, set some of them to 1 on the slave, I still get certain addresses changing from 0/1

Any help is appreciated!

0 Kudos
Message 2 of 10
(1,767 Views)

You are doing something wrong.  Of course, you failed to attach your LabVIEW code (please, if you are using LabVIEW 2022 or 2023, do a "Save for Previous Version" and specify LabVIEW 2019 or 2021 to reach a wider audience of long-time LabVIEW Developers), so we can't easily "guess" what you did (and I, for one, don't know what a "Coil Command" is, or what you mean by a LabVIEW "Slave.vi").  What is a "coil"?

 

Bob Schor

0 Kudos
Message 3 of 10
(1,783 Views)

Hi Bob,

 

I had attached some screenshots previously but my initial post dissapeared, so this was a quick re-post.

 

I have attached a 2019 VI.

 

A coil is a modbus term describing the data type attributed to address ranges, in this case a coil is a boolean, 1 or 0.

 

slave.vi is the VI that contains the code for the slave modbus server.

 

 

As you may be able to see from the attached, it reads and writes a number of addresses.

But when I use modpoll as the master, certain coil writes will affect other addresses from those modpoll is updating.

 

e.g. addresses 40139 - 40148 are 1
modpoll writes 0 to 40138 but 40139, 40140 and 40141 are also affected and turned to 0.

 

Any help is appreciated.

0 Kudos
Message 4 of 10
(1,769 Views)

@ESSConnor wrote:

Hi Bob,

 

I had attached some screenshots previously but my initial post dissapeared, so this was a quick re-post.

 

I have attached a 2019 VI.

 

A coil is a modbus term describing the data type attributed to address ranges, in this case a coil is a boolean, 1 or 0.

 

slave.vi is the VI that contains the code for the slave modbus server.

 

 

As you may be able to see from the attached, it reads and writes a number of addresses.

But when I use modpoll as the master, certain coil writes will affect other addresses from those modpoll is updating.

 

e.g. addresses 40139 - 40148 are 1
modpoll writes 0 to 40138 but 40139, 40140 and 40141 are also affected and turned to 0.

 

Any help is appreciated.


In the shared code i am not able to see write registers (40138 --40141)

 

Also I suggest you to read all the registers at once and Extract the data from array as you need.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 10
(1,752 Views)

registers 40138 - 40141 are read in the code as it is the slave.

The write for these is in modpoll, an external application that runs ideally on another PC/PLC on the same network (network is not the problem).

 

I could try that, thank you for the suggestion.

Though the list is bigger than shown so it may be quite a large amount of memory.

0 Kudos
Message 6 of 10
(1,748 Views)

@ESSConnor wrote:

I had attached some screenshots previously but my initial post dissapeared, so this was a quick re-post.


I merged your previous post with this one. No images though.

0 Kudos
Message 7 of 10
(1,739 Views)

Oops.  I just looked up "What is Modbus", and see that this is way outside my area of expertise and experience.  I'm going to "drop out" of this topic, as I'm more likely to muddy the waters than add clarification.  Sorry.

 

Bob Schor

0 Kudos
Message 8 of 10
(1,698 Views)
Solution
Accepted by topic author ESSConnor

According to the ModBus spec, writing multiple coils at once is always done in a magnitude of 8, even if you only pass one 1 boolean. So the Write Multiple Coils for 40129 followed by 40130 is expected to fail.

0 Kudos
Message 9 of 10
(1,631 Views)

Nicely spotted, hadn't seen that after hours of sifting through documents and websites.

Thank you!

0 Kudos
Message 10 of 10
(1,621 Views)