Intelligent Oscillation Controller

From Mech
Jump to: navigation, search

Contents

Team Members

Scott Mcleod: Electrical Engineering Class of 2009

Brett Pihl: Mechanical Engineering Class of 2008

Sandeep Prabhu: Mechanical Engineering Class of 2008

Overview

The overall goal of this project is to create a system that induces a forcing function upon a basic, spring, mass, wall system to achieve an arbitrary periodic acceleration profile (a combination of a 10 and 20 Hz sine wave for our system) on the mass. An accelerometer is mounted upon the mass in the system. A PIC microprocessor records this acceleration data as well as controls a speaker (with the help of a DAC) that provides the external force to the system. This PIC communicates with MATLAB via Serial RS-232 communication. MATLAB processes this data and sends back a control signal for the speaker. After several iterations the actual mass acceleration profile begins to match the chosen profile it is told to "learn."

Mechanics

Speaker-Rod Connection
Mass-Rod Connection
Spring-Mass Connection

The basic mechanical system for this device is a simple one, but must be assembled with precision. The major components are the speaker, linear ball bearings on a precision rod, and a spring. The basic construction method is described below.

First, the speaker is mounted perpendicular to the ground. This must then be attached via a rod to the mass. We tried several approaches, but what seemed to be the best solution was to epoxy about a one inch section of PVC pipe to the center of the speaker. The diameter of the pipe we used matched the diameter of the junction in the speaker where the cone turns from concave to convex (See the figure to the right). This pipe also had two tapped holes running along the length of the section for a plate to attach to. The plate attached to this PVC also had a threaded hole in the center for the rod that attaches to the mass. The other end of the rod screws into a threaded hole in a piece of polycarbonate which is attached to the block atop the mass, as shown in the figure to the right.

The forces exerted by the speaker are small enough (approximately 3 Newtons) that only about an 8 ounce mass is needed. The bearing we used didn't require any additional mass to satisfy this constraint. A piece of modeling foam was machined and attached to the bearings through threaded holes (shown in the figures to the right). The purpose of this block was to provide a connection surface for both the rod and spring, it also was where the accelerometer was mounted. A piece of sheet metal was screwed into the spring side of the block with spacers. This piece of metal is used to anchor spring to the mass, and allows the spring to easily be removed. A similar piece of sheet metal is attached to the wall on the opposite side of the spring. However, this sheet has a vertical slot about an eighth of an inch wide cut from the bottom. This allows the coil of the spring to slide up further on the plate, thereby creating a more solid connection. The spring mass connections are shown in the figure to the right.

The final step is to mount the linear slide atop a block such that the rod, mass, and spring are all level. It is very important to design each component with all other components in mind at the same time. Mainly, making sure that the linear slide is level, and the rod attached to the speaker is centered, level, and in line with the mount on the mass and spring on the opposite side of the mass. This will help to ensure that all motion in the system is one dimensional.

The above was not the first iteration of our mechanical design. We originally had a homemade linear slide. However, we found the lack of precision resulted in unreliable bode plots of the system due to the loose tolerances of the design creating side-to-side motion. The first iteration also had the rod epoxied directly to the mass and speaker. During initial testing the connection between the speaker and rod actually severed.

The current design has much greater adaptability suitable for the experimental nature of this project. The threaded rod allows for minor distance changes to ensure the spring attached to the wall is at its natural rest length. To attach it the plate is detached from the PVC on the speaker and screwed onto the rod. With the spring detached, the other end of the rod is screwed into the threaded hole on the mass. Finally, the plate is then screwed into the PVC through the two threaded holes. The non-permanent spring attachment also allows for springs with different k-values to be added to the system and experimented upon. If the spring is longer or shorter then desired, a simple change in rod length is all that is needed to incorporate the new spring into the system.

Circuitry

Main Circuit
Accelerometer on mass


Power Supply Wiring
Amplifier Input
Amplifier Output and Power

The main elements of the circuit were a PIC, DAC (Digital-to-Analog converter) and accelerometer. The PIC would store a discretized sine waveform with integer values from 0-255. It would then output a function of this sine wave (our control signal) to the DAC. The analog signal output from the DAC would be sent to the amplifier, which would then power the speaker. The accelerometer on the mass would feedback the actual acceleration profile of the mass back to MATLAB. MATLAB would then recompute the next control signal and repeat the cycle until the mass was moving with the desired acceleration profile.

Our circuit diagram is shown below. An optional component is a 24FC515 EEPROM chip (24FC515 Data Sheet). The 512 KB of memory could be used to store data to later be retrieved and processed by MATLAB. We found this to be unnecessary in our experimentation. Learn more about external memory and EEPROM's here.

The speaker car amplifier must be powered by a 12 volt DC source, to accomplish this we used an Emtel EMV15012v power supply (Emtel EMV15012v). A picture of the wiring terminals is shown in a figure at the right. When powering your amplifier, the "REMOTE" terminal must be powered high with 12 V for the amplifier to remain on. We included a switch here to be able to power on our amplifier separately from the power supply. Using the left low impedance input on the amplifier means the output will be on the CH1/L terminals. Using the low impedance inputs also requires an RCA cable. We had to cut this cable in half and strip the insulation coating in order to access the positive and negative terminals of the RCA jack. The outside ring is negative, and the inside hole is positive. A picture of the amplifier input is shown to the right.

