New quadrature encoder, index questions

More
31 Aug 2015 21:46 - 31 Aug 2015 22:11 #61941 by tome
I want to do rigid tapping on the EMCO 120P lathe. It had a single channel plus index encoder which didn't work due to not knowing exactly when the spindle reversed. I replaced the encoder with a US Digital quadrature 1024ppr optical disk encoder. When I connected a scope to the pins and applied power I could see the three channels (A,B and Index) and they seemed to be clear and aligned as they should. I then wired the encoder to my Mesa 5i25/7i85s card and thought I'd rigid tap some air. The tap moves in, the spindle reverses, and just sits there for many (10-12) revolutions and then backs out. It is as if it isn't seeing the index pulse in order to back up the second the spindle reverses.

I ran Show Hal Configuration and try to watch hm2_5i25.0.encoder.00.input-index but never see it turn yellow as I turn the spindle by hand. hm2_...input-a and input-b flash yellow as I turn the spindle, so I assumed that input-index would as well. Should it? I then ran Halscope to watch these pins (plot below). Is this how it should look or is the index only appearing once in a while? Not sure what is going on. Is my config correct for wiring the encoder/spindle together? My .hal file is here: pastebin.ca/3145477 and custom.hal is here: pastebin.ca/3145518 and .ini here: pastebin.ca/3145480

Attachments:
Last edit: 31 Aug 2015 22:11 by tome.

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

More
31 Aug 2015 22:28 - 31 Aug 2015 22:30 #61942 by PCW
That is all expected since with a high resolution encoder, the index signal itself may be much shorter
than the servo thread time. This means you will only seldom see it on halscope if your spindle speed is not very slow.

The way to check index operation is to "sets" the signal that carries the spindle index enable "true",
then hand rotate the spindle to see if this signal is cleared at the index position

Most commonly when spindle synchronized operations don't work its something wrong in the hal file
usually something wrong with these motion pins:

motion.spindle-revs

motion.spindle-index-enable

motion.spindle-at-speed

(man motion)
Last edit: 31 Aug 2015 22:30 by PCW.

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

More
31 Aug 2015 22:40 #61943 by tome
Thanks Peter. I see that index-enable is being reset at the index pulse so that must be working.

I also see that I have a bunch of cruft in my config from when we were trying to get the single channel encoder working. I removed that and tried to put the original config back but must have one of the signals you refer to wrong. Now my tapping operation just sits infinitely after the spindle starts and tool moves to position probably waiting on one of those...

The new .hal file is here: pastebin.ca/3145549

-Tom

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

More
31 Aug 2015 23:04 #61946 by tome
I think it is spindle-at-speed that is my problem. The conflict I am running into is that in the custom.hal file for the vfd I have this line:

# connect the GS2 at speed to the motion at speed
net gs2-at-speed motion.spindle-at-speed <= spindle-vfd.at-speed

That conflicts with this section of the hal file below (because motion.spindle-at-speed is already defined):

# connect one input to the commanded spindle speed
net spindle-cmd => near.0.in1
# connect one input to the encoder-measured spindle speed
net spindle-velocity => near.0.in2
# connect the output to the spindle-at-speed input
net spindle-at-speed motion.spindle-at-speed <= near.0.out
# set the spindle speed inputs to agree if within 1%
setp near.0.scale 1.01


Also, I think "spindle-cmd" should be something else in my config, like spindle-vel-cmd-rps , or spindle-vel-cmd-rpm, or spindle-vel-cmd-rps-abs, or spindle-vel-cmd-rpm-abs?

And should "spindle-velocity" above should be replaced with spindle-vel-fb?

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

More
01 Sep 2015 08:06 - 01 Sep 2015 08:06 #61965 by tome
For those following along at home :) ... I had a couple issues. I needed to invert the spindle encoder scale (make it negative) and also needed to account for the difference between the spindle motor pulley and the pulley on the head. This was causing the spindle to never get to the commanded speed and so spindle-at-speed never became true.

To invert the spindle encoder scale (in my main .ini file):
#********************
# Spindle
#********************
[SPINDLE_9]
ENCODER_SCALE = -4096

In my main .hal file:

setp hm2_5i25.0.encoder.00.counter-mode 0
setp hm2_5i25.0.encoder.00.filter 1
setp hm2_5i25.0.encoder.00.index-invert 0
setp hm2_5i25.0.encoder.00.index-mask 0
setp hm2_5i25.0.encoder.00.index-mask-invert 0
setp hm2_5i25.0.encoder.00.scale [SPINDLE_9]ENCODER_SCALE

net spindle-revs hm2_5i25.0.encoder.00.position motion.spindle-revs
net spindle-vel-fb-rps hm2_5i25.0.encoder.00.velocity motion.spindle-speed-in
net spindle-index-enable hm2_5i25.0.encoder.00.index-enable motion.spindle-index-enable

#Convert the spindle velocity (in RPS) signal to RPM and filter it so it isn't so variable. This is
#only to feed the spindle RPM display in my Glade side panel
setp scale.0.gain 60
setp lowpass.0.gain 0.01
net spindle-vel-fb-rps => scale.0.in
net spindle-fb-rpm scale.0.out => abs.0.in
net spindle-fb-rpm-abs abs.0.out => lowpass.0.in
net spindle-fb-rpm-abs-filtered lowpass.0.out


In custom.hal:

# connect the GS2 at speed to the motion at speed
net gs2-at-speed motion.spindle-at-speed <= spindle-vfd.at-speed

# connect the spindle RPM to the GS2
# scale pulley ratio on spindle
setp scale.1.gain 1.154
net commanded-speed scale.1.in motion.spindle-speed-out
net gs2-RPM spindle-vfd.speed-command scale.1.out


In custom_postgui.hal:

# RPM Meter in Glade panel is fed by filtered encoder velocity signal
setp gladevcp.hal_table4 1
net spindle-fb-rpm-abs-filtered gladevcp.hal_meter1
Last edit: 01 Sep 2015 08:06 by tome.

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

More
13 Jun 2020 10:12 #171394 by zz912
I bought an encoder for playing and learning. I was interested in the sentence:

The way to check index operation is to "sets" the signal that carries the spindle index enable "true",


Is possible set encoder.00.index-enable true only in HAL?

I tried it:
net signal-index-enable <= hm2_7i96.0.gpio.001.in
net signal-index-enable => hm2_7i96.0.encoder.00.index-enable
but it didn't work because the pin is an I/O

(bit in/out) index-enable
When this pin is set to True, the count (and therefore also
position) are reset to zero on the next Index (Phase-Z) pulse.
At the same time, index-enable is reset to zero to indicate that
the pulse has occurred.



The second thing that intrigued me was that hostmot2 negates the input index, but input-a and input-b are normal. See oscilloscope image.
Should I deal with this? I can fix it:
setp hm2_7i96.0.encoder.00.index-invert 1
Then it works the same as tome users.
Attachments:

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

More
13 Jun 2020 14:18 #171456 by PCW
All inputs are handled the same ( but all of our TTL interfaces invert A,B,I )

Note that inverting the index is usually a no-op since its edge detected
and changing the polarity will just change the active edge

If you want to set the index from a "out" pin, you can use the "tristate_bit" component

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

Time to create page: 0.237 seconds
Powered by Kunena Forum