Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: polaraligned on April 05, 2007, 09:06:15 PM

Title: Macropump help
Post by: polaraligned on April 05, 2007, 09:06:15 PM
I need some code help.  I have the following:

If IsActive(Input1) Then      'Read input 1
     DoOEMButton(310)         'activate the "Y--" jog button
End If

I just want to make this button jog in the Y axis.
It works except that when you let go of the button the axis does
not stop.  Electrically, it is working fine as witnessed by the
ModIO LED indicator going out when you let go of the button.
Do I have to look for when the button is not pressed and do some
sort of a reset?

Also,
How do you change the state of a led on the screen?
I have tried:

Call SetOEMLed(66,1)       '66 is the OEM number of the block del led
 
I tries several variations and it always
 returns an error: Function not defined SetOEMLed

The Mach customization WIKI that lists the OEM LED's says this is a
valid call.

Thanks,
Scott
Title: Re: Macropump help
Post by: poppabear on April 05, 2007, 10:32:02 PM
well here is the deal,

  Jogs only work "Right", when you push the keyboard hotkey, or click a job button on the screen, or an hardware input will jog it.

But, VB jogging doesnt work right, when you "push it" the axis will take off and not stop. This is a problem I ran into also, and that is what Brian told me, it has something in the way that mach works with the jog inputs.

Second:  You cannot set the state of an OEM Led, it will only toggle via, buttons that control its status.

scott
Title: Re: Macropump help
Post by: Brian Barker on April 06, 2007, 02:07:39 PM
You should not jog the axis from VB.. if you need an input to Jog the machine please use the Jog inputs under inputs on the ports and pins page


Thanks
Brian
Title: Re: Macropump help
Post by: polaraligned on April 06, 2007, 05:20:04 PM
Thanks Brian.  I hand no idea they were there.   :)

Scott



Title: Re: Macropump help
Post by: polaraligned on April 06, 2007, 08:21:04 PM
Ok.  I got my jog switches up and running.  Thanks Brian.

How do I handle operating the Reset button with a switch on my pendant?
Is this doable?

Thanks,
Scott

Title: Re: Macropump help
Post by: Chaoticone on April 06, 2007, 08:28:46 PM
Same place, it is the one that says e-stop.

Brett
Title: Re: Macropump help
Post by: polaraligned on April 07, 2007, 07:14:13 AM
OK.  So e-stop and reset are the same.  I guess I need to use another hard input
for that.  Running out quickly.  I think that the Sound Logic BOB uses this input. 
When you hit a limit switch Mach immedietly goes into reset. 
I want to be able to reset the software without resorting to the mouse, not e-stop it. 
I somehow doubt that I can do this now if the Sound Logic board uses this input.

Any Ideas?

Scott



Title: Re: Macropump help
Post by: Chaoticone on April 07, 2007, 08:27:21 AM
Scott,
     Could you just take the wire form your board and run it through your e-stop button on your pendent or daisy chain the button, it would use the same input. Do you have a link for your board that I can look at? Also, what kind of drives are you using? There are lots of ways to do it, with the e-stop circuit, the main thing is safety. I have sent you a personal message.

Brett
Title: Re: Macropump help
Post by: poppabear on April 07, 2007, 10:11:50 AM
'I think I know what you want, do this:

'note you don't have to actually have these listed LED's and Dros physicaly on the screen set but,
'you can add them with screen designer if you want. we will use UserLed 1200, and userDro 1200
'Use any one of your free Inputs, in the example, I used INPUT4, but use what you want.
'Depending on your set up of your Input, remember to set the Active high or low depending on what your input does.

'In your Macropump put the following, save it, then goto cofig and turn on macropump, close mach and reopen

'MacroPump.m1s

If IsActive(INPUT4) and Not(GetUserLED(1200)) and GetUserDRO(1200)=0 Then
   SetUserLED(1200,1)    'This sets a "counter" it allows the "button" to be pushed only once.
   SetUserDRO(1200,1)   'This is optionally in case you want to drop a LED to see the state
   DoOEMButton(1021)    'this "Pushes" the reset button
Else
   SetUserLED(1200,0)     'When you release the button, the system resets for next push
   SetUserDRO(1200,0)
End If


'Hope this is what you wanted
'Scott

Title: Re: Macropump help
Post by: polaraligned on April 08, 2007, 06:37:20 PM
Thanks Scott,
What I was really looking for was the OEM button number for the reset.  I didn't
think one existed.  I must have looked up and down my sheets 50 times and still
missed the reset.  You posted it as 1021 and there it was....on my sheet looking me
straight in the face. 
Your code is interesting but it looks like it is for a latching switch.  I am using
pushbutton switches off of a voltage divider and feeding my ModIO analog input.
I am running 12 pushbutton switches into one analog input. 


What I REALLY need is a method of debouncing these switches.  The Single step is the
worst.  You need to hit it just right for it to consistantly work.  The  Feed up and Feed
down are also a bit nuts.  Sometimes they increment it more than the 10% value they
should be doing.  I tried a few things to slow down the switch polling but it only caused
problems with Mach. 

