Hi,
I have a design that requires 3 rotary encoders. The part I am using has 2 eQEP inputs which I can use but I need a 3'rd. Can I use the eCAP to read a third?
If so, are there any app notes for setup.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Yes, The ecap can be used as an encoder module. But the fundamental difference between the two is QEP gives the counts and ecap gives the timestamp. So if you wanted to use CAP as QEP then you need to implement a software counter. Give 1 encoder input (say A) to a capture pin and other(say B) to a GPIO. Whenever a capture interrupt comes increment/decrement the counter depending on the state of the GPIO.
Actually this is exactly what a QEP module does. We implemented this using a capture module and GPIO but in MSP430. I'm not sure whether there are any sample codes but you can always check the control suite.
Vivek
Thanks Vivek. this solution seem to be reasonable.
One thing about set up the ecap, I am trying to capture on both side (rising & falling edges) on channel A but I can only capture on rising edge.
Here's my init for ecap:
#define
ECCTL1_INIT_STATE ( CAP1POL_RISING_EDGE + \
CAP2POL_FALLING_EDGE + \
CAPLDEN_ENABLE + \
CTRRST1_DIFFERENCE_TS + \
CTRRST2_DIFFERENCE_TS + \
EVTFLTPS_X_1 + \
EMULATION_FREE )
#define
ECCTL2_INIT_STATE ( CONTINUOUS_MODE + \
TSCNTSTP_FREE + \
SYNCI_DISABLE + \
SYNCO_DISABLE + \
CAPTURE_MODE )
void
F280X_CAP3_Init(QEP*p)
{
ECap3Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap3Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
// Init ECAP Control Registers 1 and 2 for ECAP3
ECap3Regs.ECCTL1.all = ECCTL1_INIT_STATE;
ECap3Regs.ECCTL2.all = ECCTL2_INIT_STATE;
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap3Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap3Regs.ECEINT.bit.CEVT1 = 1; // 1 events = interrupt
ECap3Regs.ECEINT.bit.CEVT2 = 1; // 1 events = interrupt
}
Do you have any idea ?