Introduction: ChIMP: This IS the Droid You've Been Looking For!

About: I’ve loved robots for as long as I can remember…and started building them when I was 10 years old. Currently, a friend and I are working to develop an easy to build, inexpensive and impressive robot that will …

The Charleston Robotics ChIMP (Chimpanzee Inverted Motorized Pendulum) is an easy to build, scaleable and impressive robot that grows along with the skills of its Maker. Assembled from common PVC plumbing pipe and basic hand tools, the Maker can build as time and money allow, while participating in an online community that encourages beginners and supports the ChIMPs Darwinian evolution. Did we mention it's FREE!?! My name is Christian, and my Co-Founder Lukas and I invite you to ask questions here, and join our forum at www.charlestonrobotics.com to ask anything we may have missed in this Instructable!

Supplies

Simple Tools Needed:

  • Safety Glasses.
  • Cheap Miter Box and Saw or Chopsaw.
  • Assorted Sandpaper and Rosin Paper.
  • Handdrill and Bits.
  • Screwdrivers, Allen Keys and Wrenches for chosen hardware.
  • Utility Knife.
  • Clear PVC Pipe Cement.
  • Acetone.
  • Nitrile Gloves.
  • Paper Towels.
  • 3D Printer, or Access to a 3D Printer, or Access to the Internet to find someone with a 3D Printer. You get the idea... Should have a 150mm x 150mm x 150mm Build Area.
  • Soldering Iron and Solder (for Electronics)
  • Wire Cutter / Stripper
  • Rotary Tool (Dremel) or Files and Chisel
  • Ruler and Measuring Tape.

Step 1: Building the Frame

If a picture is worth a thousand words, what must 30 frames per second be worth? Be sure to download the attached ChIMP Construction Manual, (where you will find the Bill Of Materials with all pipe dimensions, etc.), and watch ALL of the videos before starting construction. Remember, you are not alone in this process! You can visit us at www.charlestonrobotics.com and ask anything on the Forum. Now, follow along as I build a ChIMP frame in real time...

Step 2: Building the Backpack

Once the ChIMP frame is complete, it's time to build and install the Backpack. We found our Backpack on Amazon, but there are a lot of project boxes, etc. that would work for this step. Follow along, and look for the Backpack modifications in the downloadable Construction Manual.

Step 3: Building the Electronics

The ChIMP utilizes 24 volt or 36 volt Hoverboard Brushless Motors, usually sourced from a used board, along with a Bosch IMU (Inertial Measurement Unit), an Arduino Mega Microcontroller, and an ODrive 3.6 Motor Controller. The only costly part of the ChIMP is the ODrive board, but, as you can see from the videos, it helps keep the robot rock solid. Perhaps in the future a more cost effective solution may be implemented, if one presents itself. The Electronics Bill Of Materials is included in the downloadable Construction Manual, as well as a full Fritzing wiring diagram. Please watch both electronics videos before proceeding with installation and wiring.

Step 4: Programming and Set Up

What follows is instruction on programming, testing, and setting up a ChIMP. If this seems foreign, do not fear. Our community is there to support you. No one is born with this knowledge, but I suspect my Co-Founder Lukas might have come close!


THE ARDUINO MEGA:

Arduino IDE (Integrated Development Environment) Installation and setup:

The first step is to download the latest Arduino IDE from here, and install it on your PC. This program allows you to modify and upload programs (Sketches in Arduino speak) onto your Arduino Microcontroller.

After installation, connect your Arduino Mega to the PC via USB and restart the IDE. Under Tools > Board, select “Arduino/Genuino Mega or Mega 2560” and under Tools > Port select the port your Arduino is connected to.

