Go Down

Topic: Want to generate PWM of 30 hz and 60 hz on single pin of the arduino board (Read 1 time) previous topic - next topic

Mayankipsa

First of all thanks for reading this.

I m able to change the frequency of the pwm signals generated by the servo.write()function by changing the code in the servo library .So i can get the PWM of desired frequency.

code from servo.h where i have made changes to get pwm of the desired frequency:
from
#define MIN_PULSE_WIDTH       544     // the shortest pulse sent to a servo
#define MAX_PULSE_WIDTH      2400     // the longest pulse sent to a servo
#define DEFAULT_PULSE_WIDTH  1500     // default pulse width when servo is attached
#define REFRESH_INTERVAL    20000     // minumim time to refresh servos in microseconds


to
#define MIN_PULSE_WIDTH       544     // the shortest pulse sent to a servo
#define MAX_PULSE_WIDTH      2400     // the longest pulse sent to a servo
#define DEFAULT_PULSE_WIDTH  1500     // default pulse width when servo is attached
#define REFRESH_INTERVAL    33333   // minumim time to refresh servos in microseconds


After changing the above code i m able to get PWM of frequency 30hz(and period of (1/30)sec=33333 usec)


Now my problem is that i want to generate PWM of both 30HZ and 60 HZ on the same pin of the arduino alternately...please help me in this regard

The programme to generate PWM i used is ;

#include <Servo.h>
Servo servo00;
int pwm1 = 10;
void setup()
{
  pinMode(pwm1, OUTPUT); //10 pin as OUTput pwm1
  servo00.attach(10);    //10 pin  is attached as output for motor1
}

void loop()
{
  servo00.write(180);
  delay(3000);
}
Mayank Gupta

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy