extra signals DMA example epm Duty Cycle

14 vues (au cours des 30 derniers jours)
Gauthier Mervillie
Gauthier Mervillie le 11 Mar 2019
Modifié(e) : Osvaldo Gonza le 14 Juil 2022
Hello everyone,
For my project I'm using MATLAB and SIMULINK to program the TI Launchpad. The program C2000 and Matworks both provide an example to generate a variable PWM signal. The link to this example is given here: https://nl.mathworks.com/help/supportpkg/texasinstrumentsc2000/ug/modify-epwm-using-dma.html
I could implement the signal without a problem, but now is my question how I can get three such variable signals out of the TI Launchpad. I tried understanding the program behind it, but without succes. The result I want in the end is a three phase inverter with 120° phase difference. Below you can see what I tried to do:
PWM_generator.JPG
I was able to get three signals on the Launchpad, but only one had variable pwm. More precisely, the one which was already present in the example. Hope you can help me with this issue
Thanks in advance!

Réponse acceptée

Venkatesh Chilapur
Venkatesh Chilapur le 18 Mar 2019
Hi Gauthier,
That can complicate things as the DMA runs in steps of 1, picking next value from table until 500 such iterations are done to copy all entries from duty_cycle_table over a period of time where we get 1 full sine wave. However starting the source address with a offset will actually make the DMA overshoot the table entries as the transfer size is 500. It would call for complicated configuration of the DMA which I am not sure is currently supported. For more information on specific configuration of the DMA to suit an application scenario it would be best to talk to experts at TI E2E forum. Please can you accept the post as an answer so that in future we can guide customers to this looking for similiar information.
Regards,
Venkatesh C
  1 commentaire
Gauthier Mervillie
Gauthier Mervillie le 18 Mar 2019
Hello Venkatesh,
Thank you for the information. I was also thinking if it is not possible to write an extra duty cycle table with the values of each phase? I will accept your answer above and thank you for all your support!
Kind regards,
Gauthier

Connectez-vous pour commenter.

Plus de réponses (9)

Venkatesh Chilapur
Venkatesh Chilapur le 11 Mar 2019
Hi Gauthier,
You may not need other DMA's for generating rest of the PWM's.
Once you have the First ePWM working, you can synchronize the rest of the PWM's to the Master. Master is the ePWM which is generated using DMA.
We provide an option to provide the Phase delay after synchronization in the ePWM block which can be used in this case.
'Phase offset value (TBPHS)'
More details for the configurations options available in ePWM block is provided below:
There is also a TI e2e post which talks about this possibility.
You may want to explore this option for your implementation.
Regards,
Venkatesh C
  1 commentaire
Gauthier Mervillie
Gauthier Mervillie le 11 Mar 2019
Hello Venkatesh Chilapur
Do you have any idea of how I can synchronise the other ePWM's with the Master? I am struggling to get the other two signals also variable.
The phase difference of 120 degrees is already possible thanks to your recommendations, thank you for that!
Kind regards,
Gauthier

Connectez-vous pour commenter.


Venkatesh Chilapur
Venkatesh Chilapur le 11 Mar 2019
Hi,
Please refer this video:
In the video at time 6:45 we cover the PWM synchronization topic. That will give a fare idea on how PWM can be synchronized to each other. In your case you need them to be 120 deg in phase offset, so the TI post can be handy for the same.
Regards,
Venkatesh C
  1 commentaire
Gauthier Mervillie
Gauthier Mervillie le 11 Mar 2019
Modifié(e) : Gauthier Mervillie le 11 Mar 2019
Hello,
I followed the video and I adjusted the paramaters similar to the video. Apparently I am not able to synchronise because there is no connection with pin2 inside the launchpad. So I suggest to generate the signal on another pin. I have tried to generate the variable PWM on pin7 with succes but still I am not able to synchronise.
I have added the file in an attachement. Am I doing something wrong in the hardware settings?

Connectez-vous pour commenter.