Open the Serial Monitor under Tools > Serial Monitor and set the baudrate to 115200 (just to make sure there won't be issues with this later). Close the Serial Monitor again.

Test your general setup:

Under File > Examples < 01.Basics select ”Blink”. The IDE will display the respective Code in a new window. Click on “Upload” (the right pointing arrow in the top left corner in the IDE). The code should get compiled and then be uploaded to the Arduino. After successful upload, the Arduino's LED should blink steadily. You can change the values of delay() in lines 34 and 36 (times in milliseconds) and re-upload to change the blinking pattern. This test is powered by the USB connection…NO BATTERY NEEDED, AND IT SHOULD REMAIN UNCONNECTED!

Test the IMU:

After following the Electronics videos, and wiring up your ChIMP as shown in the included Fritzing Wiring Diagram (and then double checking EVERYTHING), it's time to test the IMU.

To easily use this relatively complicated sensor we need two software libraries that will do all the heavy lifting for us. Those are also provided by Adafruit here (sensor driver) and here (unified sensor interface). Installing and using libraries from GitHub is explained in Annex I.

To test if the sensor is working, start (or restart) your Arduino IDE, connect the Arduino with attached IMU and open the sensorapi example (as described here). Compile and download the code to the Arduino, open the Serial Monitor (to be found under tools; make sure the baudrate matches that in the code) and watch the stream of orientation data coming in as you tilt and turn your ChIMP! You are getting there! This test is powered by the USB connection…NO BATTERY NEEDED, AND IT SHOULD REMAIN UNCONNECTED!

Test the RC receiver:

Standard RC receivers run on 5 Volts, so they require 5V and GND from a power supply. The connectors of a receiver typically have three pins for each servo, with one for 5V, one for GND and one for the signal. The Positive and Ground power pins are each wired in parallel (all together), hence GND can be connected to any GND pin and 5V can be connected to any 5V pin.

The signal for each channel is encoded using PWM (pulse width modulation). For standard RC equipment, a pulse is sent 50 times per second. The duration of this pulse, which typically ranges from 1 to 2 ms long, is the signal. ChIMP needs three signals (throttle, steering and enable), thus three signal pins of the receiver are connected to the Arduino. You choose the 3 channels based on how your RC Transmitter is laid out, and how you want your controls to work. There are different ways of reading PWM input signals on an Arduino, but the most efficient one is to use interrupts. This ensures that the Arduino's processor is never busy waiting for the next pulse. By using interrupts, special hardware inside the Arduino’s microcontroller is used for triggering an interrupt service routine only when the processor really needs to do something (i.e. calculating the duration of the pulse). The downside is that this only works on dedicated pins, of which smaller Arduinos only have two. This is the reason that ChIMP needs an Arduino Mega which provides six interrupt pins.

For testing, wire up the receiver as described in the Chimp Electronics Videos and the Wiring Diagram. Connect the three channels you want to use to control the robot to the Arduino pins 2, 3 and 18 (as defined in the config file). Normally Pin 2 is for Steering, Pin 3 is for Throttle, and Pin 18 is for the Enable (used as a failsafe, the Enable must be "On" for the Chimp to balance and operate)

Upload the receiver_test sketch in the tests subfolder to the Arduino.This test is powered by the USB connection. NO BATTERY IS NECESSARY FOR THIS TEST, AND IT SHOULD REMAIN UNCONNECTED!

Once the sketch is uploaded and running, open the Serial Plotter in the Arduino IDE (Tools > Serial Plotter). As you move the sticks on the RC transmitter, you should see three curves react accordingly. They show the three signals’ pulse widths in microseconds and should be centered roughly around 1500, ranging from 1000 to 2000.

ODrive Motor Controller Wiring:


Power and Motors:

The ODrive is powered from the battery via its DC Terminals, and each motor's three phases (A, B, C, Blue, Yellow and Green) are connected to one of its motor output terminals (M0 and M1). The ChIMPs righthand motor (his right hand) is connected to M1, his left connected to M0. The order in which the motor wires are connected does not matter, as the ODrive figures this out by itself during calibration.

Auxiliary resistor:

Since the ChIMP is running on batteries, generally no auxiliary braking resistor is required (the ODrive dumps recuperated energy back into the battery). However, depending on the type of battery you are using, the resistor might help avoid issues on the power bus that could lead to the ODrive unexpectedly shutting down.

Hall sensors:

Each hoverboard motor comes with internal Hall (magnetic) sensors that tell the ODrive when to power which of the three motor phases. Each Hall sensor set has five wires: Two for power (5V, usually red and GND, usually black) and three for signal (often blue, yellow and green). A motor's Hall sensors are connected using extension cables to the corresponding sensor inputs (M0 and M1) on the ODrive's J4 connector. The three signal lines are connected to inputs A, B and Z where the order again does not matter. You will probably need to make an extension cable (the shorter the better for the signal). Note that it is necessary to add a 22nF capacitor between each of the three signals lines and ground for signal integrity. Charleston Robotics has developed a neat little PC board that incorporates these capacitors along with a header and pads to solder your extension wires. Look for them shortly on our website!

Configuring the ODrive:

To configure the ODrive for the ChIMP you need to first install the ODrive tools software and setup the necessary drivers. There is a comprehensive explanation of how to do this for different operating systems here.

The tools include the odrivetool interactive shell and a Python3 library. 

Once you have installed all the tools following these Instructions, this script takes care of setting up the ODrive. This will only work if the wiring of the motors and Hall sensors is correct.

All you need to do is:

  1. Wire up the ODrive and motors as directed in this Construction Manual.
  2. Make sure both motors are ABSOLUTELY FREE TO TURN. Secure the robot on a stand.
  3. Connect the ODrive to a computer via USB.
  4. Power up the ODrive with the ChIMPs battery.
  5. Run this script ODrive Setup using a Python3 interpreter. On Linux this will look like so for motor M0:

./odrive_setup.py -a 0

And like so for motor M1:

./odrive_setup.py -a 1

You can use the interactive odrivetool to check if the motors are working as expected, or you can go right to the next step!

Remote control the motors via the Arduino:

Now that the ODrive is ready to use and the Arduino receives the RC signals, you can control the motors via the remote control. 

Wiring:

The Odrive provides enough power from it's 5V regulated output to power the Arduino and the receiver. You also need to connect the Arduino’s serial interface to the ODrive - an overview over all necessary connections is shown on the ChIMP Wiring Diagram.

Code:

Once the ODrive, the motors, the Arduino and the receiver are wired up, you can upload this test project to the Arduino Mega. 

Test:

MAKE SURE THE ROBOT IS PROPPED UP AND THE WHEELS CAN TURN FREELY!

Connect the battery to the ODrive. You should see the Arduino’s LED flashing, indicating that the 5V power supply from the ODrive is working.

The motors should be in idle mode. Activate them by sliding/switching/turning the respective knob (Stick) on the RC transmitter. After that, check if they move when you move the sticks. Applying throttle should make them turn in the same direction, applying steering should make them turn in opposite directions. If that’s not the case, adjust one of the MOTORDIR definitions in the config.h, recompile and reupload.

Control the motors by tilting the IMU:

At this stage, you can go ahead and compile and upload the complete HoverBot.ino file onto your robot. For testing, again make sure that the wheels are free to turn!

Once you turn on the robot, the blinking LED indicates that communication with the IMU is established and the system is ready to go. If the LED does not blink, something is wrong with the IMU.

In addition to reacting to the RC commands, once activated the wheels will now also react to the tilt of the vehicle. Tilting forward should make them turn forward, tilting backward should result in the wheels turning backward. Think of balancing a ruler in your palm: if it falls away from you, you must quickly move your hand forward to catch its fall...Rotating the robot around the vertical axis should make the wheels counter-rotate - this helps with driving straight.

Controller tuning:

The controller is based on five parameters:

  • KP_BALANCE: Determines how much the robot reacts to leaning forward or backward. A high value might lead to tilt oscillations
  • KD_BALANCE: Determines how much the robot reacts to the rate of tilt change. It generally dampens oscillations, but a value too high might lead to increased oscillations (mainly due to time lags in the control loop)
  • KP_POSITION: Determines how strongly the robot reacts to RC throttle commands
  • KP_STEERING: Determines how strongly the robot reacts to RC steering commands
  • KD_ORIENTATION: Determines how much the robot tries to counteract turning around the vertical axis - higher values make going straight easier but turning slower

Tuning these parameters is not trivial and generally is a tedious, iterative process (test, change, compile, upload, repeat). However, the default parameters should be a very good start and if anything you should only need to change the first one (KP_BALANCE). If the robot does not seem to balance well, try a (slightly!) higher value. If it oscillates, try a (slightly!) smaller value.

Change the parameter in the config.h accordingly, recompile and reupload.

Annex 1. Installing Arduino Libraries from Github:

Installing Libraries:

Software libraries are an efficient and common way to encapsulate and distribute pieces of reusable code (such as sensor drivers) that are not expected to need to be changed by the user. A library typically consists of two files, a header file (.h) and a source file (.cpp). Some libraries consist only of a header file, some contain additional files or even subfolders.

Using a library in an Arduino project generally requires two steps: 

  • Placing all files (.h and .cpp) in a subfolder of your Arduino IDE’s libraries folder. The libraries folder is created automatically upon installation of the IDE. The subfolder needs to have the same name as the library. This step is referred to as “manual installation” in the official Arduino tutorial on the topic
  • At the top of your Arduino sketch, including the library with a precompiler instruction that looks something like #include <myLibrary.h>. This line of code alternatively gets created automatically when you click Sketch>Include Library>myLibrary as is shown at the very bottom of the tutorial.

Getting the Code from GitHub:

Many open-source projects (such as our ChIMP) are hosted on GitHub, which is an online platform building on the powerful and widely used software version control tool Git. On any project main page, there is a green button captioned “Clone or download”. 

If you are familiar with Git you can simply clone the entire project into the right folder, e.g. into a subfolder of the Arduino libraries folder in case of an Arduino library. If not, simply click on “Download ZIP” and, once downloaded, extract the archive into a subfolder of the libraries folder. Alternatively, you can use the Arduino IDE’s built-in functionality to include ZIP libraries, described here.

Note: You will need to restart your Arduino IDE after installing a library before you can use it in your code.

Step 5: The Path Forward, and the Future

As designed and presented here, our ChIMP is Radio Controlled. He’s really fun to drive and people love him, but this is really just the beginning! His head design is nearly complete, and will be posted soon. It’s also designed to be 3D Printed by a small, inexpensive printer. Charleston Robotics is working with Synthiam Software to develop their ARC software to control the ChIMP using a second microcontroller, while adding robotic capabilities such as OpenCV vision tracking, ChatBots, WiFi control with their mobile Apps, video transmission, and much more. This adds a way to add features to a robot without actually mastering a programming language. Check out Synthiam's ARC here Those that love to program can develop their own control software using a myriad of sensors and their preferred Microcontroller and language.

Mechanically, the ChIMP has just begun! We are hoping to see our community add functionality to ChIMP's Arms, Elbows and Hands / Grippers, along with a kickstand and a way to actually sit down. We will share STLs for 3D printing, and we hope future iterations of ChIMPs will continue to be modeled in 3D. Solidworks has been very supportive of our project, and has graciously allowed us a Startup license...In fact several of the images in this Instructable and on our website are actually 3D renders in Fusion 360!

If you are interested in this project, we would love to have you visit our website and join our forum! We are hoping to build a community of like-minded Makers and budding roboticists who can have a blast while developing a truly special robot!

Have questions? Post here, or head over to www.charlestonrobotics.com and join the forum!