Let's Make Robots! | RobotShop

Micro Servo Robot

 
AttachmentSize
MiniRobot_1_3.ino_.zip2.73 KB
MiniRobot_1_3EN.ino_.zip3.52 KB
Micro_Servo_Robot_Flowchart.pdf84.04 KB
Micro_Servo_Robot_Diagramm.pdf74.13 KB

4 axis robot arm with a small gripper and teach function. (In fact: it is a 3 axis robot)

This robot can follow. This robot can learn. And this robot can repeat endles. And he lost all his memory if the batterys are low. This makes it new all the time he is powered again. - The idea for this project is taken from https://www.robotshop.com/letsmakerobots/node/21633 - Stoerpeak made me do it! -

Arduino mini pro 5V/16MHz

4 micro servos 180degrees

4 22k potentiometer

NmH Battery 4.8V

Wires, Button, Switch

Balsa wood, Metal, Plastic

Zip Ties and Glue

 

Teach mode: After a reset the robot arm follows the teach in arm while simple mapping the analog inputs every 25ms to the servo motors. Pressing the button stores each servo position in a array

Play mode: Double press the button switch to play mode. The sketch reads the array step by step and and moves the robot arm. For cool loocking movements i added a routine calculates different micro steps for each servo to have moving start and end sync on all axis. Also added a ramp for soft increase/decrease velocity. Shorter travel distances the robot does slow, longer distances with faster speed. Its all about timing so my thoughts in this moment

Play Mode version 1.1 The gripper input is used to set the delay (0,1,3,15,60,300 seconds) after a loop is done. The switch (it was left from the project start) pauses the robot

08/2015 i added the same code 1.3 but i try add english comments

10/2015 flowchart for the code and electrical diagram. (make sure you use a pullUp resistor at input 4,6 / change the code for input 4. This should fix the 'slow running problem' often happend)

 

Hey people!!: If u share my code please keep decency and give me credits. And dont forget Stoerpeak!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Pinaut,

I was able to recreate your robot. I recreated the circuit and the arm. I'm running your code but the playback is very slow.

I have read a lot of comments here of people with slow playback. I read your comment as well in which you recommend to replace the 'time' variable with a number in these lines:

else // ausführen

 

    {

      if (currentMicros - previousMicros > time) // speed für servo update/step

      {

        previousMicros = currentMicros;

        play_servo(); 

      }

    }

  }// ende playmode

 

I did replace 'time' with a number, I tried all numbers from -10000 to 10000 and, not sure if the negatives would work...  but I am still getting very slow playback. Since your code has a part that makes the servos play back slow in X movements... I was wondering if it was possible to remove that portion from your code, but I'm not able to identify it. 

Up to this point everything is working great, but the playback is very slow.

Here you can see a picture of my robot:

Robot Arm

You think you can give me a hand?

I'm very unhappy see the code not running well and i have no idea why that happend. I did reload the code (the file i put here) on my robot and it works fine on the arduino mini i used.

So.. i decided to rebuild a new setup to see what happend and maybe find a solution. But... I dident have the time at the moment because my work, summertime and other hobbies. So it will takes time until i can do. Also i will try that with a different arduino (UNO).

Please stay patient

Pinaut

I have been able to make some modifications and got the robot running. Just finishing up some details and will post a picture and/or a video for you to see.

Thanks a lot Pinaut

can u tell us what are the changes in the code? what arduino board it is running?

thx

StepsMax is what is calculating the speed of the playback, so I commented out that portion of the code and set a constant value to StepMax to fix the playback speed

Playback speed

 

Also, the delay was an issue for me after the first cycle, it was taking too long to play back the second cycle. I believe you mentioned previously that the Gripper Potentiometer was the one that set the delay, and that is correct, I changed the following on the Calc_pause() function:

calc pause

I'm not very good with coding I wish I could have used the same logic with yours, that smaller distances goes slower and longer distances goes faster, but I was not able to adjust the code to do that. So the two changes I did above did do the trick for my robot. It set the pace at a good playback speed and also I was able to make it start as soon as possible with every playback without a delay. 

I will post a video once finished :)

I am running an Arduino Mega, and also I added more servos to have two servos per joint:

 

Arm

stepsMax is the biggest distance to travel from all 4 servos. From the momentary position to the next position read from the stored array. Set this to a fixed value makes no sense. 

Did someone change the serial baudrate in the code to 9600 for a test? I used 'Serial.begin(115200);' 

I tride 9600 and it did not work for me. It only works with 115200.

The Problem with the slow playback is in the Button part.

 

void Button() // check buttons for single and
doubleclick
{
  if (digitalRead(6) == false)
  {
    delay(20);
    if (digitalRead(6) == true) // taster
losgelassen

 

The delay of 20 msec is the reason why the CPU cycle time is too long and the servos too slow.

interesting! the 20ms is used to debounce the button.

The button MUST have a 10k pullup resistor to +5V! Maybe software pullup also work. https://www.arduino.cc/en/Reference/Constants

If the button is pressed digital IN6 goes to GND (if (digitalRead(6) == false)) and the 20ms is debouncing time before check for release the button. So.... if this solves the slow running problem we search since months: thx to czpollib