router spindle PWM control (open loop)

More
24 Feb 2023 16:48 #265250 by PaulQUE
I added net spindle-enable => hm2_7i96.0.pwmgen.00.enable but I still get 5v between GND and step- or between step- and step +

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

More
24 Feb 2023 16:59 #265251 by PCW
Yes that's expected.

You need to invert the PWM output to use the STEP- pin:

setp hm2_7i96.0.pwmgen.00.out0.invert_output true

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

More
24 Feb 2023 17:46 #265253 by PaulQUE
Yes I had that pin inverted since you suggested it, here is what I have currently setup for my spindle:


loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt hostmot2
loadrt hm2_eth board_ip="10.10.10.10" config=" num_encoders=0 num_pwmgens=1 num_stepgens=4 sserial_port_0=0xxxxx"
setp [HMOT](CARD0).watchdog.timeout_ns 5000000
loadrt pid names=pid.x,pid.y,pid.y2,pid.z,pid.s

addf [HMOT](CARD0).read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pid.x.do-pid-calcs servo-thread
addf pid.y.do-pid-calcs servo-thread
addf pid.y2.do-pid-calcs servo-thread
addf pid.z.do-pid-calcs servo-thread
addf pid.s.do-pid-calcs servo-thread
addf [HMOT](CARD0).write servo-thread

setp hm2_7i96.0.pwmgen.00.output-type 1
setp hm2_7i96.0.pwmgen.00.scale 18000

#*******************
# SPINDLE
#*******************

#setp pid.s.Pgain [SPINDLE_0]P
#setp pid.s.Igain [SPINDLE_0]I
#setp pid.s.Dgain [SPINDLE_0]D
#setp pid.s.bias [SPINDLE_0]BIAS
#setp pid.s.FF0 [SPINDLE_0]FF0
#setp pid.s.FF1 [SPINDLE_0]FF1
#setp pid.s.FF2 [SPINDLE_0]FF2
#setp pid.s.deadband [SPINDLE_0]DEADBAND
#setp pid.s.maxoutput [SPINDLE_0]MAX_OUTPUT
#setp pid.s.error-previous-target true

setp [HMOT](CARD0).pwmgen.pwm_frequency 10000
setp [HMOT](CARD0).pwmgen.00.scale 18000
setp [HMOT](CARD0).pwmgen.00.output-type 1
setp [HMOT](CARD0).pwmgen.00.out0.invert_output TRUE
#setp hm2_7i96.0.pwmgen.00.scale [SPINDLE_0]MAX_OUTPUT

net spindle_output <= pid.s.output

#net spindle-index-enable <=> pid.s.index-enable
net spindle-enable [HMOT](CARD0).pwmgen.00.enable

net spindle-vel-cmd-rpm => pid.s.command
net spindle-vel-fb-rpm => pid.s.feedback
#net spindle-output <= pid.s.output

#net spindle-speed-out-rpm-abs [HMOT](CARD0).pwmgen.00.value

# ---setup spindle control signals---

net spindle-vel-cmd-rps <= spindle.0.speed-out-rps
net spindle-vel-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-vel-cmd-rpm <= spindle.0.speed-out
net spindle-vel-cmd-rpm => hm2_7i96.0.pwmgen.00.value
net spindle-on <= spindle.0.on => [HMOT](CARD0).ssr.00.out-00
#net spindle-cw <= spindle.0.forward
#net spindle-ccw <= spindle.0.reverse
#net spindle-brake <= spindle.0.brake
#net spindle-revs => spindle.0.revs
net spindle-at-speed => spindle.0.at-speed
net spindle-vel-fb-rps => spindle.0.speed-in
#net spindle-index-enable <=> spindle.0.index-enable
net spindle-enable => hm2_7i96.0.pwmgen.00.enable
#net spindle-speed-out-rpm-abs hm2_7i96.0.pwmgen.00.value
# ---Setup spindle at speed signals---
#net spindle-enable => [HMOT](CARD0).ssr.00.out-00
sets spindle-at-speed true


Just to be sure, when using step-, I should connect p
my PWM board + and - to the step 5 5v and step-?

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

More
24 Feb 2023 17:50 #265254 by PCW
You should connect your PWM board+ to 7I96 STEP-
and PWM board GND or - to 7I96 GND

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

More
24 Feb 2023 18:09 #265256 by PaulQUE
okay I've changed the wiring, still nothing, when looking at Hm2_7i96.0.pwmgen.00.value" on the hal meter I still have the value set as exactly the value set with M3, furthermore, it seems the value doesn't mind going past the set scale value ( 18000 in my case )

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

