Hello Guest it is September 16, 2019, 03:22:07 AM

Author Topic: Probably simple but...(G-Code help)  (Read 11549 times)

0 Members and 1 Guest are viewing this topic.

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Probably simple but...(G-Code help)
« Reply #50 on: January 13, 2016, 05:23:34 AM »
Dry-Run button script...

I have a screen button and a LED (2244) next to it, I would like to get the button to toggle the LED, when the LED is green it jumps to the subroutine, you press RUN and it runs the subroutine, then turns the LED off and rewinds. If you press the button again when it is on it should turn the led off and rewind.

If getuserled(2244) Then
   setuserled(2244,0)
        Code "M30"
Else
   setuserled(2244,1)
   Code "M98 P549"
   End
   setuserled(2244,0)
End If 

Above works but does not extinguish the LED after.
   
If getuserled(2244) Then
   setuserled(2244,0)
        Code "M30"
Else
   setuserled(2244,1)
   Code "M98 P549"
   setuserled(2244,0)
        End
End If

Above does not light the LED but does jump to the sub.

I know this is all bells-and-whistles stuff but why dumb-down a brilliant product like Mach3 by not making every addition as smart as possible?

Can this be done?
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline BR549

*
  •  6,887 6,887
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #51 on: January 13, 2016, 11:41:55 AM »
HIYA Dave , NOTHING wrong with bells and whistles.  They make life easier after you get them working (;-)  I have buckets full of them here.  That is one of the great things about Mach3 . In most things you are only limited by your imagination. 

You were close in your first example  (;-) you just ENDED teh program before you turned off teh LED.

If getuserled(2244) Then
   setuserled(2244,0)
        Code "M30"           
Else
   setuserled(2244,1)
   Code "M98 P549"
   End                             <<<<<<<<<<<---------------  You ended too soon
   setuserled(2244,0)
End If 


######################

If getuserled(2244) Then
   setuserled(2244,0)
        Code "M30"
Else
   setuserled(2244,1)
   Code "M98 P549"
      setuserled(2244,0)
End If 
   End

Offline BR549

*
  •  6,887 6,887
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #52 on: January 13, 2016, 12:20:25 PM »
IF By chance it does not turn ON teh LED add in a Wait state to give it time to do teh process before jumping over it.  IF you have to add in the Wait after each action line


If getuserled(2244) Then
   setuserled(2244,0)
        Code "M30"
Else
   setuserled(2244,1)
While Ismoving()
Wend
   Code "M98 P549"
      setuserled(2244,0)
End If
   End

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Probably simple but...(G-Code help)
« Reply #53 on: January 13, 2016, 01:01:50 PM »
Hi again, brilliant, will try that.

I have just come in from another play and arrived at the destination by turning the LED off in the M05 macro - same result but different way around it, this also cancels the dry-run LED when you press STOP. Seems I have two options here now - great stuff :)

I also discovered I needed to add this - Code "F3000" before the Code "M98 P549" as unless you have already run some code, there is no feed-rate set and the dry-run runs at about 1mm/min :) adding the F3000 works perfectly.

SO, I was on a roll after that success, I thought I'd add a safety feature and stop the Dry-Run button doing anything at all if the RUN LED is on - pressing dry run while code is paused makes it a bit messy ;)

Easy-peasy I thought, just do this...

If GetLed(804)=0 then
   If getuserled(2244) Then
      setuserled(2244,0)
      Code "M30"
   Else
      setuserled(2244,1)
      Code "M98 P549"
      End
   End If  
End If

Of course that didn't work :( then I got too cold and came in :)

ALSO regarding the Brain Logic Failure issue..

It's NOT a logic failure, I did a brain-view and loaded some code and you can see that when loading code, Mach3 sets the RUN led to ON even though the LED does not illuminate !!!

That is why the probe is allowed to trigger all the time!

Now I need to fine a way to fix it :)
« Last Edit: January 13, 2016, 01:04:25 PM by Davek0974 »
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline BR549

*
  •  6,887 6,887
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #54 on: January 13, 2016, 01:37:30 PM »
When I tested you r brain here teh logic failed due to teh fact that you never created a logic condition to compare to in teh #var value side. Teh led is automatically a boolean value true/false, BUT teh DRO value has to be compared to a value to reach a boolean state.  #var = 1 == ON  so then you compare the Value against 1  IF #var = 1 then it is true.

IF you use the Brain monitorr you can SEE all the values and the STATE of each lobe of the brain.  Not saying it cannot happen but I have never seen a state change without it lighting the LED IF there is one.

You also need to be aware that Mach3 does not always treat the value of the GetLED(804) as 0,1. It can be true ,false, and -1,1  And at times it is NOT consistant. AND I do not know why it does it but I KNOW for a fact it does it. I have spent days in the past tracing values and comparing them. I find it best to always treat it as true,False condition(boolean)

AND again you need to move the END to the actual END of the  script in this case.

Just a thought,  (;-) TP
« Last Edit: January 13, 2016, 01:47:52 PM by BR549 »

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Probably simple but...(G-Code help)
« Reply #55 on: January 13, 2016, 01:49:05 PM »
Hi

Yes I can see the need to create a logic condition, BUT if you create a simple brain that monitors the 804 RUN LED you (should) see the brain trigger while loading code even thought screen LED is off.

Edit...

On my laptop test setup, the RUN LED does indeed come on during code load - thats why it triggers then!!

Now, how do we sort the problem out :)
« Last Edit: January 13, 2016, 01:53:00 PM by Davek0974 »
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline BR549

*
  •  6,887 6,887
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #56 on: January 13, 2016, 04:24:57 PM »
YOU find something else to trigger on (;-)   

(;-) TP

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Probably simple but...(G-Code help)
« Reply #57 on: January 13, 2016, 04:45:46 PM »
LOL :)

Yes I figured that but as Mach seems to use the RUN function when loading, presumably to parse the code, there doesn't seem to be much left really, Brains don't seem to have any knowledge of code being loaded which is fair enough,.

I messed around a bit tonight but I can't find a way round this so will likely chalk it up to "can't really be done" and move on, sounds a bit defeatist, but 'net trawling, messing about and your very helpful input have come up blank so maybe it just cant be done??

Maybe, Just maybe, a custom "Load Code" button which sets a #var before starting to load and releases it after might the way??
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline BR549

*
  •  6,887 6,887
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #58 on: January 13, 2016, 07:50:54 PM »
You could look at teh cycles start led.  

(;-) TP

Offline BR549

*
  •  6,887 6,887
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #59 on: January 13, 2016, 08:15:57 PM »
I had to make a phone call to verify but in all the years I have had the DryRun feature here with plasma no one has every hit that button with a program cutting(;-)  IF you find one that does just smack him hard with the Dummy stick a time or too and it will not be a problem again .

Just a thought(;-) TP