The design is a simple PIC based servo motor
controlled CCTV camera which will use a joystick to control the direction of
the camera. The microcontroller used is pic16f84A which is an 18 pin Integrated
Circuit and may be supplied by a 2 to 5.5 Voltage. The motion of the camera is a 2 degrees of freedom, can
be side to side which is the left or right direction, and the up or down
direction.
CIRCUIT DESCRIPTION
The power supply used is a fixed 5 volts since
the Servo motor can only accomodate 3 to 6 volts which is also the same for the
PIC microcontroller then the supply is connected to pin 14 of the PIC
microcontroller. Capacitors of 22pF are used to increase the stability of the
oscillator which is then connected to ground and to the crystal of 8Mhz which
will serve as the clock frequency and is connected to pin 16 and 15 which is
the clock in and clock out respectively. The joystick is connected to a
resistor to enhance stability of the signal. The joystick is connected to pins
1, 2, 17, 18 which serves as the input
of the design, and in Vcc. Pin 17 is for the upward motion, 18 for the
downward, 1 for the right, and lastly pin 2 for the left motion.
The output pulse
of the portb pin0 of our microcontroller is the input pulse of our servo
no.1,and the output pulse of the portb pin4 of our microcontroller is the input
pulse of our servo no.2.
If the pulse is 1.5ms on
and 18.5ms off the servo motor goes to its 0o.
If the pulse is 2.5ms on
and 18.5ms off the servo motor goes to its +90o.
If the pulse is 0.5ms on and 18.5ms
off the servo motor goes to its -90o.
Source
code
int a=150;
int b=150;
void main() {
TRISA=0xff; //set portA as input ports
TRISB=0x00; //set portB as output
ports
while(1){
PORTB=0x01; //make portB pin0 high
vdelay_ms(a/100); //maintain portB pin0 high for
a/100 ms
PORTB=0x10; //make portB pin4 high
vdelay_ms(b/100); //maintain portB pin4 high for
b/100 ms
PORTB=0x00; //make all portB low
delay_ms(37/2); //maintain all portB low for
18.5 ms
if(RA0_bit){ //when portA pin0 is
pressed
if(a>=250)
continue; //set maximum value
for a=250
a=a+10; //increment a=a+10
}
if(RA1_bit){ //when portA pin1 is
pressed
if(a<=50)
continue; //set minimum value
for a=50
a=a-10; //decrement a=a-10
}
if(RA2_bit){ //when portA pin2 is
pressed
if(b>=250)
continue; //set maximum value
for b=250