#emc-devel | Logs for 2009-04-11

Back
[06:25:44] <CIA-2> EMC: 03cmorley 07TRUNK * 10emc2/lib/python/pyvcp_widgets.py: add the option to create 'disable' halpins to label, led, rectled and button widgets for the ability to create pyvcp panels that have 'sensitive' widgets
[13:09:22] <Pilotltd> Hi Guys - can anyone answer the following - gotta be easy, but I'm too stupid :) My spindle direction is controlled by a relay. Stepconf put the following in, which works for CW - how do I get it to toggle pin 16 for CCW
[13:09:27] <Pilotltd> setp parport.0.pin-16-out-invert 1
[13:09:27] <Pilotltd> net spindle-cw => parport.0.pin-16-out
[20:12:58] <Pilotltd> Hi Guys - how do you toggle a pin in hal file for spindle cw/ccw - I want pin 16 low for cw and high for ccw. All it does it flip a relay.
[20:13:34] <alex_joni> connect spindle-forward to it
[20:13:45] <alex_joni> or reverse, depending how you like it
[20:14:02] <alex_joni> but using one pin for cw/ccw you can't say when it should be on/off
[20:14:12] <alex_joni> so you need a second one for on/off
[20:14:17] <Pilotltd> tried that seems only to work in one direction
[20:14:48] <alex_joni> when the spindle is reversed, the spindle-forward should be low
[20:15:21] <Pilotltd> setp parport.0.pin-16-out-invert 1
[20:15:21] <Pilotltd> net spindle-cw => parport.0.pin-16-out
[20:15:42] <Pilotltd> works for forward, but no reverse
[20:16:00] <SWPadnos> how do you turn the spindle on and off?
[20:16:17] <alex_joni> Pilotltd: what do you mean by "works for forward, but no reverse"
[20:16:19] <SWPadnos> does it have a single enable and a +/-10V speed, forward enable and reverse enable? ...
[20:16:21] <alex_joni> be a bit more specific..
[20:16:24] <Pilotltd> Hi SWP - it's always enabled
[20:16:27] <SWPadnos> hi
[20:16:35] <SWPadnos> ah, so you command zero speed to "turn it off"
[20:16:42] <Pilotltd> yup
[20:16:58] <alex_joni> you probably need to abs() the output from the motion controller if you're feeding an DAC
[20:17:09] <SWPadnos> (or PWM)
[20:17:18] <Pilotltd> its pwm
[20:17:39] <alex_joni> if you're feeding pwmgen, then you surely need to convert the speed setting to an absolute value
[20:17:52] <alex_joni> as it is now the output from motion is negative for reverse rotation
[20:18:26] <alex_joni> Pilotltd: http://www.linuxcnc.org/docview/devel/html//man/man9/abs.9.html
[20:18:38] <SWPadnos> didn't we add a spindle-speed-abs output or something?
[20:18:45] <alex_joni> maybe for 2.3
[20:18:49] <alex_joni> * alex_joni isn't sure
[20:18:50] <SWPadnos> well, by "we" I mean "you" :)
[20:18:56] <Pilotltd> I'm using 2.3
[20:19:05] <alex_joni> * alex_joni looks
[20:19:13] <Pilotltd> gor
[20:19:18] <alex_joni> you don't seriously expect me to know what I'm doing :D
[20:19:22] <Pilotltd> arrgghh got
[20:19:30] <SWPadnos> no, that's why I'm here to remind you
[20:19:30] <Pilotltd> net spindle-cw <= motion.spindle-forward
[20:19:30] <Pilotltd> net spindle-ccw <= motion.spindle-reverse
[20:19:35] <SWPadnos> (as if I knew :) )
[20:19:44] <Pilotltd> in the pwm section
[20:20:03] <alex_joni> SWPadnos: nope, I don't see it
[20:20:06] <SWPadnos> ok
[20:20:18] <alex_joni> Pilotltd: ok so far, but you only need one I think
[20:20:28] <SWPadnos> Pilotltd, are you modifying the "main" HAL file, or a "custom.hal" file?
[20:20:35] <Pilotltd> main
[20:21:18] <SWPadnos> ok, in that case you'll need to load an abs function and add it to the servo thread
[20:21:32] <alex_joni> loadrt abs
[20:21:39] <SWPadnos> find the spindle-speed signal and connect it to abs.0.in instead of the pwmgen
[20:21:40] <alex_joni> addf servo-thread abs.0
[20:21:57] <Pilotltd> hang on got
[20:22:01] <SWPadnos> and then make a new connection between the abs and the pwmgen:
[20:22:16] <SWPadnos> net spindle-speed-abs abs.0.out pwmgen.(whichever).value
[20:22:38] <Pilotltd> lost me :(
[20:22:43] <SWPadnos> heh
[20:22:52] <alex_joni> Pilotltd: lets take it step by step first
[20:22:58] <alex_joni> (no HAL code, just concept)
[20:23:03] <SWPadnos> ok - you take it, I'll get more coffee
[20:23:04] <SWPadnos> :)
[20:23:20] <alex_joni> emc2 outputs 2 things (spindle-forward and spindle-speed)
[20:23:36] <alex_joni> (we'll disregard the other outputs, these 2 will do just fine)
[20:23:45] <Pilotltd> OK - but don't forget I'm a linux and EMC virgin :)
[20:23:58] <alex_joni> Pilotltd: I'm taking it slowly .. let me know if you're keeping up
[20:24:07] <Pilotltd> yup
[20:24:21] <alex_joni> so.. spindle-forward.. this is TRUE if the spindle is moving forward, and false for otherwise
[20:24:29] <alex_joni> (either moving in reverse, or stopped)
[20:24:45] <Pilotltd> ok
[20:24:47] <alex_joni> S1000 M3 -> spindle-forward is active
[20:24:54] <alex_joni> S2000 M4 -> inactive
[20:25:05] <alex_joni> M5 -> inactive
[20:25:18] <alex_joni> hope this is clear
[20:25:22] <alex_joni> now, spindle-speed
[20:25:25] <Pilotltd> yep
[20:25:36] <alex_joni> spindle-speed holds the velocity the spindle should turn
[20:25:41] <alex_joni> S1000 M3 -> 1000
[20:25:48] <alex_joni> S2000 M4 -> -2000
[20:25:54] <alex_joni> M5 -> 0
[20:26:07] <Pilotltd> ok so far
[20:26:15] <alex_joni> so for reverse rotations you get negative speeds
[20:26:23] <alex_joni> for forward you get positive speeds
[20:26:26] <alex_joni> and 0 when halted
[20:26:41] <alex_joni> ok, the spindle-speed needs to drive the pwmgen
[20:26:50] <alex_joni> but pwmgen accepts a positive input only
[20:27:02] <alex_joni> if it gets a negative input it just assumes 0
[20:27:23] <alex_joni> so we need to convert the spindle speed to positive only
[20:27:38] <alex_joni> abs does that -> generates the absolute speed value
[20:27:53] <Pilotltd> right
[20:28:17] <alex_joni> now we take the speed preset (negative for reverse, and positive for forward) connect it to the abs component, and we get a positive only speed
[20:28:23] <alex_joni> which we use to drive the pwmgen
[20:28:48] <alex_joni> as a schematic: motion.spindle-speed -> abs -> pwmgen
[20:29:22] <alex_joni> if you got so far, we can go to actually do it in HAL
[20:30:39] <Pilotltd> OK so far, pwmgen is scattered in a few sections in the stepconf produced hal
[20:30:59] <alex_joni> you can leave it like that, or put things in the same place
[20:33:00] <Pilotltd> Where does the abs command have to go, after the addf commands but before the
[20:33:03] <Pilotltd> net spindle-cmd <= motion.spindle-speed-out => pwmgen.0.value
[20:33:05] <Pilotltd> net spindle-enable <= motion.spindle-on => pwmgen.0.enable
[20:33:07] <Pilotltd> net spindle-pwm <= pwmgen.0.pwm
[20:33:29] <alex_joni> you need to break up the first link
[20:33:41] <alex_joni> and add the abs between the 2
[20:34:11] <alex_joni> currently 'spindle-cmd' comes from 'motion.spindle-speed-out' and goes to 'pwmgen.0.value'
[20:34:36] <Pilotltd> OK???
[20:34:42] <alex_joni> we want 'spindle-cmd' to come from 'motion.spindle-speed-out' and go to 'abs.0.in'
[20:35:03] <alex_joni> and 'spindle-abs-cmd' to come from 'abs.0.out' and go to 'pwmgen.0.value'
[20:35:18] <alex_joni> net spindle-cmd <= motion.spindle-speed-out => abs.0.in
[20:35:32] <alex_joni> net spindle-abs-cmd <= abs.0.out => pwmgen.0.value
[20:37:03] <alex_joni> Pilotltd: so simply comment out the first line you pasted (using #), and add the 2 lines I pasted
[20:37:15] <Pilotltd> so it should read
[20:37:19] <Pilotltd> addf servo-thread abs.0
[20:37:21] <Pilotltd> net spindle-cmd <= motion.spindle-speed-out => abs.0.in
[20:37:23] <Pilotltd> <alex_joni> net spindle-abs-cmd <= abs.0.out => pwmgen.0.value
[20:37:25] <Pilotltd> net spindle-enable <= motion.spindle-on => pwmgen.0.enable
[20:37:27] <Pilotltd> net spindle-pwm <= pwmgen.0.pwm
[20:37:29] <Pilotltd> setp pwmgen.0.pwm-freq 0.0
[20:37:31] <Pilotltd> setp pwmgen.0.scale 27403.8461538
[20:37:33] <Pilotltd> setp pwmgen.0.offset 0.000456140350877
[20:37:35] <Pilotltd> setp pwmgen.0.dither-pwm true
[20:37:37] <Pilotltd> net spindle-cw <= motion.spindle-forward
[20:37:39] <Pilotltd> net spindle-ccw <= motion.spindle-reverse
[20:37:54] <Pilotltd> oops without your name
[20:37:57] <alex_joni> yup, without the <alex_joni> in there
[20:38:12] <alex_joni> and you probably want to connect spindle-cw or -ccw to an parport pin
[20:38:49] <Pilotltd> yes - pin 16 toggles the VFD direction
[20:40:07] <Pilotltd> will just defining it for cw work?
[20:40:18] <alex_joni> yup
[20:41:48] <Pilotltd> Thanks - I'll give that whirl in the morning, it's 9.45pm here, been a long day
[20:42:06] <alex_joni> it's close to midnight here :)
[20:42:16] <Pilotltd> where are you?
[20:42:22] <alex_joni> 2 timezones east
[20:42:31] <alex_joni> Timisoara/Romania
[20:42:52] <Pilotltd> assumed you were in the USA
[20:43:38] <alex_joni> :)
[20:44:19] <Pilotltd> Time for a beer here, and a read of Peter Smids CNC3 book I bought last week <G>
[20:44:46] <alex_joni> * alex_joni prefers some Terry Pratchett before bed
[20:45:14] <alex_joni> Pilotltd: I know there's a learning curve to HAL, but I'm sure it's worth it
[20:46:27] <Pilotltd> I'm going to need to learn it <G>
[20:49:53] <Pilotltd> I've all sorts of other junk in my head like CAD/CAM support, VB, writing post processors and sorting Gcode out for clients, as well as harware testing for OEM's.
[20:50:16] <alex_joni> Pilotltd: tell me about it..
[20:52:26] <Pilotltd> OEM's are the worst - they ask you for an honest appraisal of their stuff, you give, make sugeestions for improvements and they take no notice!
[20:52:42] <alex_joni> heh
[20:53:02] <Pilotltd> Hence I'm stuck with this crappy VFD <G>
[20:54:49] <Pilotltd> Don't know whether it's a good or bad thing when they let you keep the machine ;)
[20:55:42] <alex_joni> sounds good to me
[20:59:27] <Pilotltd> Beer and book beckons - thanks very much, I'll let you know how it goes
[20:59:34] <alex_joni> Pilotltd: cool
[20:59:37] <alex_joni> see you
[20:59:42] <Pilotltd> cu
[20:59:52] <alex_joni> 'night all