Hello Guest it is March 28, 2024, 12:22:43 PM

Author Topic: Turn on an Output? Shamefully simple?  (Read 6391 times)

0 Members and 1 Guest are viewing this topic.

Turn on an Output? Shamefully simple?
« on: November 18, 2010, 10:36:40 PM »
All-

I give up...  What command, OEM code, M-Code, or whatever do I use to turn on a given output pin from Mach3???  I want to make a screen to turn on or off the ~15 digital outputs my BOB has, but at the simplest level I just want to know what to do inside MACH first.  Of course I know how to use m-codes for the pre-defined outputs like spindle, coolant, etc but how do I manipulate an output that's not hardcoded to an M-Code???????  Seems like a very basic thing but I don't find a word about it in the Mach manual, or in the hundreds of messages I get after entering various search words on the forum... 

HELP!!! 

Offline Greolt

*
  •  956 956
    • View Profile
Re: Turn on an Output? Shamefully simple?
« Reply #1 on: November 19, 2010, 01:10:13 AM »
Make an on-screen button in a program like MachScreen

Set the function to "Execute VB-Script"

Enter code like this example in the "Execute Code" field

If IsOutputActive(OUTPUT4) Then
DeActivateSignal(OUTPUT4)
else
ActivateSignal(OUTPUT4)
end if


This will toggle output  4.

Set the relevant ouput to the pin of your choice in "Ports and Pins"

Hope this helps

Greg
« Last Edit: November 19, 2010, 01:12:49 AM by Greolt »
Re: Turn on an Output? Shamefully simple?
« Reply #2 on: November 20, 2010, 11:14:47 AM »
Works perfectly.  You guys rock. 
Re: Turn on an Output? Shamefully simple?
« Reply #3 on: November 20, 2010, 04:33:30 PM »
Hmmm...  now a slightly separate issue...  The code works great, I also added a polling routine to my macro pump that watches for any outputs in an "on" state and it lights up an LED button for me if it sees anything. 

On the BOB itself, I can also see that on each of my 16 outputs te "activity light" responds whenever I press the software buttons I made...  Furthermore, I put a mutimeter on a couple of the pins and sure enough when I hit my software button I get ~12VDC out!  Which is exactly what I wanted BUT....

I hooked up the 12VDC relay coil to it and clicked my software button and no-go.  I thought maybe I had a bad relay so I swapped it out, same story. The coils require 75mA at 12VDC to fire, and my BOB is supposedly rated to output 100mA, so I shouldn't have a current problem...
Re: Turn on an Output? Shamefully simple?
« Reply #4 on: November 20, 2010, 04:35:49 PM »
As an experiment, I unhooked the relay from the BOB and ground and attached the leads to a little 9VDC battery (one of the small rectangular ones). The relay instanly fired, no problems.  I put a DC ampmeter around one of the leads and connected it again, and saw that not only did it work but it was only drawing about ~60mA to fire the relay even though it was a 9V battery.

Re: Turn on an Output? Shamefully simple?
« Reply #5 on: November 20, 2010, 04:39:53 PM »
So I hooked the relay back up to the BOB with the ampmeter around one of the leads and clicked my software button for that output pin.  The BOB's activity light came on, but the relay did NOT fire and the ampmeter stayed the same - 0 amps!!!! 

What gives?  How could my BOB be outputting a voltage with so little current that the relay cannot fire? 

Offline Greolt

*
  •  956 956
    • View Profile
Re: Turn on an Output? Shamefully simple?
« Reply #6 on: November 20, 2010, 04:54:12 PM »

The code works great, I also added a polling routine to my macro pump that watches
for any outputs in an "on" state and it lights up an LED button for me if it sees anything. 


Rather than running a macro pump, try adding a LED for each output on your screen and adding these lines to the example code.

If IsOutputActive(OUTPUT4) Then
DeActivateSignal(OUTPUT4)
SetUserLED(XX, 0)
else
ActivateSignal(OUTPUT4)
SetUserLED(XX, 1)
end if

Greg
Re: Turn on an Output? Shamefully simple?
« Reply #7 on: November 20, 2010, 05:25:57 PM »
Good point, the conditional for the button state can just as easily include the code to activate the LED.  And is much more efficient.

Anyone got a clue on the lack of current from the output pin????

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Turn on an Output? Shamefully simple?
« Reply #8 on: November 20, 2010, 05:39:30 PM »
What BOB is it, got a link to the docs? What is the voltage when you try to operate the coil?
Hood
Re: Turn on an Output? Shamefully simple?
« Reply #9 on: November 20, 2010, 05:52:03 PM »
Well, I was wondering when someone would ask.  It's actually a Gecko G100, which I am otherwise very happy with.  I chose to post here rather than the g100 section because the original issue I figured was a Mach software command issue rather than a g100 problem...  That and people seem to look at the g100 like it's the plague...