More
24 Feb 2023 18:18 #265259 by PCW
Yes, the value you set can be anything (though the actual PWM value will saturate at 100%)

If you measure the voltage on STEP4- relative to GND, you should get about 5V*value/scale
(assuming the PWM output is inverted and enabled)

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

More
24 Feb 2023 18:31 #265260 by PaulQUE
I get 0v whatever the rpm I set via MDI, could you tell me if the PWM is properly configured in my hal flie?

loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt hostmot2
loadrt hm2_eth board_ip="10.10.10.10" config=" num_encoders=0 num_pwmgens=1 num_stepgens=4 sserial_port_0=0xxxxx"
setp [HMOT](CARD0).watchdog.timeout_ns 5000000
loadrt pid names=pid.x,pid.y,pid.y2,pid.z,pid.s

addf [HMOT](CARD0).read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pid.x.do-pid-calcs servo-thread
addf pid.y.do-pid-calcs servo-thread
addf pid.y2.do-pid-calcs servo-thread
addf pid.z.do-pid-calcs servo-thread
addf pid.s.do-pid-calcs servo-thread
addf [HMOT](CARD0).write servo-thread

setp hm2_7i96.0.pwmgen.00.output-type 1
setp hm2_7i96.0.pwmgen.00.scale 18000

#*******************
# SPINDLE
#*******************

#setp pid.s.Pgain [SPINDLE_0]P
#setp pid.s.Igain [SPINDLE_0]I
#setp pid.s.Dgain [SPINDLE_0]D
#setp pid.s.bias [SPINDLE_0]BIAS
#setp pid.s.FF0 [SPINDLE_0]FF0
#setp pid.s.FF1 [SPINDLE_0]FF1
#setp pid.s.FF2 [SPINDLE_0]FF2
#setp pid.s.deadband [SPINDLE_0]DEADBAND
#setp pid.s.maxoutput [SPINDLE_0]MAX_OUTPUT
#setp pid.s.error-previous-target true

setp [HMOT](CARD0).pwmgen.pwm_frequency 10000
setp [HMOT](CARD0).pwmgen.00.scale 18000
setp [HMOT](CARD0).pwmgen.00.output-type 1
setp [HMOT](CARD0).pwmgen.00.out0.invert_output TRUE
#setp hm2_7i96.0.pwmgen.00.scale [SPINDLE_0]MAX_OUTPUT

net spindle_output <= pid.s.output

#net spindle-index-enable <=> pid.s.index-enable
net spindle-enable [HMOT](CARD0).pwmgen.00.enable

net spindle-vel-cmd-rpm => pid.s.command
net spindle-vel-fb-rpm => pid.s.feedback
#net spindle-output <= pid.s.output

#net spindle-speed-out-rpm-abs [HMOT](CARD0).pwmgen.00.value

# ---setup spindle control signals---

net spindle-vel-cmd-rps <= spindle.0.speed-out-rps
net spindle-vel-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-vel-cmd-rpm <= spindle.0.speed-out
net spindle-vel-cmd-rpm => hm2_7i96.0.pwmgen.00.value
net spindle-on <= spindle.0.on => [HMOT](CARD0).ssr.00.out-00
#net spindle-cw <= spindle.0.forward
#net spindle-ccw <= spindle.0.reverse
#net spindle-brake <= spindle.0.brake
#net spindle-revs => spindle.0.revs
net spindle-at-speed => spindle.0.at-speed
net spindle-vel-fb-rps => spindle.0.speed-in
#net spindle-index-enable <=> spindle.0.index-enable
net spindle-enable => hm2_7i96.0.pwmgen.00.enable
#net spindle-speed-out-rpm-abs hm2_7i96.0.pwmgen.00.value
# ---Setup spindle at speed signals---
#net spindle-enable => [HMOT](CARD0).ssr.00.out-00
sets spindle-at-speed true

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

More
24 Feb 2023 18:39 #265261 by PCW
Looks like nothing drives the signal "spindle-enable" so pwm enable is always false

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

More
24 Feb 2023 18:52 #265263 by PaulQUE
thanks, that was it, sorry for the noob questions

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

More
24 Feb 2023 19:15 #265266 by PCW
It takes a while to get used to the fact that signals
(like spindle-enable) do nothing but carry values
from pin to pin

Also, using halshows watch tab on critical signals/pins can
help speed up debugging

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

Time to create page: 0.079 seconds
Powered by Kunena Forum