SC08A with P18F4580

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

SC08A with P18F4580

Postby twinsleong » Thu Feb 28, 2013 7:48 pm

I've been trying to program the servo controller with the microcontroller 18F4580 but can't seem to get it to work. I'm using MikroC to work this around. I hope you could help point out where my mistake is in doing this,

CODE: SELECT_ALL_CODE
void main() {

     TRISB = 0X0F;

     UART1_Init(9600);
     // for activating servo channel
     UART1_Write(192);           //select all servo
     UART1_Write(1);             //activate all servo
     
     UART1_Write(129);           //select all servo
     UART1_Write(62);             //activate all servo
     UART1_Write(32);           //select all servo

     while (UART1_Read() !=0x04){
     }

     //for position and speed command
     while(1){
     if (PORTB.F0 == 0){
     Delay_ms(40);
     // for activating servo channel
     UART1_Write(225);           //position & speed command servo 1
     UART1_Write(62);            //higher byte position
     UART1_Write(32);            //lower byte position
     UART1_Write(0);             //servo speed
     }
     
     //for position and speed command
     if (PORTB.F1 == 0){
     Delay_ms(40);
     // for activating servo channel
     UART1_Write(225);           //position & speed command servo 1
     UART1_Write(31);            //higher byte position
     UART1_Write(16);            //lower byte position
     UART1_Write(0);             //servo speed
     }
     //for position and speed command
     
     if(PORTB.F2 == 0){
     Delay_ms(40);
     // for activating servo channel
     UART1_Write(225);           //position & speed command servo 1
     UART1_Write(93);            //higher byte position
     UART1_Write(48);            //lower byte position
     UART1_Write(0);             //servo speed
     }
  }
}
twinsleong
Freshie
 
Posts: 5
Joined: Thu Feb 28, 2013 5:44 pm

Re: SC08A with P18F4580

Postby gadgetng » Fri Mar 01, 2013 9:40 am

First i am not familiar with mikroC. Anyway, i used SC08A before. Maybe you can try to start with simple code which just activate the servo. The servo will hold at its position to make sure all the hardware set up is correct before going further to programming.
gadgetng
Discoverer
 
Posts: 97
Joined: Tue Jul 24, 2012 11:20 am

Re: SC08A with P18F4580

Postby twinsleong » Thu Mar 07, 2013 12:35 am

Thanks. Found out that the problem was actually due to the board I was using. :oops:
twinsleong
Freshie
 
Posts: 5
Joined: Thu Feb 28, 2013 5:44 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 1 guest