Programming a microcontroller to conrol servos?

Ask and answer questions, share tips and resources for installing lighting and other electronics in your models.

Moderators: Sparky, Moderators

Post Reply
User avatar
MillenniumFalsehood
Posts: 17033
Joined: Tue Nov 16, 2004 5:23 pm
Location: Wichita, KS, USA
Contact:

Programming a microcontroller to conrol servos?

Post by MillenniumFalsehood »

I'm at a lost as to how to do this.

I want to use two servomotors to motorize the Imperial Shuttle. One will move the wings and cannons, and the other will extend the landing gear and ramp. I also want to use a microcontroller so I can push a single button to both raise the wings and lower the landing gear and ramp, as well as control all the lights and such.

Thing is, I have no idea how to accomplish this. I understand a bit about programming, but I'm not sure how to get the PIC to signal the servos.

Can someone offer some good advice on how to do this? The rest I can handle, but this is going to drive me crazy. I already have the mechanics worked out, I just need help on the electronics end of it.
If a redhead works at a bakery, does that make him a gingerbread man?

Ponies defeat a Star Trek villain? Give them a Star Wars award ceremony!
m_ubelaker
Posts: 61
Joined: Sat Jul 13, 2002 8:11 pm
Location: Central Washington, The State

Post by m_ubelaker »

You might try this guy. Bernie is great with PLC controllers and a sci fi nut to boot. http://www.theplcguy.com/
User avatar
Pat Amaral
Posts: 3730
Joined: Fri Jul 12, 2002 2:44 pm
Location: Ok, I'm here. You can start now

Post by Pat Amaral »

Pat A.
=============================
50% Nerd, 50% Geek, 100% Cool
Wug
Posts: 2363
Joined: Sun Sep 05, 2004 8:52 pm
Location: Kentucky

Post by Wug »

Hi MillenniumFalsehood,

A regular R/C servo, not a digital servo, has three wires coming out of it power, ground and the control line. The arrangement of the wires varies from manufacturer to manufacturer.

The control line carries a series of pulses from the receiver or microcontroller to the servo. The rotation of the shaft is proportional to the duration of the pulse sent to the control line of the servo. This varies a bit among manufacturers.

The refresh rate is around 40Hz or 50 Hz and isn't very critical. Most servos center with a pulse duration of around 0.0015 seconds. The limits of rotation are usually at 0.001 seconds and 0.002 seconds. However on some servos the limits are at 0.00075 seconds and 0.00225 seconds.

I hope I didn't screw up the units.

Mike
RossW
Posts: 198
Joined: Wed Oct 02, 2002 1:04 pm
Location: Toronto, ON

Post by RossW »

If you've not yet bought a PIC, compiler or programmer than check out this book: http://www.amazon.com/PIC-Microcontroll ... s=picbasic by John Iovine. This uses PicBasic Pro and a programmer from meLabs (who make PBP). It's a little expensive to get started, btw, but well-worth it (I only use PICs to do my lighting now). Amazon also lists PBP3 compiler and programmers.

It's what I used to get started on programming PICs. It has a chapter on servo motors and DC motors with sample code and schematic diagrams.
Doomgiver
Posts: 49
Joined: Tue Oct 27, 2009 9:46 am
Location: Kiel, Germany
Contact:

Post by Doomgiver »

Another very interesting project is the Arduino ( http://arduino.cc/en/ ). Especially for people without experience in programming PIC/Atmel, this could be very interesting. Controlling servos, motors, LEDs (with PWM you can easy simulate the Photon-Torpedo-Effect for Star Trek-Models or engine-flickering for every other Spaceship :shock: ) and much more.
Post Reply