PICBASIC PLUS LITE Manual - Profe Saul
PICBASIC PLUS LITE Manual - Profe Saul
PICBASIC PLUS LITE Manual - Profe Saul
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>PICBASIC</strong> <strong>PLUS</strong> CompilerThe width of the pulse determines the position of the servo. Since aservo’s travel can vary from model to model, there is not a definitecorrespondence between a given pulse width and a particular servoangle, however most servos will move to the center of their travelwhen receiving 1.5ms pulses.Servos are closed-loop devices. This means that they are constantlycomparing their commanded position (proportional to the pulse width)to their actual position (proportional to the resistance of an internal potentiometermechanically linked to the shaft). If there is more than asmall difference between the two, the servo’s electronics will turn onthe motor to eliminate the error. In addition to moving in response tochanging input signals, this active error correction means that servoswill resist mechanical forces that try to move them away from a commandedposition. When the servo is unpowered or not receiving positioningpulses, the output shaft may be easily turned by hand. However,when the servo is powered and receiving signals, it won’t movefrom its position.Driving servos with <strong>PICBASIC</strong> <strong>PLUS</strong> is extremely easy. The SERVOcommand generates a pulse in 1microsecond (µs) units, so the followingcode would command a servo to its centered position and hold itthere: -Again: SERVO PORTA.0 , 1500DELAYMS 20GOTO AgainThe 20ms delay ensures that the program sends the pulse at thestandard 50 pulse-per-second rate. However, this may be lengthenedor shortened depending on individual motor characteristics.The SERVO command is oscillator independent and will always producea 1us resolution regardless of the crystal frequency used.118Copyright Crownhill 2001