AME 30315 Pendulum Project

From Bill Goodwine's Wiki
Revision as of 16:37, 15 March 2012 by Goodwine (talk | contribs)
Jump to navigationJump to search

Introduction

In this project you will design a feedback controller to stabilize an inverted pendulum. The basic steps are:

  1. system identification,
  2. controller design,
  3. implementation and verification.

The first and third steps require that you be able to program a microcontroller. The second step requires that you understand the course material.


The System

The pendulum and controller are shown in the figure on the right. It is comprised of

  1. the pendulum,
  2. a d.c. motor with optical encoder,
  3. an H-bridge current controller (the device with the heat sinks),
  4. a Freescale 68hc11 8-bit microcontroller with peripherals, and
  5. a usb-port logic analyzer.

The microcontroller is very inexpensive and has limited capability, as is realistic in industry where component costs are of significant importance.

There are two green printed circuit boards on the pendulum platform.

  • The smaller one, with the serial port on it, has the 68hc11 microprocessor on it. The actual hc11 is the square chip on the vertical board sticking out from the base. The chip on the base board is the serial interface. The round silver component next to the hc11 is the clock. The larger rectangular chip on the other side is the EEPROM.
  • The larger printed circuit board provides the interface between the microcontroller and the H-bridge and, the encoder, the index encoder and some limit sensors. It also has a chip on it that is a decoder for the encoder. Whenever the encoder encounters an edge, the decoder generates a pulse that produces an interrupt on the hc11. The hc11 then can query the decoder to determine which direction the pendulum is moving.

The H-Bridge has the heat sinks on it. It takes the PWM signal from the hc11 and produces a current proportional to the duty cycle.

You will need to use one of the desktop computers in XXXXX Stinson-Remick. Those computers should have the following software installed:

  • the 68hc11 port of the gcc compiler (look in xxxxxxx)
  • the bootloader
  • putty, to be able to communicate with the microcontroller over the serial port
  • notepadd++, for editing your programs
  • the logic analyzer (????) software.

There are 10 pendulum platforms and USB logic analyzers in the rooms. Return them to XXXXXXX when you are finished.

Getting Started

This section outlines the steps to write, compile, download and execute a program on the microcontroller. Until you have a controller designed that is supposed to stabilize the pendulum, make sure the pendulum is pointing down.

The file format that can be downloaded to the hc11 is called an "S-record" and has a filename that has a ".s19" suffex. Here is an example of an S-record that commands a square-wave torque to the pendulum with a period of approximately two seconds. It is a text file, so it is something you can look at and open in an editor, but it is not really decipherable.

The steps required to download the run this example square-wave program are

  1. ensure that the pendulum is hanging down,
  2. plug in both power plugs (one is for the hc11 board and the other is for the motor and controller XXXXXXX?)
  3. connect the serial port (elaborate XXXXXX, are there two comm ports on the PCs?)
  4. set the switches the right way and push the right buttons
  5. open a command window on the computer (how to do this?XXXXXX)
  6. cd to where XXXXXX?
  7. in the command window type
 whatever we type
  1. when it's downloaded you should see a prompt again. It takes between 30 seconds and two minutes, depending on how long the code is
  2. open putty and configure XXXXXX
  3. hit the right button
  4. you should see
     something
    in the putty window
  5. move the pendulum through the zero position
  6. etc


Interrupts

There are three interrupts in the program. Two are output compare interrupts and one is a pulse accumulator, which is acting like an input compare interrupt.

  • One output compare interrupt runs nominally at 880 Hz and is for the pulse width modulation control of the motor (OC3).
  • The other output compare runs nominally at 20 Hz and is the main control loop (OC2).
  • The input compare interrupt happens whenever the optical encoder senses an edge. There is a decoder chip on the board

Important Parameters

  • There are approximately 5 or 6 interrupts per angular degree of motion of the pendulum. More specifically, there is .18 degree per interrupt generated by the encoder.
  • There is an index on the encoder that happens only once per revolution. It should be aligned so that the pendulum is vertical when the motor goes through this position. There is a whitish/blue LED near the grey ribbon cable that flashes when it goes through this position. The calibration steps outlined below provide for an offset if this is not aligned with the vertical position. However, it must be the case that this position is within the range of motion of the pendulum. If the shaft slips too much and it's outside the range of motion, then the code will not work.