- Posts: 45
- Thank you received: 0
Test index of rotary encoder with hal only
I am trying to test the index of a suspicious rotary encoder.
My idea is to use the pulse of the index as input of a HAL toggle and observe its output.
Any time the index pulses, the toggle output should change.
Underr halcmd, I load and start the following :
Then I do : halcmd :sets index-enable true thats sets hm2_7i92.0.encoder.00.index-enable to true.
Then rotate the shaft of the encoder to observe that hm2_7i92.0.encoder.00.index-enable comes false after some degrees of rotation and that no pulse occurs on the toggle.
That is the behavior observed in many posts of PCW or in John Thorton's Servo Tuning Tutorials/Encoders. Behavior I experienced running Linuxcnc.
I thought by using minimal HAL only and not launching linuxcnc that this behavior would not have existed.
Is there a way to manage to get my idea working ?
Thanks for help.
Please Log in to join the conversation.
Please Log in to join the conversation.
If you want to toggle a pin on index you need to use index enable, something like this:
loadrt not
loadrt tristate-bit
addf not.0 servo-thread
addf tristate-bit.0 servo-thread
setp tristate-bit.0.in 1
net enable hm2_somecard.0.encoder.00.index-enable tristate-bit.0.out not.0.in
net reset not.0.out tristate-bit.0.enable
The "reset" signal will be set for one servo thread period every detected index
Please Log in to join the conversation.
If I understand well, the 7i92 will always see the index and when it is observed, the 7i92 will reset the index-enable to 0.
With your code, if, in a given servo-thread, index-enable is observed as 0, it will be set to 1 in the next servo-thread by « reset « (you defined here above). So in all servo-threads except one, index-enable will be set to 1.
Therefore, I should be able to toggle on « reset ». Is this right ?
Please Log in to join the conversation.
Please Log in to join the conversation.
With halmeter, I observe that index-enabled is always set true so the code works.
But apparently toggle.0.out always stays false.
I also adjusted toggle.0.debounce to 0 but no success.
However I am apparently successful when I applied John Thorton tutorial : gnipsel.com/linuxcnc/tuning/encoder.html
or the same from many of your posts like here : forum.linuxcnc.org/10-advanced-configura...oder-index-questions
PCW wrote:
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
Is my toggle code incorrect ?
Is any of the pins provided by 7i92 on an encoder also related to the index apart index itself and index-enable ?
Thanks
Please Log in to join the conversation.
It also could be that toggle cannot count a single servo period long signal
I would first fix the thread order and then halscope the reset signal
if reset is ok then maybe the flip-flop component would be a better choice (than toggle)
Please Log in to join the conversation.
I removed the toggle to focus on the signal reset.
Here is the HAL corrected I ran including your code :
The "reset" signal observations with halscope show unexpected behavior.
I used halscope in Run mode : single and Trigger : normal + force.
I made a first record #1 where we observe that "reset" is raised to 1 but is not set back 0 after one cycle as expected.
Then I made a second record #2 where "reset" remains at 1 except when set back to 0 periodically for one cycle, I guess when the index is detected by 7i92 as i am rotating the rotary shaft.
I checked the code as follow and for me it should work, except some unexpected behavior on index-enable that is input and output for 7i92 or something else I ignored
Please Log in to join the conversation.
I think that there is possibility of missing indexes on reversals
(with less than a few servo periods between indexes)
but this is not an issue with normal index use
Please Log in to join the conversation.
For me it looks inverted compared to what we expect according to what I determined by running your code on paper as in my previous post and especially according to your post here above :PCW wrote: The middle plot looks as expected, what do you see thats wrong?
When I rotate the shaft, I only rotate in the same direction.PCW wrote: The "reset" signal will be set for one servo thread period every detected index
Please Log in to join the conversation.
