IT"S WORKING, IT'S WORKING :woohoo: :woohoo:
Below (and attached too) is my Hal file for my now working and calibrated spindle speed control using the C6 speed control board, took a little playing to get itworking right, but was worth the effort ! Thanks for posting the above file, it along with the integrators manual and the folks on the IRC channel were a big help in not only getting it to work, but also mostly understanding what I did to make it work.
link to pic of C6 is :
cnc4pc.com/images/C6R5A.jpg
link to c6 board's webpage:
www.cnc4pc.com/Store/osc/product_info.php?products_id=58
The manual for the board is at the bottom of it's page.
Regards,
Will R. Everett, WA.
# willburrrr2003’s Hal file for CNC Mini-Lathe
# My config file for My Harbor Freight Mini-Lathe adding C6 speed board
# started with just 2-axis on my stepgen, and added the
# third one, with scaling feature for freq output
# I had to tweek my C6 adjustment pot, and my Scaling gain
# until my output voltage from the C6 was 4.35vdc
# (Which was the voltage measured across my speed
# pot) when I set speed (s1250) to max lathe speed
# and made sure that no speed settings above 1250 raised
# the C6 output voltage above the 4.35vdc, so I don’t
# fry my mini-lathe speed board.
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
#added the 3rd axis here for my my spindle, set to velocity mode
loadrt stepgen step_type=0,0,0 ctrl_type=p,p,v
loadrt classicladder_rt numPhysInputs=15 numPhysOutputs=15 numS32in=10 numS32out=10 numFloatIn=10 numFloatOut=10
#load the scaling module to use on my spindle speed
loadrt scale count=1
#connect scale to servo clock thread
addf scale.0 servo-thread
#setup for scaling
setp scale.0.in 0
setp scale.0.gain 0.92 #final setting after several tweaks to C6 and gain
setp scale.0.offset 0.0 #no offset needed
#setup for stepgen to drive spindle
setp stepgen.2.position-scale 1
setp stepgen.2.maxvel 1250 #max RPM for my HF minilathe
# set steplen so it gives max frequency of 25khz
# (servo-thread/(steplen+stepspace)=maxfreq output)
# so for me was 1000000/40000=25khz with 25khz full speed for the C6
setp stepgen.2.steplen 40000
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 20000
setp stepgen.2.dirsetup 20000
setp stepgen.2.maxaccel 200 #set max acceleration for spindle
#enable stepgen for spindle, when EMC calls for spindle on
net spindle-enable <= motion.spindle-on stepgen.2.enable
#sends the speed request from EMC to scale module
net spindle-cmd motion.spindle-speed-out => scale.0.in
#sends scaled spindle speed to EMC and spindle stepgen for requested speed
net spindle-freq <= scale.0.out => stepgen.2.velocity-cmd
#Sends frequency out to parallel port pin 1 and to EMC
net spindle-out <= stepgen.2.step => parport.0.pin-01-out
#when spindle turned on send on signal to parallel port pin 14, which
#I used to drive C6 relay board for on off control
net spindle-enable => parport.0.pin-14-out
addf parport.0.read base-thread
addf stepgen.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 classicladder.0.refresh servo-thread
addf stepgen.update-freq servo-thread
net spindle-cmd <= motion.spindle-speed-out
net xdir => parport.0.pin-02-out
net xstep => parport.0.pin-03-out
setp parport.0.pin-03-out-reset 1
setp parport.0.pin-06-out-invert 1
net zdir => parport.0.pin-06-out
net zstep => parport.0.pin-07-out
setp parport.0.pin-07-out-reset 1
net min-z <= parport.0.pin-10-in
net max-home-z <= parport.0.pin-11-in
net max-home-x <= parport.0.pin-12-in
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
net max-home-x => axis.0.home-sw-in
setp stepgen.1.position-scale [AXIS_2]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_2]STEPGEN_MAXACCEL
net zpos-cmd axis.2.motor-pos-cmd => stepgen.1.position-cmd
net zpos-fb stepgen.1.position-fb => axis.2.motor-pos-fb
net zstep <= stepgen.1.step
net zdir <= stepgen.1.dir
net zenable axis.2.amp-enable-out => stepgen.1.enable
net max-home-z => axis.2.home-sw-in
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
# Load Classicladder with modbus master included (GUI must run for Modbus)
loadusr classicladder --modmaster custom.clp
:woohoo: