Delay code for orthogonal signal

Hi, I want to create orthogonal signals with C block but, I cannot.
Can you help me, please?

the c math libraries are available so you can use the sin and cos functions in the c block.

Using a “static” variable will allow you to track theta for the calculations.

Thanks for your helping. I try but I cannot. Do you have any code?

static double theta = 0;
double freq = 60;

theta = theta + freq*2*3.1415926/1000;

y1 = cos(theta);
y2 = sin(theta);

This code should exectue at 1kHz to achieve a 60 Hz output, for faster interrupts change the “/1000” to the new frequency.

Thanks for your reply. For example, I have an sine input, how can give a delay for this signal (as two orthogonal signal)?

Hi Yasaf,

Continuing on the Albert’s code.

Let say your input y1 = sin(theta);
y2 (delay one)= -sin(theta-pi/2);…If you delays your input by pi/2 and make it negative, then y2 is actually cos (theta). Then y1 and y2 are orthogonal now.

What kind of ckt. u are working on? What’s your PSIM schematic look like?

Hi Amit
I send a file. Can you control it, please?
orthogonal signal.psimsch (12.0 KB)

Hi Yasaf,

Try this with Simplified-C-Block. You can watch this video to get know more about this.

Regards,
Amit