PSIM Sim Coder F28004x Target - ePWM EXTSYNCINx configuration
Hi all,
I am using the TMS320F280049C control board along with TMDSHSECDOCK to do some testing . I am using the Sim Coder and the code generation functions that PSIM provides for F28004x Target.
I need a specific feature of F280049C which is synchronization to an external signal. I would first need to use Input X-Bar to input the external signal that I want to sync to and secondly, configure the ePWM1 sync input to be either EXTSYNCIN1 or EXTSYNCIN2. These features are described in the control board datasheet, however, I am not able to find a way to configure the second step using PSIM Sim Coder F28004x Target blocks.
Has anyone faced this problem before?
I look forward for your replies.
Thanks,
Denys
Best Answer
-
Hi Denys,
The simulation unfortunately will not show the sync as you need to add some code manually. If you want to recreate the synch in simulation you will have to have a simulation that does not have code gen.
2 simulations are attached. one that drives a square wave and the other with the sync setup using the xbar
Do the following
- Add an input X_Bar block to the schematic and set INPUT5 to GPIO2 (can be any GPIO port).
- Add a PWM X-Bar block in the schematic and select INPUTXBAR5 as PWM X-Bar signal.
- Generate the hardware code and manually add the following function call (PS_PwmSetPhaseDelay)just after PWM1's initialization function call (PS_PwmInit).
The attached 2 schematics works fine on hardware boards, see the waveforms below:
1
Answers
-
Try below, you will need to add a custom line of code. Also, through units you will also have access to Altair Embed, it may support this requirement and you can use the wrapper functionality to import you generated c code from PSIM in Embed, here is a PDF that explains how
****
I will try to answer the question for F280049 as follows (Assume that the customer uses PWM1, PWM2 and PWM3):
- In the schematic, add the input X-BAR block, and set INPUTXBAR5 to use, and specify a GPIO port (say GPIO40)
that links to the external sync. Signal.
- Keep all synchronized PWMs at the same sampling rate.
- If PWM1 needs a phase shift, add the following code after PWM1's initialize function in function Initialize():
// Assume the first synchronized PWM is PWM1
PS_PwmInit(1, .... // PWM1 initialization
PS_PwmSetDeadBand(1... // these 2 statements are generated by SimCoderPS_PwmSetPhaseDelay(1, 1, (-45) * (1.0 / 360.0)); // this is added manually. assume phase shift is -45.
EXTSYNCIN1 in F280049 is used as below:
In PWM SYNCSELECT register, EXTSYNCIN1 is as a default, no need to change anything for this register.
Input X-Bar block can be set as follows:
Please try it out!
0 -
Hello Albert,
I appreciate your reply.
I'll try to picture what I'm trying to achieve first, so you can have an idea why I have to use the ePWM EXTSYNCIx. The main idea is to synchronize the internal PWM sawtooth to an external signal (square waveform) instead of internal clock cycle.
From what you have explained it is clear how to input the square signal with the GPIO Input X-Bar. However I have my doubts on how to configure the PWMs to sync with the EXTSYNCIx. Consequently, here are my 2 questions related to this fact:
- In the Texas Instuments datasheet they always talk about ePWM, however I am not able to find this specific name in the available Sim Coder blocks. Does this mean that in PSIM an ePWM can be represented as a 1-phase PWM block?
- Considering Table 18-106. SYNCSELECT Register Field Description you posted, does it mean that any input signal at INPUTXBAR5 will automatically act as default sync signal?
In order to verify these points I made a simple .psimsch (attached to this answer in .ZIP format) taking the assumptions from the above questions. I will describe its simple configuration.
INPUTXBAR5 is configured to be GPIO2 (defined as digital input in Hardware Config block). Its input signal is a square wave VSQ1 with its parameters on the left in order. PWM1 outputs are set to GPIO0 and GPIO1 (both defined as PWM in Hardware Config block). DSP Clock is set to internal oscillator 1 at 100MHz DSP speed.
From the results I got (figure a) you can see that there is no synchronization to the external signal. Also I have posted the result I would like to get (figure b), to make it clearer.
Looking forward to hearing from you. Thank you very much.
Regards,
Denys
0 -
Hi Denys,
As Albert suggested to you, Altair Embed can be used to easily solve your issue. To demonstrate this, I quickly put together the attached diagrams in Embed.
The results are here:
I have tried to duplicate your desired result in Embed and in accordance with your expected result, I have generated a square-wave of approx. 3x the period of the PWM frequency and included an enable sync button so that you can see the difference when not synchronized. The PWM is enabled on the first rising edge of the square-wave. I believe that this is what you are trying to do. The attached files include many explanations of the process involved in developing this type of routine. I have also attached a video which shows the PWM synchronization in action on the F280049 launchpad using the Embed target interface diagram.
I hope that this result will assist you in trying this out in Altair Embed!
1 -
Hello Anthony,
Thanks for your response.
The results you show below are exactly what I was trying to replicate in first instance using Altair PSIM: Synchronize a PWM with an external signal where, every time the input sync signal has a rising edge the PWM signal is reset.
However, you suggest the solution with Altair Embed which, according to my research license, I do not have access to. Therefore, I have to limit myself to the implementation using only Altair PSIM.
I appreciate your contribution to this thread!
Regards,
Denys Ovsiyenko
0 -
Hi Denys,
You can contact your local Altair sales representative for a trial version of Embed or you may be applicable for an academic license. If you are using Altair units, you can use the units for licensing of PSIM and for Embed.
Otherwise, Embed also provides an Embed Viewer which you can download on the Altair One Portal. With the viewer you can view and run Embed diagrams but you cannot modify them. I could provide the compiled .out file for the previous example.
Embed will also run together with PSIM in co-simulation.
Anthony
0 -
Denys Ovsiyenko_21270 said:
Hello Albert,
I appreciate your reply.
I'll try to picture what I'm trying to achieve first, so you can have an idea why I have to use the ePWM EXTSYNCIx. The main idea is to synchronize the internal PWM sawtooth to an external signal (square waveform) instead of internal clock cycle.
From what you have explained it is clear how to input the square signal with the GPIO Input X-Bar. However I have my doubts on how to configure the PWMs to sync with the EXTSYNCIx. Consequently, here are my 2 questions related to this fact:
- In the Texas Instuments datasheet they always talk about ePWM, however I am not able to find this specific name in the available Sim Coder blocks. Does this mean that in PSIM an ePWM can be represented as a 1-phase PWM block?
- Considering Table 18-106. SYNCSELECT Register Field Description you posted, does it mean that any input signal at INPUTXBAR5 will automatically act as default sync signal?
In order to verify these points I made a simple .psimsch (attached to this answer in .ZIP format) taking the assumptions from the above questions. I will describe its simple configuration.
INPUTXBAR5 is configured to be GPIO2 (defined as digital input in Hardware Config block). Its input signal is a square wave VSQ1 with its parameters on the left in order. PWM1 outputs are set to GPIO0 and GPIO1 (both defined as PWM in Hardware Config block). DSP Clock is set to internal oscillator 1 at 100MHz DSP speed.
From the results I got (figure a) you can see that there is no synchronization to the external signal. Also I have posted the result I would like to get (figure b), to make it clearer.
Looking forward to hearing from you. Thank you very much.
Regards,
Denys
Hi Denys,
I hope to have a response for you soon about this setup.
-AD
0 -
Hi Denys,
The simulation unfortunately will not show the sync as you need to add some code manually. If you want to recreate the synch in simulation you will have to have a simulation that does not have code gen.
2 simulations are attached. one that drives a square wave and the other with the sync setup using the xbar
Do the following
- Add an input X_Bar block to the schematic and set INPUT5 to GPIO2 (can be any GPIO port).
- Add a PWM X-Bar block in the schematic and select INPUTXBAR5 as PWM X-Bar signal.
- Generate the hardware code and manually add the following function call (PS_PwmSetPhaseDelay)just after PWM1's initialization function call (PS_PwmInit).
The attached 2 schematics works fine on hardware boards, see the waveforms below:
1 -
Hello Albert,
I appreciate your answer!
You explanation is more than clear, however there are 2 little things I would like to clarify:
1-Yoy said "If you want to recreate the synch in simulation you will have to have a simulation that does not have code gen." Do you mean using PSIM/SPICE blocks? Please, can you provide an example for it.
2-In step nº2 you add a PWM X-BAR block to set TRIP referenced to INPUTXBAR5. However, you are using PWM1 which is internally connected to EXTSYNCIN1 (INPUTXBAR5). Please check the image with the sync chain block diagram here below. What is the purpose of PWM X-BAR here? Would it be useful to sync other PWMs besides the PWM1?
Awaiting your reply
Best,
Denys Ovsiyenko
0 -
Denys Ovsiyenko_21270 said:
Hello Albert,
I appreciate your answer!
You explanation is more than clear, however there are 2 little things I would like to clarify:
1-Yoy said "If you want to recreate the synch in simulation you will have to have a simulation that does not have code gen." Do you mean using PSIM/SPICE blocks? Please, can you provide an example for it.
2-In step nº2 you add a PWM X-BAR block to set TRIP referenced to INPUTXBAR5. However, you are using PWM1 which is internally connected to EXTSYNCIN1 (INPUTXBAR5). Please check the image with the sync chain block diagram here below. What is the purpose of PWM X-BAR here? Would it be useful to sync other PWMs besides the PWM1?
Awaiting your reply
Best,
Denys Ovsiyenko
Hi Denys,
I'll let my firmware colleague answer your question in more detail.
Want I mean to say for the peripheral action is that you'll have to have a simulation without hardware targets. You can use subcircuits so that the control remains the same for your simulation vs code gen schematics.
I attach an example of using a sync signal to reset the PWM. you can see how the PWM waveform carrier Vcar, is resetting with the sync command.
the bit circled in green would be your emulation of the peripheral
0 -
Hi Denys,
1-Yoy said "If you want to recreate the synch in simulation you will have to have a simulation that does not have code gen." Do you mean using PSIM/SPICE blocks? Please, can you provide an example for it.
PSim doesn't support ePWM1(or PWM1) accepting a sync signal.
2-In step nº2 you add a PWM X-BAR block to set TRIP referenced to INPUTXBAR5. However, you are using PWM1 which is internally connected to EXTSYNCIN1 (INPUTXBAR5). Please check the image with the sync chain block diagram here below. What is the purpose of PWM X-BAR here? Would it be useful to sync other PWMs besides the PWM1?
Each signal sent to ePWMx must pass though PWM X-BAR.
Thanks,
Jiakai
0 -
Albert Dunford_20896 said:
Hi Denys,
I'll let my firmware colleague answer your question in more detail.
Want I mean to say for the peripheral action is that you'll have to have a simulation without hardware targets. You can use subcircuits so that the control remains the same for your simulation vs code gen schematics.
I attach an example of using a sync signal to reset the PWM. you can see how the PWM waveform carrier Vcar, is resetting with the sync command.
the bit circled in green would be your emulation of the peripheral
Thanks Albert!
0