Page 1 of 1

servo controlloer using 18f452

PostPosted: Mon Feb 01, 2010 7:34 pm
by pacai1987
i using cytron servo controller sc16a. in the source example u giv for pic16f..
however i using 18f452 and mikroc software for programming.. this my programming, just simple programming to see servo motor move and change position for every 4 second.

CODE: SELECT_ALL_CODE
#define LED1 PORTB.f3
#define LED2 PORTB.f2
#define LED3 PORTB.f1


void main() {

TRISD = 0xFF;   //input
TRISB = 0x00;   //output
TRISC = 0b10000000; // rx tx port RC7 RC6
PORTB = 0;
UART1_Init(9600);
Delay_ms(2000);

while(1)
{
UART1_Write(0b01000001); // 1st bytes
UART1_Write(0b00001011); //2nd bytes
UART1_Write(0b00011011); // 3rd bytes
UART1_Write(0b00000000); // 4th bytes
LED1 = 1;
Delay_ms(4000);

UART1_Write(0b01000001);
UART1_Write(0b00000101);
UART1_Write(0b00101101);
UART1_Write(0b00000000);
LED2 = 1;
Delay_ms(4000);

UART1_Write(0b01000001);
UART1_Write(0b00010001);
UART1_Write(0b00001000);
UART1_Write(0b00000000);
LED3 = 1;
Delay_ms(4000);
}

}


the led is on and keep changing every 4 second but the motor not moving at all.. i cant use uart lib or something wrong with my code?

Re: servo controlloer using 18f452

PostPosted: Tue Feb 09, 2010 12:09 pm
by joliza
hi Pacai1987,

We have upload sample source code of servo controller using PIC18F in website. You can use that as your references.But we can't check you programming because we use C Language in our sample program.

Re: servo controlloer using 18f452

PostPosted: Thu Jun 17, 2010 1:48 am
by tkleong1437
what is the output result on ur UART interface ? Does it present valid SC16A command ? may try verify does SC16A require Cr/CrLf after each command code