Rigid Tapping Help

More
8 years 3 months ago #115144 by andypugh
Replied by andypugh on topic Rigid Tapping Help

OT-CNC wrote: How about scaling the encoder? Is there anything I need to be aware of in using the scale component for this application, scaling index?

You would need to scale the input to motion.spindle-revs. That should be all that is needed.
You can do this with a scale component fed from a mux2 component switched by gear position.
Or, possibly, by using a mux2 to set the encoder.scale to two different numbers.
It might be possible to use gearchange rather than mux2 for this, I don't know if that would be advantageous.

You can't scale the index. It isn't worth trying.


Andy, there isn't currently a peck tap cycle correct? You just repeat the 33.1 code with different z depths?

Yes, that is correct.


does G64 path blending not affect rigid tapping?

Not as far as I know.

Please Log in to join the conversation.

More
8 years 3 months ago #115153 by Mike_Eitel
Replied by Mike_Eitel on topic Rigid Tapping Help
M5C

When U use a encoder plus a comp element and use as input your real encoder index signal than you should be able to uses encoder.index-enable as simulated/divided index puls...
The Idea ist similar to TTL using counter with Reset as a divided..
Or easier do it in a small comp.
Mike

Please Log in to join the conversation.

More
8 years 2 months ago #116601 by verticalperformance
I've used the gearchange function with a sherline mill with a two speed pulley. the "gearchange" is affected manually by a glade UI button (High Speed Pulley in screen grab), but I see no reason why that would not work with a physical sensor that detects which pulley the belt is on. (or gearbox setting etc)
As the encoder is directly on the spindle shaft, all the gearchange is doing on the sherline is scaling the speed bar graph in the GUI, but it is a reasonable example of what the function does.

Few fragments of code (hopefully not missing anything important), the HAL files get their scaling parameters from the .ini file BTW and a screen grab of the relevant bit of the axis GUI

Attachment not found



.ini file fragment
Code:
############################################################################### # Spindle Control section ############################################################################### [SPINDLE] # High Gear MAX_RPM_HIGH = 3000 GEAR_RATIO = 2 # Low Gear SCALE_LOW = 1650 OFFSET_LOW = 0.035 MAX_RPM_LOW = 1500 # Spindle at Speed tolerance (RPM) TOLERANCE = 200 # Preset Speeds for GUI S1 = 400 S2 = 1000 S3 = 2800 ############################################################################### # Hardware Abstraction Layer section ############################################################################### [HAL] # The run script first uses halcmd to execute any HALFILE # files, and then to execute any individual HALCMD commands. # # list of hal config files to run through halcmd #+ files are executed in the order in which they appear HALFILE = stepper_xyza.hal HALFILE = standard_pinout.hal HALFILE = Spindle.hal HALFILE = manualtoolchange.hal POSTGUI_HALFILE = sherline-mill-gVCP.hal

Spindle.hal
Code:
# Spindle Control File loadrt abs count=1 loadrt pwmgen output_type=0 # spindle speed feedback loadrt encoder num_chan=1 loadrt lowpass count=1 loadrt mult2 count=1 loadrt near loadrt gearchange # base thread addf pwmgen.make-pulses base-thread addf encoder.update-counters base-thread #servo thread addf pwmgen.update servo-thread addf abs.0 servo-thread addf encoder.capture-position servo-thread addf lowpass.0 servo-thread addf near.0 servo-thread addf mult2.0 servo-thread addf gearchange.0 servo-thread #Spindle Control net spindle-enable <= motion.spindle-on => pwmgen.0.enable net spindle-cmd <= motion.spindle-speed-out => gearchange.0.speed-in net spindle-cmd-scaled <= gearchange.0.speed-out => pwmgen.0.value net spindle-pwm <= pwmgen.0.pwm #Spindle Speed Scaling setp pwmgen.0.pwm-freq 5 setp gearchange.0.min1 0 setp gearchange.0.max1 [SPINDLE]MAX_RPM_LOW setp gearchange.0.min2 0 setp gearchange.0.max2 [SPINDLE]MAX_RPM_HIGH setp gearchange.0.scale2 [SPINDLE]GEAR_RATIO setp pwmgen.0.scale [SPINDLE]SCALE_LOW #low gear setp pwmgen.0.offset [SPINDLE]OFFSET_LOW #low gear setp pwmgen.0.dither-pwm true #Spindle Feedback setp encoder.0.position-scale 6.000000 setp encoder.0.counter-mode 1 # report our revolution count to the motion controller net spindle-position encoder.0.position => motion.spindle-revs net spindle-velocity encoder.0.velocity => motion.spindle-speed-in net spindle-phase-a encoder.0.phase-A setp lowpass.0.gain 0.01 net spindle-velocity => lowpass.0.in net spindle-fb-filtered <= lowpass.0.out net spindle-fb-filtered mult2.0.in1 net spindle-fb-rpm mult2.0.out setp mult2.0.in0 60 # Test for spindle at speed net spindle-cmd near.0.in1 net spindle-fb-rpm near.0.in2 net spindle-at-speed motion.spindle-at-speed <= near.0.out setp near.0.difference [SPINDLE]TOLERANCE #If within 100 RPM #Connect to physical pins setp parport.0.pin-01-out-invert 1 net spindle-pwm => parport.0.pin-01-out setp parport.0.pin-17-out-invert 1 net spindle-enable => parport.0.pin-17-out net spindle-phase-a <= parport.0.pin-15-in-not

