Am 15.12.2014 um 17:36 schrieb Russell Gower:
>> I would like to be able to operate the eQEP in counter mode (Phase
>> A = clock, Phase B = direction). As far as I understand the code,
>> this would mean to change line 333 of hal_arm335xQEP.c to:
>> eqep->eqep_reg->QDECCTL = QAP | QBP | QIP | QSRC0
>>> Can you confirm that? If that is true, there could be an
>>> additional hal pin similar to the linuxcnc encoder hal-pin
>>> "encoder.N.counter-mode bit rw". Karl
>>>
> Hi, Yes i believe that is the case, I didn’t implement this
> originally because I didn’t have that sort of encoder to test with,
> but thinking about it I could have just used two push buttons, also
> the 3 polarity bits should also be added as hal pins.
>
> I’m currently in the process of building my control enclosure, so it
> will be a few days before I can fire up the BBB again to look at
> this.
>
> Regards Russell
Hi Russel,
studying your code I stumbled over the code for the index event:
/* check if an index event has occured */
if( *(eqep->index_ena) && (iflg & IEL)) {
eqep->index_count = eqep->eqep_reg->QPOSILAT;
}
in which you do not set index_ena to zero (this is connected to the HAL
pin index-enable). The code in teh software encoder in
hal/components/encoder.c does that:
/* handle index */
if ( buf->index_detected ) {
buf->index_detected = 0;
cntr->index_count = buf->index_count;
*(cntr->index_ena) = 0;
}
and I imagined it had to be reset because of what linuxcnc motion needs:
"motion.spindle-index-enable I/O BIT
For correct operation of spindle synchronized moves, this signal must be
hooked to the index-enable pin of the spindle encoder"
and linuxcnc encoder says: "encoder.N.index-enable bit i/o
When true, counts and position are reset to zero on the next rising edge
of Phase-Z. At the same time, index-enable is reset to zero to indicate
that the rising edge has occurred". I am guessing that motion sets it
back to 1 to catch the next index? Or does motion set it to 0 as well?
Then *(cntr->index_ena) = 0; would be superfluous of course, but then I
wonder why index-enable is a hal io and not just input.
Sorry if I am showing total ingorance here, but I did hook up the
standard linuxcnc software encoder that way and it works with correct
indexing (and it does not work without that net connection). I have not
yet tested your code yet, I have to admit.
Cheers,
Karl