Thursday, October 22, 2009

Lab 4 - Methods

Op Amps:

The initial op amp was constructed to amplify the signal of the hall effect sensor. A gain of 21 was chose to provide over 800 analog input points to signficantly improve the resolution of the motor position. A second op amp, the differentiator, was used to serve as a velocity sensor for the motor by differentiating the position signal.

One problem we encountered was the grounding of the single rail op amp chip. A virtual ground had to be constructed in order for the chip to work. This was done through the implementation of two resistors.


Results - MIDI Interface

Our modified Arduino MIDI output code was combined with our Virtual spring code to implement a one key keyboard with haptic feedback. The tone was based on the motor position, with feedback force increasing the further the motor armature was pushed from the center position. With the armature in the correct position the player would press the blue touch button (key) for the tone to be emitted from the computer speakers. You could also flick the motor and press the button while the armature oscillated to produce a variety of tones.




The Arduino sent the serial data with a value of 0-127 (based on the Hall Effect Sensor) to the PureData software, which translated the data into a sine wave with a frequency of 440 Hz assigned to an Arduino analog value of 69. A range of 0 - 10,000 Hz coulb be achieved in this design.

The two videos below show how our sensor with force-feedback emitted tones out of the computer speakers through the midi interface. Now there is two different kinds of force feedback for tones with pitch higher than the reference (middle position of the motor) and with lower pitch than that. It would also be possible to implement a different spring stiffness for each tone which would allow to feedback every pitch seperately.




This video shows our accelerometer which replaces the motor as a sensor as shown above. Here there is one axis enabled which is the x-axis. The results were quite satisfying and it is fun playing this instrument while getting feedback to the acceleration of the hand.


While rebuilding our sensor circuits on the arduino board we faced some problems with the new hall effect sensor. These were due to the inhomogeneous magnetic field or the nonlinear sensing of the device. We tried to find different applicable positions of the magnet but found that the standard position in "pushing"-mode was actually the best because other positions made the field very inhomogeneous in normal direction. Although the sensor values on the arduino ranged from 1 to 800, the middle position had an average value of 600.

Tuesday, October 20, 2009

Lab 4 - A Musical Motor

In the past lab we constructed a home brewed motor, with a hall effect position sensor. This week we upgraded our motors with higher resolution sensors, added op amps to serve as amplifiers and differentiators, and finally interfaced our Arduino with PureData to turn our motors into haptic feedback musical instruments. The virtual interfaces previously designed have been re-implemented with a true differentiator, rather than Arduino code, and with higher resolution. The virutal spring and virtual damper were re-tuned to feel even more realistic than before, thanks to the addition of op amps. The Arduino produced MIDI signals, correlated to a motor position, which were translated into audio waves by PureData. Haptic feedback was provided through the motor with the use of a virtual spring. The force of haptic feedback varied with the change in melody.

Lab 4 Team Members

Cameron Greybeal
Frank Sandner
Jonathan Williams

Friday, October 16, 2009

Lab 3 - Virtual environments


Virtual Spring:

Implementing a virtual spring environment was the equivalent of adding a feedback loop through the whole motor system to do position controller. With the proportional control, the controller force is simply directly proportional to the displacement from equilibrium, just as a spring is. Therefore, this virtual environment was working once we got our position controller functioning. A (sideways) video shows below that the force was indeed a function of the armature displacement.



Virtual Damper:

Implementing a virtual damper was done similarly to the virtual spring. The only difference was that the controller force was proportional to the derivative of the position signal rather than the position itself. Since we only had access to the Hall effect sensor signal, to get the derivative we had to perform numeric differentiation in the Arduino software. By taking position measurements of θ1 and θ2 at t1 and t2, the derivative is estimated by:
The controller force is then proportional to this value in the opposite direction.

In practice, we were unable to get an effective damper working. The Hall effect sensor only had a range of roughly 20 values over the range of the arm movement and would continually fluctuate, even when the arm was held perfectly still. This translating to the controller thinking the arm was perpetually moving back and forth violently and so its corresponding response caused the arm to vibrate significantly. Furthermore, if the controller gain was too high, the vibrations would be amplified, resulting in an unstable system. The net result was that when we ran the motor with a low enough gain to be stable, the response to our input movements was not high enough to be felt significantly stronger than the continual vibration in the system.

Virtual Mass-Spring Attachment:

The final virtual environment involved simulating a mass attached to spring that was also virtually connected to the motor armature. The equation modeling this environment had been worked out in the homework and we simply needed to translate it into the Arduino code. The end result worked by tracking the force on the virtual mass and integrating it twice to obtain its position. The position was then compared to the armature position, defining both the torque on the armature and the mass at the current time step.

