- Posts: 101
- Thank you received: 11
New quadrature encoder, index questions
- tome
- Topic Author
- Offline
- Premium Member
-
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
Please Log in or Create an account to join the conversation.
- PCW
- Offline
- Moderator
-
- Posts: 17533
- Thank you received: 5334
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)
Please Log in or Create an account to join the conversation.
- tome
- Topic Author
- Offline
- Premium Member
-
- Posts: 101
- Thank you received: 11
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.
- tome
- Topic Author
- Offline
- Premium Member
-
- Posts: 101
- Thank you received: 11
# 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.
- tome
- Topic Author
- Offline
- Premium Member
-
- Posts: 101
- Thank you received: 11
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
Please Log in or Create an account to join the conversation.
- zz912
- Offline
- Platinum Member
-
- Posts: 596
- Thank you received: 98
PCW wrote: 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:
[hr](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.
Please Log in or Create an account to join the conversation.
- PCW
- Offline
- Moderator
-
- Posts: 17533
- Thank you received: 5334
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.