Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: AtlasMills on November 18, 2010, 10:36:40 PM

Title: Turn on an Output? Shamefully simple?
Post by: AtlasMills 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!!! 
Title: Re: Turn on an Output? Shamefully simple?
Post by: Greolt 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
Title: Re: Turn on an Output? Shamefully simple?
Post by: AtlasMills on November 20, 2010, 11:14:47 AM
Works perfectly.  You guys rock. 
Title: Re: Turn on an Output? Shamefully simple?
Post by: AtlasMills 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...
Title: Re: Turn on an Output? Shamefully simple?
Post by: AtlasMills 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.

Title: Re: Turn on an Output? Shamefully simple?
Post by: AtlasMills 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? 
Title: Re: Turn on an Output? Shamefully simple?
Post by: Greolt 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
Title: Re: Turn on an Output? Shamefully simple?
Post by: AtlasMills 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????
Title: Re: Turn on an Output? Shamefully simple?
Post by: Hood 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
Title: Re: Turn on an Output? Shamefully simple?
Post by: AtlasMills 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...
Title: Re: Turn on an Output? Shamefully simple?
Post by: Hood on November 20, 2010, 05:57:31 PM
Ok no probs with that, well as long as you keep at arms length from me, dont want to catch anything ;D
Seriously though, have you measured the voltage when trying to operate the coil? I am guessing it will be zero. Sounds like the output just isnt supplying the current its meant to be. Dont have any experience of the G100 . Do  you need to supply its I/O with power and if so is it possible the supply you have is not up to the job?

Hood
Title: Re: Turn on an Output? Shamefully simple?
Post by: angel tech on November 20, 2010, 06:01:25 PM
are you using the bob to sink or source the relay
Title: Re: Turn on an Output? Shamefully simple?
Post by: AtlasMills on November 20, 2010, 06:03:32 PM
The g100 comes with a wall wart that powers it and supposedly uses that to push up to 100mA on the outputs, but perhaps the wall wart is barely hangin on.   It has an alternative 24vdc input, I'll unplug the wallwart and use a bench supply on the alt power input to see if I get better performance that way...
Title: Re: Turn on an Output? Shamefully simple?
Post by: AtlasMills on November 20, 2010, 06:04:36 PM
I was using it to source, but that may have been dumb...
Title: Re: Turn on an Output? Shamefully simple?
Post by: angel tech on November 20, 2010, 06:16:23 PM
most outputs sink more current than source.
Title: Re: Turn on an Output? Shamefully simple?
Post by: AtlasMills on November 20, 2010, 11:32:32 PM
At first blush that appears to have been it.  Although the documentation I have indicates the G100 can "drive" an output such as a relay with up to 100 mA, it appears it is much more suited to sinking than sourcing.  I successfully toggled a relay with the software button I made by placing the relay inline between a stand alone 12VDC benchtop power supply and one of my output pins.  In "Ports and Pins" I set that Pin # to "Active High" and when hitting the button the pin's activity light comes on and the relay fires. 

Once again this forum rocks!