You Are Here: Home » AVR ATmega Projects » Microcontroller Programmer Projects » Multiple PID motor controller (with Wiimote!) using Atmega644

Multiple PID motor controller (with Wiimote!) using Atmega644




Introduction

The main idea for our project was to implement an inexpensive solution to the current CU Snake Arm motor-driving system by using a Mega644 microcontroller instead of multiple 3-Amp motor controllers as the snake arm was originally intended to be driven. Since we used DC motors, we implemented a PID control algorithm that determines the speed of the motors using PWM to achieve the best accuracy possible.

Multiple PID motor controller (with Wiimote!) using Atmega32

The motors can be controlled with Hyperterm or a Wiimote. Hyperterm allows for numerical input of each motor’s position ranging from 0 to 255. The Wiimote sends IR data via Bluetooth to a MacBook, which then sends the information to the MCU through a serial connection.

High Level Design

Rationale and Motivation

The Snake Arm team at Cornell designed its fourth generation arm having multiple cells involving gear assemblies, chains, springs, strings and pulleys. In order to move the arm accurately to a desired position, a real-time feedback is required.

The feedback is provided using potentiometers coupled with the motors through gears and shafts. The Snake arm team initially planned on using one Polulu 3-A motor controller to drive each DC motor. The fact that each Pololu PID controller can drive only one motor and has a cost of $50 imposes an inherent limitation in terms of cost and utility as the complete snake arm would require at least 10 controllers (5 segments). In this project, we implement a multiple PID motor controller using the Atmel Mega644 microcontroller which can drive up to 8 motors. This saves enormous cost and pain of calibration for the team.

We have also implemented Wii remote interface with our motor controller. This gives the snakearm more intuitive wireless flexibility in terms of motion control.

Background Math

The main feature of the motor controller is the ability to use feedback from sensors to continually update the motor operation and minimize error using the PID algorithm. The error is the difference between the desired condition set by the user through one of the input modes, and the actual condition reported back by a sensor. In our case the sensor is a potentiometer coupled with the motor shaft through a gear assembly and pulley system.

Tuning Method

We used manual tuning. We first set the Ki and Kd values to zero and kept on increasing the Kp until we reached a suitable value. After having full load on the motor we increased Kd until the motors were able to move the entire segment to the extreme points. Finally we increased Ki until the loop worked within an acceptable error range High values of Kd lead to extreme motor motion and instability. Increasing the Integral term helped us to get rid of oscillation problems.

Logical Structure

Hardware Design

Mechanical Components

Each segment of the snake arm comprises of three cells and two DC motors. The two motors are used to give the segment four degrees of freedom. One of the motor controls movement in the left-right direction while the other controls it in the up-down direction.

The red circular disks are three inch in diameter, laser-cut, out off acrylic for reduced weight. The motor frame has been CNC milled from Aluminum. Ball bearings are used to reduce friction. The gear assembly establishes a 20:1 worm gear reduction ratio. This leads to a maximum pulling force of 100 lbs per cable. The gap between each circular disk is 2 inches and each disk can rotate up to 20 degrees. Fiber rope is used for motion which allows the cable to be in tension at the center position thus reducing the dead zone at the straight ahead position. Opposite cables act in pairs, pull in cable on the inside of the curve, let out cable on the outside of the curve, chain and sprockets are used to synch the opposing pulleys. Springs have been attached for giving rigidity and support to the segment.

Electronic Components

Motor

We used the COPAL 60:1 gear motor, it is a high power, light weight and very efficient motor. The main reason for selecting this motor was the high amount of torque it can provide. The operating range is 6-18volts. We carried out all the tests and calibrations using 12 volts and duty cycles of of 25%, 50% and 100%.

Potentiometer

We used a Bourns single turn 10K potentiometer for getting the feedback signal

H-Bridge

We used the LMD18200 3A, 55V H Bridge. One H bridge is used to control one motor. Three main signals are being sent into the H Bridge which is the PWM, the brake and the direction bit.

Opto-Isolator

We modified the Opto Isolator circuit provided to us by Professor Bruce Land for the Lab exercise number 5. Three opto isolator circuits were required per motor: one for the brake signal, one for PWM, and the other one for direction.

Schematic showing PWM signal being fed into the H-Bridge through the opto-isolator

Wiimote and LEDs

Multiple PID motor controller (with Wiimote!) using Atmega32

The Nintendo Wii remote has a built in IR camera, which senses IR radiation from our IR LED circuit and calculates the position coordinates using triangulation method. The data from the Wii remote CPU is sent to the computer via Bluetooth. Since we couldn’t find enough IR LEDs in the lab, we borrowed a Wii “sensor” (really just ten LEDs hidden in a shiny black box) from a friend.

Parts List:

COMPONENTQUANTITYCOSTTOTAL
Total Cost:$44.50
H Bridge- LMD182002$12.00 per unit$24.00
H Bridge Holder2$1.50 per unit$3.00
Wiimote1Borrowed – Free
Wiimote IR Sensor1Borrowed – Free
Custom PC Board1$4.00 per unit$4.00
Atmel Mega6441$8.00 per unit$8.00
Small solder board2$1.00 per unit$2.00
Resistor 330 ohms6Free – ECE4760
Resistor 10K ohms6Free – ECE4760
Resistor 1M ohms6Free – ECE4760
Optoisolator – 4N356Free – ECE4760
Connecting wiresFree – ECE4760
Max233CPP1Free – Sampled from Maxim
RS232 connector1$1.00 per unit$1.00
Sip or header socket/plug40$0.05 per unit$2.00
DIP socket1$0.50 per unit$0.50

For more detail:  Multiple PID motor controller (with Wiimote!) using Atmega32

Leave a Comment

You must be logged in to post a comment.

Read previous post:
Electric Etch Using Atmega644

Introduction The "Electric Etch" project takes the classic Etch-a-Sketch® toy and turns it into a non-volatile, continuous-line display capable of...

Close
Scroll to top