Preface

About SunFounder

SunFounder is a technology company focused on Raspberry Pi and Arduino open source community development. Committed to the promotion of open source culture, we strive to bring the fun of electronics making to people all around the world and enable everyone to be a maker. Our products include learning kits, development boards, robots, sensor modules and development tools. In addition to high quality products, SunFounder also offers video tutorials to help you build your own project. If you have interest in open source or making something cool, welcome to join us! Visit www.sunfounder.com for more!

About This Kit

The Rollarm Kit for Arduino is designed for mass hobbyists to learn robot arm control. With the open source MCU Arduino UNO and a servo expansion board, you can control its four axes by the 4 potentiometer on the handle, as well as make them move by operating on your computer. In addition, it can memorize the movements it’s made and repeat again and again, making it a great tool for repeated tasks.In this book, you can learn the basics of how a mechanical arm works and how to make one piece by piece. For more information, please go to our website www.sunfounder.com and find the tutorial under Learn.

Free Support

If you have any TECHNICAL questions, add a topic under Community -> Forum section on our website and we’ll reply as soon as possible.

For NON-TECH questions like order and shipment issues, please send an email to service@sunfounder.com. You’re also welcomed to share your projects on Forum.

Content

Introduction

The Rollarm Kit is an interesting and useful learning tool for Arduino and robot hobbyists. With the structural plate and code based on Arduino, it enables users to learn programming from easy to difficult, control the mechanical arm freely and perform various fun operations!

This fun mechanical arm consists of 4 axes, each controlled by a servo. Powered by a 9V battery, the control systems is composed of SunFounder Uno board, servo extension board with remote control. The kit includes all necessary components like structural plate, circuit boards, and connector parts. For your better learning, installation and debugging video tutorials are provided on youtube. Also you can download the user manual which elaborates on the installation procedures and program explanation. With these resources, you can quickly and effortlessly make creative projects with the Rollarm. Now let’s go to get the fun!

_images/media1.png

Components List

Structural Plate

_images/media2.png _images/media3.png _images/media4.png

Electronic Components

_images/media5.png _images/media6.png

Tools

_images/media7.png

Self-Provided Components

_images/media8.png

How to control

  1. Install Arduino IDE

  2. Assemble the Rollarm (Remember to configure the servos before assembly. Pay attention to the detailed operations)

  3. Control with handle: download the Rollarm package and run the program (Indispensable step before operating the Rollarm)

  4. Control with Labview: download the Labview to your PC and install for control (download is a must-do before subsequent operating) Let’s get started. Enjoy!

Getting Started with Software

Downloading Codes

Go to Learn->Robot Kit->DIY Control Robot Arm kit for Arduino-Rollarm and download the package

_images/media9.png

Install Arduino IDE

Arduino is an open source platform that applies simple software and hardware. You can get it in a short even when you know little of it. It provides an integrated development environment (IDE) for code editing and compiling, compatible with multiple control boards. So you can just download the Arduino IDE, upload the sketches (i.e. the code files) to the board, and then you can see experimental phenomena. For more information, refer to http://www.arduino.cc.

The code in this kit is written based on Arduino, so you need to install the IDE first. Skip it if you have done this.

Step 1: Go to the arduino.cc website and click Download. On the page, check the software list on the right side under Download the Arduino Software.

_images/media10.png

Find the one that suits your operation system and click to download. There are two versions of Arduino for Windows: Installer or ZIP file. You’re recommended to download the former.

Step 2: Double click the exe. file and the following window will show up. Click I Agree. The following interface will show up.

_images/media11.png

Choose Next.

_images/media12.png

Click Browse to choose the installation path or enter a directory at the Destination Folder.

Click Install.

_images/media13.png

The following interface will show up.

Note

After the installing progress bar goes to the end, the Close button may be enabled for some PC. Just click it to complete the installation.

_images/media14.png

Then a prompt appears. Select Always trust software for “Adafruit Industries” and click Install.

_images/media15.png

Select “Always trust software for Arduino srl” and click Install.

_images/media16.png

After the installation is done, click Close. Then an Arduino icon will appear on the desktop:

_images/media17.png

Assembly

Install the base of Rollarm

_images/media18.png _images/media19.png _images/media20.png _images/media21.png

