Step/Dir Spindle changes direction immediately (but should not)

319 views
Skip to first unread message

Sag ich Dir nich

unread,
Apr 22, 2017, 2:47:01 PM4/22/17
to Machinekit
Hello,

i got the Step/Dir Spindle working with ramping and everything except if i command M4 the Dir pin changes immediately. It should change when the current rpm is 0.

Here is my spindle config:

# ################
# B [4] SPINDEL
# ################

#   Use a scale module for offset and scaling of the stepgen
#   Offset and scale are determined by first calculating and testing
#
loadrt scale count=1
addf scale.0 servo-thread
setp scale.0.in 0
setp scale.0.gain 1.00  # GIVES TRUE 600 RPM in M4
setp scale.0.offset 0
#
#   Initialise the stepgen for the spindle
#
setp hpg.stepgen.04.position-scale    1
setp hpg.stepgen.04.maxvel              8000
setp hpg.stepgen.04.steplen             1000
setp hpg.stepgen.04.stepspace         1000
setp hpg.stepgen.04.dirhold               200
setp hpg.stepgen.04.dirsetup             200
setp hpg.stepgen.04.maxaccel          2000
setp hpg.stepgen.04.steppin              924
setp hpg.stepgen.04.dirpin                926
setp hpg.stepgen.04.control-type       1

#   Enable it
net machineison halui.machine.is-on => hpg.stepgen.04.enable

#   Connect spindle speed to scaler
net spindle-cmd motion.spindle-speed-out => scale.0.in

#   Connect scaler output to stepgen velocity
net spindle-freq <= scale.0.out => hpg.stepgen.04.velocity-cmd 

#   Connect output to the pin for the analog voltage of spindle2 board
net spindle-out <= hpg.stepgen.04.steppin => #924 #bb_gpio.p9.out-24 

# Some problems setting up logic to match the reversing contactor
#   This works, connecting CCW to stepgen DIR to Spindle2 DIR
net spindle-rev motion.spindle-reverse => bb_gpio.p9.out-26


i tried commenting out "net spindle-rev motion.spindle-reverse => bb_gpio.p9.out-26" but then it does not change the direction

basically what i need is the direction pin to change, when i command the opposite direction, at 0 rpm, after the spindle has ramped down for example

M3 S100
M4 S100 (spindle ramps down to 0 rpm then the Dir pin changes state and the spindle ramps up again)

i appreciate any help


schoo...@btinternet.com

unread,
Apr 23, 2017, 4:59:59 AM4/23/17
to machi...@googlegroups.com
There was something very familiar about this config, I realised it is adapted from a lathe config I have, using a velocity stepgen, complete with the same comments :-)
I must have passed it on at some point.


On 22/04/17 19:47, Sag ich Dir nich wrote:
Hello,

i got the Step/Dir Spindle working with ramping and everything except if i command M4 the Dir pin changes immediately. It should change when the current rpm is 0.

What do you base the assertion that it should only change when RPM is 0 upon?

This old thread discusses the issue and I don't think anything has changed
https://en.industryarena.com/forum/reverse-lathe-turn-m3-m4--67203.html

You don't have any connections in your config that will ensure this, no spindle brake, no monitor of spindle speed.
The dir pin is a simple bit pin, set to forward or reverse.

An easy way to do this is just program
M3 S100
...
M5
G4 P5 ;delay to ensure spindle stops
M4 S100

Alternately, if you have a spindle brake it needs tying to M5, using detection of 0 RPM spindle etc.

The only reason you would reverse spindle direction on a lathe normally, is switching from a conventional cutting tool, to a threading tool or parting tool which
is held inverted to aid chip removal or something similar.
There is plenty of time to stop the spindle and restart it, before or after the tool change.

regards
--
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.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.

Sag ich Dir nich

unread,
Apr 23, 2017, 6:56:52 AM4/23/17
to Machinekit
Yes thats correct, i have found a config somewhere i dont remember :) The reason i need the dir pin to change at 0 rpm is if i want to do rigid tapping (forgot to mention it is about a cnc mill) and ease of programing (dont have to change the postprocessor, if it is even possible because rigid tapping are cycles, so the spindle config has to work like i described above). The spindle driver is going to be a Step/Dir closed loop servo driver (Tarocco) so i can wire the Encoder to the driver and also to my machine for spindle speed detection and index pin (i hope that works).

Sag ich Dir nich

unread,
Apr 23, 2017, 7:35:57 AM4/23/17
to Machinekit
i noticed now, that when i command m4 and then m5, the dir pin changes also, which it should not. It does not change when i command m3 and then m5


Am Sonntag, 23. April 2017 10:59:59 UTC+2 schrieb Schooner:

schoo...@btinternet.com

unread,
Apr 23, 2017, 8:20:46 AM4/23/17
to machi...@googlegroups.com

On 23/04/17 12:35, Sag ich Dir nich wrote:
i noticed now, that when i command m4 and then m5, the dir pin changes also, which it should not. It does not change when i command m3 and then m5

That may be reverting to default state.

Mine has to latch the relay to engage M4, but M3 is its 'resting state'.

Same for dir, there will be a default, exactly what depends upon whether you are using the pin value or its inverted value, that corresponds
to one dir or the other when it is powered off.

Sag ich Dir nich

unread,
Apr 23, 2017, 12:00:58 PM4/23/17
to Machinekit
so you mean that it is not possible? If thats the case, then i have to manually cut threads until it is possible :) 

thats probably something that has to be changed in linuxcnc/machinekit (that, in case of a stepgen velocity spindle config, the direction pin only changes state after ramping down to 0 rpm and then changing state.)

schoo...@btinternet.com

unread,
Apr 24, 2017, 2:16:41 AM4/24/17
to machi...@googlegroups.com

Unfortunately there are replies in this thread which are not in sync and don't include other replies.

Now that I realise you are attempting rigid tapping on a mill, not wanting to reverse direction for some inexplicable reason on a lathe, it becomes clearer.


You need a quadrature encoder and use G33.1

http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Rigid_Tapping

Sag ich Dir nich

unread,
Apr 24, 2017, 4:27:55 PM4/24/17
to Machinekit
okay i have a working eQEP encoder config with index signal for showing real rpm in pyvcp but does it need to be connected to the stepgen in any way? Atm it is configured so:

Because i dont have the tarocco servo driver yet, i use a stepper motor for testing (originally from the z axis) but the spindle servo motor with the encoder is also wired to the machine. If i start a program machinekit starts up the spindle (stepper motor), rapids to the first xy position and then waits for the near component to output high (means if i manually spin the spindle at the correct speed, the "spindle-at-speed" pin goes high and the machine continues to execute the gcode). But what bites me is, as soon as the spindle at speed pin goes high, the machine continues to execute the gcode but if i stop spinning the spindle (and the spindle at speed pin goes low) the machine does not stop motion, it would be nice if it would also stop motion when the spindle-at-speed pin is low. 

i have uploaded my hal file (eQEP encoder config is on the top at "Spindle" under "Buttons" and the Stepgen Spindle is down the B axis "Step/Dir SPINDEL")
CRAMPS.hal

schoo...@btinternet.com

unread,
Apr 25, 2017, 6:38:18 AM4/25/17
to machi...@googlegroups.com

On 24/04/17 21:27, Sag ich Dir nich wrote:
okay i have a working eQEP encoder config with index signal for showing real rpm in pyvcp but does it need to be connected to the stepgen in any way? Atm it is configured so:

I don't know anything about the eQEP

You need to have phase-Z, phase-A and phase-B connected to do rigid tapping

For threading on a lathe you can just use phase-Z and phase-A, since it always rotates in the same direction.


Because i dont have the tarocco servo driver yet, i use a stepper motor for testing (originally from the z axis) but the spindle servo motor with the encoder is also wired to the machine. If i start a program machinekit starts up the spindle (stepper motor), rapids to the first xy position and then waits for the near component to output high (means if i manually spin the spindle at the correct speed, the "spindle-at-speed" pin goes high and the machine continues to execute the gcode). But what bites me is, as soon as the spindle at speed pin goes high, the machine continues to execute the gcode but if i stop spinning the spindle (and the spindle at speed pin goes low) the machine does not stop motion, it would be nice if it would also stop motion when the spindle-at-speed pin is low.

The whole 'spindle-at-speed' thing is a pain, even on a lathe.
Unless you have a heavy spindle with high inertia and a precisely tuned motor, you are best just ignoring it, it is more trouble than it is worth.

Why you would want it at all on a mill, I don't know.
Reply all
Reply to author
Forward
0 new messages