Society of Robots - Robot Forum

Software => Software => Topic started by: Tracy M on October 11, 2011, 08:02:28 AM

Title: How can i make servo move
Post by: Tracy M on October 11, 2011, 08:02:28 AM
 
 I  found this web page .
http://www.societyofrobots.com/robot_iRobot_Create_mod.shtml (http://www.societyofrobots.com/robot_iRobot_Create_mod.shtml)
 
It's have a good video and program ,but i want to know something.
I am a novice .  I use this program . (Robot Create Sharp IR Scanner source code )
My servo couldn't moving . where can i modify the code  ? maybe pin is not same!

I request expert help . ...  thanks =)
Title: Re: How can i make servo move
Post by: Admin on October 18, 2011, 11:22:30 AM
Hi

Did you get it to work? Please explain to us in more detail what you have hooked up, what is working, etc.
Title: Re: How can i make servo move
Post by: Tracy M on October 26, 2011, 08:15:21 AM
I have a servo and sharp IR .   i want to turn servo(Futaba S3003) right or left whether first must to know the pwm and a2d.
Title: Re: How can i make servo move
Post by: Admin on October 26, 2011, 09:39:14 AM
Oh, you are asking about how to program a microcontroller, right?

start reading these tutorials:
http://www.societyofrobots.com/microcontroller_tutorial.shtml (http://www.societyofrobots.com/microcontroller_tutorial.shtml)
http://www.societyofrobots.com/actuators_servos.shtml (http://www.societyofrobots.com/actuators_servos.shtml)

Next, I recommend using WebbotLib + AVR Studio to program. There are plenty of WebbotLib video tutorials (https://encrypted.google.com/search?sourceid=chrome&ie=UTF-8&q=webbotlib#q=webbotlib&hl=en&safe=off&prmd=imvns&source=univ&tbm=vid&tbo=u&sa=X&ei=XyioToHFLYfxrQfSoZjZDQ&ved=0CEEQqwQ&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=311140613f060557&biw=1220&bih=806) online that can help you, for example:

How to Program Axon II in PD (http://www.youtube.com/watch?v=vWG1rfwgAX0#)

WebbotLib has a tutorial here:
http://webbot.org.uk/iPoint/37.page (http://webbot.org.uk/iPoint/37.page)

And I also have a WebbotLib tutorial here:
http://www.societyofrobots.com/axon_mote/axon_mote_setup1.shtml (http://www.societyofrobots.com/axon_mote/axon_mote_setup1.shtml)
It's for the Axon Mote, but you can follow the same steps for any ATmega-type microcontroller.
Title: Re: How can i make servo move
Post by: Admin on October 26, 2011, 09:52:26 AM
I just saw your private message. Please do not send me private messages about robot related questions, there are like 7000 people here and it'll drive me crazy if everyone does that.

My English is not good, please forgive me.
I have a servo (servo motor Futaba S3003) with a sharp IR.
I am a novice to write code, I have a irobot create (atmega168) and some programs.
I am using this web method, http://www.societyofrobots.com/robot_iRobot_Create_mod.shtml. (http://www.societyofrobots.com/robot_iRobot_Create_mod.shtml.)
I saw this video (http://www.youtube.com/watchv=f_VOQNXpt3g&feature=player_embedded (http://www.youtube.com/watchv=f_VOQNXpt3g&feature=player_embedded)) with this code (iRobot Create WaveFront Source Code) found on the page.
If you just simply turn to Futaba S3003 servo motor if you want to use the pwm and a2d it?
I want to have that film's four steps of the code, let me reference and learning.

The source code is here as you mentioned already:
http://www.societyofrobots.com/downloads/iRobot_Create_Stampy.zip (http://www.societyofrobots.com/downloads/iRobot_Create_Stampy.zip)

I didn't save the source code for each step, all I did was simply comment out various sections of code for that video. I recommend just loading the code as-is and just getting that to work. You can then remove the sections you don't want.

Or if you study the code long enough, it'll start to make sense so you can reverse-engineer it to do what you'd like.
Title: Re: How can i make servo move
Post by: Tracy M on October 26, 2011, 10:00:48 AM
I'm sorry. Then I will not do so
Does your code where you can control the motor rotating it?
THANK YOU
Title: Re: How can i make servo move
Post by: Admin on October 26, 2011, 10:02:36 AM
Does your code where you can control the motor rotating it?
I don't understand your question. Can you rephrase it?
Title: Re: How can i make servo move
Post by: Tracy M on October 26, 2011, 10:15:02 AM
I use your code in my robot
It is great code
But I can not Futaba S3003 servo motor rotation.
I just want to have the following video of the first steps of the code (that I'll be satisfied)
http://www.youtube.com/watchv=f_VOQNXpt3g&feature=player_embedded (http://www.youtube.com/watchv=f_VOQNXpt3g&feature=player_embedded)
I just want to let me just turn the servo motor =(

THANK YOU
Title: Re: How can i make servo move
Post by: Tracy M on October 26, 2011, 10:30:09 AM
 Can  you  write the first step program to me for reference and study?

 If you can help me, I am very grateful to you.   :)
Title: Re: How can i make servo move
Post by: Admin on October 26, 2011, 11:46:59 AM
Can  you  write the first step program to me for reference and study?
In your main code, add this:

Code: [Select]
//scan servo left and right
//each servo is different, so try different numbers until it works
while(1)
{
for(uint16_t i=200;i<2000;i++)
{
servo_scan(i);
delay_ms(10);
}
for(uint16_t i=2000;i>200;i--)
{
servo_scan(i);
delay_ms(10);
}
}
Title: Re: How can i make servo move
Post by: Tracy M on October 27, 2011, 07:09:56 AM
thank you !

excuse me, i use your code (irobot.c)...
I am stupid. i dont know where can i add it?
can you teach me?





////////////////////Enter your code below this line////////////////////

     //reset encoder function
      angle = 0;
     distance = 0;

      // Drive around until a button or unsafe condition is detected
      while(!(UserButtonPressed)
            && (!sensors[SenCliffL])
            && (!sensors[SenCliffFL])
            && (!sensors[SenCliffFR])
            && (!sensors[SenCliffR])
            && (!sensors[SenChAvailable]))
      {
   

      //servo_scan(1200);//-90 degrees at 300, lower goes CCW, 750 is centered, 1200 is far CW
      scan(30);

      if (scan_angle > 840)//scanner is on the right
         drive(100, RadCW);//turn right
      else if (scan_angle < 660)//scanner is on the left
         drive(100, RadCCW);
      else//drive to object in center
         {
         if (a2dConvert8bit(1) > 50)//too close, backup
            drive(-300, RadStraight);
         else
            drive(100, RadStraight);//drive to object in center
         }
      
   

        // wait a little more than one robot tick for sensors to update
        delayAndUpdateSensors(update_delay);
      }

      // Stop driving
      drive(0, RadStraight);

      // Play end song and wait
      delayAndUpdateSensors(500);
      byteTx(CmdPlay);
      byteTx(END_SONG);
      delayAndUpdateSensors(2000);

    }
  }
}





// Delay for the specified time in ms without updating sensor values
void delayMs(uint16_t time_ms)
{
  timer_on = 1;
  timer_cnt = time_ms;
  while(timer_on) ;
}



thanks! =)

 
Title: Re: How can i make servo move
Post by: Admin on October 27, 2011, 08:05:20 AM
You need to carefully study the code line by line to try and understand what it does. It'll make sense if you spend a minute on each line.

For example, if you see this:
Code: [Select]
////////////////////Enter your code below this line////////////////////
That means you put the code right after that line lol :P