PWM Signal on Pin 9

Hi,

I would like to control four esc with my arduino. I read a lot about PWM implementation
and finally I came up with timers. For testing reasons, I started with the attached code.
Everything works fine, the desired PWM signals can be measured correctly on pin 3, 10 and 11.
But on pin 9 the signal is very noisy (attached diagram) and the amplitude is also lower.
I have no idea what’s happening.

define NUM_MOTORS  4

uint8_t PWM_PIN[4] = {9,10,11,3};



void setup()
{

initOutputPins();

}

void loop(){
 
}


//Ausgabe Pins zuweisen
void initOutputPins()
{
  
  //Delegate Output pins
  for(uint8_t i=0; i<NUM_MOTORS; i++){
   pinMode(PWM_PIN[i],OUTPUT); 
  }
  
  //Timer and register 
  TCCR1A |=_BV(COM1A1); //pin9 to timer 1 channel 1
  TCCR1A |=_BV(COM1B1); //pin10 to timer 1 channel2
  TCCR2A |=_BV(COM2A1); //pin 11 to timer 2 channel 1
  TCCR2A |=_BV(COM2B1); //pin 3 to timer 2 channel 2
//  

  OCR1A = (1000>> 3); //pin9
  OCR1B = (1200>> 3); //pin10
  OCR2A = (2000>> 3); //pin11
  OCR2B = (500>> 3) ; //pin3
}

asd (1.62 MB)

I would like to control four esc with my arduino.

I’d recommend using the Servo library which will allow you to control up to 12 ESC’s on a standard Arduino.

#include <Servo.h>

const int NUM_MOTORS = 4;
const int PWM_PIN[NUM_MOTORS] = {9,10,11,3};
Servo myServos[NUM_MOTORS];

void setup()
    {
    for (int i=0; i<NUM_MOTORS; i++)
        {
        myServos[i].writeMicroseconds(1500);  // Set initial position/speed
        myServos[i].attach(PWM_PIN[i]);
        }
    }

void loop()
    {
    }

That looks to me like your scope is set to AC coupling. At the very least it suggets there is a capacitor in series somewhere in the circuit.

But why only on Pin9 ? I use the same setup for all measurements and there is no noise on the other pins.

Broken trace on the Arduino? Try probing the processor pin directly.

Well, I looked up the corresponding pins of the processor in the datasheet and measured directly. I measured exactly the same except the corresponding processor pin for digital output pin 9. Same signal like my posted diagram. Is my arduino broken?

Are you sure there is nothing else on that signal line that is impacting it?