Modbus Bool Write Issue?

Discuss issues and ideas you have to configuring displays with PowerVision
jbilleter
Posts: 87
Joined: Fri Oct 15, 2010 6:49 pm

Modbus Bool Write Issue?

Post by jbilleter » Wed May 14, 2014 1:30 pm

PowerVision 2.7.10406
PV450-V
Win 8.1

I am trying to write to a specific Modbus register that is set up as a bit mapped (bool) register. I would like to write to each bits individually and turn them on/off. I have a different variable for each bit/bool. They way I assume that it works is that if I set a 0 for the variable, the bit is OFF and if I set a 1 for the variable, the bit is ON. The READ portion for the mapping group seems to work without any issues, but when I attempt to WRITE to the individual bits, the variable changes to a 1, but I do not think the write occurs because the read value never changes.

I can write a 1, 2, 4, 8, 16, 32, etc. to the UShort register and see the expected results, but when I attempt to write to the individual bools, I cannot get this to work. Has writing to the individual bools been tested and verified that it works properly? Am I doing something wrong with my approach?

Your help is appreciated. Thank you.
Jacob Billeter
Staff Engineer - MurCal, Inc.
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Modbus Bool Write Issue?

Post by stalley » Wed May 14, 2014 2:40 pm

Hi!
It looks as though your approach is correct and this could be a bug. We will investigate further to see. If this is a bug, the fix should be in the 2.7 patch.
Sara Talley
Software Engineer
Enovation Controls
jtilley
Enovation Controls Development
Enovation Controls Development
Posts: 31
Joined: Wed Sep 08, 2010 10:02 am

Re: Modbus Bool Write Issue?

Post by jtilley » Mon May 19, 2014 2:38 pm

jbilleter,

After a fair bit of testing, this seems to be working as expected. Without looking at your config I can't say exactly what's going wrong, but my guess is that your Read and Write groups are pointing to the same database variables. What happens in that case is the modbus slave's response to the read request comes in and the value is written to the database variable before the write processes. So when the write goes and grabs the value of the database variable, it's already been modified with the slave's value, hence no update.

There are multiple ways to deal with this. The easiest is to have different variables for the Read group so they aren't stepping on the values that the Write group uses to send modbus register updates. The attached config "modbus master 450" shows how to do this.

Another way is to set the polling of the Write group to be faster (>2x) than the Read group. That way the processing of the Write group has a chance to complete before the Read group steps on the shared variable. This has the benefit of being able to use shared variables, but has the drawback of creating a lot more network traffic. The attached config "modbus master 450 same vars" shows how to do this.

Another way to do this that is a little more complex config-wise but allows you to use shared variables and maintain low network traffic is to stop the Read group, perform the Write, then start the Read group after some delay (the delay must be greater than the Write group's refresh rate). The attached config "modbus master 450 stop group" shows how to do this.

Like I said, without seeing your config I can't say for sure that this is the issue you're encountering. If this doesn't solve your problem, go ahead and post your config or PM it to me (if it contains sensitive info) and I can dig into it from there.

Thanks
Attachments
configs.zip
(1.98 MiB) Downloaded 16 times
Joe Tilley
Software Engineer
FW Murphy
jbilleter
Posts: 87
Joined: Fri Oct 15, 2010 6:49 pm

Re: Modbus Bool Write Issue?

Post by jbilleter » Mon May 19, 2014 2:51 pm

Thanks Joe,

I'll take a look at your examples and see if I can spot the issue. I did think about the 'using same variables' issue and tried it both ways, but it is possible I missed something.

I used another work around approach for this particular configuration that was a bit more time consuming. Since I only had to write to 6 of the bits, I only had to do it six times (rather than 16). I created state machines that added/subtracted the value of the bit (+1, -1, +2, -2, +4, -4, +8, -8, +16, -16, +32, -32) and wrote the value of the complete register (which always seemed to work). Ultimately, I think I should use the internal built bool on/off method, but I had to get something working ASAP so I went with this other approach.

If I still can't figure it out, I'll PM you the config to get your opinion. Thanks again!

Jacob
Jacob Billeter
Staff Engineer - MurCal, Inc.