Note

You can turn the wrench clockwise to tighten the selflocking nut.

_images/media22.png _images/media23.png _images/media24.png _images/media25.png

Install Accessories

_images/media26.png _images/media27.png

Calibrate the steering gear angle

Warning

Before installing the rocker arms for each servo, you need to adjust the servo. If you skip this step and finish assembling and power the product, the servo may appear to block or be damaged, you may even need to disassemble the robot from this step to reassemble it!

Step 1: Prepare four white servos, and then insert the Servo A wires into D4, Insert the Servo B wires into D5, Insert the Servo C wires into D6, Insert the Servo D wires into D7.

_images/media28.png _images/media29.png

Step 2: connect the Servo Control Board to the PC via the USB Type-B Cable, and the PC will automatically install the driver.

Step 3: Go to the folder DIY Control Robot Arm kit for Arduino-Rollarm/Arduino Code/Servo and open the file Servo.ino.

_images/media30.png

Step 4: Select the Board.

_images/media31.png

and Port

_images/media32.png

Step 5: Click Upload.

_images/media33.png

After the upload is completed successfully, keep the USB cable connecting. You may hear the sound of gear moving (or may not, if the servo shaft happens to be at 90 degrees at the beginning; but you GENTLY spin the rocker arm and you’ll find it’s unmovable). So now the servo is adjusted to 90 degrees.

Install Servo Rocker Arm

_images/media34.png _images/media35.png _images/media36.png _images/media37.png _images/media38.png _images/media39.png _images/media40.png _images/media41.png

Note

In this step, please keep the control board power on, Rotate plate 4 to a 90 degree angle with plate 5.

_images/media43.png

Note

In this step, please temporarily turn off the power of the control board, and then rotate the plate 5 to an appropriate angle to fix the servo. Similarly, use a spanner to tighten these M2 self-locking nuts.

_images/media44.png

Note

Use a spanner to tighten these M2 self-locking nuts.

_images/media45.png _images/media46.png _images/media47.png

Note

Power on the control board again in this step. Keep the gripper edge of the plate 7 parallel to the side of the plate 4.

_images/media48.png _images/media49.png _images/media50.png

Note

Make sure that the inner sides of the plate 6 and plate 7 are parallel and the gears meshed.

Install Button

Please print the scale.dwg file in a 1:1 ratio. After the printed scale paper is cut, place the paper on plate 2.

_images/media51.png

Note

It is recommended to use AutoCad software for printing.

_images/media52.png _images/media53.png _images/media54.png

Note

Align the bulged part of button with the 0° position.Rotate the potentiometer clockwise to the end, and put the button onto the potentiometer and press to tighten them.

_images/media55.png

Install Battery

_images/media56.png _images/media57.png

Control the Rollarm

There are two ways to control the Rollarm: manual control (by handle), or PC control (by Labview). The detailed operations for two ways are as follows.

Manual Control

Step 1: Run the Rollarm.ino code under the path DIY Control Robot Arm kit for Arduino-RollarmArduino CodeRollarm. There are four code files in Rollarm, Rollarm.ino is the main program, when the others are subprograms.

_images/media58.png

When you open the main program, the subprograms will be opened automatically:

_images/media59.png

Step 2: Select the corresponding board and port, then click Upload.

Step 3: After the code upload, turn the power switch on, then we can try to control the Rollarm.

Step 4: Rotate the four potentiometer buttons to try the controlled servo and direction:

White potentiometer to control the Servo D, the yellow to control Servo C, the orange to control Servo B, and the red one to control Servo A.

_images/media60.png
Record behavior

With the handle, the Rollarm can record its behaviors:

Rotate one potentiometer to control one servo to the desired position, and press the yellow button shortly to let the control board record this step. Record the rest steps in this way.

When all the steps are done, press the yellow button for a while (3s), it will repeat the recorded steps (Rollarm can record at most 100 steps because of the control board’s memory limit.)

_images/media61.png

Thus we can make it automatically carry blocks continuously:

Code Explanation

The program includes three parts: rotating the potentiometers to control the Rollarm, pressing the button slightly for less than one second to record Rollarm’s behaviors and pressing the button for a relatively longer time to make Rollarm repeat the recorded steps.

