Add external Speed control potentiometer--HELP

More
25 Apr 2016 15:52 #73857 by Stone
Hi. I use axis configuration to control my CNC machine. I have motor with PWM control (0-6000RPM). I have external control panel (JOG,Emergency, axis button, etc.) with potentiometer to set speed of motor. I set ADC converter and check it. It works. But if I use manual control potentiometer to set RPM, a G code "M3 S1000" doesn´t work. This is code for automatic spindle on (motion.spindle-speed-out is set by "M3 S1000"):

net spindle-cmd <= motion.spindle-speed-out => pwmgen.0.value
net spindle-on <= motion.spindle-on => pwmgen.0.enable

I use this code (I don´t know, how use two INPUT to set pwm.0.value):

net ADC_value => pwmgen.0.value
net SPINDLE => pwmgen.0.enable

This code can´t start motor by "M3 S1000". Can I combine this two different setting? Thanks.

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

More
25 Apr 2016 15:59 #73860 by andypugh

Can I combine this two different setting? Thanks.


Yes.What behaviour would you like to have?

What should happen if the knob is moved after M3 S1000?
What should happen if the knob is moved before M3 S100000?
What should happen if the knob is not at zero when there is an M5 command?

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

More
25 Apr 2016 16:14 #73861 by Stone
I want set PWM two ways continously. But i don´t know if it is possible. So,when I set knob to 50% value (3000RPM), motor spindle is 3000 RPM. Then I use M3 S5000 and motor spindle increase to 5000RPM. If I rotate knob to 60%, motor spindle decrease to 3600RPM. Can I make the rule "last change of spindle win" ? (sorry, I don´t explain it better :) )

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

More
25 Apr 2016 16:22 #73862 by andypugh

when I set knob to 50% value (3000RPM), motor spindle is 3000 RPM. Then I use M3 S5000 and motor spindle increase to 5000RPM. If I rotate knob to 60%, motor spindle decrease to 3600RPM.


That would be difficult. The problem is that an analogue input will always vary slightly, so the system has to decide if you have moved the knob a tiny amount, or whether it is just signal noise.

This would be very much easier if the potentiometer was an encoder knob. (such as www.ebay.co.uk/itm/401107986090 )

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

More
25 Apr 2016 16:39 - 25 Apr 2016 17:05 #73865 by Stone
I have 12-bit ADC(4096 unit).
Conversion ADC_value is a function. While ADC_value is less than 100, out value is 0. Increase and decrease have step 50 units. (0,50,100,150,200, etc.) I use this solution for constant spindle.

But if it is not possible, I prefer this solution:
If i don´t use RUN button, i use for control spindle potentiometer. If I start G code program, the potentiometer isn´t work.
Last edit: 25 Apr 2016 17:05 by Stone.

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

More
26 Apr 2016 15:10 #73914 by andypugh
You need a combination of mux components to steer one or other signal to the spindle speed output pin. You would select the mux on the basis of the machine mode HAL pins.

You might also need to use more mux components as a sample-and-hold function (you can feed a mux with its own output to achieve this, the dedicated sample-hold HAL component is S32 data type for some reason). You would subtract the sampled-value from the current value as a way to get some of the behaviour you want.

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

More
26 Apr 2016 16:42 #73918 by Stone
Thanks for reply. I have this idea. Can you help me with configuration? I need some command example if it is possible.



loadrt mux2 count=1
addf mux2.0 servo-thread

net ADC_value => mux2.0.in0
net motion.speed-out => mux2.0.in1
net scale1 mux2.0.sel0 <= halui.program-is-run

Something like this?
Attachments:

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

More
26 Apr 2016 17:07 - 26 Apr 2016 17:08 #73920 by andypugh

net ADC_value => mux2.0.in0
net motion.speed-out => mux2.0.in1
net scale1 mux2.0.sel0 <= halui.program-is-run


Yes, that's the simple version.

Don't forget that net commands need a signal name, and pin names have to be exact:
net ADC_value hm2_5i25.0.analogout-00 => mux2.0.in0
net spindle-command motion.spindle-speed-out  => mux2.0.in1
net spindle-select halui.program.is-running => mux2.0.sel
net selected-spindle mux2.0.out => pwmgen.0.value
Last edit: 26 Apr 2016 17:08 by andypugh.

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

