Hello Guest it is November 08, 2024, 09:52:12 PM

Author Topic: How to create a simple toggle button?  (Read 14146 times)

0 Members and 1 Guest are viewing this topic.

How to create a simple toggle button?
« on: November 26, 2019, 03:04:49 PM »
Can anyone explain how to create a simple toggle button (code/script) that I can use to turn on/off an output or trigger a Modbus command?  Thanks much for any replies/guidance/links/videos/etc.

Offline TPS

*
  •  2,528 2,528
Re: How to create a simple toggle button?
« Reply #1 on: November 29, 2019, 03:24:46 PM »
If IsActive(OUTPUT1) Then
    DeactivateSignal (OUTPUT1)
Else
    ActivateSignal (OUTPUT1)
End If
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: How to create a simple toggle button?
« Reply #2 on: December 14, 2019, 05:33:43 PM »
HEY!! Just saw this (don't know why the notification via email isn't working??) but THANK YOU VERY MUCH SIR!
Re: How to create a simple toggle button?
« Reply #3 on: December 14, 2019, 06:03:38 PM »
OK, I just tried it....  Output is activated as expected but will not Deactivate.    I'm using Output 6 and copied your script only changing the "1" to a "6".  Any ideas what could be Wonky??  THANK YOU!!!

Offline TPS

*
  •  2,528 2,528
Re: How to create a simple toggle button?
« Reply #4 on: December 15, 2019, 04:03:22 AM »
for Output 6 try this:

Code: [Select]
If GetOEMLed(79) Then
    DeactivateSignal (OUTPUT6)
Else
    ActivateSignal (OUTPUT6)
End If
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: How to create a simple toggle button?
« Reply #5 on: February 19, 2020, 04:12:29 PM »
Worked like a Charm!! THANK YOU !!!!!
Re: How to create a simple toggle button?
« Reply #6 on: February 19, 2020, 04:50:01 PM »
NEXT QUESTION!!!  What you explained works GREAT for Outputs already a part of the MACH3 architecture BUT, what if you run out of MACH3 Outputs and just want to turn on/off more devices via MODBUS/PLC. 

For example, I want to turn on/off the Air Compressor in my shop by pushing a button on MACH3 Screen.

Simply Put... in the example below... what do I enter to replace the OUTPUT1 identifier so it will be recognized by MODBUS instructions?

 DeactivateSignal (OUTPUT1)
Else
    ActivateSignal (OUTPUT1)


what do I enter to replace the OUTPUT1 identifier so it will be recognized by MODBUS instructions?

THANKS AGAIN SO VERY MUCH FOR YOUR HELP!

Offline TPS

*
  •  2,528 2,528
Re: How to create a simple toggle button?
« Reply #7 on: February 20, 2020, 01:31:37 AM »
should be

SetOutBit(BuffIndex, BitNumber)
ReSetOutBit(BuffIndex, BitNumber)

but never worked with modbus
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: How to create a simple toggle button?
« Reply #8 on: March 13, 2020, 06:22:21 PM »
Thanks for your reply.  Sorry if this is a stupid question but....  How do I know the BUFFINDEX address?  are you referring to the MODBUS Address?  Not clear on this.  Perhaps and example with some sample data would be helpful if you wouldn't mind??

THANK YOU!

Offline TPS

*
  •  2,528 2,528
Re: How to create a simple toggle button?
« Reply #9 on: March 14, 2020, 03:34:05 AM »
as written i never worked with modbus,

but here

http://www.machsupport.com/videos/

is a Video witch explains modbus a Little bit.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.