Reset eCAP value when the input signal off
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Eduard Monlleo
il 27 Feb 2019
Risposto: Venkatesh Chilapur
il 23 Mag 2019
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!
0 Commenti
Risposta accettata
Antonin
il 1 Mar 2019
Hi Eduard,
It's surprising that the memory copy block returns the same value. Please double check the settings like data types and eCAP module. For eCAP module 2 you have to use &ECap2Regs.TSCTR instead of &ECap1Regs.TSCTR.
I use this exact technique in the following example: c28035pmsmfoc_ert
Under:
FOC Alogrithm/Torque Control Algorithm/Input Scaling/Speed and direction are valid/Extract Position from Halls/Direction 1/Hall B falling/ECap1Regs.TSCTR'
You can copy/paste the block from there.
It should work, good luck.
Antonin.
1 Commento
Antonin
il 1 Mar 2019
Sample time is important as well, make sure that it's not "Inf" on the memory copy block, in which case Simulink may optimize the block out of the step function and only rely on the init value.
Più risposte (3)
Antonin
il 1 Mar 2019
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.
Mohsin Ejaz Ahmad
il 23 Mag 2019
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
0 Commenti
Venkatesh Chilapur
il 23 Mag 2019
Hi,
Please refer this example 'c28035pmsmfoc_ert' we have eCAP block implemention under 'c28035pmsmfoc_ert/Hall Sensor A'.
Regards,
Venkatesh C
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!