There are four potentiometers to control the arms. The 4 servos from top to bottom are connected to port 4-7 respectively of the expansion board, and the 4 potentiometers control the ports accordingly. In other words, spin the white potentiometer to control the uppermost servo, the yellow to control the next servo below, the orange to control the next servo, and the red one to control the bottom servo.

Since the Rollarm has four servos acting as the moving joint, we need to include a header file for driving the servos and define them.

//Create servo object to control a servo.
#include <Servo.h>

Servo Servo_0;
Servo Servo_1;
Servo Servo_2;
Servo Servo_3;

After defining the function of driving the servos, we need to read the AD value of the potentiometers and convert it into the rotating angle of the servo since the servos are controlled by rotating the potentiometers.

//Read the values ot the potentiometers.
void ReadPot()
{
        SensVal[0] = 0;
        SensVal[1] = 0;
        SensVal[2] = 0;
        SensVal[3] = 0;

        SensVal[0] = analogRead(A0);
        SensVal[1] = analogRead(A1);
        SensVal[2] = analogRead(A2);
        SensVal[3] = analogRead(A3);
}

//The value of the potentiometer is matched to the angle value.
void Mapping0()
{
        SensVal[0] = map(SensVal[0], 0, 1023, 10, 170);
        SensVal[1] = map(SensVal[1], 0, 1023, 10, 170);
        SensVal[2] = map(SensVal[2], 0, 1023, 10, 170);
        SensVal[3] = map(SensVal[3], 0, 1023, 100, 180);
}

After compiling the program, we need to make Rollarm remember the steps, which is done through pressing the button.

//Calculate the time the button pressed
void Button()
{
        if (digitalRead(3) == 0)
        {
                delay(10);
                if (digitalRead(3) == 0)
                {
                        KeyValue = 0;
                        while (!digitalRead(3))
                        {
                                KeyValue++;
                                delay(100);
                        }
                }
        }
}

We can tell which part of the code the Rollarm is performing by reading the value upon pressing the button. When the value is larger than 10, it means Rollarm is repeating the steps. When it is between 0 and 10, it means Rollarm is remembering. And when it is 0, it means Rollarm is being controlled by the potentiometers. The specific program is as follows:

//Check the button.
static int Flag = 1;
Button();

