This is an old revision of the document!


RC Servomotor

Servomotoren werden oft in ferngesteuerten (radio-controlled/ RC) Modellen eingesetzt und sind aufgrund ihrer Kompaktheit und ihres günstigen Preises nützlich für viele Anwendungen im Bereich der Robotik. Ein RC Servomotor beinhaltet einen eigebauten Gleichstrommotor, ein Getriebe, eine Messeinrichtung zur Bestimmung der genauen Rotorposition (meist ein Potentiometer) und die Fahrelektronik. RC Servomotoren werden mit einem externen Pulsweitenmodulierten Steuersignal (PWM) angesteuert. Das Steuersignal gibt eine (Ziel)Position für die Servo-Elektronik an, welche die angegebene Position der Motorwelle mit der geforderten vergleicht und bestmöglich anpasst. Das Steuersignal ist ein stetiges Rechtecksignal (siehe Bild)

Servomotoren haben drei Kabel:

  • Rot = Stromversorgung VCC (4.8–6V)
  • Schwarz = Masse
  • Weiß/Gelb = PWM-Input (unterschiedlich je nach Typ)

Das PWM signal has the following shape:

?400

1.0ms = farthest left position

1.5 ms = center position

2.0 ms = farthest right position

Electrical connection

Table of motor drive signals from ATmega128 to the actuator board.

servo_connection_table.jpg

Electrical connections

  1. Make sure all power is off.
  2. Connect the actuator board and main board with a 26-pin cable.
  3. Connect the RC servo motor to the actuator board, as shown in Figure 2.

Note: The signal wire (usually yellow or white) is towards the outer edge of the board.

  1. Connect the JTAG converter with the ATmega128 main board and the PC.
  2. Finally connect the power to the main and actuator boards.

Example code

/*-------------------------------------------------------------
Title:		RC Servo motor with Actuator Board
Date:		080327
Ver.:		1.1
Compiler:	AVR-GCC
Target:		ATmega128
Hardware:	ATmega128 controller board, Actuator board, RC servo motor
Author: 	Raivo Sell 2008
 
Notes:	Description: Moves slowly RC motor shaft from one edge to another.
---------------------------------------------------------------*/
#define F_CPU 14745600UL //CPU Frequency (influences delay function)
 
#include <avr/io.h>
#include <util/delay.h>
 
///////////////// Main function //////////////////////////////////
int main (void){
 
	// Set timer control registers
	TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(WGM11);
	TCCR1B = _BV(CS11) | _BV(WGM13) | _BV(WGM12); 
 
    	DDRB 	 = 0x30;  // PB5 & PB6 output
	ICR1   = 36000; // Sets the upper limit to Timer1 
    			//(creates 50 Hz signal) XTAL/8/256*50   14745600
	OCR1A  = 2700;  // Sets when the PWM signal should toggle.
 
	while(1){
		for(OCR1A=500;OCR1A!=5000;OCR1A++)  {_delay_ms(3);}
		for(OCR1A=5000;OCR1A!=500;OCR1A--)  {_delay_ms(3);}
	}
}
de/examples/motors/servo.1240494580.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0