Lincurve help with 2 speed BLDC motor

More
29 Sep 2019 00:39 #146528 by tacklem60
I started a thread a few days ago about this and realized that I was asking the wrong question for my application. I have a belt driven BLDC motor on my mill with a high and low speed. I have been struggling to set up my Hal file to allow the controller to take care of speeds in the low range.

Originally I was going to use the gearchange comp and realized that possibly Lincurve was better for me. My changeover speed is 1300RPM and I have found some example Hal files that are similar to what I want. My problem is that I have yet to see someone using it to control a variable resister and everyone has used it for PWM. Below is the majority of my Hal file. I'm unsure what I should put below all of the X/Y values of my file but I know that the lines referring to PWM are wrong (they are coppied from the examples I have found) any help would be greatly appreciated.

I basically just started with my spindle in low range at S250 (which actually yielded 85RPM) and moved up from there writing down the actual speed that came back at each requested value. I made 16 total data points which looked like the max for lincurve. I put 2 points right next to each other at 1300 and 1301 so it wouldnt try to interpolate at the transition between low and high gear.

#This adds a velocity controlled 4th axis
loadrt stepgen step_type=0,0,0,0 ctrl_type=p,p,p,v
loadrt scale count=1

#setup for scaling
setp scale.0.in 0
#must be tuned
setp scale.0.gain 0.885
#no current offset
setp scale.0.offset 0

#connect scale to servo clock thread
addf scale.0 servo-thread

#setup for stepgen to drive spindle
setp stepgen.3.position-scale 1.83
#max RPM of Spindle
setp stepgen.3.maxvel 2950

setp stepgen.3.steplen 1
setp stepgen.3.stepspace 0
setp stepgen.3.dirhold 28000
setp stepgen.3.dirsetup 23000
#max accel for spindle
setp stepgen.3.maxaccel 800

net spindle-enable <= motion.spindle-on => stepgen.3.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.3.velocity-cmd

#sends frequency out to par port 16 and to EMC
net spindle-out <= stepgen.3.step => parport.0.pin-16-out

loadrt lincurve personality=16
addf lincurve.0 servo-thread
setp lincurve.0.x-val-00 0
setp lincurve.0.y-val-00 0
setp lincurve.0.x-val-01 85
setp lincurve.0.y-val-01 250
setp lincurve.0.x-val-02 182
setp lincurve.0.y-val-02 550
setp lincurve.0.x-val-03 290
setp lincurve.0.y-val-03 700
setp lincurve.0.x-val-04 340
setp lincurve.0.y-val-04 850
setp lincurve.0.x-val-05 395
setp lincurve.0.y-val-05 1000
setp lincurve.0.x-val-06 500
setp lincurve.0.y-val-06 1150
setp lincurve.0.x-val-07 550
setp lincurve.0.y-val-07 1300
setp lincurve.0.x-val-08 1237
setp lincurve.0.y-val-08 1301
setp lincurve.0.x-val-09 1360
setp lincurve.0.y-val-09 1450
setp lincurve.0.x-val-10 1575
setp lincurve.0.y-val-10 1600
setp lincurve.0.x-val-11 1709
setp lincurve.0.y-val-11 1750
setp lincurve.0.x-val-12 1930
setp lincurve.0.y-val-12 2000
setp lincurve.0.x-val-13 2271
setp lincurve.0.y-val-13 2300
setp lincurve.0.x-val-14 2611
setp lincurve.0.y-val-14 2600
setp lincurve.0.x-val-15 2950
setp lincurve.0.y-val-15 2950
net spindle-raw motion.spindle-out => lincurve.0.in
net spindle-corrected lincurve.0.out => pwmgen.0.in

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 stepgen.update-freq servo-thread
#net spindle-cmd-rpm <= motion.spindle-speed-out
#net spindle-cmd-rpm-abs <= motion.spindle-speed-out-abs
#net spindle-cmd-rps <= motion.spindle-speed-out-rps
#net spindle-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
net spindle-cmd <= motion.spindle-speed-out
net spindle-cw <= motion.spindle-forward
net spindle-ccw <= motion.spindle-reverse
net coolant-mist <= iocontrol.0.coolant-mist

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

More
29 Sep 2019 14:03 #146567 by pl7i92
ok so far so good you now need a switch
to get the REAL or the lincurve in to the pwm
like a Mcode
working like
gernerate a BIT signal set by mcode
a AND selects the mux output witch is feeded from the lincurve and the pwm

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

More
29 Sep 2019 17:55 #146605 by tacklem60
I actually don't have an encoder on my machine yet. Well, I guess I should say I don't have an encoder that feeds into LinuxCNC. I have a single PPR encoder that gives me spindle speed readout but it's not accurate or useful enough to use for anything inside the control.

The issue im running into is that im not using PWM at all actually. My spindle is run in velocity mode basically like a 4th axis on the machine.

These lines below are the ones giving me an issue and I don't know what I should have them say because I don't know how the syntax of Hal files work

net spindle-raw motion.spindle-out => lincurve.0.in
net spindle-corrected lincurve.0.out => pwmgen.0.in

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

More
02 Oct 2019 05:30 #146860 by andypugh
How do you operate the variable resistor? Is it being rotated by a small motor or something?

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

Time to create page: 0.266 seconds
Powered by Kunena Forum