Wednesday, November 11, 2009

Lab 6 Real System Identification

To analyze the new system, we modified the code used in the previous exercise with the addition of another array to control motor direction. The array was populated with a random distribution of 1's and 0's, which translated to HIGHs and LOWs for output to the H-bridge direction pin.

A plot of the white noise input (in blue) and the system's response (in green) is given below. (Note: the input and response are not given in the same units, and thus the y-axis scale should be ignored.)


Running the system identification, Matlab returned the following bode plot of the estimated transfer function. Comparing the figure below with the expected bode plot (shown above), it is clear that the results are not as accurate as the results for the RC circuit. The phase plot decreases in degrees, but acts more like a 2nd order system than the expected 1st order system. The magnitude plot does not show the expected 20dB/decade slope. Possible causes are the resolution, or lack of calibration, in our accelerometer or noise in the system. One solution not attempted was filtering the data through an op amp filter. Further system identification work will have to be completed on our actual project system in hopes to obtain better results.

Lab 6 - Real System

The team explored system identification of the fader motor used in previous labs. Rather than measuring a position response to a motor voltage, we decided to explore acceleration response by attaching an accelerometer to the slider. We also added mass to the slider to overcome the effects of friction on the slider. We chose exploring the acceleration response of the system as we thought an accelerometer may be useful for the final project, if accelerometers were used on a drumstick.

The system is represented by a constant K, which is comprised the of motor constant, radius of the gear, and motor resistance, mass of the bolt/accelerometer, damping of the motor and system, and resistance of the motor.
This system is represented by the Bode plot shown below. It should be noted that this system is only a parametrized model and does not incorporate real numbers. It was created to see the shape, not values, of the plot.



Lab 6 - System Identification

To familiarize ourselves with Matlab's tfestimate() function and learn how to set up serial communication between Matlab and Arduino, we first constructed the RC circuit shown in the circuit diagram below.



The above RC circuit functions as a low-pass filter characterized by the transfer function and frequency response bode plot given below.



We then programmed Matlab to send a stream of white noise to Arduino, which outputs the white noise as a PWM signal to the RC circuit, senses the response, and transmits it back to Matlab. At first, we had Matlab and Arduino communicating signals one at a time (i.e., Matlab would send a single piece of white noise (a random number) to Arduino, and Arduino would respond with the RC circuit's response). We found this method to be incredibly slow, with sample rates less than 10HZ, well below the cut-off frequency of our low-pass filter. To remedy this, we reprogrammed the system so that each operation (e.g., creating the white noise, sending the PWM signal and sensing the response, etc.) was done separately with no overlap. Using this method, the system was programmed to follow these steps:

Step 1: Create the white noise and save it as an array

Rather than retrieve one random number from Matlab at a time, we programmed Arduino to create an array of random numbers that serves as the white noise. This eliminated the delay between when Arduino transmits the RC circuit's response and when it receives another random number from Matlab.

Step 2: Output the white noise as a PWM signal and sense the response

After the array of white noise is created, Arduino outputs a single element as a PWM signal to the RC circuit, senses the response and saves it to an array, and then delays for 0.9ms. This operation iterates until every element of the white noise array has been output.

Step 3: Transmit the white noise array and the RC circuit response array to Matlab

After all white noise output and response sensing is complete, Arduino transmits the two arrays to Matlab for processing. Delaying the serial communication until after all signal output/sensing is complete significantly increases the sampling rate. Using this method, we were able to achieve sampling rates of 1000Hz.

Step 4: Read and process the data from Arduino in Matlab

We programmed Matlab to process the data and produce two figures. The first figure, included below, shows the white noise (in blue) and the system's response (in green) with respect to time. The second figure, also included below, shows the bode plot of Matlab's estimate of the transfer function (in blue) and the bode plot of the actual transfer function (in green).

Lab 6 Team Members

Alex Pechette
Jonathan Williams
Dan Yoon