I not fully understand it is ok for use the amazon board you found for convert my PWM to 0/5v PWM (with try to invert pin) and use 2 other channel for enable and direction for the ebay controler?
#####################################################################
# Spindel VFD closed loop with PID LOWPASS NEAR SCALE
#####################################################################
newinst pid pid-s # used for closed loop spindle
newinst lowpass lp-s-fb
newinst near near-s-fb # used for spindle at speed
newinst scale scale-spindle-rpm # used for display RPM to user
# maxerror is related to the Igain (max value possible to add by pid = Igain x maxerrorI)
setp pid-s.maxerrorI 0
setp pid-s.Pgain 0
setp pid-s.Igain 1
setp pid-s.Dgain 0
setp pid-s.bias 50
setp pid-s.FF0 1
setp pid-s.FF1 0
setp pid-s.FF2 0
setp pid-s.deadband .05
setp pid-s.maxoutput [SPINDLE]OUTPUT_SCALE
setp near-s-fb.scale 1.01 # 1.01 Allow 1% / 1.1 Allow 10% for speed cmd vs real
setp lp-s-fb.gain 0.005
# --- Spindle encoder
setp hpg.encoder.00.chan.00.scale [SPINDLE]ENCODER_SCALE # counts per revolution
setp hpg.encoder.00.chan.00.filter 1 # Currently unsupported, included for compatability with hm2. ????
setp hpg.encoder.00.chan.00.index-mask 1 # Currently unsupported, included for compatability with hm2. ????
# disable encoder index as it is not working in pru encoder (finally seems to be ok)
#setp hpg.encoder.00.chan.00.counter-mode 0 # Quadrature mode AB default
net spindle-index-enable motion.spindle-index-enable <=> hpg.encoder.00.chan.00.index-enable pid-s.index-enable # need testing
# ---Spindle VFD closed loop with PID and compensation
net spindle-pos hpg.encoder.00.chan.00.position => motion.spindle-revs # report our revolution count to the motion controller
net spindle-vel-fb hpg.encoder.00.chan.00.velocity => lp-s-fb.in #pid-s.feedback # report encoder speed to pid and speed filter input
net spindle-vel-fb-lp lp-s-fb.out => near-s-fb.in2 motion.spindle-speed-in scale-spindle-rpm.in pid-s.feedback # report speed filtered to motion controller + scale input
# +report speed filtered to near component = Yes/No allowed with 1% difference
net spindle-at-speed near-s-fb.out => motion.spindle-at-speed # connect the near output to motion spindle-at-speed = Yes/No
setp scale-spindle-rpm.gain 60 # scale filtered speed RPSx60 = asked RPM
net spindle-vel-rpm scale-spindle-rpm.out # create hal for user display asked RPM connected with scale
# ---setup spindle control signals and soft start---
newinst limit2 lim-s-speed
setp lim-s-speed.min -[SPINDLE]OUTPUT_MAX_LIMIT
setp lim-s-speed.max [SPINDLE]OUTPUT_MAX_LIMIT
setp lim-s-speed.maxv [SPINDLE]MAX_ACC
setp hpg.pwmgen.00.out.00.scale [SPINDLE]OUTPUT_SCALE
setp hpg.pwmgen.00.pwm_period [SPINDLE]OUTPUT_PERIOD # spec du controler ACRF16
net spindle.is-on motion.spindle-on hpg.pwmgen.00.out.00.enable # active pwmgen only when spindle is on from motion
net spindle-vel-cmd-rps motion.spindle-speed-out-rps lim-s-speed.in near-s-fb.in1
net spindle-vel-cmd-rps-lim lim-s-speed.out => pid-s.command # WITH PID FOR WORKING
#net spindle-vel-cmd-rps-lim lim-s-speed.out => hpg.pwmgen.00.out.00.value # WITOUT PID FOR TEST
net spindle-output pid-s.output => hpg.pwmgen.00.out.00.value
net spindle-vel-cmd <= motion.spindle-speed-out
net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle.is-on => pid-s.enable fur.do-6 # output pin
# Spindle[SPINDLE]ENCODER_SCALE = 400
# Settings below are in Hz
OUTPUT_PERIOD = 10000000# Settings below are in unit/secondOUTPUT_SCALE = 60
OUTPUT_MAX_LIMIT = 55# #55*60seconde = 3300rpm
MAX_ACC = 17
net spindle_dir motion.spindle-reverse => bb_gpio.pN.out-NN
--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/machinekit/31333bb3-da24-42af-a3ae-d91802daf7ba%40googlegroups.com.
(pid Igain = 0, Bias = 60, Pgain = 1, scale = 120, min =-115, max = 115)
ask M4 S3300 = 5% pwm so value are 4.95
ask M4 S1 = ~50% pwm so value are 60ask M3 S1 = ~50% pwm so value are 60
ask M3 S3300 = 95% so value are 114.95
the problem come when i change Pgain = 0 and Igain = 0.1 or 1 etcask M4 S3300 = 0% pwm so value decrease quickly to -120
ask M4 S1 = ~50% pwm so value are 60 but decrease slowly to -120ask M3 S1 = ~50% pwm so value are 60 increase slowly to 120
ask M3 S3300 = 100% so value are 120
##### HAL FIle
############################ Spindle###########################
loadrt pid names=pid.spindleloadrt offset names=offset.pwmgenloadrt near names=near.at-speedloadrt scale names=scale.spindle-vel-rpm
addf pid.spindle.do-pid-calcs servo-threadaddf offset.pwmgen.update-output.funct servo-threadaddf near.at-speed servo-threadaddf scale.spindle-speed-rpm servo-thread
# scale RPS to RPMsetp scale.spindle-vel-rpm.gain [SPINDLE]VELOCITY_RPM_GAIN
# setup Spindle PIDsetp pid.spindle.Pgain [SPINDLE]Psetp pid.spindle.Igain [SPINDLE]Isetp pid.spindle.Dgain [SPINDLE]Dsetp pid.spindle.FF0 [SPINDLE]FF0setp pid.spindle.FF1 [SPINDLE]FF1setp pid.spindle.FF2 [SPINDLE]FF2setp pid.spindle.bias [SPINDLE]BIASsetp pid.spindle.deadband [SPINDLE]DEADBANDsetp pid.spindle.maxerror [SPINDLE]MAX_ERRORsetp pid.spindle.maxoutput [SPINDLE]MAX_OUTPUT
setp hpg.encoder.00.chan.00.scale [SPINDLE]ENCODER_SCALEsetp hpg.encoder.00.chan.00.counter-mode 0
setp hpg.pwmgen.00.out.00.pwm_period [SPINDLE]PWM_PERIOD
setp near.at-speed.scale [SPINDLE]AT_SPEED_SCALE
# offset the pid output the value of max output to shift the output above 0setp offset.pwmgen.offset [SPINDLE]MAX_OUTPUTnet DAC-ctrl-in <= pid.spindle.outnet 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
# set the pwmgen output pinsetp hpg.pwmgen.00.out.00.pin 921
# encoder connectionsnet spindle-pos <= hpg.encoder.00.chan.00.position net spindle-pos => motion.spindle-revs
net spindle-vel-fb-rps <= hpg.encoder.00.chan.00.velocitynet spindle-vel-fb-rps => motion.spindle-speed-innet spindle-vel-fb-rps => scale.spindle-speed-rpm.innet spindle-vel-scaled-rpm <= scale.spindle-speed-rpm
# Speed command in RPSnet spindle-vel-cmd-rps <= motion.spindle-speed-out-rpsnet spindle-vel-cmd-rps => pid.spindle.command
# offset output to feed to pwmgen outputnet DAC-ctrl-out <= offset.pwmgen.outnet DAC-ctrl-out => hpg.pwmgen.00.out.00.value
# Spindle control signalsnet spindle-enable <= motion.spindle-onnet spindle-enable => pid.spindle.enablenet spindle-enable => fur.do-6net spindle-vel-cmd-rps <= motion.spindle-speed-out-rpsnet spindle-vel-cmd-rps => near.at-speed.in1 net spindle-vel-fb-rps => near.at-speed.in2net spindle-at-speed <= near.at-speed.outnet spindle-at-speed => motion.spindle-at-speed
##### INI File
############## SPINDLE#############
[SPINDLE]# PID, input is RPSOUTPUT_PERIOD = 10000000P = 0.1I = 0.0D = 0.0FF0 = 0.0FF1 = 0.0FF2 = 0.0BIAS = 0.0DEADBAND = 0.0MAX_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 * 4ENCODER_SCALE = 1600# scale pid output to pwm control value. Max duty cycle of 1.0 / (Max speed * 2) ---range of both directionsPWM_OUTPUT_SCALE = 110# PWMgen output frequency in HzPWM_PERIOD = 10000000AT_SPEED_SCALE = 1.01VELOCITY_RPM_GAIN = 60
Saisissez le code ici...
[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
#####################################################################
# 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
net DAC-ctrl-in <= pid.spindle.output
net DAC-ctrl-in => offset.pwmgen.in
#FOR TESTING
net spindle-vel-cmd-rps => offset.pwmgen.in
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 ??
net spindle-enable => fur.do-6
What do you think of this ?
PWM_PERIOD = 20000000isolator Zero to minimumat full reverse (-55 on "motion.spindle-speed-out-rps") the "offset.pwmgen.out" pin is at 0, and your PWM is at ~0%, or~1.1v output -10.2vat 0 speed (0 on "motion.spindle-speed-out-rps") the "offset.pwmgen.out" pin is at 55, and your PWM is at ~50% or~13.8v output +0.65vat full forward(55 on "motion.spindle-speed-out-rps") the "offset.pwmgen.out" pin is at 110, and your PWM is at ~100% or~23.9v output 9.7v
--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/machinekit/2f95e20c-8bf0-40bb-909f-dd5879162408%40googlegroups.com.
One more things, your setup doesn't need "pid.spindle.feedback" ?
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to a topic in the Google Groups "Machinekit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/machinekit/hD50Ilh6IPI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to machinekit+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/machinekit/0fafc139-b0e9-4ba3-b88a-fa6267dad57b%40googlegroups.com.
It doesConnect the spindle-vel-fb-rps signal to the pid fb pin.
On Thu, Jan 2, 2020, 12:19 PM Aurelien <golf...@gmail.com> wrote:
One more things, your setup doesn't need "pid.spindle.feedback" ?--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to a topic in the Google Groups "Machinekit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/machinekit/hD50Ilh6IPI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to machi...@googlegroups.com.
###################################################################### Spindel VFD closed loop : PID NEAR SCALE OFFSET for Rev/stop/fw -10v 0v +10v# from 0/24v PWM to +-10v isolator/convertissor
#####################################################################
loadrt pid names=pid.spindleloadrt offset names=offset.pwmgenloadrt near names=near.at-speedloadrt scale names=scale.spindle-vel-rpm
loadrt and2 names=and2.spindle-ena
addf pid.spindle.do-pid-calcs servo-threadaddf offset.pwmgen.update-output servo-threadaddf near.at-speed servo-thread
addf scale.spindle-vel-rpm slow-threadaddf and2.spindle-ena servo-thread
# scale RPS to RPMsetp scale.spindle-vel-rpm.gain [SPINDLE]VELOCITY_RPM_GAIN
# setup Spindle PIDsetp pid.spindle.Pgain [SPINDLE]Psetp pid.spindle.Igain [SPINDLE]Isetp pid.spindle.Dgain [SPINDLE]Dsetp pid.spindle.FF0 [SPINDLE]FF0setp pid.spindle.FF1 [SPINDLE]FF1setp pid.spindle.FF2 [SPINDLE]FF2setp pid.spindle.bias [SPINDLE]BIASsetp pid.spindle.deadband [SPINDLE]DEADBANDsetp pid.spindle.maxerror [SPINDLE]MAX_ERRORsetp pid.spindle.maxoutput [SPINDLE]MAX_OUTPUT
# setup hardwar (encoder + PWMgen)
setp hpg.encoder.00.chan.00.scale [SPINDLE]ENCODER_SCALEsetp 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
# offset the pid output the value of max output to shift the pwm output above 12v for output 0v from +-10 DACsetp offset.pwmgen.offset [SPINDLE]OFFSET_OUTPUT
net DAC-ctrl-in <= pid.spindle.outputnet DAC-ctrl-in => offset.pwmgen.in
#net spindle-vel-cmd-rps => offset.pwmgen.in # for bypass PID only for some test
# 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 connectionsnet spindle-pos <= hpg.encoder.00.chan.00.position net spindle-pos => motion.spindle-revs
net spindle-vel-fb-rps <= hpg.encoder.00.chan.00.velocitynet spindle-vel-fb-rps => motion.spindle-speed-innet spindle-vel-fb-rps => scale.spindle-vel-rpm.in
net spindle-vel-fb-rps => pid.spindle.feedback
net spindle-vel-rpm <= scale.spindle-vel-rpm.outnet spindle-vel-cmd <= motion.spindle-speed-out
# Speed command in RPSnet spindle-vel-cmd-rps <= motion.spindle-speed-out-rpsnet spindle-vel-cmd-rps => pid.spindle.command
# offset output to feed to pwmgen outputnet DAC-ctrl-out <= offset.pwmgen.out
#net DAC-ctrl-out => hpg.pwmgen.00.out.00.value # do in the orient mux2
# Spindle control signals + and2 for stop spindle after stop GUInet spindle-enable <= motion.spindle-onnet spindle-enable => and2.spindle-ena.in0net drv-enable => and2.spindle-ena.in1net spindle-and2enable <= and2.spindle-ena.outnet spindle-and2enable => pid.spindle.enable
#net spindle-and2enable => fur.do-6 # do in the orient or2
# Spindle at speed near signalsetp near.at-speed.scale [SPINDLE]AT_SPEED_SCALE
net spindle-vel-cmd-rps <= motion.spindle-speed-out-rpsnet spindle-vel-cmd-rps => near.at-speed.in1 net spindle-vel-fb-rps => near.at-speed.in2net spindle-at-speed <= near.at-speed.outnet spindle-at-speed => motion.spindle-at-speed
#####################################################################
###################################################################### Spindle orient mode#####################################################################loadrt orient names=orient.spindleloadrt pid names=pid.orient-valueloadrt offset names=offset.orientloadrt near names=near.orient-okloadrt or2 names=or2.orient-enaloadrt and2 names=and2.orient-enaloadrt mux2 names=mux2.orient-value
addf orient.spindle servo-threadaddf pid.orient-value.do-pid-calcs servo-threadaddf offset.orient.update-output servo-threadaddf near.orient-ok servo-threadaddf or2.orient-ena servo-threadaddf and2.orient-ena servo-threadaddf mux2.orient-value servo-thread
# setup Orient Spindle PIDsetp pid.orient-value.Pgain [ORIENT]Psetp pid.orient-value.Igain [ORIENT]Isetp pid.orient-value.Dgain [ORIENT]Dsetp pid.orient-value.FF0 [ORIENT]FF0setp pid.orient-value.FF1 [ORIENT]FF1setp pid.orient-value.FF2 [ORIENT]FF2setp pid.orient-value.bias [ORIENT]BIASsetp pid.orient-value.deadband [ORIENT]DEADBANDsetp pid.orient-value.maxerror [ORIENT]MAX_ERRORsetp pid.orient-value.maxoutput [ORIENT]MAX_OUTPUT
# Set asked mode from M19 P0/1/2net spindle-orient-mode <= motion.spindle-orient-modenet spindle-orient-mode => orient.spindle.mode
# Spindle orient control signals + and2 for stop spindle after stop GUInet spindle-orient-enable <= motion.spindle-orientnet spindle-orient-enable => and2.orient-ena.in0net drv-enable => and2.orient-ena.in1net spindle-orient-and2enable <= and2.orient-ena.outnet spindle-orient-and2enable => orient.spindle.enablenet spindle-orient-and2enable => mux2.orient-value.selnet spindle-orient-and2enable => pid.orient-value.enable
# enable out for controler from regular spindle or orient modenet spindle-and2enable => or2.orient-ena.in0net spindle-orient-and2enable => or2.orient-ena.in1net spindle-orient-or2enable <= or2.orient-ena.outnet spindle-orient-or2enable => fur.do-6
# Spindle at orient near signalnet spindle-pos => orient.spindle.positionnet spindle-pos => pid.orient-value.feedbacknet spindle-pos => near.orient-ok.in2
net spindle-orient_cmd <= motion.spindle-orient-anglenet spindle-orient_cmd => near.orient-ok.in1net spindle-orient_cmd => orient.spindle.angle
net spindle-is-oriented <= near.orient-ok.outnet spindle-is-oriented => motion.spindle-is-oriented
# Rotation command in degreenet spindle-orient-pid-cmd <= orient.spindle.commandnet spindle-orient-pid-cmd => pid.orient-value.command
# offset the pid output the value of max output to shift the pwm output above 12v for output 0v from +-10 DACsetp offset.orient.offset [SPINDLE]OFFSET_OUTPUTnet DAC-ctrl-orient-in <= pid.orient-value.outputnet DAC-ctrl-orient-in => offset.orient.in
# offset output to feed to pwmgen output + mux with regular spindle modulnet DAC-ctrl-orient-out <= offset.orient.outnet DAC-ctrl-orient-out <= mux2.orient-value.in1net DAC-ctrl-out => mux2.orient-value.in0net DAC-computed-ctrl-out <= mux2.orient-value.outnet DAC-computed-ctrl-out => hpg.pwmgen.00.out.00.value
#####################################################################
# Spindle
[SPINDLE]# PID, input is RPSP = 1I = 0.0D = 0.0FF0 = 0.0FF1 = 0.0FF2 = 0.0BIAS = 0.0DEADBAND = 0.0MAX_ERROR = 0.0#Max desired spindle speed in RPMs (3300) / 60 = Spindle Speed in RPS. MAX_OUTPUT = 55.00
OFFSET_OUTPUT = 55
# quadrature mode (mode-0) is encoder PPR * 4ENCODER_SCALE = 400# scale pid output to pwm control value. Max duty cycle of 1.0 / (Max speed * 2) ---range of both directions
# +30 for having correct 0v at 0rpm at offset output value and allow to increase max speed to 3600 if wanted
PWM_OUTPUT_SCALE = 110# PWMgen output frequency in Hz
PWM_PERIOD = 20000000
AT_SPEED_SCALE = 1.01VELOCITY_RPM_GAIN = 60
# Orient Spindle[ORIENT]# PID, input is degree
P = 1I = 0.0D = 0.0FF0 = 0.0FF1 = 0.0FF2 = 0.0BIAS = 0.0DEADBAND = 0.0MAX_ERROR = 0.0#Max desired spindle speed in RPMs (3300) / 60 = Spindle Speed in RPS. MAX_OUTPUT = 55.00
I don't really understand what you mean here. I thought your problem was the hardware outputs "stick". If "losing" the software enable from Machinekit will drop an output and disconnect a relay then why isn't that relay the drive enable for the KB drive? That's the only relay that needs to disconnect to kill the drive.
As for the spindle orient thing, you are getting ahead of yourself (again). Really shouldn't bother with something so convoluted until you see the thing turn. Why don't you put that "spindle orient" thing in a separate hal file, and once you see the thing run OK then you can add the second hal file to your ini file.
setp hpg.pwmgen.00.out.00.enable 1 # allow to be at offset value else when spindle is off
# offset the pid output the value of max output to shift the pwm output above 12v for output 0v from +-10 DACsetp offset.pwmgen.offset [SPINDLE]OFFSET_OUTPUTnet DAC-ctrl-in <= pid.spindle.outputnet DAC-ctrl-in => offset.pwmgen.in#net spindle-vel-cmd-rps => offset.pwmgen.in # for bypass PID only for some test
# 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-index-enable <= motion.spindle-index-enablenet spindle-index-enable <=> hpg.encoder.00.chan.00.index-enablenet spindle-index-enable => pid.spindle.index-enable
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.velocitynet spindle-vel-fb-rps => motion.spindle-speed-innet spindle-vel-fb-rps => scale.spindle-vel-rpm.innet spindle-vel-fb-rps => pid.spindle.feedback
net spindle-vel-rpm <= scale.spindle-vel-rpm.outnet spindle-vel-cmd <= motion.spindle-speed-out
# Speed command in RPSnet spindle-vel-cmd-rps <= motion.spindle-speed-out-rpsnet spindle-vel-cmd-rps => pid.spindle.command
# offset output to feed to pwmgen outputnet DAC-ctrl-out <= offset.pwmgen.out
#net DAC-ctrl-out => hpg.pwmgen.00.out.00.value # moved in the orient mux2
# Spindle control signals + and2 for stop spindle after stop GUInet spindle-enable <= motion.spindle-onnet spindle-enable => and2.spindle-ena.in0net drv-enable => and2.spindle-ena.in1net spindle-and2enable <= and2.spindle-ena.outnet spindle-and2enable => pid.spindle.enable
#net spindle-and2enable => fur.do-6 # moved in the orient or2
# Spindle at speed near signalsetp near.at-speed.scale [SPINDLE]AT_SPEED_SCALEnet spindle-vel-cmd-rps <= motion.spindle-speed-out-rpsnet spindle-vel-cmd-rps => near.at-speed.in1 net spindle-vel-fb-rps => near.at-speed.in2net spindle-at-speed <= near.at-speed.outnet spindle-at-speed => motion.spindle-at-speed
#####################################################################
###################################################################### Spindle orient mode#####################################################################loadrt orient names=orient.spindleloadrt pid names=pid.orient-valueloadrt offset names=offset.orientloadrt near names=near.orient
loadrt or2 names=or2.orient-enaloadrt and2 names=and2.orient-enaloadrt mux2 names=mux2.orient-value
addf orient.spindle servo-threadaddf pid.orient-value.do-pid-calcs servo-threadaddf offset.orient.update-output servo-thread
addf near.orient servo-thread
addf or2.orient-ena servo-threadaddf and2.orient-ena servo-threadaddf mux2.orient-value servo-thread
# setup Orient Spindle PIDsetp pid.orient-value.Pgain [ORIENT]Psetp pid.orient-value.Igain [ORIENT]Isetp pid.orient-value.Dgain [ORIENT]Dsetp pid.orient-value.FF0 [ORIENT]FF0setp pid.orient-value.FF1 [ORIENT]FF1setp pid.orient-value.FF2 [ORIENT]FF2setp pid.orient-value.bias [ORIENT]BIASsetp pid.orient-value.deadband [ORIENT]DEADBANDsetp pid.orient-value.maxerror [ORIENT]MAX_ERRORsetp pid.orient-value.maxoutput [ORIENT]MAX_OUTPUT
# Set asked mode from M19 P0/1/2net spindle-orient-mode <= motion.spindle-orient-modenet spindle-orient-mode => orient.spindle.mode
# encoder connectionsnet spindle-index-enable => pid.orient-value.index-enable # need investigation
# Spindle orient control signals + and2 for stop spindle after stop GUInet spindle-orient-enable <= motion.spindle-orientnet spindle-orient-enable => and2.orient-ena.in0net drv-enable => and2.orient-ena.in1net spindle-orient-and2enable <= and2.orient-ena.outnet spindle-orient-and2enable => orient.spindle.enablenet spindle-orient-and2enable => mux2.orient-value.selnet spindle-orient-and2enable => pid.orient-value.enable
# enable out for controler from regular spindle or orient modenet spindle-and2enable => or2.orient-ena.in0net spindle-orient-and2enable => or2.orient-ena.in1net spindle-orient-or2enable <= or2.orient-ena.outnet spindle-orient-or2enable => fur.do-6
# Spindle at orient near signal
setp near.orient.scale [ORIENT]AT_ANGLE_SCALE #AT_ANGLE_SCALE = 1.12
net spindle-pos => orient.spindle.positionnet spindle-pos => pid.orient-value.feedback
net spindle-pos => near.orient.in2
net spindle-orient_cmd <= motion.spindle-orient-anglenet spindle-orient_cmd => near.orient.in1net spindle-orient_cmd => orient.spindle.angle
net spindle-is-oriented <= near.orient.out
halcmd -kf loadusr halmeter signal spindle-index-enable sets spindle-index-enable 1
For the normal spindle in velocity mode I would use only FF0 and P and I, and only add I when you are quite close to correct velocity following.
(FF0 only is pure open loop voltage mode with a PWM driven servo motor)
So for this mode I would get the spindle speed as accurate as possible over the
full speed range with just FF0 and then add feedback with some P (as much as it
stable) and then some I
For position mode you use As much D&P (more D allows more P) as is stable then
adjust FF1 for minimum following error vs velocity. Then finally add as much I as is stable
--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/machinekit/4f07a30d-673e-4a9f-ade1-af3263322414%40googlegroups.com.
Original wiring use a filter for brake relay, it is better to use it again ?