Venkatesh Chilapur
Venkatesh Chilapur le 12 Mar 2019
Hi Gauthier,
Keeping aside the operation of DMA in this example, we can synchronize the PWM output with help of following configuration.
The following figure provides an idea on the synchronization scheme.
Capture.JPG
So inline with this, we can configure ePWM1 as MASTER for ePWM2 and subsequently for ePWM3 time synchronization.
In order to achieve this in configuration we set SYNCO to the condition as captured below.
tempsnip.jpg
With this, when the ePWM1 Time base counter equals zero, the SYNCO output will provide the synchronization input to ePWM2.When this happens, the Time base counter of ePWM2 will be updated almost inline the time when the counter of ePWM1 gets updated.
Now we need to configure the ePWM2 for this sync.
tempsnip1.jpg
In the first marker, we specify ePWM1 is the source for sync. In the second marker the action that needs to be taken when the sync event occurs. If we choose to set the TBPHS say a value of 50, then Time base counter will start from 50 onwards at the sync event for ePWM2, unlike the ePWM1 which starts from 0. So we have achieved a phase offset here. In the last Mark we allow this sync event to the next ePWM in the ladder which is ePWM3.
Now coming to the example:
Here we are updating the CMPA compare value for the given ePWM module using DMA. If we intend to use these values for other PWM also, then we need to configure the DMA channels for those PWM's as well. But the synchronization part is achieved by the configuration as decribed above including phase offset config as described.
Regards,
Venkatesh C

Gauthier Mervillie
Gauthier Mervillie le 14 Mar 2019
Thank you Venkatesh Chilapur!
I was able to configure a signal thanks to your example above! I was able to generate three PWM signals with a 120° phase difference. I'm now making a figure for the high side and the low side of the inverter. So I'm making a PWM7a and a PWM7b signal. Of course I have to add a dead time so both sides don't switch at the same time. That's why I want to add 500 ns delay on the switching between the high and low side. I guess I need to configure this in these parameters:
Deadtime.JPG
In the settings of PWM7a I guess nothing has to be changed, but in the settings of PWM7b some parameters have to be changed probably? I guess ZERO should be clear to start with, but what about the other parameters?
Deadtime2.JPG
I would be very grateful if you could solve this last issue for me. Then my inverter is finally ready for experimentation.
Kind regards
Gauthier

Venkatesh Chilapur
Venkatesh Chilapur le 14 Mar 2019
Hi Gauthier,
To implement deadband, please do the following.
Keep all box un-checked for the ePWMxB as shown below as to produce classical dead-band waveforms the
default is ePWMxA.Untitled.jpg
Under Deadband config pane do the following:
Capture.JPG
And with these settings I could get the waveform with deadband.
1bd01047-e8cb-4ba7-9b51-4fcb4b3542a9.jfif
Hope this helps.
Regards,
Venkatesh C
  1 commentaire
Gauthier Mervillie
Gauthier Mervillie le 15 Mar 2019
Modifié(e) : Gauthier Mervillie le 15 Mar 2019
Hello Venkatesh,
This indeed help me to generate a perfect wave with a deadband! I did my first tests and everything is working fine. Although there is one problem which occured. When I changed the frequencies to another ratio instead of 500 Hz switching frequency and 1 Hz sine wave, the PWM was not generated correctly anymore. I added an image below:
As you can see there are some black bands in the PWM signal where no switching is happening. I guess it has something to do with the callback script below:
% Script to Read configuration parameter for clocking info of processor and
% create a sine table to load for DMA example
% Copyright 2018 The MathWorks, Inc.
if codertarget.target.isCoderTarget(bdroot)
cs = getActiveConfigSet(bdroot);
clk = codertarget.data.getSystemClock(cs);
sysclkout = str2double(clk) * 1e6;
% ePWM clock
ePWM = codertarget.data.getParameterValue(cs, 'ePWM');
if isfield(ePWM,'ClockDiv')
clockDiv = str2double(strrep(ePWM.ClockDiv,'SYSCLKOUT/',''));
else
clockDiv = 1;
end
ePWMClkFrequency = sysclkout / clockDiv;
else
% Set default value of 90 MHz
ePWMClkFrequency = 90e6;
end
% Required ePWM frequency = 500 Hz and Sine wave frequency = 1 Hz
epwmFrequency = 2000;
sinewaveFrequency = 15;
% Up-down counter mode, TBCKL prescalar set to 128 and HSPCLKDIV set to 1
epwmPeriod = floor(ePWMClkFrequency / (128 * 2 * epwmFrequency));
% dutycycle array size calculations
arraySize = floor(epwmFrequency/(sinewaveFrequency));
% Sine value scaled and offset to ePWM period
sineTableInput = 0 : (2 * pi / arraySize) : ((2 * pi) - (2 * pi / arraySize));
sineTable = floor(sin(sineTableInput) * (epwmPeriod) + (epwmPeriod));
%Creation of variable for duty cycle
duty_cycle_table = Simulink.Signal;
duty_cycle_table.CoderInfo.StorageClass = 'ExportedGlobal';
duty_cycle_table.DataType = 'uint16';
duty_cycle_table.Dimensions = arraySize;
duty_cycle_table.InitialValue = ['[' num2str(sineTable) ']'];
As you can see I chose for the frequencies 2000 Hz and 15 Hz for switching and sine wave. The ratio is not 500 anymore, but 200 instead so this will probably the cause of the problem. The array which is send to the table is also only 200 values. Do I solve this by adjusting the formula of array size? Or do I have to adjust more parameters?
Thanks in advance!
Kind regards,
Gauthier Mervillie

