- Configuring LinuxCNC
- Basic Configuration
- Setting Up BLDC spindle motor in Forward/Reverse direction.
Setting Up BLDC spindle motor in Forward/Reverse direction.
17 Aug 2024 14:56 #308007
by amanker
I have setup linuxCNC using remora.
Its working nice. I want to replace PWM DC motor with BLDC motor.
BLDC contoller has enable and direction pins and 0-10V input pin. I am using PWM tp 0-10V converter.
When I use spindle i forward direction then its working. But in reverse direction its not rotating. I confirmed manullly that spindle/contoller is working ok in both direction.
I can see m3 and m4 signals properly triggering suitable pins. on m3 and m4 I can see enable pin is getting voltage. and like wise direction pin is also working ok.
But I have noted that PWM out is only working in forward direction. In case of m4 there is no PWM out on pin.
Please help me.
Here is my HAL file.
Its working nice. I want to replace PWM DC motor with BLDC motor.
BLDC contoller has enable and direction pins and 0-10V input pin. I am using PWM tp 0-10V converter.
When I use spindle i forward direction then its working. But in reverse direction its not rotating. I confirmed manullly that spindle/contoller is working ok in both direction.
I can see m3 and m4 signals properly triggering suitable pins. on m3 and m4 I can see enable pin is getting voltage. and like wise direction pin is also working ok.
But I have noted that PWM out is only working in forward direction. In case of m4 there is no PWM out on pin.
Please help me.
Here is my HAL file.
# load the realtime components
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
#loadrt remora-eth
loadrt remora chip_type=STM SPI_clk_div=32 PRU_base_freq=120000
#loadrt remora chip_type=LPC SPI_clk_div=64
# estop loopback, SPI comms enable and feedback
net user-enable-out <= iocontrol.0.user-enable-out => remora.SPI-enable
net user-request-enable <= iocontrol.0.user-request-enable => remora.SPI-reset
net remora-status <= remora.SPI-status => iocontrol.0.emc-enable-in
# add the remora and motion functions to threads
addf remora.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf remora.update-freq servo-thread
addf remora.write servo-thread
# Joint 0 setup
setp remora.joint.0.scale [JOINT_0]SCALE
setp remora.joint.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
setp remora.joint.0.deadband [JOINT_0]DEADBAND
setp remora.joint.0.pgain [JOINT_0]P_GAIN
setp remora.joint.0.ff1gain [JOINT_0]FF1_GAIN
net xpos-cmd <= joint.0.motor-pos-cmd => remora.joint.0.pos-cmd
net j0pos-fb <= remora.joint.0.pos-fb => joint.0.motor-pos-fb
net j0enable <= joint.0.amp-enable-out => remora.joint.0.enable
# Joint 1 setup
setp remora.joint.1.scale [JOINT_1]SCALE
setp remora.joint.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
setp remora.joint.1.deadband [JOINT_1]DEADBAND
setp remora.joint.1.pgain [JOINT_1]P_GAIN
setp remora.joint.1.ff1gain [JOINT_1]FF1_GAIN
net j1pos-cmd <= joint.1.motor-pos-cmd => remora.joint.1.pos-cmd
net j1pos-fb <= remora.joint.1.pos-fb => joint.1.motor-pos-fb
net j1enable <= joint.1.amp-enable-out => remora.joint.1.enable
# Joint 2 setup
setp remora.joint.2.scale [JOINT_2]SCALE
setp remora.joint.2.maxaccel [JOINT_2]STEPGEN_MAXACCEL
setp remora.joint.2.deadband [JOINT_2]DEADBAND
setp remora.joint.2.pgain [JOINT_2]P_GAIN
setp remora.joint.2.ff1gain [JOINT_2]FF1_GAIN
net j2pos-cmd <= joint.2.motor-pos-cmd => remora.joint.2.pos-cmd
net j2pos-fb <= remora.joint.2.pos-fb => joint.2.motor-pos-fb
net j2enable <= joint.2.amp-enable-out => remora.joint.2.enable
# Joint 3 setup
setp remora.joint.3.scale [JOINT_3]SCALE
setp remora.joint.3.maxaccel [JOINT_3]STEPGEN_MAXACCEL
setp remora.joint.3.deadband [JOINT_3]DEADBAND
setp remora.joint.3.pgain [JOINT_3]P_GAIN
setp remora.joint.3.ff1gain [JOINT_3]FF1_GAIN
net j3pos-cmd <= joint.3.motor-pos-cmd => remora.joint.3.pos-cmd
net j3pos-fb <= remora.joint.3.pos-fb => joint.3.motor-pos-fb
net j3enable <= joint.3.amp-enable-out => remora.joint.3.enable
# Joint 4 setup
setp remora.joint.4.scale [JOINT_4]SCALE
setp remora.joint.4.maxaccel [JOINT_4]STEPGEN_MAXACCEL
setp remora.joint.4.deadband [JOINT_4]DEADBAND
setp remora.joint.4.pgain [JOINT_4]P_GAIN
setp remora.joint.4.ff1gain [JOINT_4]FF1_GAIN
net j4pos-cmd <= joint.4.motor-pos-cmd => remora.joint.4.pos-cmd
net j4pos-fb <= remora.joint.4.pos-fb => joint.4.motor-pos-fb
net j4enable <= joint.4.amp-enable-out => remora.joint.4.enable
# end-stops
net X-min remora.input.0 => joint.0.neg-lim-sw-in
net X-max remora.input.1 => joint.0.home-sw-in joint.0.pos-lim-sw-in
# net X-max remora.input.1 => joint.0.pos-lim-sw-in
net Y-min remora.input.2 => joint.1.neg-lim-sw-in
net Y-max remora.input.3 => joint.1.home-sw-in joint.1.pos-lim-sw-in
# net Y-max remora.input.3 => joint.1.pos-lim-sw-in
net Z-min remora.input.4 => joint.2.neg-lim-sw-in
net Z-max remora.input.5 => joint.2.home-sw-in joint.2.pos-lim-sw-in
# net Z-max remora.input.5 => joint.2.pos-lim-sw-in
net A-max remora.input.6 => joint.3.home-sw-in
# Probe
#loadrt debounce cfg=1
#addf debounce.0 servo-thread
#setp debounce.0.delay 100
#unlinkp motion.probe-input
#net probe-in debounce.0.0.in
#net probe-filt debounce.0.0.out => motion.probe-input
net probe-input motion.probe-input <= remora.input.7
# net probe-input => qtdragon.led-probe
# Spindle
# loadrt pwmgen output_type=0
# addf pwmgen.update servo-thread
# addf pwmgen.make-pulses servo-thread
# net spindle-speed-cmd spindle.0.speed-out => pwmgen.0.value
# net spindle-on spindle.0.on => pwmgen.0.enable
# net spindle-pwm pwmgen.0.pwm => remora.output.0
# Set the spindle's top speed in RPM
# setp pwmgen.0.scale 12000
# net spindle-speed-feedback spindle.0.speed-out-rps => spindle.0.speed-in
loadrt scale count=7
addf scale.0 servo-thread
addf scale.1 servo-thread
setp scale.0.gain 0.008333 # PWM per RPM, calculated over full scale. Example: 0-100 PWM, 12000 rpm: (100/12000) = 0.008333
net spindle-scale-in spindle.0.speed-out => scale.0.in scale.1.in
net spindle-speed-scaled scale.0.out => remora.SP.0
# spindle enable pin
net spindle-enable spindle.0.on => remora.output.1
# spindle DIR pin change to where ever it goes
net spindle-rev spindle.0.reverse => remora.output.2
setp scale.1.gain 0.000965
#net spindle-amp-in spindle.0.speed-out => scale.1.in
#net remora-status => halui.machine.on
#net user-enable-out => halui.estop.reset
#net remora-status remora.SPI-status => estop_latch.ok-in
#net estop-status estop_latch.ok-out => iocontrol.0.emc-enable-in
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
Please Log in or Create an account to join the conversation.
17 Aug 2024 18:10 #308015
by Henk
Replied by Henk on topic Setting Up BLDC spindle motor in Forward/Reverse direction.
Mu guess is that your pwm gen doesn't like negative spindle speeds and defaults to 0.
So try to change this line in your hal file....
net spindle-scale-in spindle.0.speed-out => scale.0.in scale.1.in
To this....
net spindle-scale-in spindle.0.speed-out-abs => scale.0.in scale.1.in
So try to change this line in your hal file....
net spindle-scale-in spindle.0.speed-out => scale.0.in scale.1.in
To this....
net spindle-scale-in spindle.0.speed-out-abs => scale.0.in scale.1.in
Please Log in or Create an account to join the conversation.
17 Aug 2024 18:12 #308016
by Henk
Replied by Henk on topic Setting Up BLDC spindle motor in Forward/Reverse direction.
Copied from the motion man page...
spindle.M.speed-out OUT FLOAT
Desired spindle speed in rotations per minute.
spindle.M.speed-out-abs OUT FLOAT
Desired spindle speed in rotations per minute, always positive regardless of spindle direction.
spindle.M.speed-out OUT FLOAT
Desired spindle speed in rotations per minute.
spindle.M.speed-out-abs OUT FLOAT
Desired spindle speed in rotations per minute, always positive regardless of spindle direction.
Please Log in or Create an account to join the conversation.
- Configuring LinuxCNC
- Basic Configuration
- Setting Up BLDC spindle motor in Forward/Reverse direction.
Time to create page: 0.078 seconds