Pages: [1]   Go Down
Author Topic: Want to generate PWM of 30 hz and 60 hz on single pin of the arduino board  (Read 1283 times)
0 Members and 1 Guest are viewing this topic.
Indore
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Working on Quadrotor Helicopter these days
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}
Logged

Mayank Gupta

Pages: [1]   Go Up
Jump to: