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