Bueller?...Bueller?...Bueller?... anyone?![]()
Can someone take a look at this that knows macros.. Having a hell of a time getting this to check to see if my probe is off. Basically it uses a M code relay that will turn it on or off. I want it to turn it off and make sure its off (#1029 skip) before continuing. It will try 4 times before throwing an error. With this code it will finish without error even if it turns the probe back on. It appears as if I cannot use a IF statement to read a changing variable. It outputs what the value was when the start button is pressed.
Code:% O09833 (REN MP700 OFF) G103 P1 (LOOK AHEAD ONE BLOCK) #3001= 0 G04 P250 G04 P1 G04 P1 G04 P1 G04 P1 G04 P1 G04 P1 IF [ #3001 LT 200 ] GOTO999 N2 #4= 0 N3 M63 (RESET M RELAY) G04 P200 #4= #4 + 1 (TRY TURN OFF 4 TIMES) IF [ #4 EQ 4 ] GOTO4 M63 (RESET M RELAY) G04 P200 M53 (M CODE TO SWITCH OFF PROBE) #3001= 0 (RESET MS TIMER) WH [ #1029 NE 1 ] DO1 (WAIT FOR MP700 OFF) IF [ #3001 GT 3000. ] GOTO3 (MP700 FAIL TO TURN OFF AFTER 3 SEC TRY AGAIN) END1 GOTO999 N4 #3000= 101 (TURN OFF PROBE FAILURE) N999 G103 (DISABLE LOOK AHEAD) M99 (RETURN) %
Bueller?...Bueller?...Bueller?... anyone?![]()
I am not an expert by any means, but I will give it a shot. My apologies if I am way off.
----------------
M63 (RESET M RELAY)
G04 P200
M53 (M CODE TO SWITCH OFF PROBE)
#3001= 0 (RESET MS TIMER)
WH [ #1029 NE 1 ] DO1 (WAIT FOR MP700 OFF)
IF [ #3001 GT 3000. ] GOTO3 (MP700 FAIL TO TURN OFF AFTER 3 SEC TRY AGAIN)
END1
GOTO999
N4
#3000= 101 (TURN OFF PROBE FAILURE)
N999
G103 (DISABLE LOOK AHEAD)
M99 (RETURN)
%
------------------------
For the Red line, does #3001 even have a chance to become GT 3000? If not, it will always jump to N999 and end without alarm.
On another note regarding the Blue lines, arent you turning the probe off then back on with the M53? Your comment line at the M53 says your are switching the probe off but the M53 code turns it on.
Not sure if this has helped any.
Good luck!
haastec, first let me say thanks for taking your time to help me. Let me walk through these and maybe it will help...
"For the Red line, does #3001 even have a chance to become GT 3000? If not, it will always jump to N999 and end without alarm."
This seams to work fine on turning it on... just cant make it turn it off by switching the bit on the 1029 check.
"On another note regarding the Blue lines, arent you turning the probe off then back on with the M53? Your comment line at the M53 says your are switching the probe off but the M53 code turns it on."
The probe system turns on with a momentary input. It turns off the same way. This requires the m code relay to be off.. turn on for a second or two and then turn off. This will turn the probe on if it in the off state or turn it off if its in the on state.
I think I see a problem with the way you are writing macros.
There is a peculair effect when mixing macro variable references and normal G code.
The macro variable references are all executed frist due to look-ahead.
While the first dwell G04 is running, up to 80 lines after that will be pre-fetched and all macro lines will be executed.
There are a couple of fixes to this.
The easiest is to turn off look-ahead with: "G103 P1".
Make sure you turn it back on with: "G103" before you go back to normal codes.
Look at line 2 and the 2nd from the last line of the code. I did try that and to my hopes that wasn't itAlso it seams as if I cannot make a IF statement work that way as well. Seams like it uses the value that is present at the start of the macro. If the value changes in the macro it still uses the old value. Is this the way its supposed to work? Would be very easy to just use a bunch of IFs to make this work but it wont.
This is how I would rather do the code. It also will not work.
Code:% O09833 (REN MP700 OFF) G103 P1 (LOOK AHEAD ONE BLOCK) IF [ #1029 NE 1 ] GOTO999 N2 #4= 0 N3 M63 (RESET M RELAY) G04 P200 #4= #4 + 1 (TRY TURN OFF 4 TIMES) IF [ #4 EQ 4 ] GOTO4 M63 (RESET M RELAY) G04 P100 M53 (M CODE TO SEND START SIGNAL TO SWITCH OFF PROBE) G04 P100 IF [ #1029 NE 1 ] GOTO3 (TEST FOR MP700 OFF) GOTO999 N4 #3000= 101 (TURN OFF PROBE FAILURE) N999 M63 (RESET M RELAY) G103 (DISABLE LOOK AHEAD) M99 (RETURN) %