Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Radiken on May 19, 2007, 08:50:35 PM

Title: Servo ports
Post by: Radiken on May 19, 2007, 08:50:35 PM
Do Servos/motors need to be plugged into a PWM port, or will a standard digital output port work.

I've read that they should be plugged into PWM ports, but do they still work with the digital output?
Title: Re: Servo ports
Post by: ed1380 on May 19, 2007, 09:29:36 PM
motors into pwm outputs and servos into digital. don't forget when using motors, h-bridge or motor drivers are needed, so you might need digital. it depends on the driver/h-bridge.

<-----NOOB
Title: Re: Servo ports
Post by: Admin on May 19, 2007, 09:42:40 PM
Which microcontroller?

PWM ports have the advantage that you can tell it to do something in software and then forget about it. With digital ports, you must call them every 100ms or so to run a servo.

The problem with PWM ports is that there are not very many on a microcontroller, often between 1 and 4. So this is why I always use digital outputs . . . the $50 robot only uses digital output . . .
Title: Re: Servo ports
Post by: Radiken on May 19, 2007, 09:48:11 PM
I'm putting my skills to the test by designing my first board from scratch using the PIC16F877.
I was curious on whether to set up the plugs for servos to connect to digital I/O ports or the PWM ports.

Looking at the datasheet, I can't tell whether the PIC16F877 has 2 or 4 PWMs...
Title: Re: Servo ports
Post by: JonHylands on May 20, 2007, 05:44:50 AM
The 16F877 has two, and they aren't really all that great for driving a servo, but you could do it.

Its easy enough to set up a timer interrupt to handle processing up to 8 or 9 servos on the 877 in the background, assuming you're running at a decent clock speed (8 MHz or more).

- Jon
Title: Re: Servo ports
Post by: Admin on May 20, 2007, 10:49:15 AM
Quote
Its easy enough to set up a timer interrupt to handle processing up to 8 or 9 servos on the 877 in the background, assuming you're running at a decent clock speed (8 MHz or more).
I did this method for my Fuzzy robot (http://www.societyofrobots.com/robot_omni_wheel.shtml). Download the source code here:
http://www.societyofrobots.com/downloads/fuzzy_C_source_code.zip