0 votes

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!

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!

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.

The simulation is showing that the discretization method impacts how the PLL performs. The default discretization method in PLECS for your continuous model implementation shows the additional gain at 60 Hz. There are many references on different discretizaiton methods and several papers on discretizaiton approaches for the SOGI PLL specifically.

Researching this and choosing the correct approach is an engineering decision on your part. PLECS will be helpful in analyzing how the different approaches perform in both the time and frequency domain.

I'd recommend using the wrapping integrator as you outlined. I can't comment on the problem you noticed, but if the error got worse over time, then the floating point value accuracy could be the cause.

Researching this and choosing the correct approach is an engineering decision on your part. PLECS will be helpful in analyzing how the different approaches perform in both the time and frequency domain.

I'd recommend using the wrapping integrator as you outlined. I can't comment on the problem you noticed, but if the error got worse over time, then the floating point value accuracy could be the cause.

I have modifiied the model by adding a Timer Block and control trigger with ADC, and simulate it with c2000 mcu. The figure below is what I got on d axis component. (SRF in green,SOGI in red)

The question I have is how to display the waveform properly in the external mode.

In the figure, it seems to zoom in too much and the results looks weird.

Is there any solution to zoom out and make the waveform more reasonable?

Thanks!

Thanks, I solved the display problem.

From the initial post, I wondering that the small signal analysis shows with discretization have additional gain while without discretization does not have. Is it means without other discretization method is fine in the model ?

I'm also wonder how to generate the frequence response like the figure in the initial post. I know this function is in the "analysis tools" and select 4 different analysis method. Later, add the small signal peturbation at the input and add small signal response at the output. I tried it in my continous model using steady state analysis and it shows that it fails to converge. How to solve this issue in my model?

Best regards

Thanks a lot!

From the initial post, I wondering that the small signal analysis shows with discretization have additional gain while without discretization does not have. Is it means without other discretization method is fine in the model ?

I'm also wonder how to generate the frequence response like the figure in the initial post. I know this function is in the "analysis tools" and select 4 different analysis method. Later, add the small signal peturbation at the input and add small signal response at the output. I tried it in my continous model using steady state analysis and it shows that it fails to converge. How to solve this issue in my model?

Best regards

Thanks a lot!

> I tried it in my continous model using steady state analysis and it shows that it fails to converge.

I believe I used multitone analysis to generate the plots, which achieves steady state by a transient simulation until all disturbances settle. There's a tutorial on Analysis Tools which might be helpful to better understand how they work.

Your original model will likely not reach steady-state because that requires a periodic operating condition. The states in the integrators never reach a periodic operating condition because they keep integrating towards infinity. That's another benefit of using the wrapping integrator we discussed above.

Thanks!

I have several problems when I try to design the phase jump event. Attached is the model file.

**First question:**

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

I know there is a function of "export csv" in the scope, but the response is so quick that I can not export it.

Is there any other way can achieve it ?

**Second question: **

The response of SRF-PLL one is different everytime in the same case.

As the below figure shows, the lowest value of green one(SRF-based) ranges from 0.87 to 0.97.

I suspect the theta of PLL is the probable cause, but I have no idea how to deal with.

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

Thanks for your help!

> 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.

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?

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?

What I wrote might be a bit confusing, but essentially the G(s) transfer function above is exactly the same as the derivative term in the PID controller D(s)=Kd*s/(s/Kf + 1) ( from the PID block help, with Kd =1 and Kf = 1/(2*pi*fc)).

I was attempting to show a) how to choose Kf per the linked post and b) that discretization techniques might be relevant.

I was attempting to show a) how to choose Kf per the linked post and b) that discretization techniques might be relevant.

...

First of all, is it necessary to implement this model in discrete domain?

Because I not sure this is a correct step or not. Or just continuous domain implementation is fine?

>you'll want to adjust the discretization technique to account for the desired gain at 60 Hz.

Is this means the discretization model somewhat have problems cause the db magnitude is nonzero value in the small signal analysis?

>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.

I noticed a problem before, which is the magnitude will change as the time goes. Is this issue give rise to this problem? Therefore, to deal with this problem, I have to turn on "enable wrapping" in discrete integrtor and set the upper limit as 2*pi. Is that