Any ideas?

Scott

Title: Re: Macropump help
Post by: Brian Barker on April 08, 2007, 06:41:56 PM
Or you can set an OEMtriger to do that... you need to set the OEM code under the System Hotkeys and I think you are going to need number 1021 for a reset.. (Found on the Wiki)
Title: Re: Macropump help
Post by: polaraligned on April 08, 2007, 06:57:17 PM
(http://img.photobucket.com/albums/v223/polaraligned/Bridgeport/DSCN5118.jpg)

Here is the pendant as I call it. 

I am not sure what you are saying about using an OEMtrigger Brian.
My inputs are into a ModIO analog, via a voltage divider.
This is the panel I showed you at the show in January in PA.  It was
just a drawing back then.

My problem here is debouncing the keys.  Single step for example, if you
do not hit it just right, it will toggle on and then just toggle off.
The feedrate up and down buttons often jump in increments of 20
instead of the 10 that they should.  The keys are being read 5 times
a second (via the macropump) and Mach is seeing multiple keystrokes
 for single pushes.  Clearly a debouncing problem.

The reset is working fine.
I coded it so that once it is pressed, it will not work again unless
Mach goes into reset again for some reason.

Also, I need to figure out how to get the Mode, Resolution and Axis selection switches
all into 1 analog input.  I might need some external logic.

Scott

Title: Re: Macropump help
Post by: poppabear on April 08, 2007, 08:38:28 PM
Ok,

   Goto "General config", then look to the right, and set your switch debounce upto 200-300 that should help.

Scott
Title: Re: Macropump help
Post by: chl on April 09, 2007, 06:26:14 AM
Hi here is a little example maby it can help you...there will not be any multiple keystrokes.


If GetInput (64) < 50 Then           'check if up button
   SetDRO(21,GetDRO(21)+10)      'Feedrate up 10%
      While GetInput (64) < 50        'Stay here until button released
      sleep(100)
      Wend
End If



If GetInput (64) > 151 And GetInput (64) < 250 Then          'check if down button
   SetDRO(21,GetDRO(21)-10)                                            'Feedrate down 10%
      While GetInput (64) > 151 And GetInput (64) < 250       'Stay here until button released
      sleep(100)
      Wend
End If
Title: Re: Macropump help
Post by: polaraligned on April 10, 2007, 07:28:55 PM
Thanks chl.  That code appears to be working so far during testing.


Scott
Title: Re: Macropump help
Post by: chl on April 11, 2007, 10:52:54 AM
Thats good :).....you have a very nice setup.....looks great ;)

chl
Title: Re: Macropump help
Post by: happytriger2000 on September 08, 2007, 02:08:49 AM
Hi here is a little example maby it can help you...there will not be any multiple keystrokes.

If GetInput (64) < 50 Then           'check if up button
   SetDRO(21,GetDRO(21)+10)      'Feedrate up 10%
      While GetInput (64) < 50    ??'Stay here until button released
      sleep(100)
      Wend
End If



If GetInput (64) > 151 And GetInput (64) < 250 Then          'check if down button
   SetDRO(21,GetDRO(21)-10)            ? ???????? ??????'Feedrate down 10%
      While GetInput (64) > 151 And GetInput (64) < 250    ??#039;Stay here until button released
      sleep(100)
      Wend
End If

(http://)



Hi all,
       Im building a MPG Pendent, and Im having trouble loading codes to run my mpg, can anyone guide me on how to load a code to C:\Mach3\macros\Modio?

thanks,

Freddy
Title: Re: Macropump help
Post by: Chaoticone on September 08, 2007, 05:54:51 AM
Hey Freddy,
    Open the profile you want the macro in in Mach. Go to the top tabs, choose operator, VB script editor. From there browse to your C\Mach3\macros\?whatever profile you want the macro in? If this is a macro pump, you need to add to your macro pump, If there is no macropump allready, just put your code in the VB script editor and save as macropump.m1s in the macro folder under the profile you want.

Brett
Title: Re: Macropump help
Post by: poppabear on September 08, 2007, 08:55:34 AM
Quote
Also, I need to figure out how to get the Mode, Resolution and Axis selection switches
all into 1 analog input.  I might need some external logic.

Scott

I would say to do it that way you would need a high tolorance regulated power supply, and high tolorance resistors for a larger voltage divider network.
I would look at the Register  "GetInput(65)" or what ever your using and see what the value is in the register. I noted that Under the "DROs" on the wiki, there are DROs assigned to 64,5,6 so you can drop the one that matches your register onto some "Debug" page in screen designer.
I would pull in each value as a range to account for voltage variations, i.e.  For mode(1)  0-20, for mode(2) 21-40 etc. or something like that so
so:

x=GetInput(64)
If 0<=X<20 then
dobutton(*********)
End If


NOTE: the code I wrote you was so that no matter how long the button was pushed it would only run the input 1 time. But if De-bounce still gets you and setting up the software debounce doesnt help, then put a capacitor across your switch leads. 0.01mf or something.

Scott