0
\$\begingroup\$

I'm having trouble with the circuit I'm studying but in order to modify some values, I want to get out this question of my mind.

enter image description here * Example 50e-6

enter image description here * Example 50e-7

enter image description here * Example 50e-8

I use a S-Function block in order to get this "triangular" wave, so I'll leave it here in case of:

static void mdlInitializeSampleTimes(SimStruct *S)
{
    ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
    ssSetOffsetTime(S, 0, 0.0);
    ssSetModelReferenceSampleTimeDefaultInheritance(S); 

}

static void mdlOutputs(SimStruct *S, int_T tid)

   int_T             i;
   // Corriente Snubber
   InputRealPtrsType u0_Is = ssGetInputPortRealSignalPtrs(S, 0);
   // Triangle Reference
   InputRealPtrsType u1_Iref = ssGetInputPortRealSignalPtrs(S, 1);
   //  Voltaje THY - Lectura voltaje colector/emisor
   InputRealPtrsType u2_Vce = ssGetInputPortRealSignalPtrs(S, 2);


   real_T            *IGBT = ssGetOutputPortRealSignal(S, 0);
   real_T            *THY =  ssGetOutputPortRealSignal(S, 1);
   int_T             width = ssGetOutputPortWidth(S, 0);
   int_T             width1 = ssGetOutputPortWidth(S, 1);


for (i=0; i<width; i++){

       if (*u0_Is[i] < *u1_Iref[i]){
           *IGBT++ = 1;
           if (*u2_Vce[i] >= 0.8 && (*u0_Is[i] < *u1_Iref[i]) ){
               *THY++ = 1;
           }
           else {
               *THY++ = 0;
           }
       }
       else {
           *IGBT++ = 0;
           *THY++ = 0;

       }
   }
\$\endgroup\$
  • \$\begingroup\$ Wait a minute. This isn't MATLAB code. This looks like C (maybe C++, but most likely C). Do you have this code in MATLAB? Also, your Simulink module would be nice to see as well. \$\endgroup\$ – KingDuken Mar 21 '18 at 22:59
  • \$\begingroup\$ @KingDuken that is C code, but to produce Simulink blocks \$\endgroup\$ – JonRB Mar 21 '18 at 23:08
  • \$\begingroup\$ @JonRB Interesting... I had no knowledge of that. Thank you for tell me :) \$\endgroup\$ – KingDuken Mar 21 '18 at 23:10
  • \$\begingroup\$ Try using a stiff integrator \$\endgroup\$ – Scott Seidman Mar 22 '18 at 1:41
  • \$\begingroup\$ I think this can be attributed to Nyquist-Shannon sampling theorem. Remember, sampling frequency should be always higher enough than circuit's switching frequency to get the right simulation results. \$\endgroup\$ – Hazem Mar 22 '18 at 3:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.