Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: cncbobuk on March 09, 2015, 07:17:34 AM

Title: Toggle output from button input?
Post by: cncbobuk 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.
Title: Re: Toggle output from button input?
Post by: Hood 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
Title: Re: Toggle output from button input?
Post by: cncbobuk 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 (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.
Title: Re: Toggle output from button input?
Post by: Hood 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
Title: Re: Toggle output from button input?
Post by: Hood 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
Title: Re: Toggle output from button input?
Post by: Hood 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
Title: Re: Toggle output from button input?
Post by: cncbobuk 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?
Title: Re: Toggle output from button input?
Post by: Hood on March 09, 2015, 08:48:03 AM
Yes that is the correct OEM for output 5 LED.

Hood
Title: Re: Toggle output from button input?
Post by: TPS 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
Title: Re: Toggle output from button input?
Post by: Hood on March 09, 2015, 09:52:58 AM
Yes that one seems to work well at least in simulation.

Hood
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 10:33:54 AM
Thanks for your help guys, maybe I'm doing something wrong but no joy I'm afraid. Maybe I'll just do it outside of Mach 3.

I was hoping just to copy the routine that's used for the Flood Toggle and Mist Toggle buttons on the Diagnostic screen, both of which I have operated from external buttons. I'm clearly missing something basic.
Title: Re: Toggle output from button input?
Post by: TPS on March 09, 2015, 10:38:49 AM
Have you macropump enabled in general config ?
is your macropump macro in the wright folder ?
is your input1 working in diagnostic screen ?
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 10:52:00 AM
Have you macropump enabled in general config ? Yes

is your macropump macro in the wright folder ? Yes

is your input1 working in diagnostic screen ? No

Where's the drowning man emoticon, I think I'm way out of my depth here!
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 10:58:04 AM
I think I'm getting very confused here, Do I just enter the macro as this

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

Or do I follow the guide in the pdf attached to Thomas's post???
Title: Re: Toggle output from button input?
Post by: Hood on March 09, 2015, 11:09:07 AM
That should work as above.

Remember you need to restart Mach any time you alter the macropump.

Is Input 1 working yet when you press your switch?

Hood
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 11:17:51 AM
Ok, have re-entered as above, input 1 is operating in diagnostics but not triggering output 5?
Title: Re: Toggle output from button input?
Post by: Hood on March 09, 2015, 11:22:14 AM
Does output 5 LED light on diagnostics?

Hood
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 11:33:26 AM
Does output 5 LED light on diagnostics? No!

If I step through the macro in debug mode with no input to input 1 nothing happens, with input 1 on when I get to the 2nd last EndIf then output 5 turns on but stays on irrespective of input 1 status. only reset seems to clear it.?
Title: Re: Toggle output from button input?
Post by: Hood on March 09, 2015, 11:38:38 AM
Is your switch a momentary switch?

Hood
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 11:41:38 AM
Is your switch a momentary switch?.............. Yes
Title: Re: Toggle output from button input?
Post by: Hood on March 09, 2015, 11:43:15 AM
Strange, it is working fine here when I simulate Input 1.

If you attach your xml and the macropump I will try out here.

Hood
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 11:50:32 AM

Files attached, many thanks for your assistance, much appreciated.
Title: Re: Toggle output from button input?
Post by: Hood on March 09, 2015, 11:53:53 AM
Is that the name of the macro you have?

It needs to be called Macropump.m1s.


Hood
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 12:00:03 PM
Thank you, Thank you, Thank you, Thank you, Thank you,

Why am I such a Div?  ???

Now works perfectly, on to the next step  :)

As a matter of interest then, if I want to use another macro how do I name that one, or does it all have to be done in the same one?
Title: Re: Toggle output from button input?
Post by: Hood on March 09, 2015, 12:05:57 PM
Done in the same one if it to be constantly monitoring something.

If it is just  for something you want to do and call from MDI or code then you can make a macro and name it m101.m1s (or a greater number)

For example I have a macro called m123.m1s  it is to move to a safe position, remove the tool currently in the spindle and set the height offset to H0, I just call it from MDI or code with m123

Hood
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 12:11:10 PM
Understand!

And would you believe it your tool change macro is exactly what I wanted to do after I get the system up and running. (Cheeky mode on) Any chance of a copy?  ;) (Cheeky mode off)
Title: Re: Toggle output from button input?
Post by: Hood on March 09, 2015, 12:15:30 PM
Probably wont be much use for you as it basically just sends the axes to a set position and then sends signals to my PLC which then does the rest but here it is

Code "G53G0Y310Z-5M3S200"
 While IsMoving()
 Wend
 
 If GetInput(2) Then
 SetModOutput(17,1)
  Sleep 1000
