Tuesday, September 18, 2007

Serial Servo Controller Part2

PIC SSC
Write the PIC code using MicroCode and transfer the HEX code generated from SSC.BAS to PIC chip 16F84A using EPICWIN program. This is the code that I use :
'*************************************************************************************
TRISB =000000

TRISA=001101

DEFINE 0SC 4
include "modedefs.bas"

Led VAR PORTA.4
Baud CON N2400
Com_In VAR PORTA.0
Com_Out VAR PORTA.1
Control VAR BYTE
Slider VAR BYTE

Sync VAR BYTE
I VAR BYTE
S0 VAR BYTE
S1 VAR BYTE
S2 VAR BYTE
S3 VAR BYTE
S4 VAR BYTE
S5 VAR BYTE
S6 VAR BYTE
S7 VAR BYTE

LOW PORTB.0
LOW PORTB.1
LOW PORTB.2
LOW PORTB.3
LOW PORTB.4
LOW PORTB.5

LOW PORTB.6
LOW PORTB.7
HIGH Led

S0 = 127
S1 = 111
S2 = 144
S3 = 65
S4 = 127
S5 = 127
S6 = 127
S7 = 127

Start:

SERIN Com_In,Baud,7,Set_Pos,[255],Slider,Control
SEROUT Com_Out,Baud,[Slider,Control]

IF Slider = 0 THEN S0 = Control


IF Slider = 1 THEN
S1=Control
S2=254-S1
ENDIF

IF Slider = 2 THEN S3 = Control

IF Slider = 1 THEN
S4=Control
S5=254-S4
ENDIF

IF Slider=4 THEN S6=Control

IF Slider=5 THEN S7=Control

Set_Pos:

PULSOUT PORTB.0,S0
PULSOUT PORTB.1,S1
PULSOUT PORTB.2,S2
PULSOUT PORTB.3,S3
PULSOUT PORTB.4,S4
PULSOUT PORTB.5,S5
PULSOUT PORTB.6,S6
PULSOUT PORTB.7,S7

GOTO Start
'***************************************************************************************

Futaba S3003 Test
Connect the four Futaba S3003 standard servo motors to R4, R5, R6, R7 of the PIC chip output.


VB SSC
As the actual slider program is quite long and time consuming to program, therefore for test purposes I just simply used the downloaded version of the executable file that I download from http://www.thinkbotics.com/book_support.

No comments:

Hangman