Control position of servo motor

Status
Not open for further replies.

Wingmax

New Member


With little modification from the previous program (Driving a servo motor-Timer0, Timer2), we can control the position of the servo motor.

View attachment servo_con.txt

A switch is connected to PortA.1 and PortA.2.
The shaft will be at the middle position first. When switch_A is pressed, it'll move one step to the left. When switch_B is pressed, it'll move one step to the right.
 
Reactions: vdd
Cool. Thanks mate. I just cut and paste some of your codes and modified a bit, and it works for my project.
 
Servo Motors are Actually used for precision control. And so is their use in robotics. Can you please describe in detail how to control the amount of movement on either side.
 
This is not a super accurate positioning control program. It's more like RC car or joy stick control.
The servo motor position is controlled by the input pulse width. If you read my program , you'll find that each time a button is pressed the pulse width is adjusted by +/- 80uS. The starting position is in the middle. So each time a button is pressed, the shaft is moved away from the middle position by the pulse width of 80uS.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…