How to force both PWM outputs of a single module to zero using a value in the model (F28335) ?
    37 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Thomas D'hondt
 il 2 Mag 2016
  
    
    
    
    
    Commentato: Panagis
 il 6 Ott 2017
            Hello !
I'm currently using embedded coder to program an F28335 dsp. I'm generating complementary PWM outputs using the dead band unit of the ePWM block. Is it possible to force both PWMxA and PWMxB to low based on a condition in my model ?
Ideally, this should be achieved through the trip zone block of the ePWM module. However, I can only access the hardware events linked to the TZx pins in the corresponding pane of the ePWM block. I believe the correct way to do this would be to use the TZFRC register, but I don't know how to access it and change its value based on values in my model.
Thanks in advance for your help.
Thomas
0 Commenti
Risposta accettata
  Venkatachala Sarma
    
 il 3 Mag 2016
        Hi Thomas,
You can write to any register using the custom code blocks available in the Simulink Coder. If you check in Simulink Library Browser / Simulink Coder / Custom Code, there is a block called 'System Update'. This gives fields to write functions which will appear in the generated code.
So Suppose if you write, in System Update Function Declaration Code as follows
if true
  int i = 0;
  i++;  
end
And in System Update Function Execution Code as follows
if true
  EALLOW;                                             
  EPwm1Regs.TZFRC.bit.OST = 1;
  EPwm2Regs.TZFRC.bit.OST = 1;                               
  EDIS;     
end
And in System Update Function Exit Code as follows
if true
  int k = 0;
  k++;   
end
The Generated code's step function appears as follows:
if true
/* Model step function */
void test1_step(void)
{
{
  /* user code (Update function Header) */
    /* System '<Root>' */
    int i = 0;
    i++;
    /* user code (Update function Body) */
    /* System '<Root>' */
    EALLOW;
    EPwm1Regs.TZFRC.bit.OST = 1;
    EPwm2Regs.TZFRC.bit.OST = 1;
    EDIS;
    /* user code (Update function Trailer) */
    /* System '<Root>' */
    int k = 0;
    k++;
  }
}
  end
I have written the above statements just show you the syntax. Please check the values of the registers according to your application.
Hope this helps
2 Commenti
  Panagis
 il 6 Ott 2017
				However, I cannot see how this block only executes when the simulink model changes a parameter value or calls a function. It looks like this code ALWAYS executes. Could someone please provide some assistance to this.
Più risposte (1)
  NILANJAN MUKHERJEE
 il 15 Set 2016
        Hi
Where to place this system system update block? - I tried placing within the model but it gave me an error 'Failed to generate all binary output' while building it.
Can you help me here
regards, Nilanjan
0 Commenti
Community
Più risposte nel Power Electronics Control
Vedere anche
Categorie
				Scopri di più su Simulink Coder in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



