Test index of rotary encoder with hal only

More
7 years 2 weeks ago - 7 years 2 weeks ago #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 :

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=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.
Last edit: 7 years 2 weeks ago by JC10.

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

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