SetModOutput(17,0)
SetModOutPut (29,1)
  Sleep 1000
SetModOutPut (29,0)
Else
SetModOutput(18,1)
  Sleep 1000
SetModOutput(18,0)
SetModOutPut (29,1)
  Sleep 1000
SetModOutPut (29,0)
End If
 
setoemdro(824,0)
Code "M5G43H0"   



Hood
Title: Re: Toggle output from button input?
Post by: TPS on March 09, 2015, 04:06:56 PM
ok cncbobuk,

i am not a friend of the macropump road.
can i get you into my OEMTRIGGER road as described in my small tutorial (PDF) ?

yust let me know.

Thomas
Title: Re: Toggle output from button input?
Post by: cncbobuk on March 09, 2015, 04:26:33 PM
Hi Thomas,

Many thanks for your support, the macropump does seem to work ok now that I understand a little more about it. I am however open to suggestion so would be interested to try your route as well as this will be an education for me anyway. I may well need some hand holding along the way, as although I can handle the electronics without problems the programming is a bit of a nightmare for me. Let me know what you think.

Regards, Bob.
Title: Re: Toggle output from button input?
Post by: TPS on March 10, 2015, 04:40:08 AM
Hi Bob,

looks like i have missed some posts yesterday.
glad to read that you got the Macropump running.

if you whant to try out other thing#s just let us know,
and we will give you a hand to find the way.

Thomas
Title: Re: Toggle output from button input?
Post by: stirling on March 10, 2015, 06:51:54 AM
i am not a friend of the macropump road.
can i get you into my OEMTRIGGER road as described in my small tutorial (PDF) ?

Hi Thomas

Unfortunately trigger macros have been "damaged" for many years. Your scheme as described (in your PDF) will work fine as long as Mach's not doing anything else but try triggering your macro whilst some gcode is running. I think you'll be disappointed. :'(

I tried for years to get this fixed but to no avail.

Ian
Title: Re: Toggle output from button input?
Post by: TPS on March 10, 2015, 07:07:41 AM
Hello Ian,

thank you for this information, never tryed this.

So the only possibilities during running the machine will be

macropump and brain (but brains are also courious sometimes).

Thomas
Title: Re: Toggle output from button input?
Post by: stirling on March 10, 2015, 07:54:37 AM
indeed (note that OEM triggers are fine - they fire immediately - it's just trigger MACROS that have the "turned up late for work" problem).
Title: Re: Toggle output from button input?
Post by: TPS on March 10, 2015, 08:28:00 AM
Hello Ian,

- it's just trigger MACROS that have the "turned up late for work" problem).

sorry my english is to bad to translate ("turned up late for work" problem) this correctly, could you please explain ?

Thank You Thomas
Title: Re: Toggle output from button input?
Post by: stirling on March 10, 2015, 10:56:30 AM
Sorry Thomas - I just meant to say that the problem is that the macro runs late i.e. after any gcode buffer is emptied rather than when the trigger actually fires.

Ian
Title: Re: Toggle output from button input?
Post by: TPS on March 10, 2015, 11:03:54 AM
ok got it now.

Thomas
Title: Re: Toggle output from button input?
Post by: Ghantos on May 27, 2015, 02:55:05 AM
hello hood,
as you know all Digital outputs are turned off as soon as  E-stop or Emergency Button or limit Switch is trigged.

i have 2 horizontal Routers that travill Up/Down by a Penumatic Piston controlled by 2 Digital outputs.
and if they were in working in and i press the e stop or any Limit Switch been trigged the piston will go up and damage the Wooden workPiece or breake the tool.

so how i can avoid this problem that these digital outputs not turned off if the E-Stop is trigged or any emergency button is pressed??
please let me know!

regards;
Ghantos
Title: Re: Toggle output from button input?
Post by: TPS on May 27, 2015, 07:36:15 AM
Change the valves to 5/2 pulse triggered (4 Outputs).

than the valve stayes in his last Position.

Tomas
Title: Re: Toggle output from button input?
Post by: Ghantos on May 27, 2015, 08:05:46 AM
Dear Tomas,
thank you for the answer.

by the way i know this solution but the problem that i have no more Outputs to use!

i ask if there is any logic condition or to wirte a macro for this.

please let me know!
regards;
Ghantos
Title: Re: Toggle output from button input?
Post by: TPS on May 27, 2015, 09:02:06 AM
Hi,
dont think there is a macro solution, bcause the Outputs will be turned off anyway.

may be you can use a Hardware filp-flop relay (1st puls on, next pulse off and so on)?

Thomas