Sorry bad clicl publish too early

Hi

Happy new year to all !!


A ton of thanks, i's more than expected ! For sure your file is really 
better writed for reading/understanding.

setp hpg.pwmgen.00.out.00.pin 807 # Digital out from cape Do-0
maybee this is the type of this cape output that make it work directly to 
the isolator/convertor ? As you can see i have short knowledge for all this 
pwm dac spindle stuff.

As i have check all work as wanted from -10.2v to +9.6v accroding to asked 
speed and direction.

Only one problem with the half (55) value that provide ~+2v to the isolator 
output in place of wanted 0v (maybee only need to replace change the offset 
value not tested for now)



I paste the updated file like you write :

#####################################################################
# Spindel VFD closed loop with PID NEAR SCALE and OFFSET for Rev/fw -10v 0v 
+10v
# from 0/24v PWM out to 0/10v Analog to -10v 0v +10v isolator/convertissor
#####################################################################


loadrt pid names=pid.spindle
loadrt offset names=offset.pwmgen
loadrt near names=near.at-speed
loadrt scale names=scale.spindle-vel-rpm 


addf pid.spindle.do-pid-calcs             servo-thread
addf offset.pwmgen.update-output          servo-thread
addf near.at-speed                        servo-thread
addf scale.spindle-vel-rpm                servo-thread


# scale RPS to RPM
setp scale.spindle-vel-rpm.gain [SPINDLE]VELOCITY_RPM_GAIN


# setup Spindle PID
setp pid.spindle.Pgain     [SPINDLE]P
setp pid.spindle.Igain     [SPINDLE]I
setp pid.spindle.Dgain     [SPINDLE]D
setp pid.spindle.FF0       [SPINDLE]FF0
setp pid.spindle.FF1       [SPINDLE]FF1
setp pid.spindle.FF2       [SPINDLE]FF2
setp pid.spindle.bias      [SPINDLE]BIAS
setp pid.spindle.deadband  [SPINDLE]DEADBAND
setp pid.spindle.maxerror  [SPINDLE]MAX_ERROR
setp pid.spindle.maxoutput [SPINDLE]MAX_OUTPUT


setp hpg.encoder.00.chan.00.scale [SPINDLE]ENCODER_SCALE
setp hpg.encoder.00.chan.00.counter-mode 0


setp hpg.pwmgen.00.pwm_period [SPINDLE]PWM_PERIOD
setp hpg.pwmgen.00.out.00.enable 1  # allow to be at half value when 
spindle is off due to offset use but maybee bad idea ??


setp near.at-speed.scale [SPINDLE]AT_SPEED_SCALE


# offset the pid output the value of max output to shift the output above 0
setp offset.pwmgen.offset [SPINDLE]MAX_OUTPUT
net DAC-ctrl-in <= pid.spindle.output
net DAC-ctrl-in => offset.pwmgen.in


# scale max expected input * 2 to equal a PWM duty cycle of 1.0 
setp hpg.pwmgen.00.out.00.scale [SPINDLE]PWM_OUTPUT_SCALE


# encoder connections
net spindle-pos <= hpg.encoder.00.chan.00.position 
net spindle-pos => motion.spindle-revs


net spindle-vel-fb-rps <= hpg.encoder.00.chan.00.velocity
net spindle-vel-fb-rps => motion.spindle-speed-in
net spindle-vel-fb-rps => scale.spindle-vel-rpm.in
net spindle-vel-rpm <= scale.spindle-vel-rpm.out  # name changed according 
to my other config for display axctual rpm (actually unfiltered)
net spindle-vel-cmd <= motion.spindle-speed-out   # added according to my 
other config for display asked rpm


# Speed command in RPS
net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
net spindle-vel-cmd-rps => pid.spindle.command


# offset output to feed to pwmgen output
net DAC-ctrl-out <= offset.pwmgen.out
net DAC-ctrl-out => hpg.pwmgen.00.out.00.value




# Spindle control signals
net spindle-enable <= motion.spindle-on
net spindle-enable => pid.spindle.enable
net spindle-enable => fur.do-6
net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
net spindle-vel-cmd-rps => near.at-speed.in1 
net spindle-vel-fb-rps  => near.at-speed.in2
net spindle-at-speed <= near.at-speed.out
net spindle-at-speed => motion.spindle-at-speed 



[SPINDLE]
# PID, input is RPS

P = 1

I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 0.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_ERROR = 0.0
#Max desired spindle speed in RPMs (3300) / 60 = Spindle Speed in RPS.
MAX_OUTPUT = 55.00
# quadrature mode (mode-0) is encoder PPR * 4

ENCODER_SCALE = 400

# scale pid output to pwm control value. Max duty cycle of 1.0 / (Max speed 
* 2) ---range of both directions
PWM_OUTPUT_SCALE = 110
# PWMgen output frequency in Hz
PWM_PERIOD = 10000000
AT_SPEED_SCALE = 1.01
VELOCITY_RPM_GAIN = 60

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/machinekit/6a7175bb-efd5-403d-a2d0-510ccec177a7%40googlegroups.com.

Reply via email to