control a servo motor according to a 3-state switch



This simple micro-control circuit controls a servo motor according to a 3-state switch. A servo motor acts as an actuator in 3 position. It has 3 wires, one for VCC, one for Ground and another one for position control. The last signal is a single pulse with variable width. The pulse width can vary between 1 and 2 mSec. An 1 mSec pulse width turns the motor axis in -45 degrees position. An 1.5 mSec pulse width turns the motor axis in 0 degree position. A 2 mSec pulse width turns the motor axis in +45 degrees position. The following source code has been written in PICBasic:


Symbol porta = 5
b3 = 150
start:
Peek porta,b0
If bit0 = 0 Then sweepl
If bit1 = 0 Then sweepr
Pulsout 0,b3
Pause 18
Goto start
sweepl:

b3=b3-1

Goto start


EmoticonEmoticon

Advertisement