Hello Guest it is April 19, 2024, 07:35:06 AM

Author Topic: Toggle output from button input?  (Read 13967 times)

0 Members and 1 Guest are viewing this topic.

Toggle output from button input?
« on: March 09, 2015, 07:17:34 AM »
Apologies for this as again I'm sure it's been covered but I want to do a simple toggle on/off of a relay connected to Port 2 pin 3 from a hardware button on Port 3 pin 15. Controller is UC300

I've been looking at the macro in this thread "Re-routing input to output in Mach??" but am just going round in circles trying to work it out, not a good day I'm affraid >:(

Would someone please point me in the right direction?

Many thanks.

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Toggle output from button input?
« Reply #1 on: March 09, 2015, 07:42:42 AM »
Does the UC300 have built in modbus similar to the CSMIO or are you just setting the inputs and outputs up in ports and pins in Mach?

BTW your link didnt seem to work so I could not follow to the thread you mentioned.

Hood
Re: Toggle output from button input?
« Reply #2 on: March 09, 2015, 07:54:42 AM »
Thanks for getting back, the link should be http://www.machsupport.com/forum/index.php/topic,29178.0.html if that helps. (Don't think that's the way to do it but should work)

I'm just setting I/O in Mach 3, I don't think the UC300 offers Modbus. I/O is via 5 LPT ports, 2 normal and 3 set to input mode.

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Toggle output from button input?
« Reply #3 on: March 09, 2015, 08:21:16 AM »
Ok something like this in the macropump may work, I am assuming They are set up as Input 1 and Output 1 for the code, so if you are using differnt ones you would need to amend accordingly.


LED = GetOEMLED(852)  ' LED looks at state of Output 1 LED


If IsActive (Input1) And LED = True Then  ' looking at input 1 and LED of Output 1
DeActivateSignal (OutPut1)
Else
 If IsActive (Input1) And LED = False Then
  ActivateSignal (OutPut1)
 End If
 End If



Hood

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Toggle output from button input?
« Reply #4 on: March 09, 2015, 08:28:31 AM »
Just checked, that wont work correctly, will have to think about it and hopefully I can work out how to do it.

Hood

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Toggle output from button input?
« Reply #5 on: March 09, 2015, 08:31:19 AM »
Maybe it is working, I am just simulating here and it seems to work most of the time,  so if you get a chance give it a go and shout back if it is not correct.

Hood
Re: Toggle output from button input?
« Reply #6 on: March 09, 2015, 08:38:25 AM »
I have my system hooked up on the bench with motors, switches etc. all connected so can try it without any fear of damage, but just so I don't mess this up I'm assuming this to be correct if I use Input 1 and Output 5

LED = GetOEMLED(78)  ' LED looks at state of Output 5 LED


If IsActive (Input1) And LED = True Then  ' looking at input 1 and LED of Output 5
DeActivateSignal (OutPut1)
Else
 If IsActive (Input1) And LED = False Then
  ActivateSignal (OutPut1)
 End If
 End If

Am I right?

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Toggle output from button input?
« Reply #7 on: March 09, 2015, 08:48:03 AM »
Yes that is the correct OEM for output 5 LED.

Hood

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Toggle output from button input?
« Reply #8 on: March 09, 2015, 08:58:19 AM »
Hi,

don't think its gona work in macropump because you have to create a rising edge of the input.

this may work:

If not IsActive (Input1)  = True Then
  LED = GetOEMLED(78)  ' LED looks at state of Output 5 LED
End If

If IsActive (Input1) And LED = True Then  ' looking at input 1 and LED of Output 5
  DeActivateSignal (OutPut5)
Else
 If IsActive (Input1) And LED = False Then
   ActivateSignal (OutPut5)
 End If
End If







made a small document how it should work, not the easy way, but it's working here.
sorry for the german windows, but you should find them in the english version.

Thomas
« Last Edit: March 09, 2015, 09:14:16 AM by TPS »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Toggle output from button input?
« Reply #9 on: March 09, 2015, 09:52:58 AM »
Yes that one seems to work well at least in simulation.

Hood