By tuning the values of the mass and spring, we were able to get a good response in the motor that could easily be felt. The most intuitive settings were a relatively high value for the mass and a low value for the spring stiffness. This led to a high oscillation time period, during which the trajectory of the mass could very clearly be felt in the armature as it both stretched the spring out to maximum displacement and crossed over the center point, switching the torque direction.

Lab 3 - Motor controllers

PID

In addition to simple proportional control, we also were able to implement a full PID controller. For the I and D components of the PID controller we were forced to numerically differentiate and integrate the Hall effect sensor reading. Differentiation was done by computing the difference between successive sensor readings divided by the time period between them and integration was done by adding the current position error multiplied by a time interval to a running sum of the cumulative error. It turned out that the integral was far more stable that the derivative control due to the noise in the Hall effect. The integral controller also had the benefit of removing steady-state error in the arm position, but did have the disadvantage of a much slower response time, especially when a significant amount of error had accumulated, as can be seen in the video below.




Detent

The detent controller was designed to simulate a hard stop in the arm movement that could be passed over with enough force, similar to plucking a taut string. To implement this, we specified a small region in the center of the motor's workspace where a large torque was exerted away from the center. This was a simple discontinuous function that jumped to a high value in the detent region and was zero everywhere else. The net effect was a force strong enough to push back the arm unless a large external torque was applied, allowing the arm to "jump" over the detent and return to equilbrium on the other side of the workspace.


Lab 3 - Frequency response

We were also able to evaluate our motor system in terms of its frequency response. To do this, we removed the position control from our model, resulting in a simple forward path transfer function:

Vpwm corresponds to the duty cycle of the PWM signal being sent to H-bridge which acts as the input to the motor system. Vpwm was output from the Arduino board as a sine wave of varying frequencies and amplitudes. The minimum frequency we could take a valid reading at was 10 rad/s with a duty cycle value of 3.5 out of 255. This was the minimum value to overcome friction in the motor and at any lower frequencies the gain was high enough that the motor would reach the edge of its workspace. We took several data points over a frequency range up to 100 rad/s, with a maximum PWM output value of 40. For each frequency and amplitude combination we collect data points from the Hall effect sensor and measured the resulting amplitude in position. The two amplitudes were then divided to find the gain in each case. The resulting comparison is shown below.

The data clearly has similar behavior to the model with the major difference being an offset in the gain. This is most likely due to an incorrect characterization of one or more of our gain values.

Lab 3 - Motor model and theoretical behavior



Given the differential equations governing the motor system behavior, we were able to create a Simulink model of the system, following the general idea of the block diagram models discussed in class. The key element of the model is the element representing the motor mechanical dynamics which takes a torque as an input and outputs the resulting speed. The torque is determined by a series of gains starting at the Arduino PWM signal duty cycle value, which is converted to an effective voltage seen by the motor by the H-bridge and then further modified by the resistance of motor wires and the torque constant. Additionally, there is also feedback from the motor speed in terms of back EMF, but as we were almost always operating the motor at stall, our model assumes no back EMF feedback (Km = 0). Finally, there is an additional external feedback loop which takes the integrated velocity output (in reality, measured by the Hall effect sensor) and feeds it back to perform position control. There is also the potential for a load torque on the armature, which acts as a disturbance to the position controller, but in our case the only load torque was gravity, which was negligible for the motor in vertical position.

To validate the model, we performed both a simulation and an experiment of the motor response when commanded to move to a position of 5 degrees with a position controller gain of 5. As can be seen in the simulation, the net result is a highly underdamped system that converges to the desired position after roughly 5 seconds. When the actual experiment was performed, we found that the motor immediately moved to the desired position and then stayed there with little to no extra oscillation beyond the Hall effect sensor noise. This difference was mostly likely due both to non-linear effects of the friction in our motor, and the poor quality and extreme quantization of the Hall effect sensor.

Lab 3 - Motor Characterization

J

We estimated the inertia of the motor armature through the use of a bifilar pendulum. This method involves hanging the ends of the arm by two long strings and measuring the time period of small angle oscillations in the horizontal plane. This gives the moment of inertia about the point halfway between the hanging strings, or the geometric center of the arm, through the relation:

