Reset eCAP value when the input signal off
Show older comments
I am using the C2000 extension on MATLAB 2018b.
I've configured the eCAP block to read the duty cycle of a PWM.
To do so, i divide the 2 outputs generated by the block. For example, with a duty cycle of 0.2 the outputs are 200 and 1000.
The problem is that when you turn off the signal generator, the value obtained by this is the same as the last one.
In the attached image, it can be seen the next cycle: Off --> 0.2 --> 0.5 --> 0.8 --> Off --> 0.8 --> 50
Whenever the generator is working there is noise in the signal, but when it is off, the signal holds the last value and has no noise.
How can I reset the value when it is off?
Thank you!
Accepted Answer
More Answers (3)
Antonin
on 1 Mar 2019
0 votes
Hi Eduard,
Interesting question. The capture module can only give you time that elapsed between edges. If your PWM reaches 0% or 100%, the eCAP module will not update.
I would read the eCAP counter and detect when it goes beyond the maximum PWM period, in which case I would invalidate the readings from the eCAP registers. You can do this with the Memory Copy block (cf snapshot attached), the address of the register you need to access is: &ECap1Regs.TSCTR to read the time value.
To make the difference between 0 and 100%, you could enable the status flag on the eCAP block and keep track of which of the 2 events came last. Alternatively, you could also use the Memory Copy block and read the GPIO data register to detect whether the eCAP pin is high or low.
The eCAP block is always best used in an interrupt like in the c28069pmsmfoc_ert example to make sure that you are not missing events. I would also react on the overflow of the eCAP counter to make sure that you don't get bogus results if the signal stays flat for too much time.
I hope it helps,
Good luck

Antonin.
1 Comment
Eduard Monlleo
on 1 Mar 2019
Mohsin Ejaz Ahmad
on 23 May 2019
0 votes
Hello all,
I am also trying to use eCAP module to read the PWM signal but in my case the eCAP is not giving any output. Please help me in this regard. May be I have some issue in the "model configuration parameters" but I am extending the simulink block of one of the LIN example present in the libarary for F28035 controller. I have uploaded the whole figure.
Regards,
Mohsin Ejaz Ahmad

Venkatesh Chilapur
on 23 May 2019
0 votes
Hi,
Please refer this example 'c28035pmsmfoc_ert' we have eCAP block implemention under 'c28035pmsmfoc_ert/Hall Sensor A'.
Regards,
Venkatesh C
Categories
Find more on Texas Instruments C2000 Processors in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
