spindle control with gearchange and near

More
16 Dec 2011 06:12 #15717 by fabworx
Ok I currently have my spindle running correctly and scaled correctly but id like to add the gear change to the mix. My current configuration (mechanically) is in hi gear the spindle is belt driven by the motor at a 1:1 ratio, and my encoder is mounted to the motor shaft.
My low gear is a back gear arrangement that is like 6.558875:1 meaning the motor will rotate 6.558875 times to the one rotation of the spindle. I just want everyone to be clear. I have got the gear change function working with the hal and on the screen however I cant figure out how to or what I need in the hal to change the scale of the encoder to speed up the motor by 6.558875 times to get my spindle speed to read correctly to the commanded input. As I have an over lap of 100 rpm in between gear changes meaning both gears will run at 550 rpm. I can’t get the motor to speed up so that I can run the commanded 550 rpm (spindle speed). Any help would be greatly appreciated I know I’m over looking something but I’m not sure if it’s just a scaling component or what.

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

More
16 Dec 2011 10:29 #15725 by andypugh
fabworx wrote:

I cant figure out how to or what I need in the hal to change the scale of the encoder to speed up the motor by 6.558875 times to get my spindle speed to read correctly to the commanded input


On the face of it, all you should need is a mux2 component with the inputs set to the two encoder scale values and the output connected to the encoder scale pin.

However, for some reason the encoder scale pin is of i/o type, which means that you might have trouble connecting it to a mux2.

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

More
16 Dec 2011 17:58 - 17 Dec 2011 06:50 #15735 by ArcEye
Hi

my encoder is mounted to the motor shaft.

It might considerably simplify the logic if you were able to mount the hardware encoder on the spindle.

I matched the actual spindle speed to the commanded RPM for my lathes 4 pulley settings, by using a scale component, with a simple M code bash script which alters the scale ratio depending upon which pulley is selected.

I did the same for my 2 speed mill, albeit the ratio difference was nowhere as severe as your back gear, just a standard Hi /Lo.

regards
Last edit: 17 Dec 2011 06:50 by ArcEye. Reason: mental dyslexia

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

More
16 Dec 2011 18:12 - 16 Dec 2011 19:17 #15738 by fabworx
Thanx you guys. Arceye could I possibly see how you did a m code bash maybe that part of your hal and ini would help in terms of an example. Thanx again.
Last edit: 16 Dec 2011 19:17 by fabworx.

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

More
17 Dec 2011 07:22 #15762 by ArcEye
Of course.

First apologies for my reference to displayed speed instead of commanded speed, I have now amended.

The whole point of mounting the encoder on the spindle is that the displayed RPM is always correct, you just have to get the motor speed right to produce the commanded speed.

Late afternoon brain dyslexia I think!

The scale component is basically inserted between commanded speed from hal and the speed command to the stepgen.

loadrt scale count=1
setp scale.0.in 0
setp scale.0.gain 1.16 # GIVES TRUE 600 RPM in M4 IN 600-1200 PULLEY RANGE
setp scale.0.offset 0
addf scale.0 servo-thread

net spindle-cmd motion.spindle-speed-out => scale.0.in

net spindle-freq <= scale.0.out => stepgen.4.velocity-cmd


The bash script in M101
!/bin/bash

## sets scale gain to make output speed accurate
## for each of 4 pulley settings

if [ ! $# -ge 1 ]; then
  echo "Usage: M101 n - where n is speed range 1 - 4"
  exit 1
fi

float=$1
int=${float/\.*}

case $int in

    1 ) halcmd setp scale.0.gain 0.595;;
#       accurate at 1200 in M4 for turning

    2 ) halcmd setp scale.0.gain 1.16;;
#       accurate at 600 in M4 for turning

    3 ) halcmd setp scale.0.gain 2.175;;
#       accurate at 300 in M3 for threading

    4 ) halcmd setp scale.0.gain 4.3;;
#       accurate at 150 in M3 for threading
esac

exit 0

hopefully that explains a bit more fully

regards

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

More
17 Dec 2011 22:30 #15784 by fabworx
only problem with that is i have no physical way of mounting the encoder to the spindle due to a power drawbar attachment on the end of the spindle. so at the same time i have to scale the motor i also have to scale the encoder thats where im having problems

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

More
17 Dec 2011 23:05 #15785 by andypugh
fabworx wrote:

only problem with that is i have no physical way of mounting the encoder to the spindle due to a power drawbar attachment on the end of the spindle. so at the same time i have to scale the motor i also have to scale the encoder thats where im having problems


You need to change the encoder scale. You can do that with a setp in a bash script called by n M-code. Because the encoder scale is an unhelpful form of pin, you can't do it in HAL. However, you could use a "scale" function to scale the encoder velocity by the appropriate factor (probably feeding the scale factor input from a mux2 pre-programmed with the two relevant factors)

Is the situation that you change gear manually, and you want EMC2 to compensate (a microswitch on the lever, for example) or that you want to have the encoder scaling change as art of an automatic gear change?

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

