Author Topic: Switching function (toggle) Code  (Read 1590 times)

sts69

  • Newbie
  • *
  • Posts: 18
    • View Profile
Switching function (toggle) Code
« on: February 05, 2017, 11:14:42 PM »
Hello,
I would like to query 16 digital inputs with momentary switch (Adr. 10001 ....) to toggle 16 digital outputs (Adr. 00065 ....).
I have only a 16 port in/out module without its own intelligence. Is an Modbus DAQ from Inlog "EDAM-5029".
The switch and Indicators by AHMI works very well. But I also need the normal Wall-Buttons for on-site operation.
E.g. if push Wall-Button 1 then toggle Output 1 etc.

Thanks and best regards
Steffen

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Switching function (toggle) Code
« Reply #1 on: February 06, 2017, 12:39:57 AM »
I am not familiar with your module and might not be understanding this right, but the logic suggests that if your Wall-Button is a physical button and brings the voltage to the input of the module when it's switched ON, then you cannot really control that input through the logic by using AHMI (the switch that you mentioned shouldn't have effect when you click it).

Can you provide more information about your setup, what switches and indicators are doing in the AHMI and what will Wall-Buttons be doing as well?

If your module only allows you to read from the inputs and write to the outputs then you can use VB code to setup a logic that compares the states of physical and logical inputs and then writes to the outputs.

Most of this stuff is normally done in the ladder logic and physical devices cannot be controlled by software.

Who knows, Archie might have a better answer/suggestion about this.
« Last Edit: February 06, 2017, 12:51:49 AM by Godra »

sts69

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Switching function (toggle) Code
« Reply #2 on: February 06, 2017, 06:07:41 AM »
OK, in short.
I will replace the MouseClick Event from a Button with a Input Signal (momentary, not latch) from DI.
This toggle the Output. The Modbus-Modul has no PCL funktions. I think the 16 I/O's is not to much for the great AHMI :-). And 99% i will control the outputs per AHMI on a Tablet.

sorry for the poor english.

best regards
Steffen

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Switching function (toggle) Code
« Reply #3 on: February 06, 2017, 07:19:41 AM »
Try something like this:

- Add a Datasubscriber to the form
- Set PLCAddressValue to the input address (00001)
- Double click the DataSubscriber to get back to the code
- Enter code similar to this:
Code: [Select]
If e.PLCAddress="00001" andalso e.Values(0)="True" then
   Dim CurrentValue as string=ModbusRtu.Read("10001")
   if CurrentValue="True" then
        ModbusRtuCom1.Write("10001","0")
    else
        ModbusRtuCom1.Write("10001","1")
     End If
End If

sts69

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Switching function (toggle) Code
« Reply #4 on: February 06, 2017, 07:31:18 AM »
I have changed the Adresses a little and then works fine :-)

Thank You very much

Steffen