Go Down

Topic: PWM signal, Software or Hardware ? (Read 3088 times) previous topic - next topic


Hi i use 18 servos in my hexapod, and use PIC16F877A, I use the PWM Software, but has the big problem..
Pic is Old ! And i use now Arduino, i think in AT1280...
I do not want to use software PWM, the controller only makes this routine ever!
I need a PWM signal to my 18 servo, and i need to use the microcontroller Free sensors.(Need Microcontroller to Servos and Sensors, Not Only in servo)
Now the question, I use the Hardware PWM? What would be the best for this application arduino? I need I program the microcontroller, not buy complete or plug and play.
Or microcontroller, i see the shield Arduino PWM, with 32 PWM!
Uses Texas Instruments TLC5940.
Please help me I need your help.
Thats My Hexapod!.

Tank You



You should look at the current "servo" library (http://arduino.cc/en/Reference/Servo )
This supports up to 48 servos on the 1280, and uses an approach that combines the use of hardware and software, so that you can control more servos than there are hardware PWM outputs.   The servo signal itself is NOT easily produced by a hardware PWM pin; the ratio of ON time to OFF times is too small.  See my diagrams here: http://www.flickr.com/photos/58843278@N00/3927527975/in/set-72157601072004330/


May 05, 2011, 02:39 am Last Edit: May 05, 2011, 02:58 am by jcrazy Reason: 1
Using the PWM hardware and software, I will not take up the routine of 1280 forever? (while in C), and want to generate PWM using line sensor, it would be possible as you said.
In my case I used the PIC PWM Software and occupied the whole routine of the PIC.

Thats example of my Program.

#use delay(clock=20000000)

unsigned int D1;
int time;
void main()




Ever in while :/ to generate the PWM.
This only example my Atmega1280 is here. :)

Only i use Delay right ? Solve my problems


Using the Arduino Servo library, dealing with the actual timer hardware is hidden for you, and your code would look something like:
Code: [Select]
Servo D1_servo;  /* Servo object for internal use. */
static const byte D1_pin = 18; /* pin number for D1 servo */

void setup() {
  D1_servo.write(117);  /* move to initial position */
  /* Other setup code */


Your code ocupies all the cpu yes, but remenber, that servos operate in the ms scale so you can have all interrupt driven and so more than just software pwm, the key point is timers and interruptions, but leave the PIC16F its a pretty old and very limited device.


May 05, 2011, 04:52 am Last Edit: May 05, 2011, 03:38 pm by jcrazy Reason: 1
Ok, So to my problems, I'm trying to understand 100% what you are giving me.
I'm creating my code, my 18 servos are working  (hexapod walking) and with a sensor line.
That would be possible using my ATmega1280 correct?
I need to find the point where I no longer use the timer?
Or I use delay, in order to use the sensor line.
Sorry I got confused.
I need to study of course.

Go Up