method for resting a stepgen position to zero?

More
28 May 2013 03:14 #34789 by garymcrobertpdx
Been trying to find a way to seting the position of a stepgen to zero

one way would be to unlink the output then use a position-cmd to zero
then reconnect it. Not a very elegant solution

Is there a better way?

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

More
28 May 2013 08:13 #34806 by andypugh

Been trying to find a way to seting the position of a stepgen to zero


It might help if you explained why. LinuxCNC never needs to. (it isn't that there is a special secret reset)

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

More
29 May 2013 03:43 #34872 by garymcrobertpdx
The goal is to reliably position the spindle for a tool change.
The 5i25 & 7i76 board combo provides ten stepgens in this case
spindle step/dir & encoder is provided Via the 7i76 TB3 stepgen.04

I have explored several possible methods to achieve orienting the
spindle.

The best idea I have so far works like this:
Use a M100 type G code containing an executable written with C and
Hal commands.

Set stepgen.04.control-type to FALSE (position control mode)
Read the stepgen.04.counts Sum this with a constant which equates to
2 turns of the spindel. Set the encoder.00.latch-enable to TRUE.
Read stepgen.04.maxval and save it to a temp var.
write stepgen.04.maxval a constant which equates to 60 RPM
Write to stepgen.04.position-cmd the new postion sum.

On encoder.00.latch-enable FALSE Read the stepgen.04.counts Sum this
with a constant (relative to the index) tool change position for the spindle.
rewrite to stepgen.04.position-cmd the new position sum.

Hopefully the spindle stops at the desired tool change position

write stepgen.04.maxvel temp var
Set stepgen.04.control-type to TRUE (velocity control mode)
Exit

In Hal Configuration I have manually tested changing the stepgen.04.control-type,
stepgen.04.maxvel and imputing positions to stepgen.04.position-cmd and the
encoder.00.index-enable which is bi directional pin connected to a signal.
In order to test had to unlink it.

I am uncertain how to deal with bi directional pins and signals in Hal
and if there is a way to mux the encoder.00.index-enable pin so runtime
unlinking and re netting would be unnecessary.

Despite it's appearance This seem the cleanest way to do it.
Unfortunately I have no experience building a M100 executable and
combining C with Hal commands I am assuming this can be done.

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

More
29 May 2013 04:38 - 29 May 2013 04:40 #34873 by BigJohnT
I thought there was a spindle orient component in master?

Edit: yep here it is.

JT
Last edit: 29 May 2013 04:40 by BigJohnT.

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

More
29 May 2013 05:00 #34877 by andypugh

here


And there is no need for an M100, use the already-existing (but well hidden) M19

www.linuxcnc.org/docs/devel/html/gcode/m-code.html#sec:M19

Basically you need to connect the moton.spindle-orient pin to some HAL logic that instead of connecting the spindle speed command to the normal motion.spindle-speed-out instead connect is to a PID that closes a position loop.

There is a terse usage example on there.

However, I don't entirely understand your "stepgen" requirements. Is this is stepper-driven spindle, or a step-servo system, or neither?

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

More
29 May 2013 09:45 #34890 by garymcrobertpdx
Excellent ! I assume that a multiplexor is used such that

When Then when motion.spindle-orient = TRUE connect pins
orient.0.comand to stepgen.04.velocity-cmd.

When Then when motion.spindle-orient = FALSE connect pins
spindel-vel-cmd-rps to stepgen.04.velocity-cmd.

Is this correct?

The spindle is a self contained DC servo drive which accepts
step & dir like a step motor.

Thanks again guys

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

More
29 May 2013 10:22 #34891 by garymcrobertpdx
Here is my custom Hal code making use of orient.
There must be error some where since it fails to function.

loadrt mux2 count=1
loadrt orient count=1

addf orient.0 servo-thread
addf mux2.0 servo-thread

unlinkp hm2_5i25.0.stepgen.04.velocity-cmd
net orient-sig-out orient.0.command => mux2.0.in1
net spindle-vel-cmd-rps => mux2.0.in0
net mux2-select-sig motion.spindle-orient => mux2.0.sel => orient.0.enable
net mux2-output-sig mux2.0.out => hm2_5i25.0.stepgen.04.velocity-cmd

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

More
29 May 2013 16:29 #34902 by andypugh

There must be error some where since it fails to function.

net orient-sig-out orient.0.command => mux2.0.in1


You need a PID component too, to turn it into a controller.
(You also need to be running Master, or M19 doesn't exist).

If you look at the orient manpage the example loads a pid controller and calls it orient-pid

You will also need to tune that PID to work properly. (setp orient-pid.Pgain 1 might be at least a starting point)

While you are doing that you might want to consider running the spindle closed-loop on velocity too. (loadrt pid names=orient-pid, speed-pid maybe)

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

More
30 May 2013 02:05 #34922 by garymcrobertpdx
I missed seeing the pid part.

I have muddled my way through the coding of the ORIENT and it WORKS!!!!!

How ever the doc example has some flaws

The example [net spindle-pos ...encoder..position orient.position orient-pid.position] is confusing

The Pin [orient-pid.position] dose not exist, actually it should be [orient-pid.feedback]

My line of code ended up like this [net spindle-revs orient.position orient-pid.feedback]

Other wise the between the Docs and the man pages I made it through the process.

Again thanks for the helping hand

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

More
30 May 2013 02:54 #34923 by BigJohnT

How ever the doc example has some flaws
The example [net spindle-pos ...encoder..position orient.position orient-pid.position] is confusing
The Pin [orient-pid.position] dose not exist, actually it should be [orient-pid.feedback]
My line of code ended up like this [net spindle-revs orient.position orient-pid.feedback]


Thanks for reporting the error in the man page, I have fixed it.

JT

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

Time to create page: 0.727 seconds
Powered by Kunena Forum