G96 CSS problem

More
12 years 7 months ago #45276 by BigJohnT
Replied by BigJohnT on topic G96 CSS problem
Here is the spindle section of my CHNC.
Code:
####### #Spindle uses encoder.02 and pwmgen.02 ####### #spindle scales addf scale.0 servo-thread addf scale.1 servo-thread #10v/6000rpm=0.001667 setp scale.0.gain -0.0002 # offset for spindle #setp scale.0.offset 0.0001loadrt pwmgen output_type=0 # This creates a 1Hz signal setp scale.1.gain 60 #load abs comp make spindle RPM pos loadrt abs count=3 addf abs.0 servo-thread addf abs.1 servo-thread addf abs.2 servo-thread #spindle speed out limits loadrt limit1 count=1 addf limit1.0 servo-thread setp limit1.0.min -6000 setp limit1.0.max 6000 #set scale and pwm setp hm2_5i20.0.encoder.02.scale -4096 setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.output-type 1 net spindle-speed-limit motion.spindle-speed-out => limit1.0.in net spindle-speed-limit-out limit1.0.out => scale.0.in net spindle-speed-DAC scale.0.out => hm2_5i20.0.pwmgen.02.value net spindle-rpm => abs.1.in net spindle-speed-abs <= abs.1.out #spindle enable net spindle-enable-req motion.spindle-on => and2.1.in0 net spindle-brake-sensor hm2_5i20.0.gpio.051.in_not => and2.1.in1 net spindle-enable and2.1.out => hm2_5i20.0.pwmgen.02.enable # enable spindle drive net spindle-enable => hm2_5i20.0.gpio.065.out # force spindle lock pin out net spindle-enable => hm2_5i20.0.gpio.042.out # release spindle brake net spindle-brake-prg not.0.out => or2.2.in0 net spindle-brake-logic motion.spindle-brake => not.0.in net spindle-brake hm2_5i20.0.gpio.040.out <= or2.2.out #spindle sync net spindle-index motion.spindle-index-enable <= hm2_5i20.0.encoder.02.index-enable net spindle-velocity motion.spindle-speed-in <= hm2_5i20.0.encoder.02.velocity net spindle-revs motion.spindle-revs <= hm2_5i20.0.encoder.02.position net spindle-velocity => abs.0.in net spindle-v-abs abs.0.out => scale.1.in net spindle-v-abs-out <= scale.1.out # spindle speed net spindle-velocity mult2.0.in0 setp mult2.0.in1 60 net spindle-abs abs.2.in mult2.0.out net spindle-rpm abs.2.out # spindle at speed setp near.0.difference 0.1 net spindle-velocity near.0.in1 net com-spindle-vel near.0.in2 <= motion.spindle-speed-out-rps net spindle-at-speed near.0.out <= motion.spindle-at-speed # trick Axis net trick-axis motion.spindle-reverse ####### #end of spindle ######

JT

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

More
12 years 7 months ago #45281 by newbynobi
Replied by newbynobi on topic G96 CSS problem
Helo Jim,

if you do not use feedback, why do you use a PID? It is not necessary then.