Where m is the arm mass, g is gravity, r is half the distance between the hanging strings, h is the length of the strings, and T is the time period of a single oscillation. All of these values were easily measured with the time period taken as one tenth the value of the time required for 10 oscillations. As the resulting inertia is about the geometric center of the arm, two applications of the parallel-axis theorem are required to find the inertia about the axis of the rotation shaft. First, the inertia is translated from the geometric center to the center of mass and second from the center of mass to the shaft axis. This required knowing the distance between these three points. The geometric center and shaft axis were easily measured, while the center of mass position was found by balancing the arm on a fine edge. The net result for the inertia about the motor rotational axis was therefore found to be J = 5.64 x 10-5 kg•m2 or J = 564 g•cm2.

B

To find the damping coefficient of the motor, we ran an experiment where we attached a relatively large weight to the armature, held the motor vertically, and let it oscillate as a pendulum. Assuming small angle oscillations, the equation of motion describing the arm behavior can easily be derived from a standard 2nd order rotational mass-spring-damper system. Using the Hall effect sensor to estimate position, the results of our test appear below with the peaks of the oscillations describing a exponentially decreasing function:

H0 is the initial Hall effect reading when the arm is released and HC is the reading at the center when the arm is completely vertical and at equilibrium. Pulling out the data of just the oscillation peaks to measure the rate of decay, the values can be modified to fit the modified equation below, which is conducive to a linear fit.


The linear fit was then done on these data points, resulting in a value for T of 1.24s. From the equation of motion, T = J/b and compensating for the change in J from the mass added to arm, a value of b = 9.1 x 10-5 N•s/m can be calculated.

K_t

To find K_t, we mounted the motor sideways on the table and hung various weights off the end of the armature. The voltage at the power supply was then slowly increased until enough current was flowing to produce enough torque to suspend the weights. We then were able to collect the data points measuring the current with a multimeter and knowing the torque produced on the motor by the weights. As can be seen in the plot of our data, the data points do not tend towards the origin, but rather a point of no current and non-zero torque. We believe this the static friction inherent that has to be overcome before lifting the weight and so we ignore the offset and simply use the slope of the linear fit as our torque constant. This value was Kt = .01562 N•m/A.

R

R was found simply by using the multimeter to measure the resistance in the motor wire. We measured a value of R = 0.4 Ω.

Wednesday, October 14, 2009

Lab 3 - LabVIEW Interface to generate sound

A part of our lab experience was connecting the aruino and the motor with a LabVIEW environment. We used LabVIEW to receive a signal sent by arduino and play appropriate tone of sound. We used the detent mode to replicate the guitar string. Once the user plucks the string (goes over the detent window) a digital signal is sent to the computer. The LabVIEW VI interprets the digital signal and generates a short sound with pitch controlled by the location of a potentiometer which is connected seperately to the LabVIEW. The block diagram and front panel screenshorts are shown below.



The VI runs on an infinite loop with sampling frequency of 1 kHz. Once a digital signal is received (the digital input voltage goes from 0 to 5 V), the DAQ system sends out a True signal to the case structure. Inside the case structure is Play Waveform.vi which generates a sound with certain frequency (note) provided from somewhere else. Of course the False case doesn't do anything. The frequency (note) is determined by the voltage output from a potentiometer. We wrote the model in a way so taht the potentiometer voltage output (0 to 5 V ) is translated to the frequency range of 220 Hz and 1220 Hz.

The front panel is made to give visual feedback of the sound generation. The LED shows whether the sound is played or not while the waveform chart shows the musical frequency.

Here is the final result of the interface in action:

Lab 3 - Motor Construction and Control

Some of the motor parts weren't as perfect as we wanted, so we ended up damaging the motor parts while we were characterizing the motor properties. However the deligent GSI, Hasan, was there to supply us spare parts. We followed the iTouch motor assembly instruction provided to us. The majority of the time was spent on reducing the friction between the rotor and the housing. The friction was minimized by the generous use of spacers/washers and multiple reassembly trials. The total number of wire winding was 22.

We used the sign-magnitude method to control the motor speed. We were not able to control the motor torque as we had no way to control the current flowing in the system. Arduino conveniently provided the sign-magnitude method capability via its analogWrite function. The H-bridge assembly (Pololu motor controller) was used to control the motor. The PWM signal and the direction signal were sent from Arduino. The both signals were in digital inputs and their magnitudes (high or low) determined the speed and direction the motor would rotate.

The controllable variables were the direction and motor speed and the feedback available from the motor was the rotor's relative location determined by the hall effect sensor mounted in the middle of the pendulum. Using these resources, we were able to implement multiple control strategies (P, PI, and etc) to achieve our goals throughout the lab experience.

Lab 3 Members

Josh Langsfeld
Amit Ranjan
Deokkyun Yoon