How to modify an existing Simulink TI C2000 ePWM block?

14 visualizaciones (últimos 30 días)
Mike Buba
Mike Buba el 4 de Nov. de 2022
Respondida: Antonin el 17 de Oct. de 2023
I would like to change the ePWM up-down counting direction (PHSDIR) online on a synchronization signal and set the TBPHS parameter to the last TBCTR+1 value before synchronization. This apprach was suggested by TI support when I asked how to implement a different PWM algorithm.
Currently, in the ePWM block, a PHSDIR is hard-coded, i.e. I am not able to change direction (count-up or count-down) online and there is no TBCTR output.
#1
Is it possible, and how, to modify an existing Simulink TI C2000 ePWM block to get those two signals?
Thank you in advance.
Edit:
#2 (another approach)
After reading through a few more threads, one of the solutions could be using the Memory Copy block. The idea is to trigger the sequence to read ( from source):
EPwm1Regs.TBCTR // read the value
and then update (to destination):
EPwm1Regs.TBCTL.bit.PHSDIR // change direction
EPwm1Regs.TBPHS.half.TBPHS // update with TBCTR + 1
for ePWM1, etc.
In the block help, it says the address input expects either the decimal address or the address as a hexadecimal character vector.
How to know the address of EPwm1Regs.TBPHS.half.TBPHS? Is there a list of registers and memory addresses available?

Respuestas (1)

Antonin
Antonin el 17 de Oct. de 2023
Hi Mike,
As explained on the following page:
You need to use the Memory Copy block with code symbol and the .all notation.
For example: &EPwm2Regs.TBPRD.all
As an alternative, you can use a function-call subsytem and use a Simulink Coder custom code block "System Output" where you can write the custom code you need. You can find this block in the Simulink Library Browser, under Simulink Coder > Custom Code > "System Output". This block will work in an atomice subsystem like the function-call subsystem. This technique will allow you to write any custom code but doesn't allow easy interaction with Simulink signals present in the model.
I hope it helps,
Thanks,
Antonin.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by