We used a surface mount LIS2L02AS4 accelerometer. We set pins 9, 11, and 13 LOW to give us a 2g resolution. These chips read acceleration in 2 dimensions, we used the X-direction (pin 10) read by pin 02/RC0 on the PIC. You can read more about accelerometers here.

Serial communication between the PIC and MATLAB was accomplished by using a FTDIChip TTL-232R USB to RS232 Cable. It is a bit more expensive then using a leveler chip and a DB-9 connector, but much more convenient. You can read more about this cable and the alternative option here. To learn more about serial communication between a PC and PIC, see this page.


Circuit Diagram


Programming

PIC Code

In our project, a PIC was used to drive the speaker via its I2C digital-to-analog converter and record accelerometer values at fixed intervals. Since the control system’s algorithm requires too much processing for the PIC, all the computations are performed in Matlab after the accelerometer data is transported to a computer via a serial cable. This setup simplified the program for the PIC.

To generate the waveform of voltage levels sent to the speaker, a single quantized period was used. Since the waveform is periodic in nature, the wave can be repeated indefinitely in a continuous fashion. The nature of our processing algorithm constrained the number of samples for the accelerometer data to be equal to the number of samples for the control voltage.

Since our system used a waveform of fixed intervals, we used an interrupt service routine (ISR) to change the wave and record accelerations at precise intervals. We chose to sample each signal every 1ms (as this is an achievable I2C speed and ISR). To oscillate our system at 10 and 20Hz, we needed at least 100 samples per waveform (1/10Hz / 1ms = 100 samples/waveform). For this reason, we created two 100-byte long vectors for the control voltage ‘u’, and the acceleration data ‘acc’.

PIC Learning Control
PIC Bode Plot Generator

Matlab Code

The Matlab code simply follows the protocol as established above. The user specifies in Matlab the parameters for the amplitude and phase of the desired acceleration waveform. *Note that the frequencies of these waves are set to 10 and 20Hz (as constrained by the transfer functions captured from the Bode and the periodic nature of 100 samples/wave).

Below are the 4 m files used in Matlab. Their names must be changed to the last part of their filenames as they are functions.

Main Matlab Loop
Learning Control Algorithm
Smoothing Algorithm
Plot Initialization Code
Bode Plot Generator

Program Flow

Program Flow

Control System

To “learn” the control voltages to create a desired waveform, a simple proportional control system was used. We should note much of this code was developed, tested and debugged by Tom Vose, who was invaluable to our final project. Below is our understanding of Tom’s control algorithm.

The system first guesses a control voltage of all zeros. This ideally results in no forcing of the speaker and a flat response of acceleration. After this initial guess, the program uses proportional control to match the desired acceleration waveform. Mathematically, it multiplies the error by a proportional factor k. The error is computed by subtracting the Fast Fourier Transform (fft) of the measured acceleration from the fft of the desired acceleration. This error is multiplied by the proportional control k, and two discrete Bode plot values corresponding to the transfer function of voltage to acceleration at 10 and 20Hz. The resulting signal is the control signal u, in the frequency domain. From here, the control signal is converted back to the time domain via an inverse fft, and sent to the PIC. All of the math is computed in discrete time, for the waveforms of 100 samples long. Below is a block diagram of this control system. Note that it is in the standard unity feedback form.

Learning Control System

Results

Below are three tests performed on various superpositions of sin waves at 10 and 20Hz. We have adjusted the phase of the waves to produce different results.

Each diagram, shows one period of an acceleration profile. The faint blue curve in the left subplot is the desired acceleration motion. The red lines on top of the blue curve are experimental accelerations as recorded by the pic. We can see that the red lines converge on top of the desired blue motion. The right subplot (green) shows the learned voltage waveform to create the desired acceleration profile.

Each wave follows the equation below with the given parameters:

acceleration_desired = amp1*sin(2*pi*base_freq*t+phi1) + amp2*sin(2*pi*(2*base_freq)*t+phi2)

Wave 1: phi1 = 1, phi2 = 2 Wave 2: phi1 = 0, phi2 = 0 Wave 3: phi1 = 1, phi2 = 0

Potential Applications

A common question regarding this project is its applications to the real world. In the Northwestern University LIMS lab, a similar type of undertaking is being researched, but on a much grander scale. This same type of oscillation control is being done for 6 dimensions (X, Y, Z, Roll, Pitch, Yaw). However, the microprocessors used in this type of control are extremely expensive, and this one dimensional test of a learning system provides a possibly cheaper solution. The six dimensional control system has possible real-world applications in product assembly.

Reflections

Great results were achieved from the learning algorithm. For engineers working on it in the future, here are some topics for further investigation to get a more complete understanding about the control system:

  • In this project, the control signal was manually phase-shifted by pi radians before outputting it to the speaker
    • This made the algorithm work perfectly
    • It is not well-understood why this step was necessary
    • The algorithm would not work otherwise
  • In the input for the FFT, the transfer function used in this project did not have an imaginary component
    • The robust algorithm still worked perfectly, and would shift phase and 'learn' when the program was run
    • In future experiments, a transfer function including an imaginary term could be used, to fully utilize the capabilities of the algorithm
  • Faster learning
    • The various constants in the algorithm equations can be tweaked for faster learning
    • Currently, it takes about 10-20 iterations to hit the desired waveform
    • More rapid learning would be a huge benefit in real-world applications

References

Personal tools