More
26 Apr 2016 19:26 - 26 Apr 2016 20:10 #73931 by Stone
Ok. I edit my HAL file and it works. But I have a big problem. If I use ADC_value Input and a value is non-zero, my JOG wheel not responding (include axis choice buttons). But if the value is zero, all inputs work correctly. My opion is,that I have problem with priority(mux2 for ADC_value has HIGH priority than JOG mux4 (X,Y,Z,A)). Can you solved this problem?

This is part of my HAL file (PWM and JOG)

# ##################################################
# PWM Signals
# ##################################################

loadrt pwmgen output_type=1
loadrt mux2 count=1
loadrt or2 count=1
addf pwmgen.make-pulses servo-thread
addf pwmgen.update servo-thread
addf mux2.0 servo-thread
addf or2.0 servo-thread

setp pwmgen.0.pwm-freq 1000
setp pwmgen.0.offset -0.1
setp pwmgen.0.dither-pwm true
setp pwmgen.0.scale 6000
newsig PWM_ON_ADC bit
newsig PWM_ON_CNC bit
newsig PWM_ADC float
newsig PWM_CNC float

net PWM_ADC Therm.ch-04.value => mux2.0.in1
net PWM_CNC motion.spindle-speed-out => mux2.0.in0
net PWM_ON_ADC => or2.0.in0
sets PWM_ON_ADC true
net PWM_ON_CNC motion.spindle-on => or2.0.in1
net MODE mux2.0.sel <= halui.program.is-idle


net spindle-cmd <= mux2.0.out => pwmgen.0.value
net spindle-on <= or2.0.out => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
net spindle-cw <= bb_gpio.p9.in-29
setp bb_gpio.p8.out-07.invert 1
net spindle-pwm => bb_gpio.p8.out-07
net spindle-cw => bb_gpio.p9.out-12

# ##################################################
# Jog control
# ##################################################

loadrt encoder num_chan=1
loadrt mux4 count=1
addf encoder.capture-position servo-thread
addf encoder.update-counters servo-thread
addf mux4.0 servo-thread

# If your MPG outputs a quadrature signal per click set x4 to 1
# If your MPG puts out 1 pulse per click set x4 to 0
setp encoder.0.x4-mode 0

# For velocity mode, set to 1 [stops when the dial is stopped]
# For position mode (the default), set to 0 [axis will move exactly jog-scale]
setp axis.0.jog-vel-mode 1
setp axis.1.jog-vel-mode 1
setp axis.2.jog-vel-mode 1

# This sets the scale that will be used based on the input to the mux4
setp mux4.0.in0 0.005
setp mux4.0.in1 0.01
setp mux4.0.in2 0.1
setp mux4.0.in3 1

# The inputs to the mux4 component
net scale1 mux4.0.sel0 <= bb_gpio.p8.in-18
net scale2 mux4.0.sel1 <= bb_gpio.p8.in-17

# The output from the mux4 is sent to each axis jog scale
net mgp-scale <= mux4.0.out
net mgp-scale => axis.0.jog-scale
net mgp-scale => axis.1.jog-scale
net mgp-scale => axis.2.jog-scale

# The MPG inputs
net mpg-a encoder.0.phase-A <= bb_gpio.p8.in-19
net mpg-b encoder.0.phase-B <= bb_gpio.p8.in-26

# The Axis select inputs
net mpg-x axis.0.jog-enable <= bb_gpio.p8.in-16
net mpg-y axis.1.jog-enable <= bb_gpio.p9.in-24
net mpg-z axis.2.jog-enable <= bb_gpio.p9.in-26

# The encoder output counts to the axis. Only the selected axis will move.
net encoder-counts <= encoder.0.counts
net encoder-counts => axis.0.jog-counts
net encoder-counts => axis.1.jog-counts
net encoder-counts => axis.2.jog-counts
Last edit: 26 Apr 2016 20:10 by Stone.

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

More
26 Apr 2016 20:22 #73935 by andypugh
I am fairly sure that it is nothing to do with the HAL component order. The HAL components are executed in strict sequence, but each one gets run every single time.

It looks like you are using a Beaglebone. I know nothing about them. Machinekit and LinuxCNC have diverged quite a long way.

Is it possible that configuring a channel for ADC disables it for GPIO?

You should be able to see where the problem is with Halmeter, you can watch the encoder counts and look at the jog-enables and jog-selects to see which stops happening when the ADC is nonzero.

If it is an IO interaction problem then you definitely need to be asking on the Machinekit forums.

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

Time to create page: 0.208 seconds
Powered by Kunena Forum