# hostmot2 encoder details

05 Apr 2021 20:03 #204948 by lrak
I'm not feeling confident that I understand the details of counter mode from the man page which says:

Set to False (the default) for Quadrature. Set to True for Step/Dir (in which case Step is on the A pin and Dir is on the B pin).

One can understand quadrature to be the same as step/dir for the most part - we get the same number of counts - up-and down. (The other phase will correctly set direction). I think there are other things that change with this setting?

05 Apr 2021 20:30 - 05 Apr 2021 20:30 #204956 by PCW
Replied by PCW on topic hostmot2 encoder details
Counter mode 0 is quadrature and uses A and B signals shifted
by 90 degrees. Almost all encoders work this way. Quadrature
has the advantage that every edge is counted and the count rate is
4X the actual frequency of the A,B signals.

Counter mode 1 is step/dir or up/down counter mode where
every rising edge of A is counted, and the direction of the count
depends on the state of the B input at the A rising edge.
Last edit: 05 Apr 2021 20:30 by PCW.
The following user(s) said Thank You: lrak

05 Apr 2021 20:35 - 05 Apr 2021 20:36 #204960
Replied by tommylight on topic hostmot2 encoder details
Step dir signals on the left, CV/CCV signals on the right:

##### Attachments:
Last edit: 05 Apr 2021 20:36 by tommylight.
The following user(s) said Thank You: lrak

05 Apr 2021 22:54 - 05 Apr 2021 22:55 #204980 by lrak
Replied by lrak on topic hostmot2 encoder details
It is not the above that confused me - it seems something else get changed at the same time? - Is it the way index works?

If I set counter mode true - count increases as the spindle rotates - if I set if false - count no longer increments (along with position and raw counts ). I would expect that even in quadrature mode it would increment? I'm missing something?

The input is actually quadrature - and if one phase is connected to direction (seen as a level ) - the other phase as step (edge) - it works as step-and-direction, but it seems it should also work as quadrature as it is quadrature? What am I missing?

,.,
I also see that encoder outputs both 'velocity' and velocity-rpm .. which is heads to the PID - then to ABS - then to frequency-input of the VFD . The output of the encoder can be scaled - but motion's spindle.0.speed-out is always in RPM. The PID should correct (via P) for what ever unit is used to jump it up to inverter frequency - but that might be sub optimal?

I can fix the vfd component so it has a scale input?
Last edit: 05 Apr 2021 22:55 by lrak. Reason: clarity

05 Apr 2021 23:01 #204982 by PCW
Replied by PCW on topic hostmot2 encoder details
Sounds like something wrong with the 'B' input

You might want to 'halscope' the encoder input 'A'
and encoder input 'B' while turning the spindle
slowly to see if you truly have quadrature
The following user(s) said Thank You: lrak

06 Apr 2021 00:44 #205010 by lrak
Replied by lrak on topic hostmot2 encoder details
@PCW - I had just finished looking at A and B on the HAL-scope when I saw your post -- that seems to be what it is.

Looks like I don't quite have proper quadrature! - It is as if B is inverted -- but it looks different if I reverse the spindle - this might be from some of the fancy foot work of the detector chip (ATS667LSG) or the cut of the gear - not a perfect 50% duty cycle - just enough variation in the chips? I was quite careful in tweaking the spacing. I suppose these chips are mostly used for unidirectional sensing. (I thought had this working when I tested with a portable O-scope (that lacked storage - duh)).

According to the M19 docs:

Spindle orientation requires a quadrature encoder with an index to sense the spindle shaft position and direction of rotation.

Not a huge loss - wonder if M19 would sort-of-work in counter-mode if I set Sxx to something very slow? (I'm counting my blessings that it works at all!)..

I wanted to use a magnetic disk and pickup with a quad output - just couldn't come up with good way to mount it.