> Am 15.07.2016 um 10:11 schrieb Simon Jones <[email protected]>:
> 
> 
> 
> On Sunday, 10 July 2016 20:41:01 UTC+1, Marius Alksnys wrote:
> Should this feature work? If so - what special thing should I 
>  know? Encoder works right except for index. Where should index 
>  pin be connected? I connected it to eQEP index pin. 
> 
> 
> ----Android NewsGroup Reader---- 
> http://usenet.sinaapp.com/ 
> 
> 
> I hit the same problem. I'm running with kernel:
> 
> simonj@beaglebone:~$ uname -a
> 
> Linux beaglebone 3.8.13-xenomai-r78 #1 Sat Sep 26 17:07:01 UTC 2015 armv7l 
> GNU/Linux
> 
> The cause is a clash with the active kernel QEP driver. The HAL driver relies 
> on seeing the IEL index event latch interrupt flag but the kernel driver 
> interrupt handler clears this. Depending on timing, it occasionally works, 
> with a 100us update thread, the HAL driver detected the index pulse about one 
> in ten times.
> 
> I guess the cleanest solution would be to disable the kernel QEP driver but I 
> couldn't see an easy way to do this, and I'm not set up to rebuild the kernel 
> at the moment, so I did a quick and dirty hack to the HAL driver:


here is an easy way: try 'unbind': 
https://xenomai.org/pipermail/xenomai/2015-March/033707.html


> 
> diff --git a/src/hal/drivers/hal_arm335xQEP.c 
> b/src/hal/drivers/hal_arm335xQEP.c
> 
> index 39a9e67..7cebd61 100644
> 
> --- a/src/hal/drivers/hal_arm335xQEP.c
> 
> +++ b/src/hal/drivers/hal_arm335xQEP.c
> 
> @@ -211,9 +211,19 @@ static void update(void *arg, long period)
> 
>          eqep->raw_count = eqep->eqep_reg->QPOSCNT;
> 
>          iflg = eqep->eqep_reg->QFLG & EQEP_INTERRUPT_MASK;
> 
>  
> -        /* check if an index event has occured */
> 
> -        if( *(eqep->index_ena) && (iflg & IEL)) {
> 
> -            eqep->index_count = eqep->eqep_reg->QPOSILAT;
> 
> +        // See if the latched position has changed, indicating that an index
> 
> +        // event has happened. Can't rely on interrupt flags because kernel
> 
> +        // driver captures and clears it
> 
> +        hal_s32_t latched_count =  eqep->eqep_reg->QPOSILAT;
> 
> +        hal_bit_t index_flag    = 0;
> 
> +        if (eqep->old_latched_count != latched_count)
> 
> +        {
> 
> +            index_flag                  = 1;
> 
> +            eqep->old_latched_count     = latched_count;
> 
> +        }
> 
> +        if( *(eqep->index_ena) && index_flag) {
> 
> +            rtapi_print("QEP index triggered %d %d\n",eqep->index_count, 
> latched_count);
> 
> +            eqep->index_count = latched_count;
> 
>              *(eqep->index_ena) = 0;
> 
>          }
> 
>  
> @@ -436,6 +446,8 @@ static int setup_eQEP(eqep_t *eqep)
> 
>      eqep->eqep_reg->QCAPCTL = 0u; // reset to prevent prescaler problems
> 
>      eqep->eqep_reg->QCAPCTL |= CEN; // enable eQEP capture
> 
>  
> +    eqep->old_latched_count = eqep->eqep_reg->QPOSILAT;
> 
> +
> 
>      rtapi_print("%s: REVID = %#x\n",modname, eqep->eqep_reg->QREVID);
> 
>      return 0;
> 
>  }
> 
> diff --git a/src/hal/drivers/hal_arm335xQEP.h 
> b/src/hal/drivers/hal_arm335xQEP.h
> 
> index 8341d57..e727e15 100644
> 
> --- a/src/hal/drivers/hal_arm335xQEP.h
> 
> +++ b/src/hal/drivers/hal_arm335xQEP.h
> 
> @@ -100,6 +100,7 @@ typedef struct {
> 
>      hal_s32_t       raw_count;
> 
>      hal_u32_t       timestamp;
> 
>      hal_s32_t       index_count;
> 
> +    hal_s32_t       old_latched_count;
> 
>      hal_s32_t       counts_since_timeout;
> 
>  
>      hal_bit_t       *index_ena;
> 
> 
> 
> 
> 
> 
> 
> This seems to work, but corner cases not really tested or even thought about.
> 
> 
> 
> 
> 
> Simon
> 
> 
> -- 
> website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
> https://github.com/machinekit
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Machinekit" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> Visit this group at https://groups.google.com/group/machinekit.
> For more options, visit https://groups.google.com/d/optout.

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to