interfacing arduino with Sc16a servo controller

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

interfacing arduino with Sc16a servo controller

Postby Lu_01 » Fri Mar 18, 2011 6:49 pm

hi all,

I have an arduino BT connected to a cytron sc16a servo controller and i am trying to use this to drive a servo motor. the end result is to drive the servo motor using commands being sent to the arduino BT from a gui on my pc. so basically, i click a button on my pc screen, a character is sent to the arduino where it is processed and then info is sent to the servo controller which in turn drives the motor. this is the plan.

sadly, nothing seems to be happening (i.e the servo is not turning). to trouble shoot, i eleminated the bluetooth element from my set up and am now using pushbuttons connected to the arduino in order trigger the serial communication (from arduino to servo controller). even this seems not be working as well...

next, with the same setup just mentioned, i used the arduino serial monitor to check the integrity of the data (4 bytes) i am sending....and it seems like it is correct. the servo controller seems to be receiving the pulses from the arduino (i checked with an oscilloscpe) but the its still not turning the servo.

I am running short of ideas here and hoping someone out there could help me out.....so, anybody out there???
Lu_01
Freshie
 
Posts: 4
Joined: Fri Mar 18, 2011 6:40 pm

Re: interfacing arduino with Sc16a servo controller

Postby ober » Sat Mar 19, 2011 7:39 am

Can you share a basic setup (connection) from Arduino to SC16A? How about connection from computer to SC16A via USB port and uses the sample GUI to control the drive servo motor? That should be able to verify that SC16A is working.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: interfacing arduino with Sc16a servo controller

Postby Lu_01 » Tue Mar 22, 2011 9:28 am

ok here it is
Lu_01
Freshie
 
Posts: 4
Joined: Fri Mar 18, 2011 6:40 pm

Re: interfacing arduino with Sc16a servo controller

Postby Lu_01 » Tue Mar 22, 2011 9:29 am

I have my arduino's TX (pin1) and RX(pin 0 ) connected to the cytron sc16a's servo controller's RX and TX pins repectively. I also have the Arduino's 5V and GND pins connected to the servo controller's %V and GND pins. the servo motor is connected to one of the ports of the servo controller. its power is obtained from an external 9v alkaline battery which is connected to the servo controller (as the sc16a provides a slot for this). that's basically my setup. here is the sample code I am currently trying to run:-

CODE: SELECT_ALL_CODE
#define mainbodyLEFT_Button_9   10           
#define mainbodyRIGHT_Button_10  11         

int state1 = HIGH;
int position1 = 732;

void setup()
{
  Serial.begin (9600);            //Set USART Baud Rate to 9600 

pinMode (mainbodyLEFT_Button_9, INPUT);       //Set button pin to input   
  digitalWrite (mainbodyLEFT_Button_9, HIGH);/*ENABLE INTERNAL PULL-UP RESISTORS ON  THIS PIN*/
 
pinMode (mainbodyRIGHT_Button_10, INPUT);       //Set button pin to input
  digitalWrite (mainbodyRIGHT_Button_10, HIGH);/*ENABLE INTERNAL PULL-UP RESISTORS ON  THIS PIN*/

 
                                                 
                                                   
}

void loop()
{
  delay(100); // debounces switches

   int mainbodyLEFT_Button_9_value = digitalRead(mainbodyLEFT_Button_9);
   int mainbodyRIGHT_Button_10_value = digitalRead(mainbodyRIGHT_Button_10);
 
            if(mainbodyLEFT_Button_9_value != state1 ||mainbodyRIGHT_Button_10_value != state1||Stop_Button_13!= state1)
            {
                               
                if (mainbodyLEFT_Button_9_value != state1)
                {
                   if (position1 >1463) {
                   position1 =1463;
                   send_cmd(0X41, position1,0);
                   }
                  else{
                   
                    position1+=100;
                    send_cmd(0X41, position1,0);
                  delay(10); //wait for message to transmit
                }
                }
               
                else if (mainbodyRIGHT_Button_10_value != state1)
                {
                 
                  if (position1 <0) {
                  position1 =0;
                  send_cmd(0X41, position1,0);
                  }
                  else
                 
                  position1--;
                  send_cmd(0X41, position1,0);
                  delay(10); //wait for message to transmit
                }
                         
            }
           
}

 void send_cmd(unsigned int num, unsigned int data, unsigned int ramp)
//UART transmit 4 bytes: servo number, higher byte position,
//lower byte position and speed

{
     unsigned char higher_byte=0, lower_byte=0;   
      
   higher_byte=(data>>6)&0x003f;
   lower_byte=data&0x003f;

         
         Serial.print(num, HEX);                //First byte is the servo channel 0x41-0x60
         //delay(2000);
         Serial.print(higher_byte,HEX);        //second byte is the higher byte of position
                                                          //0b00xxxxxx
         //delay(2000);
         Serial.print(lower_byte, HEX);         //third byte is the lower byte of position 0b00xxxxxx
         //delay(2000);
         Serial.println(ramp,HEX );              //fourth byte is the speed value from 0-63
         //delay(2000); 
}

thanx
Lu_01
Freshie
 
Posts: 4
Joined: Fri Mar 18, 2011 6:40 pm

Re: interfacing arduino with Sc16a servo controller

Postby ober » Tue Mar 22, 2011 9:37 pm

ok here it is

You place to paste a photo of the setup? Or you want to start the explanation under this reply?

I have my arduino's TX (pin1) and RX(pin 0 ) connected to the cytron sc16a's servo controller's RX and TX pins repectively. I also have the Arduino's 5V and GND pins connected to the servo controller's 5V and GND pins. the servo motor is connected to one of the ports of the servo controller. its power is obtained from an external 9v alkaline battery which is connected to the servo controller (as the sc16a provides a slot for this). that's basically my setup.


Sorry, but not familiar with arduino programming language and library :)

Anyway, I am suspecting a few things:
1. What is the power specification for the servo you are using? Because you said you connect 9V to the SC16A power port for servo motor. Normally, standard RC servo have the range of 4.8V to 6.0V, higher might reach 7.0V, but frankly, seldom see RC servo with 9V. Additionally, even if 9V battery is suitable for the servo you are using (in term of voltage), it does not have sufficient power to drive RC servo, maybe a few turn is possible, it will eventually drain off.

2. Why don you try the setup using USB from SC16A to computer and use the sample GUI for SC16A to control the servo. You will know what is working and what is not.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: interfacing arduino with Sc16a servo controller

Postby Lu_01 » Mon Mar 28, 2011 3:51 pm

Hey yeah it was working well when using usb. and I am using 9v because i intend to drive more than one motor.

well, just wanna let you know that everything is working properly now, fixed it a few days ago. It turns out the problem was with the data format the arduino was outputing to the serial port (using the Serial.print statement). I was using HEX all along, I changed it to BYTE and the servo started turning. Apparently, this is the only correct format that the Sc16A board understands.thanx alot for your help. cheers.
Lu_01
Freshie
 
Posts: 4
Joined: Fri Mar 18, 2011 6:40 pm

Re: interfacing arduino with Sc16a servo controller

Postby ober » Tue Mar 29, 2011 10:43 pm

Good to hear that, but I am curious to know what is the servo motor you are using which can be supplied with 9V battery.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: interfacing arduino with Sc16a servo controller

Postby khailonewolf » Sat Jul 02, 2011 4:48 am

me too.huhu :D
khailonewolf
Greenhorn
 
Posts: 2
Joined: Sat Jul 31, 2010 3:45 am


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 12 guests

cron