Hi, I already get to move the servo motor by using SC16A controller. However I don know what command \i need to sent to get the position from SC16A. ( like the example show in cytron website, but it's write it in PIC16F and 18F) can U give me any of samplre code to get the position of servo motor from SC16A by using PIC30F ?
Here the function I try estimate from PIC16F
unsigned int request_position_cmd(unsigned char channel)
{
unsigned char first_byte=0, check_id, higher_position, low_position;
first_byte=0b10100000|channel;
U1TXREG = first_byte;
higher_position = UART_Rec();
low_position = UART_Rec();
position = higher_position<<6;
position = position|(low_position&0x3F);
return position;
}
unsigned char UART_Rec(void) //receive uart value
{
unsigned char rec_data;
while(U1STAbits.URXDA == 0); //wait for data
U1STAbits.OERR = 0;
rec_data = U1RXREG;
returnrec_data; //return the data received
}