how to control servo motor using the zilog
Hi there! I am trying to make a mini servo motor turn in both clockwise and anticlockwise direction using Zilog Z8F042APH020SC. There are 2 buttons. Button A is to turn the motor clockwise by 180° whenever it is pressed, while Button B does the same function except the motor is moving in the opposite direction.
The type of motor I am using is Cytron of the model C8.0C, however the product website does not have product specification, but I am able to find another product that I think is similar to the one I have; it is HS-55 Standard Feather Servo with pulse width control of 1500us.
I have attached the schematic and the codes are as below:
# include <eZ8.h>
void main (void)
{
long D;
int PButton = 0;
PBDD = 0x00;
PBAF = 0x08;
T1RH = 0x08;
T1RL = 0x00;
T1CTL0 = 0x00;
T1CTL1 = 0x03;
PButton = PBIN;
while (1)
{
switch(PButton)
{
case PB1:
for (D = 0; D < 300000; D++){}
T1PWMH = 0x01;
T1PWML = 0x80;
break;
case PB2:
for (D = 0; D < 300000; D++) {}
T1PWMH = 0x0C;
T1PWML = 0x80;
break;
default:
break;
}
}
}