11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PICBASIC</strong> <strong>PLUS</strong> Compiler5.63. SERVOSyntax :Overview :Operators :Example :SERVO Pin , Rotation ValueControl a remote control type servo motor.Pin is a Port.Pin constant that specifies the I/O pin for the attachmentof the motor’s control terminal.Rotation Value is a 16-bit (0-65535) constant or WORD variable thatdictates the position of the motor. A value of approx 500 being a rotationto the farthest position in a direction and approx 2500 being thefarthest rotation in the opposite direction. A value of 1500 would normallycenter the servo but this depends on the motor type.‘ Control a servo motor attached to pin 3 of PORTADEVICE 16F628DIM Pos as WORDSYMBOL Pin = PORTA.3CMCON = 7CLSPos = 1500PORTA = 0TRISA = %00000111‘ We’ll use the new PICmicro' Servo Position' Alias the servo pin' PORTA to digital‘ Clear the LCD' Centre the servo' PORTA lines low to read buttons' Enable the button pins as inputs' ** Check any button pressed to move servo **‘ Move servo leftMain: IF PORTA.0 = 0 THEN IF Pos < 3000 THEN Pos = Pos + 1' Centre servoIF PORTA.1 = 0 THEN Pos = 1500' Move servo rightIF PORTA.2 = 0 THEN IF Pos > 0 THEN Pos = Pos - 1SERVO Pin , PosDELAYMS 5' Servo update ratePRINT AT 1 , 1 , "Position=" , @Pos , " "GOTO MainNotes :Servos of the sort used in radio-controlled models are finding increasingapplications in this robotics age we live in. They simplify the job ofmoving objects in the real world by eliminating much of the mechanicaldesign. For a given signal input, you get a predictable amount ofmotion as an output.To enable a servo to move it must be connected to a 5 Volt powersupply capable of delivering an ampere or more of peak current. Itthen needs to be supplied with a positioning signal. The signal is normallya 5 Volt, positive-going pulse between 1 and 2 milliseconds(ms) long, repeated approximately 50 times per second.117Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!