Abc->alfabeta->dq transformation in c-script

Hi All,

I am looking for an advise what I am doing wrong in the c-script code in terms of transforming currents from abc to alfabeta and alfabeta to dq. The file with relevant code is attached.

Any advise is highly appreciated.

BR,
Kamil
20250122_abcalfabetadq_picontrollers.plecs (44.7 KB)

There are two basic errors in your model.

  1. The Multiplexer block is flipped such that the signal order in the C-Script doesn’t align with the inputs (i.e. currents in indices 4-6 in signal vs 1-3 in C-Script).
  2. You never assign A.alphabeta and so alpha_out and beta_out are always zero. Lines 12-13 in your Update function code were pointing to the dq variables instead of the alphabeta variables.

You also are inserting an extra one model step delay in your alpha-beta calculations. See the “Eliminate One Cycle Delay” section of the C-Script tutorial for additional information.

Attached is a modified version of your code fixing the issues and comparing the impact of the delay.
20250122_abcalfabetadq_picontrollers_bl.plecs (51.3 KB)

@Bryan_Lieblick Thanks for clarification! Highly appreciated.