Test index of rotary encoder with hal only

More
7 years 3 weeks ago - 7 years 3 weeks ago #147471 by PCW
I could be a thread order issue (the hm2_card.0.write should always be the last thing done)

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)
Last edit: 7 years 3 weeks ago by PCW.

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

More
7 years 3 weeks ago - 7 years 3 weeks ago #147557 by JC10
Yes, hm2_7i92.0.write needs to be located in last position.
I removed the toggle to focus on the signal reset.

Here is the HAL corrected I ran including your code :
Code:
loadrt hostmot2 loadrt hm2_eth board_ip="10.10.10.10" config=" num_encoders=1 num_pwmgens=0 num_stepgens=0 sserial_port_0=0000xx" loadrt threads name1=servo-thread period1=1000000 loadrt not loadrt tristate_bit addf hm2_7i92.0.read servo-thread addf not.0 servo-thread addf tristate-bit.0 servo-thread setp tristate-bit.0.in 1 addf hm2_7i92.0.write servo-thread net enable hm2_7i92.0.encoder.00.index-enable tristate-bit.0.out not.0.in net reset not.0.out tristate-bit.0.enable

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 :(
Code:
First cycle index-enable = 0 not.0.in = 0 not.0.out = 1 tristate-bit.0.in = 1 tristate-bit.0.enable = 1 tristate-bit.0.out = 1 enable-index = 1 Cycles where 7i92 did not detect index index-enable = 1 not.0.in = 1 not.0.out = 0 tristate-bit.0.in = 1 tristate-bit.0.enable = 0 tristate-bit.0.out = 1 enable-index = 1 Cycle following 7i92 detected index (exactly identical to First cycle) index-enable = 0 not.0.in = 0 not.0.out = 1 tristate-bit.0.in = 1 tristate-bit.0.enable = 1 tristate-bit.0.out = 1 enable-index = 1
Last edit: 7 years 3 weeks ago by JC10. Reason: Typo

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

More
7 years 3 weeks ago #147561 by PCW
The middle plot looks as expected, what do you see thats wrong?
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 or Create an account to join the conversation.

More
7 years 3 weeks ago - 7 years 3 weeks ago #147564 by JC10

PCW wrote: The middle plot looks as expected, what do you see thats wrong?

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 "reset" signal will be set for one servo thread period every detected index

When I rotate the shaft, I only rotate in the same direction.
Last edit: 7 years 3 weeks ago by JC10.

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

More
7 years 3 weeks ago #147568 by PCW
Yes, maybe there some unexpected feedback/latchup issue because of the delays
You might play a bit with the thread order or might need a oneshot component for reset

Plotting hm2_7i92.0.encoder.00.index-enable would probably give some
better insight into whats happening

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

More
7 years 3 weeks ago #147570 by JC10
Here you go, records #1a and #2a taken in the same conditions.

On both records, we can observe that index-enable is well set to 1 from the beginning of the record.

I assume it can not be observed going to 0 because of the hal code where : before running the code it is 0 but after running the code it is 1.

I assume that halscope gathers the shown data at the end of each cycle.

index-enable is almost always set to 1 so the signal "reset" should be 0 almost aways but it is 1 that i don't understand...

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

Moderators: PCW, jmelson
Time to create page: 0.071 seconds
Powered by Kunena Forum