Exploring PWM and Electronic Modules

Lecture: 7

Estimated read time: 1:20

    Summary

    The lecture dives into the intricacies of electronic Pulse Width Modulation (PWM) modules, detailing the various components and their functions within the DSP (Digital Signal Processing) context. Key topics include the role and operation of time-based submodules like counters, action qualifiers, and the specific nuances of chopper, dead band, and trip zone features. The lecture emphasizes the synchronization of PWM modules, interrupt generation, and manipulation of comparator values, highlighting the practical application of these concepts in controlling electronic circuits and preventing shoot-through conditions in inverters.

      Highlights

      • The lecture breaks down the components of a PWM module including time-based counters and action qualifiers. 🎯
      • Understanding of dead band feature can prevent catastrophic short circuits in inverters. 🚨
      • Efficient use of interrupts can optimize electronic module performance. ⚡
      • Chopper feature complements PWM to create fine-tuned, high-frequency signals. 📡
      • Practical examples provide insights into real-world applications and algorithm improvements. 💡

      Key Takeaways

      • Master the basics of PWM modules for efficient electronic signal control. 📊
      • Learn how to safely synchronize PWM components for optimal performance. 🧩
      • Understanding 'dead band' helps prevent dangerous shoot-through conditions. 🚫
      • The lecture simplifies error troubleshooting with practical examples. 📚
      • Integrate chopper frequency for advanced waveform modulation. 🎛️

      Overview

      This lecture takes an in-depth look at PWM (Pulse Width Modulation) modules within DSP systems. Beginning with a breakdown of submodule components such as action qualifiers and counters, the tutorial explains how these elements contribute to generating controlled electronic signals. The importance of constants and phase triggers in shaping PWM waves is also covered.

        Following this, the session delves into dead band and PWM chopper features. Dead bands are crucial for safe electronic operation, preventing circuit-damaging short circuits by ensuring switches do not conduct simultaneously. The lecture also highlights how the chopper function allows modulation of waveforms into small, precise signals, ideal for complex electronic tasks.

          Ending on a practical note, the lecture provides methods for synchronizing PWM modules and employing interrupts to control operations. Through detailed code examples and explanations of electronic concepts such as shoot-through prevention and duty cycle adjustments, the session equips listeners with knowledge to apply these practices effectively.

            Chapters

            • 00:00 - 01:00: Introduction and Overview of the Lecture The chapter covers the components of the develop module, highlighting the time based sub-module, counter comparison model, action qualifier, and several other features. It elaborates on the 16-bit counter which operates by incrementing and decrementing to produce a triangular output waveform. A counter compare register is also discussed, which is used to store steady start digital values.
            • 01:00 - 02:00: EPWM Module and Time-Based Counter This chapter covers the EPWM module and the time-based counter. It delves into the use of a constant straight line as a counter compare, which compares with a triangular wave. Based on this comparison, the action qualifier determines specific actions to turn the EPWM process on and off. The chapter also explains how to trigger phase shifts using the TBPHS register, and it further discusses the action qualifier register and its 16 bits, particularly focusing on bit numbers zero to one.
            • 03:00 - 04:00: Action Qualifier and Technical Reference Manual The chapter delves into the function and operation of action qualifiers and how they are configured and managed through a technical reference manual. It provides insights into how setting and programming a register with specific binary values (zeros and ones) influences a system's behavior, such as triggering particular actions. The text emphasizes the importance of understanding the mapping of these binary values to the desired outcomes, encouraging users to consult the technical reference for guidance.
            • 04:00 - 05:00: Synchronization and Instruction Set The chapter titled 'Synchronization and Instruction Set' discusses the technical reference manual, focusing on the EPWM (Enhanced Pulse Width Modulation) and the action qualifier sub-module. It guides the reader through understanding the resistors available within this module, concluding with a mention of the EPWM as a significant aspect of the technical manual.
            • 07:00 - 08:00: Code Examples and Functions The chapter explores the concept of code examples and functions, providing detailed explanations for each part. It demonstrates what happens when different values, like ones and zeros, are inputted into specific bits. This section also covers the synchronization of output, discussing the methods of syncing and synchronized output.
            • 10:00 - 12:00: Interrupts and Event Trigger The chapter "Interrupts and Event Trigger" begins by discussing the ease of following instructions provided by Texas Instruments (TI), which help in programming various tasks. It emphasizes that using these instructions, one can easily program, whereas, programming directly from the datasheet might be more challenging.
            • 14:00 - 15:00: Comparator Operations This chapter titled "Comparator Operations" explores the concept of comparator operations. It's likely to involve understanding how comparators function in various systems or processes. The transcript provides an introduction to the chapter but doesn't delve into detailed explanations or topics covered in this chapter. Additional context is needed to create a comprehensive summary of the chapter's content.
            • 17:00 - 18:00: Modifying PWM Code and API Discussion The session is shorter than usual, and a longer session is planned for the evening when more people are available.
            • 21:30 - 23:00: Explanation of Deadband and PWM Chopper The chapter titled 'Explanation of Deadband and PWM Chopper' begins with a reminder to watch all previous videos for a better understanding of the exercises. The instructor emphasizes that each video contains essential information on what needs to be done, aiding in the ease of understanding and application of the exercises. The current focus appears to be on the continuation from a previous session where PWM (Pulse Width Modulation) modules were being initialized, suggesting a practical aspect to the chapter content.
            • 24:00 - 25:00: Gate Drivers and Shoot-Through Conditions This chapter likely covers the topic of gate drivers and the shoot-through conditions that might arise in electronic circuits. It seems to discuss how triangle wave generations are connected to comparator register times.
            • 27:00 - 29:00: Deadband Logic and Modes of Operation The chapter discusses the structure and definition of certain inherent variables, specifically unsigned 16-bit integers, which range from 0 to 2^16. It introduces the use of a pointer, called the pwm register handle, to manage these variables within the structure.
            • 34:30 - 36:00: Chopper Frequency and One Shot Mode The chapter titled 'Chopper Frequency and One Shot Mode' covers the topic of declaring and defining functions within a codebase. It explains the necessity of function prototypes and how they are declared globally, especially when the functions are not predefined in a header file. The chapter discusses the use of several key functions, totaling around six to seven, that are integral to the code being discussed. It also covers the procedure for the main code involving system control, peripheral clock, and VPWMs, as well as how to effectively trigger interrupts.
            • 44:00 - 45:00: Sine Wave Generation Example The chapter titled 'Sine Wave Generation Example' covers the intricacies of handling interrupts through the PI vector table and ISR (Interrupt Service Routines). It explains the mapping of instructions to ISR functions and the process of calling interrupts. Furthermore, the chapter delves into the synchronization of PWM (Pulse Width Modulation) modules using time-based clock synchronization, ensuring all EPW (Enhanced Pulse Width) modules work in harmony.
            • 48:00 - 50:00: Three-Phase Signal Generation and Comparator Usage In this chapter, the focus is on three-phase signal generation and the usage of comparators within that context. The discussion highlights the importance of managing interrupts efficiently by clearing the interrupt flag and acknowledging the interrupt. It also mentions the use of an event trigger selection register and an event trigger clear register to manage interrupts properly.
            • 56:00 - 57:00: Module Synchronization and Deadband Modes The chapter titled 'Module Synchronization and Deadband Modes' discusses the setup and configuration of interrupts used with event triggering in electronic modules. The transcript explains how an interrupt can be configured to reoccur at specific events, such as zero instant or period instant, by selecting it in the event trigger register. It was noted that an interrupt enable must be set to '1' to activate the interrupt module through the event. Options like comparator a up or comparator b down instant are mentioned as points for triggering interrupts.]

            Lecture: 7 Transcription

            • 00:00 - 00:30 develop module consists of a time based sub module counter comparison model action qualifier and then we have chopper dead band trip zone event trigger and digital compressor so from this sub modules we saw that time based of module is a 16 bit counter and time base counter is there and it goes on increment and decrement and gives you output as a triangular way and then we have a counter compare register which is there in order to store your steady start value digital value and in that case if
            • 00:30 - 01:00 you have a constant straight line okay so that straight line will be there as a counter compare so that will be comparing your triangular wave and based on that action qualifier will say certain particular action so that your epwm process will be on and off and then we saw how to trigger the phase shift by using tbphs resistor so by using tb phs this was about action qualifier resistor so you can see an action qualifier resistor there are 16 bits and bit number zero to one if you
            • 01:00 - 01:30 assign zero zero it means what will happen over here that is shown so you can see uh if you put zero in this particular bit it will start triggering one zero other bits other bits in this case should be zero and this zero one bit should be one only so that your counter will start at zero similarly you can program this register okay and you can see what your action qualifier is assigned to do uh best way to look into this is to is through the technical reference
            • 01:30 - 02:00 manual as it won't be confusing you can go to technical reference manual and uh from here if you go to epwm and the action qualifier sub module so from action qualifier sub module itself you can see what are the resistors available to you so the end of this end of this particular epwn movie
            • 02:00 - 02:30 i think somewhere here so actually detailed explanation will be given for each and every bit but if you put one into that particular bit what will happen if you put zero into that particular bit what will happen so you can actually do it like this and this was about synchronization of output that we saw sinking and sync output
            • 02:30 - 03:00 so through instruction it was little bit easy as compared to looking over from this particular data sheet okay through instructions which actually given you all the examples by ti it will be easy for you to program from there and then you look over here if you want to program something else so this resistors will be there okay so we saw about epwm three modules like time based counter compare and action qualifier today we'll see about dead band and pwm shopper
            • 03:00 - 03:30 and trip zone i will teach you later event trigger we saw how to trigger an interrupt using event trigger that is
            • 03:30 - 04:00 so this session will be little bit short and evening session will try to take more time because evening most of the people are free so
            • 04:00 - 04:30 so i guess everybody has not watched all the videos okay so i request you that you watch all the videos first before going through every exercise okay because each and every in each and every video i have told you what to do okay so it will be easy for you so we saw this code yesterday how to initialize pwm modules
            • 04:30 - 05:00 okay and how do you see that your triangle is generated you can see from this one that your drag i think someone has came just hold on for a minute yeah so we saw this that yesterday um there are certain variables that we have assigned to comparator register time
            • 05:00 - 05:30 based period resistor then there was a structure where we defined certain inherent variables which are unsigned integer 16 bit okay and which will be i mean these values will be ranging from 0 to 2 to the power 16 as we saw yesterday then there we suggested one pointer known as the pwm register handle in order to take care of all the uh variables that are there into this structure type of variable so
            • 05:30 - 06:00 and this one then we saw how we can declare the functions these are our function prototypes global function prototypes and these are the declaration of the functions that we saw why it is necessary and some of there are in header file if you are defining your function on your own then you have to declare it somewhere here like this so six to seven functions we are using into this code so they are defined over here and then we saw the procedure for main code using system control peripheral clock vpwms and how to trigger interrupts we are the
            • 06:00 - 06:30 lover of that and how to take particular is or how to call particular isr from pi vector table so this is the instruction for that particular thing and it is mapped to your isr function any call of any interrupts okay so after this we saw how to synchronize all the pwm modding that is this particular instruction of time with time based clock synchronization is used for synchronizing all the epw modules together then then we saw about that whenever our
            • 06:30 - 07:00 interrupt is executed it is executed with the help of event trigger selection register and we saw that i did i forgot to tell you yesterday that whenever any interrupt is occurred first you have to clear that interrupt flag so that your ifr bit becomes zero so this event trigger clear register will clear the interrupt uh from that particular bit which is occurring like epidural and three from here and after that you have to acknowledge the same interrupt like like group three interrupt so that your interrupt keeps on receiving so as we saw yesterday acknowledges like thanking
            • 07:00 - 07:30 so that interrupt should occur again and again you can understand it like that and we saw the event trigger resistor as well that your interrupt selection where you have to select your interrupt to occur whether it is on zero instant period instant comparator a up instant comparator b down instant it's your selection completely so in this interrupt selection resistor you can select any one of the event from here after that this is an interrupt enable which we saw yesterday that you have to put one over here in order to enable your interrupt module through event
            • 07:30 - 08:00 trigger so event trigger is basically extending the capabilities of your pi module so that it should trigger interrupt on particular event and then you have a period of interrupt selection that is for after how many triangles of your time base period your interrupt is generated that is we have assigned it on third one so so i guess still here nobody had any doubt and we saw that how particular you know interrupt we are
            • 08:00 - 08:30 taking into account in order to vary our comparator so that our comparator should move up and down and how its value is increasing with comparator plus plus with this particular uh pointer which is in the arrow direction the pwm info is accessing everything with this epm resistor handle pointer and it is pointing towards the beat of comparator and then we are incrementing it by one and a certain condition is written over here that if your comparator is
            • 08:30 - 09:00 greater than maximum we ask comparator to go down if it is less than minimum we ask it to go up so that condition is there into this particular block for comparator a and comparator b so this was the example which is given to you in order to you know try to write your own algorithms so what you can do whenever you are practicing you can just copy this code okay and you can take your text file so into this notepad you can paste your
            • 09:00 - 09:30 code so whenever you want to change anything into the code you can easily change it from the text file and when your changes are done you can paste the same file in here so in that way you can modify if any content is there okay you can as well see if any errors are there during building by then and you can change it so whatever codes you write you try to save main file into text file and as you all know apis we saw how to create and generally they are into their c2000 where device support only so you
            • 09:30 - 10:00 don't have to create apis on your own otherwise it will show that you have redefined the apis as they are already defined in c2000 compiler okay so all the drivers and everything it's over here and whenever you are trying to generate any code we saw through resource explorer that you can implement since my board is not connected
            • 10:00 - 10:30 so this we saw yesterday so this was about the revision and phase shift we saw that if you put your time base counter value equal to tbphs automatically your triangle will reset at that point of time and then your phase shift will occur so in this way you can generate the phase shift you can imagine your triangle will start from here itself after that so that your comparator whenever it is comparing with that particular signal it will
            • 10:30 - 11:00 generating the phase shift okay and then we took the exercise so from this example you can see i put certain value into tbprd and i have put phase shift as paste as zero i have said here zero four e zero if you convert this into binary you will understand that uh tpph's bit is assigned to what value so from here the face is zero so comparator i have set it at half the values of tbprd so my fifty percent duty will be there my pwm which
            • 11:00 - 11:30 will be generated it will be of 50 duty cycle so if we have scope also we can see with this and once you receive your board you try to change this bit and try to measure your duty as well how it is coming when you are putting your comparator values okay uh so it is like that and uh so this was about pwm module i will look into little bit about deadband and pwm chopper so deadband is something which offers you
            • 11:30 - 12:00 like let's say whenever you have an inverter everybody is well aware that an inverter so whenever we see any edge bridge inverter so from this edge bridge inverter we know that we want some phase shift uh some sorry we want some dead band into
            • 12:00 - 12:30 s1 and s4 if that is not so what will happen is if s1 and s4 are on at the same time then the dc link capacitance which is connected over here it will get shorted and as you all know igbt has a longer turn of time than turn on time so it takes longer time for any switch to turn off so when this switch is getting turned off with little delay you don't want this switch to be on at the same time otherwise there will be short circuit over here and it will cause a huge current to flow through your dc link capacitance
            • 12:30 - 13:00 this condition we call it as a shoot through condition so in order to avoid that shoot through condition we give dead band in between these two switches so that before turning on off s4 your s1 should be off so that deadband you can give it into this particular microcontroller with some logic and that logic diagram is shown over here so basically there are actually these are the modes of dead band this upper signal is ebwm 1a signal
            • 13:00 - 13:30 below signal is epm1b signal so you can call it as output a and another one will be output p so uh from here you can see what i mean by rising edge delay is sorry this one is rising edge delay so if your output is something like this and you want to give rising edge delay so that your rising edge will come with certain delay and your falling age will be at the same same instant so you can put rising edge delay or you can put a falling edge delay like your waveform will start at the same time and you can
            • 13:30 - 14:00 you know turn off switch s4 after certain period of time before turning on off switch s1 okay so in this way you can delay uh turn on and turn off of any particular switch so there are four modes of this one is active high complementary active low complementary active high and active low so in this mode you can see epwma and epwmp are totally inverted in which epwma is there with certain rising edge delay and epwmp also has
            • 14:00 - 14:30 certain falling edge delay so active high complementary means epwm 1 a will be totally inverted as that of the epwm 1b then you have active low complementary in this active low complementary signal your epwma will be active low you can see here and epwmp will be active high then active high uh in active high mode your dpwm 1a will be high and 1b will be also active high in the active low mode you can say 1a as active low and epwm1b has as well
            • 14:30 - 15:00 as active low so you can select any on one of these mode okay where let's say if you have uh generally your s4 switch is is inverted of your s1 switch i guess so in this active high complementary mode you can see this flexible facilities available in which your ipwm1a will be in the positive way where your this one will be on and in this case your s4 will be off so you can use this mode as well so
            • 15:00 - 15:30 whatever mode that you want to have okay as per your requirement you can set into this i don't know what circuit you're operating so if your waveforms are like that if you see pwm on your oscilloscope okay then you can decide that uh what delay you want to keep what uh deadbend you want to keep okay generally in any gate drivers if you employ skype 32 gate drivers if you look into
            • 15:30 - 16:00 fiber 32 gate drivers so if you employ this kind of the drivers it is suitable for switching frequency to 20 kilohertz okay you can't go beyond is 40 kilowatts it is the uh so igbtsi igbt you can switch easily with this particular microcontroller uh you can switch sic as well okay but that needs to operate below 40 kilowatts frequency so you can use this gate driver this is power module of that gate driver and this is the uh
            • 16:00 - 16:30 another extending you have to fix this power module onto this particular board look at this holes over there black holes are there you just have to put it over here and you have to insert certain resistances so with this module uh there is a already inbuilt uh deadband is there in order to prevent your short circuit or shoot through condition so that protection is also there into this gate driver so in that case you don't need to do it in software but if you want to have extra protection
            • 16:30 - 17:00 you can do that as well in your deadbolt you can try to see when we'll see our code we'll see how actually it is okay so what is the time that you can set for this particular thing and what are the modes for selection so there are basically two resistor one is rising edge delay counter another one is falling edge delay counter so in this counter uh you can select your dead band mode to this particular switches that is s0 s1 s2 s3
            • 17:00 - 17:30 and other modes are also there like if you want to bypass certain uh uh epwmp and you have to give delay into epwma only that you can also give like you can see in more description if your s1 and s0 are zero zero and whatever you put into this red band control polarity selection s2 s3 bits okay your epwm and epwmp will pass with no delay so you won't have any delay into your epwme and epwmp so
            • 17:30 - 18:00 whenever you are implementing any dead band and you don't want to have a dead band you can put it like this in active high complementary mode that if your pwm a signal something like this and your pwm b signal is something like this and in that case if you want to give uh if you want to generate that kind of thing you can use polarity selection as one zero and output mode as one one then you have active low complementary as we saw over here so you can put these values we'll see in code how to put these values and what kind of
            • 18:00 - 18:30 modes you're getting okay after that you have polarity selection output mode with the help of s0 s1 s2 and s3 so you try to understand the this logic through this particular bits that is shown over here this particular diagram it's showing that if you click your s4 to 1 it means you will have if suppose this is pwme okay it is coming through s6 like this like this like this if it is coming and then it can go to one as well it can go to zero as well so if it is on to zero and this
            • 18:30 - 19:00 bit is on to one okay then your rising edge delay will be on okay and it will come through this particular line and if s8 is zero it will it will connect to rising edge delay block and after that this has to connect it to pwma again so in this way loop will get completed okay so this switches are there in order to design logic you can see if this s4 is connected to one then your pwm b okay your pwm b has a rising hdr
            • 19:00 - 19:30 similarly input mode in s5 if you select this switch as 0 you can in you can implement pwm a into falling edge delay mode and if it is connected to one then you can implement pwm b into falling edge dilemma so you have a rising edge delay circuit you have a falling edge delay circuit and these two circuits are used for both pwms pwma and pwm b with the help of this input mode okay then you have your deadband mode
            • 19:30 - 20:00 like whether you want to bypass this any particular deadband let's see if this switch is connected to one okay this logic is little bit complicated to understand okay so uh that's why they have given uh output mode and polarity selection mode bits uh written over here that if you put anything it will somewhat happen like this okay so in this way you can use any of the bits okay i will explain this in detail how it actually you can do it from here
            • 20:00 - 20:30 it is little bit difficult to understand okay so uh once one by one if you see okay let's go to technical reference manual exactly will understand from there
            • 20:30 - 21:00 yeah so these are the modes that i have shown you for operation and these are the additional dead band operating modes so from additional deadband operating modes you can as well have facility to bypass particular signal like epwma in this one if you select s6 s7 and s8 bit which is for dead band mode and output swapping
            • 21:00 - 21:30 mode if you put 0 0 0 both the signals are determined by output mode bits means it depends on output mode now what you are putting okay if you are putting 0 0 0 into swap and this particular deadband mode then your epwma and epwmp will be decided by output mode okay if you are putting 0 0 1 it means epwm a will be defined by output a modes like output mode bits whatever you put if wme signal will be based on that okay but if you are putting like zero zero
            • 21:30 - 22:00 one your epwm b will have path that will be defined by rising edge delay or delay bypassed like uh like you can only introduce rising edge delay or you can bypass the delay you cannot introduce falling edge delay into the cpwmb after having this particular thing okay so uh uh little bit tricky it will be to understand and this will try to explain it through
            • 22:00 - 22:30 okay let's have a look into this as of now okay once we'll see the code we'll try to demonstrate it over the oscilloscope by putting every other bit okay into every other mode so that you can see problem a and b signal i think that will be more clear to you as compared to this so one by one then i will explain so the time for this any rising edge and falling each delay is given by this particular formula that is deadband fed
            • 22:30 - 23:00 deadband red so these are the register in which you can put any value like 1 5 10 100 any value you can put and your time-based clock time time for time based clock is what as we saw yesterday your time based clock operates on 50 megahertz so this time for time based clock will be 20 nanoseconds so 20 nanoseconds into one so whatever you are getting that will be your falling hd then you have 20 nanoseconds here and if you are putting red as one your falling edge delay will be 20 nanoseconds rising
            • 23:00 - 23:30 hdl and falling is delayed so depends on your time for time based clock and your these values your rising engine falling edge delay will be there okay is this clear to everybody okay so this was about dead band and we'll take a code of that okay first i'll talk about pwm chopper so into this
            • 23:30 - 24:00 pwm chopper you have two pwm signals a and b and what does pwm chocker chopper does is it chops your pwm a or b signal into a low frequency sorry into other high frequency signals like you can see this a and b are low frequency signals okay now you have a certain wave of top frequency in which you can put frequency up to 10 20 megahertz and what you can do is you can pass this particular you can logically add this chopper frequency to a and b
            • 24:00 - 24:30 and after that your epwm a and b will have output something like this you can chop your pwm wave into small small turn on and turn off interval with this pwm chopper so if any application requires this you can as well have this feature of pwm chop so there are certain registers like you can put it into the one-shot mode okay so how it will be like that and okay so how you can set your chopper
            • 24:30 - 25:00 clock frequency like high frequency that wave chopper frequency wave you can set it from this one whatever your system clock is operating at like let's say your system clock is operating at 200 megahertz or something and you can put a frequency division value into that particular bit we'll see in the program how to put that so based on that your chopper clock frequency will be decided and your chopper duty cycle also you can adjust like uh
            • 25:00 - 25:30 like this is 50 percent duty so if you want to change the duty of this you can actually change the duty of your chopper signal so that your epwm signals duty will also change it won't be in 50 percent okay so this is the main register of pwm chopper in order to enable uh your uh chopping of your waves the chopper duty you can set from a bit number eight to ten chopper frequency you can set from bit number five to seven and uh you have to enable one shot pulse width one shot pulse width is what
            • 25:30 - 26:00 that will see okay so you can see from this figure you can see from this figure the the period of the the time for which your first pulse is on that is called as one shot mode so you can as well have facility in order to change the first pulse duration turn on duration that you can do with this programmable pulse so this is a programmable pulse whatever value you will put into one shot okay it will have that particular on period so
            • 26:00 - 26:30 you can operate it in one shot mode or you can as well bypass that particular mode okay then you have a chopper frequency that you can set shopper duty and chopper enable like if you put 0 it will be disabled if you put one it will be another okay so this is the formula for time for setting first pulse time of system clock out means 1 divided by 200 megahertz into it into whatever one shot width that you are you wish to put put okay that you can put over here so it is based on this particular values
            • 26:30 - 27:00 okay from 1 to 4 if you are putting 0 0 0 it will be 8 divided by 8 to your system clock frequency so like this you can put okay and uh this was about chopper and little bit about chopper and your dead band okay once then we'll see the code and when we'll see the exercise into that module we'll see return what is there sign pwm this was the first code that i have
            • 27:00 - 27:30 written so so into this particular code i have assigned certain variables like modulation index uh clock frequency of cpu with this dac and everything that i will explain later so certain variables i have assigned result as s2s3 for my convenience then i have put sampling frequency ts then i have put omega naught fundamental 2 pi f to set that
            • 27:30 - 28:00 you have theta 0 that is initial value of theta in order to program your sine wave these variables are required so this reference reference one reference to output then these are all the float variables like they will they can have as well as decimal values that's what float means you can as well put double then you can have then i have put certain variables which are unsigned integer for 16 bit and then i have certain functions like epwm one two six since i'm programming six pwms into this example i
            • 28:00 - 28:30 have written six examples six uh initialized epwm examples okay so as per the procedure first i have enabled the clock then i have disabled all the interrupts and i have enabled the peripheral clock we saw this is a peripheral clock control resistor 2 in which pwm one bit clock is on then i have initialized my pwm this is the initialization of pwms through gpios so these are the predefined functions so
            • 28:30 - 29:00 six i'm using so i put the f6 then i had a pi control resistor and i'm clearing all the core interrupts from my er and ifr then i had initialized pi vector table and that for my purpose in order to see the output so once back section will be clear you will understand that so this is what i have done over here that uh in this one it's one more thing that i would like to tell you is that you can as well divide your epwm clock
            • 29:00 - 29:30 okay if you put a pwm clock divider one okay your clock frequency of epwm will also decrease like if you want don't want to have it at 100 megahertz you want to have it at 50 megahertz you can put here one as well okay so this is also one register which is peripheral clock divider selection resistor okay so many resistors are available in technical reference manual like this okay so this is not required but if you wish to put you can put it then
            • 29:30 - 30:00 it means that my pwm clock is now operating at 100 megahertz okay then you have a peripheral clock control resistor time based clock synchronization equal to one so it will synchronize all the time based modules then i have triggered here timer zero interrupt that is cpu timer zero and i have called an isr that is cpa timer0isr this certain arrays i have initialized in order to store my values of sine
            • 30:00 - 30:30 function so what i have done is i have taken an array of 10 in size and i have initialized it to 0 0 0 first so i've taken 6 arrays here like that a b c d e and f i guess yeah so this is the instruction that we saw we are calling interrupt at particular period of time so i have operate i'm operating at 200 megahertz
            • 30:30 - 31:00 previously we saw example of 60 megahertz so cpu frequency megahertz you can see from here it is set at 200 so i am operating at 200 megahertz my cpu timer then i am calling my interrupt after this particular execution of this particular instruction that is whatever value of int rpt and uh into this okay so after this time my interrupt will occur so i let me
            • 31:00 - 31:30 check what is this okay so i have put it here something like this so as per my convenience i have done that whatever sampling frequency to which i need to generate my particular pwm so it should be higher than that because whenever you are generating sign you are generating it in a discrete way that is sample by sample so whenever you are generating one sample you need to make sure that whenever interrupt is occurring so the time duration between that sample that two samples will be much more lesser okay than your sampling frequency
            • 31:30 - 32:00 or your sampling time so from here this particular instruction into pcr bit okay it's to start the cpu timer don't forget to add this instruction i always used to forget to add this so this is important in order to start your cpu timer then we have triggered an interrupt of group one m is enabled which we saw this
            • 32:00 - 32:30 is belonging to group one and subgroup seven and then we are turning on the interrupt so this is the isr in which i have returned the code okay so i have uh execute i have returned zero zero zero into tcr bit once again in order to reset my cpu timer whenever isr is happening once again i am resetting my cpu timer okay so it's basically one over here it should be zero so uh here i'm generating
            • 32:30 - 33:00 a sine wave okay so from here you can see your sine is basically of 2 pi which is 6.28 so whenever another 0 comes if your theta is greater than 2 pi your initial theta will be assigned to 0 so this is the logic for generating sine i am taking initial value as 0 and then i am taking it here as ts into omega naught so this is 2 pi f omega naught and this is ts is sampling time so 2 pi f into t x plus initial value that will be my theta so accordingly my theta will update and if
            • 33:00 - 33:30 theta is greater than 6.28 that is 2 pi again it will go to 0. so in this way one of the one sine wave will be created and then here i have used the function called as sine theta so i have stored my values into or g where i am storing all the values of sine theta so whatever sine wave is generating it is stored into this particular org bit okay then i am adding certain reference into the sine because this sign will be from i guess minus 1 to plus 1 so i don't want it from minus 1 to plus 1 as my triangle
            • 33:30 - 34:00 into this tb pid resistor it will be starting from 0. so for that i am putting 1 into this sine theta so that my sign will be now from not minus 1 to plus 1 it will be from 0 to 2 okay then i am initializing again theta 0 to theta and then i am putting this values into a i so that i can see into the array what is the value of my sign signal okay so whenever this kind of ai and reference everything is available to you you can just put this into expression okay we
            • 34:00 - 34:30 saw our expression window it's something like this variables window when you run your code you can put into variables and can monitor the values of all the arrays okay so it is like this then i'm putting comparator into this comparator what i'm putting is this is the side so i'm putting my sign into comparator and i'm scaling it with respect to my pprd because my tprd if it is from 0 to you know 2 000 and if sine is from 0 to
            • 34:30 - 35:00 1 i will not be able to compare that so i have to multiply it by 2000 in order to make that comparator equal to pprd so this way i can set my modulation index as well okay this is the logic for setting modulation index into comparators so this was about it then i'm shifting another sign with respect to uh you know two pi by three and another sign with four pi by three so this is for three phase okay so three-phase signal i'm generating here okay for a three-phase inverter to operate so in three comparators of ppwm
            • 35:00 - 35:30 one and two and three i'm putting three sine waves which are 120 degree phase shifted okay and that i'm comparing with the triangle uh let's show you in a particular way so this is like what i'm trying to do there these three sine waves i'm taking 120 degree phase shifted into comparator resistor and this tpprd is there
            • 35:30 - 36:00 okay and i'm comparing this particular sign with this triangle which is from uh i guess 0 to 2000 so my sign also has to have magnitude from 0 to 2000 that's why i have multiplied it by dprd and then i'm putting the logic into my code that logic that logic i have set it over here
            • 36:00 - 36:30 that whenever my comparator is counting is touching a on up count and it's touching a on down count i am setting and clearing the pulse so in this way also you can obtain and b signal if you want inverted of up signal you just put clear and set opposite instruction to that okay then you can see i have assigned sync output of epwm one module at time based counter zero it means my counter will start counting from zero itself
            • 36:30 - 37:00 and now rest of the pwm module i have to put time based singular instruction so this is the inherent uh the keyword okay this this time basically is a keyword which will having be some micro expansion what does this mean is that your synchronization flow will be continue so once if you want to synchronize every module from one two three four five six you just put this instruction sync output selection equal to tv sync it so with this instruction you are able to synchronize all the modules together
            • 37:00 - 37:30 okay so you can see in my every module that particular instruction will be there sync output selection okay so four five and six every module is synchronized with that particular instruction and the first module is synchronized to time based counter zero like whenever my counter is starting to zero okay then after that point of time i have told the pwm module to turn its clock on and other pwms module will be there into the flow with this particular
            • 37:30 - 38:00 instruction okay it just allows you allows to pass through you can say like that okay so this is about that i have selected the advantage here also previously these are the modes for selecting dead band i have enabled that bind into active high complementary mode as epwm 1a and 1b i wanted in complementary mode okay and you can also put here bits okay 0 1 1 2 2 3 whatever values are there
            • 38:00 - 38:30 according to your uh what you which mode you want okay we saw how to put that by using interrupts as well so input mode i'm selecting here dba all means i want a deadband into both the pulses that is fwma and b as well then i am putting rising edge delay and following his delay into epm1 so that is of 200 here that particular value is 200 so it's i guess into the nanoseconds 200 nanoseconds of delay i'm giving into
            • 38:30 - 39:00 two pulses so it's like that so whenever you are what i'm doing exactly here is i'm putting comparators for sine values into comparators and i'm that comparing that values with my triangle which is there with the this tprd okay so till here does anybody has any doubt