Schematic and program of a Microchip PIC16F873 controlled  dc-motor
used in a 2-engine patrol-ship
last update: 01/16/2002
author: Guenther Geissler,Germany

1.) block diagramm:
load this sheet as pdf: block.pdf
1.1) Description of block diagramm:
As you see, the block diagramm consists of 4 different blocks:

2.) servo_heart:
load this sheet as pdf: heart.pdf
2.1)Description of servo_heart:
Lets read the schematic from the left to the right: The poweraccu (usually 3-10 cells, depending on the motorvoltage) supplies 3.6 to 12VDC to the circuit.
IC1 is a linear technology DC/DC-step-up-converter, performing a constant voltage of 11.5V between D1 and D2. This voltage is used to load the 9V-accumulator.
IC2, also linear technology, is a DC/DC-step-down-converter. It delivers a constant 5V-Voltage to the servo_brain_circuit and the servo_receiver.
Background: If the poweraccu goes out of power, servo_brain assures that there is enough power for the control-circuits. Also it reduces the influence of oscillation
on the poweraccu-voltage.

3.) servo_muscle:
load this sheet as pdf: muscle.pdf
3.1)Description of servo_muscle:
This circuit is well known as "H-Bridge". Input on JP1, from brain, depends on the teach-in-procedure descibed later. One Pin (1 or 2) is switched to ground, while the other
Pin (2 or 1) serves a  0 to 5V PWM-Signal.
Lets say, Pin 1 is grounded by PIC-Controller, Pin 2 serves a PWM-Signal:
First examine Pin1:
- Pin 1               ---> 0V
- T6,T2,T3         ---> Collector Emitter open
Second examine Pin2 (PWM):
- Pin 2               ---> 0V
- T5,T1,T4         ---> Collector Emitter open
DC-Motor on JP4 rotates not.
- Pin 2               ---> 5V
- T5,T1,T4         ---> Collector Emitter closed
DC-Motor on JP4 rotates.

Depending on the Pulse-Width on the PWM the motor rotates slower or faster.

If Pin 2 is grounded and Pin 1 serves the PWM-Signal, the procedure is the same, but mirrored:
T5,T1,T4         ---> Collector Emitter open, T6,T2,T3         ---> Collector Emitter open/closed
motor direction changed
Please use wire-thickness >= 1mm for Ground and V-Batt and connect them directly to the power-accu.

4.) servo_brain:
load this sheet as pdf: brain.pdf
4.1)Description of servo_brain:
The UController PIC 16F873 could be programmed via a ICP (in circuit programming) interface, connected to JP1. I used a micochip MPLAB-ICD,worked fine.
Q1 is a 500kHz ceramic-resonator, I  choiced a JTB455E from company Jauch. After TeachIn the PWM-Pulse is available at Pin13/IC1, Pins14 and 15 control the
direction of motors rotation.
After programming connect the servo-receiver to JP2 (signal & ground), dont forget to connect also +5V from servo_heart to the servo_receiver.
Teach In procedure:
Switch your radio control on, control stick in middle position.
Press push button SW1 once -> red LED lights up.
Move the control stick to maximum forward position until red LED turns off and yellow LED lights up.
Move the control stick to middle position until yellow LED turns off and green LED lights up.
Move the control stick to maximum backward position until green red LED turns off .
Teach values are stored in the internal eeprom.
click here to download the hex-file: servo.hex
program with option: no watchdog