//The time of pressing the button is not long then record the action.
if ((KeyValue < 10) && (KeyValue > 0))
{
        KeyValue = 0;
        Record();
        Mapping1();
}
//Long press the button and open the auto mode,start repeating the action.
else if (KeyValue > 10)
{
        if (Flag == 1)
        {
                Flag = 0;
                Calculate();
        }
        Drive_init();
        delay(3000);
        for (int i = 1; i < Time; i++)
        {
                Drive_repeat(i);
                delay(500);
        }
}
//Did not press the button, open the manual mode.
else
{
        ReadPot();
        Mapping0();

Next, we are going to call the function to write the value of the servo rotating angle. However, it is not merely about writing the values directly; the difference between two adjacent rotating values will also be written into the servos. Here we take a servo program for example.

//The first axis.
if (Dif0[n] > 0)
{
        for (int j = Joint0[n - 1]; j <= Joint0[n]; j++)
        {
                Servo_0.write(j);
                delay(10);
        }
}
else
{
        for (int j = Joint0[n - 1]; j >= Joint0[n]; j--)
        {
                Servo_0.write(j);
                delay(10);
        }
}

PC Control

Install Labview Software

For this kit, we use the Labview software for control on PC. If you have other better options, welcome to share by post under Community -> FORUM on our website www.sunfounder.com.

Download the Labview package in the link below:

https://s3.amazonaws.com/sunfounder/Arduino/Labview.zip

After downloading, open it and you will see the folder Rollarm’s Installer. Then find the setup file as shown below:

_images/media63.png

After the installation is done, in Start Menu, find Rollarm to open the Rollarm software. Or, enter the installation directory we used just now, and double click Rollarm.exe to open it. The defaulted installation directory is: C:Program Files (x86)Rollarm.

_images/media64.png

The following interface will show up.

_images/media65.png
Upload the Code

Before using the Rollarm Labview software, flash the control codes into the Rollarm robot, and the steps are as follows.

Step 1: In order to avoid the incompatibility, please download Arduino IDE 1.0.5 on Arduino official website:

https://www.arduino.cc/en/Main/OldSoftwareReleases#previous

You are suggested to download zip version because zip version does not need installation and you can use it directly.

_images/media66.png

Step 2: After downloading and unzipping them, you need to double click the arduino.exe to open it.

_images/media67.png

Step 3: Click File- >Open, and you can find the LIFA_Base.ino on the path

DIY_Control_Robot_Arm_kit_for_Arduino-Rollarm.1Arduino CodeLIFA_Base

And click to open.

_images/media68.png

Step 4: Choose the proper Board and Port, and upload the codes to the control board.

_images/media69.png

DO NOT unplug the USB cable at the moment.

Using the Software

Back to the Rollarm Labview software, which includes two parts: Manual Mode and Automatic Mode.

Manual Mode

Step1: See the interface of manual control below. After the Labview is installed and run, this mode is enabled by default.

_images/media70.png

Step2: Click the inverted triangle icon for Serial Port, select the port according to you COM port. Here is COM24, which varies for different computers.

Note

If you can only see COM1,to solve the problem, just replug the USB cable. Then start from sketch upload again.

_images/media71.png

Step 3: Select the Board Type (Uno) and Connection Type(USB/Serial).

_images/media72.png

Step 4: There are three small icons at the top left. Click the middle on to run the software.

_images/media73.png

Step5: Click Start, and the button will change from dark to light green.

_images/media74.png

Note

Sometimes you can see the mistakes like 5005 or 5002 that are as results of the software recognition failure of Arduino control board. Now, please click OK. Then there is a quick quiver state in Rollarm robot to return to the setting position. After that, you can continue to do your next step.

_images/media75.png

Step 6: M1-M4 correspond to Servo1-Servo4, you can move the slider control the 4 servo on the Rollarm.

_images/media76.png _images/media77.png

Automatic Mode

You can also switch to Auto Mode. Fill the value of the rotating angle of the servos into the table under Auto Mode one by one. After filling the figures, click the Start button, then Rollarm will then perform as you just set.

M1-M4: Servo1-Servo4.

1-9: 9 groups of rotating angle.

Interval times(ms): The interval times between two groups, such as interval times between M4 in row 1 and M1 in row 2.

Interval times(ms) 2: The interval time between two rotating angles within a group.

Note

the range of the data for Mode 4 is 90~180. Otherwise, it will be damaged due to stalling.

_images/media78.png

FAQ

About the Assembly

Q1: After assembly and program download, the Rollarm’s four axes are in wired position, some maybe out of control. What should I do?

A: Remember to power on and calibrate each servo before assembly.

About the Arduino code control

Q1: When I open a program, it prompts me that a new folder should be created. After I click Yes and a new folder is created, the main program reports an error when I want to open the main program. What’s going wrong?

A: DO NOT open these subprograms under Arduino codeRollarm separately:

_images/media79.png

If you open the subprograms separately, a dialog box will pop up like this:

_images/media80.png

If a new folder has been created for the subprogram, please cut the subprogram file to the original directory Arduino codeRollarm. Reopen the main program:

_images/media81.png

If a new folder has been created for the subprogram, please cut the subprogram file to the original directory Arduino codeRollarm. Reopen the main program:

_images/media82.png

About the Labview software control

Q1: After powering on the Rollarm, why do the servos shake a little when there’s no movement at all?

A: There may be something wrong with the Serial Port. For instance, the following condition may appear:

_images/media83.png

Turn off the Rollarm, power it on again, and reconnect the serial port to try.

Q1: The Rollarm is in a strange position when I click Start and it’s in the automatic mode. Anything wrong?

A: Here no values is filled in the table yet. The first three axes are in 0°, and the last one is in 90°. You need to fill the correct value of the rotating angle first, and click Start to run.

_images/media84.png

Before clicking Start, you need to fill in the rotating angle for each axis in different steps, and the interval time between steps. If you don’t know the exact angle, you can shift to the manual mode and note down the angle values for each step, and then shift back to fill in. When all the steps above are done, you can click Start to let Rollarm perform the automatic control.