Tuesday, December 6, 2011

CIRC3-Assignment 4

Purpose
      The purpose of this lab is to learn to control a motor's speed using button input signals. 


Equipment

  • 1 x DC Motor
  • 1 x Diode
  • 1 x Transistor
  • 2 x Pushbuttons
  • 4 x LEDs
  • 3 x 10k Ohm Resistor
  • 4 x 330 Ohm Resistor
  • 14 x Wires
Assembly

     The following lab consisted of two circuits, the second one being a modification of the first one. The first circuit simply consists of a motor & its associated parts, and two pushbuttons. Exclude the LEDs and its associated resistors, wires, etc. Used for Part One, the pushbuttons are used to accelerate and decelerate the motor. Building the first circuit can take 3-5 minutes, however the most important step is taking a minute to check afterwards. Certain parts such as the diode is important for the safety of the parts. For instance the diode protects the motor from power surges and therefore must be connected properly. This also applies to the resistors used in all circuits (especially 10K). See the image of the assembled circuit to the right.



     
      The second circuit simple adds the four LEDs and its associated parts. This takes an additional 2 minutes, however if the primary circuit is not available, the whole circuit can take around 7 minutes to assemble. The additional LEDs play an important role representing the speeds in parts 2&3, so make sure they are connected accurately, and correspond to the program code. This circuit also only utilizes the first button. Simply ignore the other one. Nothing happens if it's pressed. See the image of the circuit to the left.




Program Details

     This assignment consists of 3 parts, each a slightly advanced modification of the other. Most functions were discussed in the previous blog, the only new concepts surround the inclusion of the motor. The motor's speed functions off an analog command. The range is 0-255, where 0 is off, and 255 is the maximum speed.  Commanding the motor to function at a certain speed follows this format: 'analogWrite(motorpin, speed), where the speed is a number from 0-255. In part 1, the 'for loop' is used to accelerate and decelerate the motor as the loop counts from 0 up to 255, then later from 255 down to 0. Each part's objective and code is explained below (comments). 

Part 1: Use the two buttons in the first circuit to accelerate (button 1) and decelerate (button 2) the speed of the motor.
Part 2: Use the first button to tell the circuit how fast the motor should be spinning. The number of times the button is pressed corresponds to how fast, and which LED is turned on. This can be 25% (one press, 1st LED), 50% (two presses, 2nd LED), 75% (three presses, 3rd LED), or 100% (four presses, fourth LED) of full speed. 

Part 3: Using the same circuit and speed values in Part 2, tell the motor what speed to function in. In addition, make the motor reduce to 25% of its speed every 0.5 seconds until it is turned off. As it reduces speed, the corresponding LED should be on as well. 


*The three parts serve as modifications, refer to CIRC03 for additional modifications.

Results

     There were certain minor errors that were often overlooked, but soon after correcting these, everything worked as it was supposed to. Again, there is strict timing as to when the buttons are pushed and when the buttons' states are read. To make this more user friendly, there were certain delays placed after reading the buttons' state. It was also hard to see the motor accelerating, it easier to feel it. To enhance the outcome, attach something light weight to the top of the motor, such as a small piece of paper. If possible, secure the detachable shaft from the mini servo on to the motor. Besides this, it was interesting to connect the two outputs, with one input. 

Tips include:

  • separate various parts of the circuit to avoid clutter (For instance, keep the LEDs bottom right, pushbuttons bottom left, and motor top left)
  • make sure the pins that the various inputs and outputs are connected to match the code, or else the data will not be conveyed
  • connect important pieces CORRECTLY, for safety issues (Eg, diode as explained earlier)
  • as always take the time to check over

Resources

Spark Fun Inventor's Starter Guide
http://schools.tdsb.on.ca/danforthcti/arduino/ArduinoGuide.html

No comments:

Post a Comment