Test index of rotary encoder with hal only

More
09 Oct 2019 15:01 #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
09 Oct 2019 15:51 #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...
Attachments:

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

More
13 Oct 2019 08:15 - 13 Oct 2019 08:46 #147798 by JC10
Trying many things I figured out that the records were identical rotating or not the shaft of the rotary encoder...

So definitely the code working on the paper does not work. I suspect that HAL does not like to have an io pin read and written in a same cycle.

So I decided to find a workaround and found one by reading the hal manual about encoder.

I looked for a consequence of the index being triggered to rearm index-enable a bit later.

I found that counts were set to 0 when index triggered. (Makes sense because that is a purpose of an index in case of homing) and used it as follow :


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=500000

loadrt wcomp
loadrt not
loadrt conv_s32_float
loadrt tristate_bit
loadrt updown

addf hm2_7i92.0.read servo-thread
addf conv-s32-float.0 servo-thread
addf wcomp.0 servo-thread
addf not.0 servo-thread
addf tristate-bit.0 servo-thread
addf updown.0 servo-thread
addf hm2_7i92.0.write servo-thread

setp tristate-bit.0.in 1
setp wcomp.0.min -100
setp wcomp.0.max  100

net s32_count hm2_7i92.0.encoder.00.count conv-s32-float.0.in
net count conv-s32-float.0.out wcomp.0.in
net in_min_max wcomp.0.out not.0.in
net reset not.0.out tristate-bit.0.enable
net enable tristate-bit.0.out hm2_7i92.0.encoder.00.index-enable updown.0.countup 

start

loadusr halscope
loadusr halmeter

And the plot in attachment.

Thanks to PCW that put me on track.
Attachments:
Last edit: 13 Oct 2019 08:46 by JC10.

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

Moderators: PCWjmelson
Time to create page: 0.095 seconds
Powered by Kunena Forum