Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

Implementation of DQ transform with TI C2000

0 votes
253 views
Hi

I am working on implement DSOGI PLL algorithm to perform dq transform on c2000 F280069 controller in external mode.

I use a RT BOX as AC signal to transmit the 3 phase controllable voltage signal from plant subsystem to controller subsystem, and use ADC module to receive the signal in controller side.

The first problem I faced is the value of d axis and q axis are not accurate as I expected (d should be 1 and q should be 0).

I tested it in offline simulation and result looks fine.

I also tested in Codegen mode I found out that if the discretization step size is about 1us , then the value will be more correct. However, only 100us is compatible with mcu.

So I replace my model with z domain blocks. But the value is still not so accurate like offline simulations.

Also,I used the trapzoidal method in my discrete model to generate the quaduature signal.

The second problem is that I try to design a phase jump event with parameter inlining function during simulation.

Hence, I used a controllabe voltage source in my plant subsytem.

and the question is I can not record the response for the event moment.

I know the trigger controls function in external mode. But I still can't get it how to use this function.

 

Thanks for your help!
asked May 16 by ian (14 points)

1 Answer

0 votes

> I also tested in Codegen mode I found out that if the discretization step size is about 1us , then the value will be more correct. However, only 100us is compatible with mcu.

Like you interpreted, the issue is in the continuous to discrete transformation.  

Note that without a Control Task Trigger in the C2000 model, the system is treated as continuous.  If you add a Timer Block, set the ADC to show the trigger port, and a add Control Task Trigger you'll model the discretized model behavior in your offline simulation.

You can see this in the small signal analysis of the SOGI cell with and without discretization.  Discretizing the system results in a 0.42 dB gain opposed to 0 dB at 60 Hz.  As you have suggested, you'll want to adjust the discretization technique to account for the desired gain at 60 Hz.

> But I still can't get it how to use this function.

Here's a link explaining how to setup triggering in the external mode.

A few relevant points for your application:

  • You want to choose an appropriate trigger signal that will only change once the phase jump occurs (likely frequency or Vd)
  • There is a limited amount of data captured in external mode and you want to capture a signal with slow dynamics relative to your sample rate.
    • You'll want to significantly reduce the number of scopes in your model so you have more samples per scope.
    • You'll want to increase the decimation in the Coder Options + External Mode tab.
    • You can increase the target buffer size in the Coder Options + Target + External Mode tab (e.g. 2000) for additional data.
  • Your angle value is not limited and does not have any roll over.  As the angle increases to very high values over time, the floating point value will lose resolution.  You'll want to adjust your integrator to wrap instead of using the "Mod" approach.
answered May 16 by Bryan Lieblick (1,949 points)

> How to export the data to MATLAB at the moment of the event occurs like the figure below ?

The Export to CSV from the scope is the only option at the moment for embedded targets.  You can will have to set up your external mode triggers such that you capture the event - for example, set the trigger channel to when the SRF Vd goes below 0.95.  

You can also time shift and set a delay.  See the following video at T=4:00 on how to configure this.  I find dragging the trigger in the active scope window to be most convenient, as explained in the video.

If the event is periodic and you want to capture just one instance, click the "Manual Trigger" option instead of the autotrigger.

> Also, how to design the event occured at a specified time?

It's not clear to me why the minima is different.  One theory is that the Decimation setting is set  too high (40) as you are capturing just one sample showing the minimum value. There are 39 samples you may be missing that show the true minimum. I would decrease the decimation to get more samples during the transient event to see if the results are more consistent.

I think i got the desired results. Thanks a lot!

Hello I have another question

I need to implement a derivative function in my model and I found the c-script file for derivatives in the forum.

https://forum.plexim.com/9/why-is-there-no-derivative-block-in-the-component-library?show=9#q9

It can simulate with variable solver. But for running with dsp, it shows poor response.

Are there any other approaches that can be used for derivative function with dsp simulation?

Is PID controller can be treat as a derivative function?

Thanks!

As mentioned in the forum post you linked, derivatives have some less-than-ideal numerical properties when it comes to their practical implementation.  In real-time implementations there is quite a bit of sensitivity to noise.

One approach would be to use a transfer function block with G(s) = s / ( s + 2*pi*fc).  This adds a real-pole such that the derivative action is neutralized above fc.  You should choose fc based on your application.  See the related discussion for the PID blocks.  I would also suggest looking at the discrete PID block's derivative implementation as it implements different discretization techniques for the derivative implementation.

To make use of the derivative in PID, setting Kp,Ki as 0 and Kd=1. And Kf depends on the model.

So the G(s) is a low pass filter to filter noise before proceeding PID controller.

Is what Kf does the same as G(s), both filtering out noise?
...