sherline-mill-gVCP.hal
Code:
# create a 'estop-is-deactivated' signal loadrt not count=3 #names=not.0,not.1 addf not.0 servo-thread addf not.1 servo-thread addf not.2 servo-thread net estop halui.estop.is-activated => not.0.in # and activate the settings box when estop is off #net estop-inactive not.0.out => gladevcp.settings # activate the spindle HAL table and all its children when the machine is on net machine-on halui.machine.is-on => gladevcp.spindle => gladevcp.pulley net machine-on => gladevcp.preset-speeds # **** Setup of spindle speed display using glade -START **** # **** Use ACTUAL spindle velocity from spindle encoder # **** spindle-velocity is signed so we use absolute component to remove sign net spindle-fb-rpm => abs.0.in net spindle-fb-abs-rpm abs.0.out => gladevcp.spindle-rpm-hbar net spindle-fb-abs-rpm => gladevcp.spindle-speed net spindle-cmd => gladevcp.spindle-commanded-speed # **** set up spindle at speed indicator **** net spindle-at-speed => gladevcp.spindle-at-speed-led # Link the gearchange to the pulley button net gearchange-cmd <= gladevcp.high_speed_pulley => gearchange.0.sel

And the python handler
Code:
import os,sys from gladevcp.persistence import IniFile,widget_defaults,set_debug,select_widgets import hal import hal_glib import gtk import glib import linuxcnc import time debug = 1 c = linuxcnc.command() s = linuxcnc.stat() config_ini_file = linuxcnc.ini(os.getenv("INI_FILE_NAME")) axes = int(config_ini_file.find("TRAJ", "AXES") or 0) def all_axes_homed(): print "axes: %i" % axes axes_home= s.homed print axes_home print axes_home.count(1) if axes_home.count(1) == axes: print ("All axes homed") return 1 else: print ("At least one axes is not homed") return 0 def ok_for_mdi(): s.poll() print ("OK for MDI Mode") print ("estop: %i" % s.estop) print ("enabled: %i" % s.enabled) print ("interp_state: %i" % s.interp_state) return not s.estop and s.enabled and all_axes_homed() and (s.interp_state == linuxcnc.INTERP_IDLE) def ok_for_manual(): s.poll() print ("OK for Manual Mode") print ("estop: %i" % s.estop) print ("enabled: %i" % s.enabled) print ("interp_state: %i" % s.interp_state) print ("task_mode: %i" % s.task_mode) return not s.estop and s.enabled and (s.interp_state == linuxcnc.INTERP_IDLE) and (s.task_mode <> linuxcnc.MODE_AUTO) class HandlerClass: ''' class with gladevcp callback handlers ''' S1 = 0 S2 = 0 S3 = 0 def on_pulley_toggled(self,widget,data=None): if widget.get_active(): self.builder.get_object('spindle-rpm-hbar').max = float(self.max_speed_high_gear) else: self.builder.get_object('spindle-rpm-hbar').max = float(self.max_speed_low_gear) self.builder.get_object('spindle-rpm-hbar').queue_draw() self.spindle_rpm_hbar_max = self.builder.get_object('spindle-rpm-hbar').max print "Toggle Pulley" def on_stop_clicked(self,widget,data=None): c.spindle(0) print "Stop Clicked" def on_s1_clicked(self,widget,data=None): if ok_for_mdi(): c.mode(linuxcnc.MODE_MDI) c.wait_complete() # wait until mode switch executed c.mdi("M3 S%d" % self.S1) print "S1: M3 S%d" % self.S1 def on_s2_clicked(self,widget,data=None): if ok_for_mdi(): c.mode(linuxcnc.MODE_MDI) c.wait_complete() # wait until mode switch executed c.mdi("M3 S%d" % self.S2) print "S2: M3 S%d" % self.S2 def on_s3_clicked(self,widget,data=None): if ok_for_mdi(): c.mode(linuxcnc.MODE_MDI) c.wait_complete() # wait until mode switch executed c.mdi("M3 S%d" % self.S3) print "S3: M3 S%d" % self.S3 def on_destroy(self,obj,data=None): self.ini.save_state(self) def __init__(self, halcomp,builder,useropts): ''' Handler classes are instantiated in the following state: - the widget tree is created, but not yet realized (no toplevel window.show() executed yet) - the halcomp HAL component is set up and the widhget tree's HAL pins have already been added to it - it is safe to add more hal pins because halcomp.ready() has not yet been called at this point. after all handlers are instantiated in command line and get_handlers() order, callbacks will be connected with connect_signals()/signal_autoconnect() The builder may be either of libglade or GtkBuilder type depending on the glade file format. ''' self.halcomp = halcomp self.builder = builder self.useropts = useropts self.max_speed_high_gear = float(config_ini_file.find("SPINDLE", "MAX_RPM_HIGH") or 0.0) self.max_speed_low_gear = float(config_ini_file.find("SPINDLE", "MAX_RPM_LOW") or 0.0) self.S1 = float(config_ini_file.find("SPINDLE", "S1") or 100.0) self.S2 = float(config_ini_file.find("SPINDLE", "S2") or 1000.0) self.S3 = float(config_ini_file.find("SPINDLE", "S3") or 2800.0) spindle_S1=self.builder.get_object('hal_spindle_s1') spindle_S2=self.builder.get_object('hal_spindle_s2') spindle_S3=self.builder.get_object('hal_spindle_s3') spindle_S1.set_label("%d RPM" % self.S1) spindle_S2.set_label("%d RPM" % self.S2) spindle_S3.set_label("%d RPM" % self.S3) print "High Gear: %d" % self.max_speed_high_gear print "Low Gear: %d" % self.max_speed_low_gear self.defaults = { IniFile.vars : { 'spindle_rpm_hbar_max' : self.max_speed_high_gear}, IniFile.widgets: widget_defaults(select_widgets(self.builder.get_objects(), hal_only=True,output_only = True)) } self.ini_filename = __name__ + ".ini" print "Ini File Name: %s" % self.ini_filename self.ini = IniFile(self.ini_filename,self.defaults,self.builder) self.ini.restore_state(self) self.builder.get_object('spindle-rpm-hbar').max= float(self.spindle_rpm_hbar_max) self.builder.get_object('spindle-rpm-hbar').queue_draw() def get_handlers(halcomp,builder,useropts): ''' this function is called by gladevcp at import time (when this module is passed with '-u <modname>.py') return a list of object instances whose methods should be connected as callback handlers any method whose name does not begin with an underscore ('_') is a callback candidate the 'get_handlers' name is reserved - gladevcp expects it, so do not change ''' return [HandlerClass(halcomp,builder,useropts)]

Please Log in to join the conversation.

More
7 years 7 months ago #129283 by gmarconi2
Replied by gmarconi2 on topic Rigid Tapping Help
I happened by chance here, but the error is a comma instead of the point in the first post N445 line

instead of G43 Z0.6 H2 changes to G43 Z0.6 H2

Hi gmarconi2

Please Log in to join the conversation.

Time to create page: 0.357 seconds
Powered by Kunena Forum