Delay code for orthogonal signal

Altair Forum User
Altair Forum User
Altair Employee
edited August 2023 in Community Q&A

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

Tagged:

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2023

    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.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2023
    Albert_Dunford:

    static

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

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2023
    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.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2023

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

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2023

    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?

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2023

    Hi Amit
    I send a file. Can you control it, please?

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2023

    Hi Yasaf,

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


    https://www.youtube.com/watch?v=HreH4Cx-a94

    Regards,
    Amit

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2023

    Yes I found the information useful it helps me from your code albert since i am also finding answer for this
    even I tried this PrepaidGiftBalance and get worth result.