Connectez-vous pour commenter.


Venkatesh Chilapur
Venkatesh Chilapur le 15 Mar 2019
Hi Gauthier,
If you get 200 values in the duty cycle table then you may need to update the DMA configuration w.r.t this. We set the transfer size base on the number of entries in the duty_cycle_table.
Capture.JPG
The field as highlighted above needs to be updated with 200 now. Please try this and let me know if it helps.
Regards,
Venkatesh C
  1 commentaire
Gauthier Mervillie
Gauthier Mervillie le 15 Mar 2019
Modifié(e) : Gauthier Mervillie le 15 Mar 2019
Hello Venkatesh,
I adjusted the value and indeed that did the trick. Although the first phase works 100%, the other phases don't synchronise anymore. Is this because the frequency became to high or should I adjust some other parameters? On the example frequencies with 500 Hz switching frequency and 1 Hz sine wave everything works fine, but when the ratio of 500 is lost the synchronisation isn't there anymore. Should I change something in the callback script mentioned above? Or could it be that the phase shift ain’t right anymore?
Kind regards
Gauthier

Connectez-vous pour commenter.


Venkatesh Chilapur
Venkatesh Chilapur le 15 Mar 2019
Hi Gauthier,
I may need your model. Can you attach the up to date model.?
Regards,
Venkatesh C

Gauthier Mervillie
Gauthier Mervillie le 15 Mar 2019
Hello Venkatesh,
I added the model in attachment here. Thanks in advance for the support.
Kind regards
Gauthier Mervilie

Venkatesh Chilapur
Venkatesh Chilapur le 18 Mar 2019
Hi Gauthier,
As I mentioned, since the Master ePWM is configured to react on CMPA count and we update the same using DMA ch 1, we need to do the same for other ePWM as they cannot be synchronized for CMPA values but only for TBPRD value. So, from your model I could see the DMA ch as required to update the CMPA value for ePMW8A and ePMW9A are not configured. You can configure DMA ch 2 for ePWM8A and DMA ch 3 for ePWM9A such that, there CMPA values are also copied and that way all 3 ePWM output can be in sync. When configuring the DMA ch, ensure to update the destination register value for ePMW8A and ePMW9A and keep the source same i.e 'duty_cycle_table'. Please let me know if this helps.
For example:
Enable the DMA channel as shown in below fig and configure for ePWM8A. Similarly enable DMA channel3 for ePWM9A.
Capture.JPG
  2 commentaires
Gauthier Mervillie
Gauthier Mervillie le 18 Mar 2019
Hello Venkatesh,
Indeed, I also tried this weekend to do this with succes. Although everything works fine, I see that the phase offset only works for on the pulses of the PWM and not on the simulated sine wave. Should I change the source begin adress to e.g. 'duty_cylce_table+167' to acquire a difference of 120° between my simulated sine waves?
Kind regards
Gauthier M.
Osvaldo Gonza
Osvaldo Gonza le 10 Juil 2022
Modifié(e) : Osvaldo Gonza le 14 Juil 2022
I have been following your question. I am also trying to implement a three phase inverter with a 120° phase difference using DMA with MATLAB and SIMULINK and I have the same issue. How can I acquire a 120° difference between the other sine waves?
Kind regards
Oswal

Connectez-vous pour commenter.

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by