Author Topic: Reading and writing to %MW holding register  (Read 1046 times)

jbsquires

  • Newbie
  • *
  • Posts: 3
    • View Profile
Reading and writing to %MW holding register
« on: September 21, 2020, 05:52:49 PM »
I am using OpenPLC and a UniPi 1.1 and have a program that controls a vacuum sealer working. I set up an HMI screen in AdvancedHMI and have all the button and pilot lights working. In OpenPLC I am using 3 INT variables (vtime=%MW0, stime1=%MW1 and stime2=%MW2)  and using INT to Time converters to change the INT value to time for the timer. In AdvancedHMI I have setup 3 digital meters to read/write the %MW values from/to the PLC. So far reading the value (40001, 40002, 40003) seems to work (It shows for the initial value set in the PLC program but using the keypad and change the value to say 8 does not seem to be changing the time in the timer. Any suggestions or ideas would be greatly appreciated. I am a electrician doing this for a friend who doesn't have the $8000 to replace the machine.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5276
    • View Profile
    • AdvancedHMI
Re: Reading and writing to %MW holding register
« Reply #1 on: September 21, 2020, 06:28:34 PM »
Does something in the PLC program write to the values?

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Reading and writing to %MW holding register
« Reply #2 on: September 21, 2020, 10:13:58 PM »
Maybe you should explain the whole setup you have and Modbus mapping in a better way than what's in your post.

AdvancedHMI has drivers that should be able to directly communicate with the device, so what role does the OpenPLC play here?

If your %MW0 to %MW2 are Read/Write registers then AdvancedHMI should be able to read from as well as write to.

jbsquires

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Reading and writing to %MW holding register
« Reply #3 on: September 22, 2020, 06:30:39 PM »
Ok so attached is the the ladder diagram from OpenPLC and the variable list.  Also attached is the vbs file from. AdvancedHMI.

Simply there is a button to Start the vacuum pump and open the lid,one to stop it. Once the Pump is running there is a "Run" button that starts the sequence:
1. Lid closes
2. Chamber vacuums are out.
3. Seal One seals the bag
4. Seal Two seals the bag
5. Vacuum exhausts and lid rises

HMI Screen:

Has Stop, Start and Run buttons (although they are not necessary)
Also has Indicators to show when machine is on, chamber is vacuuming, seal1 and seal 2.
Also 3 Digital meter to show Time (In seconds between 1 and 10) for Vacuum, Seal 1 and Seal 2

Hope this enough information.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5276
    • View Profile
    • AdvancedHMI
Re: Reading and writing to %MW holding register
« Reply #4 on: September 22, 2020, 07:04:08 PM »
I'm not able to read the ladder program image. What I am looking for is where vtime is used in the program.

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Reading and writing to %MW holding register
« Reply #5 on: September 22, 2020, 11:50:19 PM »
If you check the following page, can you confirm that your Modbus addressing is correct (as %MW range should be 41024 to 42047):

  https://www.openplcproject.com/reference/modbus-slave/


The picture seems to go like this:

- vtime to IN of the INT_TO_TIME whose OUT is going to PT of TOF2
- stime1 to IN of the INT_TO_TIME whose OUT is going to PT of TOF0
- stime2 to IN of the INT_TO_TIME whose OUT is going to PT of TOF1

It is possible that program is writing the original values back every time the PLC cycles.

« Last Edit: June 11, 2021, 04:38:59 PM by Godra »

jbsquires

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Reading and writing to %MW holding register
« Reply #6 on: September 26, 2020, 07:08:03 AM »
If you check the following the page, can you confirm that your Modbus addressing is correct (as %MW range should be 41024 to 42047):

  https://www.openplcproject.com/reference/modbus-slave/


The picture seems to go like this:

- vtime to IN of the INT_TO_TIME whose OUT is going to PT of TOF2
- stime1 to IN of the INT_TO_TIME whose OUT is going to PT of TOF0
- stime2 to IN of the INT_TO_TIME whose OUT is going to PT of TOF1

It is possible that program is writing the original values back every time the PLC cycles.

Found the problem, I had the wrong ModBus entries, corrected (41025,41026,41027) and it works like a charm.
Thanks to everyone for the patience and input.