This is a spindle.hal that works with PID and in both directions. (7i43 and 7i40 with DC motor and self made encoder)
wotks within 3 % accuracy! Encoder with 1000 ppr and max spindle speed 3500 rpm
Code:
#******************* # SPINDLE S #******************* # as I do use a 7i43 we will have to load the stuff for that # you may need to add this to your needs loadrt hostmot2 loadrt hm2_7i43 ioaddr=0xcc00 epp_wide=0 config="firmware=hm2/7i43/SVST4_4S.BIT num_encoders=2 num_pwmgens=2 num_stepgens=0" setp hm2_7i43.0.pwmgen.pwm_frequency 100000 setp hm2_7i43.0.pwmgen.pdm_frequency 100000 setp hm2_7i43.0.watchdog.timeout_ns 10000000 addf hm2_7i43.0.read servo-thread addf hm2_7i43.0.write servo-thread addf hm2_7i43.0.pet_watchdog servo-thread # for closed loop we ned a PID control, so lets load it loadrt pid num_chan=1 addf pid.0.do-pid-calcs servo-thread setp pid.0.Pgain [SPINDLE_9]P setp pid.0.Igain [SPINDLE_9]I setp pid.0.Dgain [SPINDLE_9]D setp pid.0.bias [SPINDLE_9]BIAS setp pid.0.FF0 [SPINDLE_9]FF0 setp pid.0.FF1 [SPINDLE_9]FF1 setp pid.0.FF2 [SPINDLE_9]FF2 setp pid.0.deadband [SPINDLE_9]DEADBAND setp pid.0.maxoutput [SPINDLE_9]MAX_OUTPUT # ---PWM Generator signals/setup--- # no quadratur counting = 1 else 0 setp hm2_7i43.0.pwmgen.01.output-type 1 # Set the spindle's top speed in RPM setp hm2_7i43.0.pwmgen.01.scale 3500 # ---Encoder feedback signals/setup--- setp hm2_7i43.0.encoder.01.counter-mode 1 setp hm2_7i43.0.encoder.01.filter 1 setp hm2_7i43.0.encoder.01.index-invert 0 setp hm2_7i43.0.encoder.01.index-mask 0 setp hm2_7i43.0.encoder.01.index-mask-invert 0 setp hm2_7i43.0.encoder.01.scale [SPINDLE_9]INPUT_SCALE # we need a scale for feedback to the pid loadrt scale names=scale_rps_to_rpm addf scale_rps_to_rpm servo-thread setp scale_rps_to_rpm.gain 60 # ---setup spindle control signals--- net spindle-on hm2_7i43.0.pwmgen.01.enable <= pid.0.enable <= motion.spindle-on net spindle-vel-cmd pid.0.command <= motion.spindle-speed-out net spindle-output pid.0.output => hm2_7i43.0.pwmgen.01.value net spindle-vel-fb-rps hm2_7i43.0.encoder.01.velocity => scale_rps_to_rpm.in net spindle-vel-fb-rpm scale_rps_to_rpm.out => pid.0.feedback net spindle-vel-fb-rpm motion.spindle-speed-in net spindle-index-enable motion.spindle-index-enable <= hm2_7i43.0.encoder.01.index-enable ############################## # spindle at speed detection # ############################## loadrt near names=near_spindle_speed addf near_spindle_speed servo-thread # set the spindle speed inputs to agree if within 3% setp near_spindle_speed.scale 1.03 # connect one input to the commanded spindle speed # we declared above already # net spindle-vel-cmd pid.0.command <= motion.spindle-speed-out net spindle-vel-cmd near_spindle_speed.in1 # and the other input to the encoder-measured spindle speed # we declared above already # net spindle-vel-fb-rpm scale_rps_to_rpm.out => pid.0.feedback net spindle-vel-fb-rpm near_spindle_speed.in2 # connect the output to the spindle-at-speed input net spindle-at-speed motion.spindle-at-speed <= near_spindle_speed.out
you will need to adapt the PID values to your hardware

My INI has the following values:
#********************
# Spindle
#********************
[SPINDLE_9]
P = 4.0
I = 10.0
D = 0.0
FF0 = 1.0
FF1 = 0.8
FF2 = 0.0
BIAS = 0.0
DEADBAND = 5
OUTPUT_SCALE = 1.0
OUTPUT_OFFSET = 0.0
MAX_OUTPUT = 0.0
INPUT_SCALE = 1000.0

and for gmoccapy you need to connect than:
Code:
loadrt abs names=abs_spindle_feedback addf abs_spindle_feedback servo-thread net spindle-vel-fb-rpm abs_spindle_feedback.in net spindle-speed-rpm abs_spindle_feedback.out => gmoccapy.spindle_feedback_bar net spindle-at-speed gmoccapy.spindle_at_speed_led

hope that helps.

Norbert
Attachments:

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

More
12 years 7 months ago #45286 by jbunch
Replied by jbunch on topic G96 CSS problem
JT,

I am using master. 2.6.0. It used to work with AXIS and 2.5.3 and it used to work with master. It now seems to have problems.

Jim

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

More
12 years 7 months ago - 12 years 7 months ago #45292 by BigJohnT
Replied by BigJohnT on topic G96 CSS problem
Did you change "anything" between 2.5.3 and master?

The basic G96 test in sim/lathe works fine.

JT
Last edit: 12 years 7 months ago by BigJohnT.

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

More
12 years 5 months ago - 12 years 5 months ago #46783 by ap machine works
Replied by ap machine works on topic G96 CSS problem
I'm having a similar issue, how was this resolved?
Last edit: 12 years 5 months ago by BigJohnT.

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

More
12 years 5 months ago #46790 by newbynobi
Replied by newbynobi on topic G96 CSS problem
You will need to explain your issue in detail, otherwise the answer will be,
Use a similar solution:-)

Norbert

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

Time to create page: 0.268 seconds
Powered by Kunena Forum