How i programm a Spindle Soft Start exactly

More
25 Aug 2014 00:52 #50228 by sutter.michi
Hello, my name is Michi and i would use Linux CNC with my bild CNC machine.

Everything works fine, exclude the Spindle...

I have a circuit which works with frequency uf pulses.

Example:

100Hz -> spindle has 1000 rpm
6000Hz -> spindle has 60000 rpm

I would use pwmgen in PDM mode to generate the pulses.

I need a soft start for the spindle, while my hardware can`t do this...

I have found this exaple for a spindle soft start, but i don`t know waht in my hal code i need to rewrite:

linuxcnc.org/docs/html/examples/spindle.html

Must i write this direct in the hal file or did i need a new one?

And which code exactly i need to replace?


Best regards and thanks a lot for anyones help!!

Michi


Please excuse my bad english, i hope you can understand it ;)

Please Log in or Create an account to join the conversation.

More
25 Aug 2014 01:13 - 25 Aug 2014 01:13 #50230 by PCW
Since the spindle is controlled by a pulse rate, you should use the stepgen component (in velocity mode)
The stepgen component has the added advantage that it has a programmable acceleration limit for "soft" start and speed change
Last edit: 25 Aug 2014 01:13 by PCW.

Please Log in or Create an account to join the conversation.

More
25 Aug 2014 03:47 #50239 by sutter.michi
Okay i check this out, and read tomorrow something about the stepgen.

But in which document i need to write the code?

In the HAL - file that is created with the StepConf Wizard, or must i create a new HAL file with only this stepgen code?


regards

Michi

Please Log in or Create an account to join the conversation.

More
26 Aug 2014 20:38 #50313 by BigJohnT
Now would be a good time to read the Basic HAL Tutorial .

JT

Please Log in or Create an account to join the conversation.

More
27 Aug 2014 05:23 #50333 by sutter.michi
Hello.

Thanks for your help!

I tryed it again this evening, and with my oszilloskop it seems to functionate :)
The frequency steps slowly up and down

Can you look at my code, if he is okay this way?

The codelines between the # signs i have addet to the HAL Code which was generated from the StepgenConfig Tool.


Best regards and good night!

Michi

loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt probe_parport
loadrt hal_parport cfg="0x378 out  "
setp parport.0.reset-time 5000
loadrt stepgen step_type=0,0,0
loadrt pwmgen output_type=1

#
loadrt limit2 names=spindle-ramp
loadrt near names=spindle-at-speed
addf spindle-ramp servo-thread
addf spindle-at-speed servo-thread
setp spindle-ramp.maxv 40
#

addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf pwmgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread

addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf pwmgen.update servo-thread

#net spindle-cmd <= motion.spindle-speed-out => pwmgen.0.value # <-- this line must be deactivated

#
net spindle-cmd <= motion.spindle-speed-out => spindle-ramp.in
net spindle-ramped <= spindle-ramp.out => pwmgen.0.value
net spindle-cmd => spindle-at-speed.in1
net spindle-ramped => spindle-at-speed.in2
net spindle-ready <= spindle-at-speed.out => motion.spindle-at-speed
#

net spindle-on <= motion.spindle-on => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
setp pwmgen.0.pwm-freq 0.0
setp pwmgen.0.scale 60595.959596
setp pwmgen.0.offset 0.00983497249542
setp pwmgen.0.dither-pwm true



net spindle-cw <= motion.spindle-forward



net estop-out => parport.0.pin-01-out
net xstep => parport.0.pin-02-out
setp parport.0.pin-02-out-reset 1
net xdir => parport.0.pin-03-out
net ystep => parport.0.pin-04-out
setp parport.0.pin-04-out-reset 1
net ydir => parport.0.pin-05-out
net zstep => parport.0.pin-06-out
setp parport.0.pin-06-out-reset 1
net zdir => parport.0.pin-07-out
net spindle-on => parport.0.pin-08-out
net spindle-pwm => parport.0.pin-09-out
net spindle-cw => parport.0.pin-14-out
net spindle-pwm => parport.0.pin-16-out
net xenable => parport.0.pin-17-out




setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 0
setp stepgen.0.dirhold 35000
setp stepgen.0.dirsetup 35000
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
net xpos-cmd axis.0.motor-pos-cmd => stepgen.0.position-cmd
net xpos-fb stepgen.0.position-fb => axis.0.motor-pos-fb
net xstep <= stepgen.0.step
net xdir <= stepgen.0.dir
net xenable axis.0.amp-enable-out => stepgen.0.enable

setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.1.steplen 1
setp stepgen.1.stepspace 0
setp stepgen.1.dirhold 35000
setp stepgen.1.dirsetup 35000
setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
net ypos-cmd axis.1.motor-pos-cmd => stepgen.1.position-cmd
net ypos-fb stepgen.1.position-fb => axis.1.motor-pos-fb
net ystep <= stepgen.1.step
net ydir <= stepgen.1.dir
net yenable axis.1.amp-enable-out => stepgen.1.enable

setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.2.steplen 1
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 35000
setp stepgen.2.dirsetup 35000
setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL
net zpos-cmd axis.2.motor-pos-cmd => stepgen.2.position-cmd
net zpos-fb stepgen.2.position-fb => axis.2.motor-pos-fb
net zstep <= stepgen.2.step
net zdir <= stepgen.2.dir
net zenable axis.2.amp-enable-out => stepgen.2.enable

net estop-out <= iocontrol.0.user-enable-out
net estop-out => iocontrol.0.emc-enable-in

loadusr -W hal_manualtoolchange
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared

Please Log in or Create an account to join the conversation.

Time to create page: 0.068 seconds
Powered by Kunena Forum