Generating a phase between two PWM signals

Hi,

In fact, I want to have a phase between two PWM signals. Here is a simple code that generates two PWM signals at the frequency of 100 KHz :

  // #include <PWM.h>

  // #include <PWM.h>

   // int pwm1 = 9;
   //  int pwm2 = 10;

  //   int32_t frequency = 100000; // desired frequency in Hertz

    // void setup()
   // {
          //   InitTimersSafe(); 
           //    bool success = SetPinFrequencySafe(pwm1, frequency);
           //    bool test = SetPinFrequencySafe(pwm2, frequency);
        //  }

  //   void loop()
   //  {
   // pwmWrite(pwm1, 90);
   //  delay(120);
   //  pwmWrite(pwm2, 90); 
   }

But I want to have a phase between the two signals and thanks in advance

I don't think the PWM library lets you do this.

you could read this article and configure timers the way you want

if you don't use your successs variable, don't declare it (twice!), and just don't read the return value.


Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

The problem for that code is that you cannot go for higher frequencies. In my case the use of PWM allows me to get higher frequencies

Sorry but that's not a very informed comment (ie it's BS, timers will get you very close to the max capability of the hardware)

here is another link to also read (or anything on timers)

I'm pretty sure that Pin 9 and Pin 10 are completely in phase because they are both on Timer1. Setting one Output Compare Register 120 milliseconds after the other does nothing to change relative phase.

Since the phase difference is 0, what do you mean by "a phase between"?

johnwasser:
I'm pretty sure that Pin 9 and Pin 10 are completely in phase because they are both on Timer1. Setting one Output Compare Register 120 milliseconds after the other does nothing to change relative phase.

Since the phase difference is 0, what do you mean by "a phase between"?

If they are in phase, then why do we say 'phase correct' and 'frequency correct' PWM signals?

What phase angle do you want between the two?

A 100kHz square wave has a period of 10uS. You appear to be trying to put them 120mS "out of phase". Thing is, 120mS is exactly 12000 cycles of a 100kHz waveform so the two waveforms would technically be "in phase" anyway.

Can you draw an image of what you're trying to achieve or better describe it?