More
17 Dec 2011 23:29 #15786 by fabworx
yes im changing gear manually i dont currently have a switch on the physical lever im performing the function with a toggle button and led indicaters to indicate which gear im in. i would like to eventually have emc figure out for the operator which gear the machine should be in but for now im running the machine and i know where i should be. essentially the only time i need to be in low gear is during a taping operation. with manual toolchanges im probably going to just put in my post processor from cam to include a note to operator to put in low gear when doing the tool change for the tap.

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

More
17 Dec 2011 23:33 #15787 by fabworx
by the way what do you think of this

hal
setp hm2_5i20.0.pwmgen.04.output-type 2

#net spindle-speed-cmd motion.spindle-speed-out => hm2_5i20.0.pwmgen.04.value
net spindle-enable hm2_5i20.0.gpio.071.out <= motion.spindle-on hm2_5i20.0.gpio.045.out
linksp spindle-enable => hm2_5i20.0.pwmgen.04.enable

loadrt mux2 count=2
loadrt flipflop count=2
addf flipflop.0 servo-thread
addf mux2.0 servo-thread
setp mux2.0.in0 8000
setp mux2.0.in1 1219.7213699
net gearchange-scale-change mux2.0.sel flipflop.0.out

addf flipflop.1 servo-thread
addf mux2.1 servo-thread
setp mux2.1.in0 3550
setp mux2.1.in1 23284.00625
net gearchange-scale-change mux2.1.sel flipflop.1.out

# Set the spindle’s top speed in RPM
net hm2_5i20.0.pwmgen.04.scale mux2.1.out

# controls
net spindle-cw <= motion.spindle-forward
net spindle-ccw <= motion.spindle-reverse

#****************************
# Spindle Synchronized Motion
#****************************

# add the encoder
setp hm2_5i20.0.encoder.04.counter-mode 0
setp hm2_5i20.0.encoder.04.filter 0
setp hm2_5i20.0.encoder.04.index-invert 0
setp hm2_5i20.0.encoder.04.index-mask 0
#setp hm2_5i20.0.encoder.04.index-mask-invert
net hm2_5i20.0.encoder.04.scale mux2.0.out

net spindle-index-enable <=> hm2_5i20.0.encoder.04.index-enable

# connect the hal encoder outputs[The hal encoder index-enable is an exception to the rule in that it behaves as both an input and an output, see manual for details] to EMC2
net spindle-position hm2_5i20.0.encoder.04.position => motion.spindle-revs
net spindle-velocity hm2_5i20.0.encoder.04.velocity => motion.spindle-speed-in
net spindle-index-enable hm2_5i20.0.encoder.04.index-enable <=> motion.spindle-index-enable


#*****************
# Spindle At Speed
#*****************

loadrt near
addf near.0 servo-thread
net spindle-speed-cmd near.0.in1
net spindle-rpm-filtered near.0.in2
net spindle-at-speed motion.spindle-at-speed <= near.0.out
setp near.0.scale 1.01

#*********
#RPM Scale
#*********

loadrt lowpass count=4
loadrt scale count=3
loadrt abs count=1
addf abs.0 servo-thread
setp scale.0.gain 0.01225
setp lowpass.0.gain .005
addf lowpass.0 servo-thread
addf scale.0 servo-thread

#******************
#Spindle Gearchange
#******************

loadrt or2 count=1
net spindle-cw or2.0.in0
net spindle-ccw or2.0.in1
loadrt toggle count=4
loadrt not count=4
loadrt gearchange count=1
addf toggle.0 servo-thread
addf not.0 servo-thread
addf gearchange.0 servo-thread
setp toggle.0.debounce 0
setp gearchange.0.min1 10
setp gearchange.0.max1 600
setp gearchange.0.min2 500
setp gearchange.0.max2 3595
setp gearchange.0.scale2 6.558875
net spindle-speed-raw motion.spindle-speed-out gearchange.0.speed-in
net spindle-speed gearchange.0.speed-out hm2_5i20.0.pwmgen.04.value

postguihal

net spindle-velocity => lowpass.0.in
net spindle-fb-filtered-rps lowpass.0.out => abs.0.in
net spindle-fb-filtered-abs-rps abs.0.out => scale.0.in
net spindle-rpm-filtered scale.0.out => pyvcp.spindle-speed-meter
net spindle-at-speed => pyvcp.spindle-at-speed-led
net togout toggle.0.out not.0.in gearchange.0.sel flipflop.1.reset => pyvcp.highgear-led flipflop.0.reset
net logear not.0.out flipflop.0.set flipflop.1.set => pyvcp.lowgear-led
net gearswap toggle.0.in <= pyvcp.gearchange-button
net spindle-rpm-filtered scale.0.out => pyvcp.spindle-speed-number

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

More
17 Dec 2011 23:34 #15788 by fabworx
i know my near scaling is off im dealing with a firmware problem im not concerned with that yet

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

Time to create page: 0.079 seconds
Powered by Kunena Forum