Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: dacostad on February 16, 2007, 09:37:35 AM

Title: Help with macropump code
Post by: dacostad on February 16, 2007, 09:37:35 AM
Hi all,

I have just built a pendant for my CNC Router I built (see
http://web.mac.com/dacostad) and I have the following in my
macropump.m1s to control the turning on and off of the LED's on my
pendant.

As you can see towards the end of the code I have a single LED on the
pendant that when on means that the pendant is not in MPG mode.
However as there are two non-MPG modes (cont and step) I would like to
have the LED be on for cont mode and flash for step.

At the moment I just turn it on for both (OEM LED 14 and 15) and as I
am not a programmer I am not sure how to get to flash when OEM LED 15
is on.

I imagine that I need something like a do while loop.

Can someone advise me on the correct code.

Here is the code;

If GetOEMLed(59) Then ' X Axis selected
ActivateSignal (OUTPUT4)
Else
DeActivateSignal(OUTPUT4)
End If

If GetOEMLed(60) Then ' Y Axis selected
ActivateSignal (OUTPUT5)
Else
DeActivateSignal(OUTPUT5)
End If

If GetOEMLed(61) Then ' Z Axis selected
ActivateSignal (OUTPUT2)
Else
DeActivateSignal(OUTPUT2)
End If

If GetOEMLed(14) Or GetOEMLed(15) Then
ActivateSignal (OUTPUT3) 'Jog Mode, LED on is cont. mode
Else
DeActivateSignal(OUTPUT3)
End If

Thanks

David
Title: Re: Help with macropump code
Post by: Graham Waterworth on February 17, 2007, 04:45:55 AM
Hi David,

if you add a dro onto a mach screen, (it can be off visible area of screen if you wish) you can set it to a value, say 0 for cont and 1 for step then add another dro for a counter.

Then you can read this to know the state of your jog.

then in your macropump put something like :-

Add code to set jog type dro and set counter

IF yourdro = 1  then
  if countdro>40 then (adjust the 40 to set flash rate)
    If GetOEMLed(15) Then
      turn led off
      set dro count to 0
    Else
      turn led on
      set dro count to 0
    End If
   else
     add 1 to dro count
   Endif
ENDIF

As the macropump runs about 40 times a second you need a delay to see the led flash the counter dro will do this.

Just a quick thought, but it should work

Graham.
Title: Re: Help with macropump code
Post by: poppabear on February 18, 2007, 08:55:07 PM
It might be easier for you to just put 2 leds one for cont, and one for step. Set one led to solid and the other to flash. Then just turn on the one for the function that is on.