Quebuster busting my mind
- sqmathlete
- Offline
- Premium Member
Less
More
- Posts: 118
- Thank you received: 17
14 Nov 2019 00:42 #150333
by sqmathlete
Quebuster busting my mind was created by sqmathlete
Hi,
I'm trying to remap M36/M37/M39 in python. These were the old mazak codes that were called to shift gears, low, neutral, high.
M36/M37/M39 consists of
prolog; check some conditions
python remap:
check to see if the spindle is running
stop spindle if necessary
M64 turn on the appropriate solenoid
M66 wait xx seconds for limit switch to go high
yield INTERP_EXECUTE_FINISH, *** this is where things get weird
epilog : check the state of the limit switch hal pin and do something based on the result
Obviously if the spindle is not in gear we need to abort. Currently I don't have anything connected so I set the signal in halshow for testing purposes. However, it doesn't seem to mater whether the M code succeeds or fails the epilog doesn't seem to be called. Basically, I can't quite seem to figure out the magic incantation to 1) abort after a failed M-code 2) call the epilogue.
In my .ini file
in std-glue
in remap.py
Without the INTERP_EXECUTE_FINISH the print out in the terminal shows that the limit switch pin is read before the M64/M65 sequence is executed. Not sure how to deal with this. There are a bunch of codes for the tailstock and turret that also have the same conditions. So it seems like a general solution will work for all codes... Any ideas?
Thanks in advance .
Dan
I'm trying to remap M36/M37/M39 in python. These were the old mazak codes that were called to shift gears, low, neutral, high.
M36/M37/M39 consists of
prolog; check some conditions
python remap:
check to see if the spindle is running
stop spindle if necessary
M64 turn on the appropriate solenoid
M66 wait xx seconds for limit switch to go high
yield INTERP_EXECUTE_FINISH, *** this is where things get weird
epilog : check the state of the limit switch hal pin and do something based on the result
Obviously if the spindle is not in gear we need to abort. Currently I don't have anything connected so I set the signal in halshow for testing purposes. However, it doesn't seem to mater whether the M code succeeds or fails the epilog doesn't seem to be called. Basically, I can't quite seem to figure out the magic incantation to 1) abort after a failed M-code 2) call the epilogue.
In my .ini file
# M36 shift NEUTRAL
REMAP=M36 prolog=gear_change_prolog python=m36_remap epilog=gear_change_epilog modalgroup=10
in std-glue
def gear_change_prolog(self, **words):
print"gear change prolog"
return INTERP_OK
def gear_change_epilog(self, **words):
print "gear change epilog"
#lsw1_status = emccanon.GET_EXTERNAL_DIGITAL_INPUT(0,0)
#print "limit switch 1 status =" , lsw1_status
return INTERP_OK
in remap.py
def m36_remap(self,**words):
try:
spindle_run_inhibit(self)
hyd_shift_neutral(self)
yield INTERP_EXECUTE_FINISH
#lsw1_status = emccanon.GET_EXTERNAL_DIGITAL_INPUT(0,0)
#print "limit switch 1 status =" , lsw1_status
print "end of M36 remap"
#return INTERP_OK
except IOError as e:
print "I/O error({0}): {1}".format(e.errno, e.strerror)
#return ReturnERROR()
def in_case_of_spindle_running(self):
print "stopping spindle"
self.execute("M5")
def zero_speed_detect(self):
# we need to check the value of the hal pin spindle.0.at-speed
# the spindle.0.at-speed pin must be connected to digital input 16
# wait 5 seconds for the spindle to wind down
self.execute("M66 P16 L3 Q5")
# check the zero speed digital input
pin_status = emccanon.GET_EXTERNAL_DIGITAL_INPUT(16,0)
print "zero speed detect =" , pin_status
if pin_status == 1:
return INTERP_OK
else:
#enter a message in the error log and return an error
self.set_errormsg("something went wrong, spindle still running")
return INTERP_ERROR
def spindle_run_inhibit(self):
print "checking if spindle is running"
try:
spindle_status = self.params["_spindle_on"]
print "M3/M4 ACTIVE" , spindle_status
if spindle_status == 1:
in_case_of_spindle_running(self)
zero_speed_detect(self)
if spindle_status == 0:
# potientally the spindle could be off but still rotating so we need to check
zero_speed_detect(self)
# the spindle is now off and zero speed has been detected
# ok to switch gears
#return INTERP_OK
except Exception, e:
return "%s" % e
Without the INTERP_EXECUTE_FINISH the print out in the terminal shows that the limit switch pin is read before the M64/M65 sequence is executed. Not sure how to deal with this. There are a bunch of codes for the tailstock and turret that also have the same conditions. So it seems like a general solution will work for all codes... Any ideas?
Thanks in advance .
Dan
Please Log in or Create an account to join the conversation.
15 Nov 2019 15:39 #150432
by andypugh
Replied by andypugh on topic Quebuster busting my mind
As your std_glue are no longer standard there may be no reason to retain them.
ie, you can probably perform all checking and error handling in your single remap file.
Does your remap code import your std_glue, or is it finding the LinuxCNC std_glue routines?
You don't need to have prolog, epilog and stdglue, they are just provided as ways to save remappers some work.
ie, you can probably perform all checking and error handling in your single remap file.
Does your remap code import your std_glue, or is it finding the LinuxCNC std_glue routines?
You don't need to have prolog, epilog and stdglue, they are just provided as ways to save remappers some work.
Please Log in or Create an account to join the conversation.
Time to create page: 0.062 seconds