Tuesday, January 31, 2017

Lab 11 - Using the Serial Port

Demonstrate Serial Input Turning the LED ON

Materials:

Summary:

CODE.ORG Homework Asssignment

Code Goes Here:)

In this game you start off as R2-D2 at normal speed on Endor, but be careful there are two Stormtroopers after you.  You must get the Mynock, which then produces a Puffer Pig.  Get the Puffer Pig and you are now on Hoth with a Tauntaun.  The bad guys are still after you.  Get the Tauntaun and you find yourself on a Starship and as C3-PO.  C3-PO is super slow, so use the Obstacles to give him super speed.  Get the Mouse Droid, but two more Stormtroopers follow it.  You must quickly kill the Probot to save the Rebel Pilot, who is also being chased by two more Stormtroopers.  You win the game by saving the Rebel Pilot and lose the game whenever a Stormtrooper kills you at any map level.

Have Fun!!!

setBackground("Endor");
setMap("blobs");
setDroid("R2-D2");
setDroidSpeed("normal");
playSound("R2-D2random");
function whenUp() {
  goUp();
}
function whenDown() {
  goDown();
}
function whenLeft() {
  goLeft();
}
function whenRight() {
  goRight();
}
moveSlow("PufferPig");
moveSlow("Probot");
moveNormal("Mynock");
moveNormal("Tauntaun");
moveNormal("RebelPilot");
moveFast("MouseDroid");
moveFast("Stormtrooper");
addCharacter("Mynock");
addCharacter("Stormtrooper");
addCharacter("Stormtrooper");
function whenTouchObstacle() {
  setDroidSpeed("fast");
}
function whenGetMynock() {
  setDroidSpeed("normal");
  addCharacter("PufferPig");
  playSound("MynockRandom");
  addPoints(1);
}
function whenGetPufferPig() {
  addCharacter("Tauntaun");
  playSound("PufferPigRandom");
  addPoints(5);
  setBackground("Hoth");
  setMap("circle");
  setDroidSpeed("normal");
}
function whenGetTauntaun() {
  addCharacter("MouseDroid");
  playSound("TauntaunRandom");
  addPoints(10);
  setDroidSpeed("normal");
}
function whenGetMouseDroid() {
  setDroid("C-3PO");
  setDroidSpeed("slow");
  setBackground("Starship");
  setMap("grid");
  addCharacter("Stormtrooper");
  addCharacter("Stormtrooper");
  addCharacter("Probot");
  playSound("MouseDroidSoundRandom");
  addPoints(25);
}
function whenGetProbot() {
  addCharacter("RebelPilot");
  addCharacter("Stormtrooper");
  addCharacter("Stormtrooper");
  playSound("ProbotSoundRandom");
  addPoints(50);
  setDroidSpeed("fast");
}
function whenGetStormtrooper() {
  endGame("lose");
  playSound("alert1");
  removePoints(100);
}
function whenGetRebelPilot() {
  endGame("win");
  playSound("R2-D2random");
  addPoints(100);
}
I put a lot of time and thought into this game so it wasn't just a bunch of random aliens forever spawning, and then crash the game cus there are thousands of them.  You actually need to collect the critter with getting killed by stormtroopers and save the rebel pilot.  This game makes sense and has a defined goal and story to it.
Be nice!!! 
I made a super awesome snowflake, you'll just have to take my word for it.

I did the Design one, all my animals had free range.  Zombies and Creepers always attack at night and my Iron Golem beats them up without me having to tell it.

Sunday, January 29, 2017

Lab 7 - Introduction to Microcontrollers

What is a Microcontroller?

A microcontroller is pretty much a computer on a chip.  It looks like a small piece of black plastic with a bunch of metal legs protruding from the sides and goes on a circuit board.  Microcontrollers are a lot than meets the eye as it is low-cost and has many function integrated into it to perform specific operations.  The microcontroller is an integrated circuit (IC) that contains memory, processing units, and input/output circuitry on a small chip that interfaces with a much larger circuit board that may have sensors, switches, and motors.  Every microcontroller that is purchased comes as a "blank", which means you need to plug it into your computer and program it with a specific control program.  When the microcontroller is programed with a specific purpose it can then be built into a product to make it more intelligent and easier to use.  A super, big plus of a microcontroller is that it can replace a number of separate parts and components, or complete an electronic circuit.  Everyday products that use microcontrollers are household appliances, alarm systems, medical equipment, vehicle subsystems, and electronic instrumentation.

Advantages:
  • Increase reliability through a smaller part count
  • Reduce stock levels, as one microcontroller replaces several parts
  • Simplified product assembly and smaller end products
  • Greater product flexibility and adaptability since features are programmed into the microcontroller and not built into the electronic hardware
  • rapid production changes or development by changing the program and not the electronic hardware
Demonstrate Knight Rider LED Flashing Band

Materials:
  • Arduino Board
  • Breadboard
  • Sufficient wire
  • 4 LEDs
  • 4 resistors between 200-500 Ohms (Red, red , brown is 220ᘯ is ideal)
Summary:

To show how simple and easy it is to get started with programming the Arduino we needed to go to the link Arduino.cc to download the Programming Environment for the Arduino (PEA).  It took about 5 minutes to download everything needed for this lab.  The PEA is also easy to navigate with example lessons.  First we need to make sure the settings are correct by clicking "Tools" so that the PEA can communicate and transfer programs to the Arduino via USB cable.  We start off with a program called Blink and run the program to the Arduino to blink its orange light built into the board.  Then we are tasked to change the blinking intervals from 1 second to half of a second.

We first go over three functions that are easy to understand: pinMode(Pin #, Input/Output), digitalWrite(Pin #, LOW/HIGH), and delay(time in milliseconds).  The pinMode() function initializes the digital I/O pin on the Arduino board and defines it as an output signal for switches or input signal for sensors.  The digitalWrite() function tells the pin being used to either be HIGH (5V or 3.3V) or LOW (0V).  HIGH and LOW can be thought of as On and Off.  The delay() function causes the Arduino to halt execution for the specified time between its parenthesis bar in milliseconds.


K.I.T.T. LED Flash (Program as typed into PEA):

void setup()

{
pinMode(10,OUTPUT);  //Initialize Digital Pin 10 as an output
pinMode(9,OUTPUT);  //Initialize Digital Pin 9 as an output
pinMode(8,OUTPUT);  //Initialize Digital Pin 8 as an output
pinMode(7,OUTPUT);  //Initialize Digital Pin 7 as an output
}

void loop()

{
digitalWrite (10,HIGH);  //Set the LED On
delay(500);                      //Wait for 500ms
digitalWrite(10,LOW);   //Set the LED Off
delay(500);                     //Wait for 500ms

digitalWrite (9,HIGH);
delay(500);
digitalWrite(9,LOW);
delay(500);

digitalWrite (8,HIGH);
delay(500);
digitalWrite(8,LOW);
delay(500);

digitalWrite (7,HIGH);
delay(500);
digitalWrite(7,LOW);
delay(500);

digitalWrite (8,HIGH);
delay(500);
digitalWrite(8,LOW);
delay(500);

digitalWrite (9,HIGH);
delay(500);
digitalWrite(9,LOW);
delay(500);
}     


Lab 10 - Microcontollers, Input and Output

Lab 10 is mainly apply C++ code knowledge to take information form sensor to turn ON and OFF output devices, which is pretty fun once you know a few good function and what the variable represent in the physical world.

"HELLO WORLD!"

Demonstrate Flashing LED with Variable Delay

Example Code:
  • "#define"-  Sometimes it can be hard to remember which pins are connected to which devices.  This command can be used at the start of the program to rename the inputs and outputs.
  • A "function"-  Is like the void setup() or void loop() in the program below.  When the label is first defined as a "type".  The type void means that it won't return any data.
  • "delay()" and "delayMicroseconds()"-  The delay() command delays for a time in milliseconds.  delayMicroseconds() command delays for a time in microseconds for shorter intervals.
  • for loops- Repeats a block of statements enclosed in brackets. The for loop is used for any repetitive operation and is used in combination with arrays to operate on a collection of data/pins.
#define LED 6     //Define the symbol LED to be pin 6

void setup()
{
     pinMode(LED,OUTPUT);  //Initialize Digital Pin 6 as an OUTPUT
}

void loop()
{
    digitalWrite(LED,HIGH);  //Set the LED On
    delayMicroseconds(16000);  //Wait for 116ms
     digitalWrite(LED,LOW);  //Set the LED OFF
    delayMicroseconds(16000);  //Wait for 16ms
}

For loop Example:

for(int = 0 ; x < 100 ; x++)
{
      println(x);  //prints 0 to 99
}

Summary:

Change your loop so that the delay varies from 1000 to 50 in increments to -50.

#define LED 6
void setup()
{
pinMode(LED,OUTPUT);  //Initialize Digital Pin 6 as an OUTPUT

for(int counter = 1000;counter < 50; counter = counter-50)
     {
      digitalWrite(LED,HIGH);  //Set the LED on
      delay(200);  //Wait for 0.2 second
      digitalWrite(LED,LOW);  //Set LED off
      delay(200);  //Wait for 0.2 second
      }
}

void loop()
{
      digitalWrite(LED,HIGH);  //Set the LED on
      delay(1000);  //Wait for 1 second
      digitalWrite(LED,LOW);  //Set LED off
      delay(1000);  //Wait for 1 second
}


Demonstrate Pushbutton LED Using if/else Statement

Example Code:
  • A digital sensor is a simple switch that can only be on or off.
  • "Variable"-  A variable as a bit of program memory that can store information, which we will use to store the status of the button
  • "if()"-  If is used in conjunction with comparison operator, test whether a certain condition has been reached, such as an input being above a certain number.
    • Comparison Operators
      • x == y (x is equal to y)
      • x != y (x is not equal to y)
      • x < y (x us less than y)
      • x > y (x is greater than y)
      • x <= y (x is less than or equal to y)
      • x >= y (x is greater than or equal to y)
  • "if()/else"-  Allows greater control over the flow of code than the basic if statement, by allowing multiple tests to be grouped together.    
#define buttonPin 8  //the number of the pushbutton pim
#defineledPin 6  //the number of the LED pin
int buttonState = 0;  //variable for reading the pushbutton status

void setup()
{
pinMode(ledPin,OUTPUT);  //initialize the LED pin as an output
pinMode(buttonPin, INPUT);  //initialize the pushbutton pin as an input
}

void loop()
{
buttonState = digitalRead(buttonPin);  //read the state of the push button value
//Check if the button is pressed.  If it is, the buttonState is HIGH
if(buttonState == HIGH)
      {
            digitalWrite(ledPin,HIGH);  //turn LED on
      }
if(buttonState == LOW)
      {
          digitalWrite(ledPin, LOW);  //turn LED off
       }
}

Summary:

Modify your code above to replace the two if statements with a single if/else block.

#define buttonPin 8  //the number of the pushbutton pim
#defineledPin 6  //the number of the LED pin
int buttonState = 0;  //variable for reading the pushbutton status

void setup()
{
pinMode(ledPin,OUTPUT);  //initialize the LED pin as an output
pinMode(buttonPin, INPUT);  //initialize the pushbutton pin as an input
}

void loop()
{
buttonState = digitalRead(buttonPin);  //read the state of the push button value
//Check if the button is pressed.  If it is, the buttonState is HIGH
if(buttonState == HIGH)
      {
            digitalWrite(ledPin,HIGH);  //turn LED on
      }
else
      {
          digitalWrite(ledPin, LOW);  //turn LED off
       }
}



Demonstrate LDR Controlling LEDs

Example Code:
  • An analog sensor measures a continues signal such as light, temperature, or position; and provides a varying voltage, which is represented by a number in range 0 to 255.  This means 0 is the equivalent to dark and 255 is the equivalent to super bright.
  • "readAnalog()"- The value of an analog input can be copied into a variable.  The following code switch's the LED on, if the value is greater than 750 and off if it is less than 750.
#define sensorPin A0  //select the input pin for the potentiometer
#defineledPin 6  //the number of the LED pin
int sensorValue = 0;  //variable to store the value coming from the sonsor

void setup()
{
pinMode(ledPin,OUTPUT);  //initialize the LED pin as an output
}

void loop()
{
sensorValue = analogRead(sensorPin);  //read the value of the sensor
if(sensorValue > 750)
      {
            digitalWrite(ledPin,HIGH);  //turn ledPin on
            delay(sensorValue);              //stop the program for <sensorValue> milliseconds
      }
else
      {
          digitalWrite(ledPin, LOW);  //turn ledPin off
          delay(sensorValue);  //stop the program for <sensorValue> milliseconds
       }
}

Summary:

Now attach a second LED to pin 7 of your Arduino using a 220 Ohm series resistor.  Change your program so that it has 4 states:
  • If the room is Bright both LEDs on
  • If the room is Medium lit turn LED 1 on
  • If the room is Dimly lit turn LED2 on
  • If the room is Dark turn LEDs off
#define sensorPin A0
#define ledPin 6
#define ledPIn 7
int sensorValue = 0;

void setup()
{
pinMode(ledPin, OUTPUT);  //LED 1
pinMode(ledPIn,OUTPUT);  //LED 2
}

void loop()
{
sensorValue = analogRead(sensorPin);
if(sensorValue>900)
{
digitalWrite(ledPin,HIGH);
digitalWrite(ledPIn, HIGH);
}

if(sensorValue>850)
{
digitalWrite(ledPin,HIGH);
digitalWrite(ledPIn, LOW);
}

if(sensorValue>800)
{
digitalWrite(ledPin,LOW);
digitalWrite(ledPIn, HIGH);
}

else
{
digitalWrite(ledPin,LOW);
digitalWrite(ledPIn, LOW);
}
}


Demonstrate Thermistor Controlling Motors

Materials:
  • 10K thermistor
  • 10K resistor
  • TIP 120 transistor
  • BDC motor
Summary:
#define sensorPin A0
#define ledPin 6
int sensorValue = 0;

void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);  //LED 1
}

void loop()
{
sensorValue = analogRead(sensorPin);
if(sensorValue>490)
{
digitalWrite(ledPin,HIGH);
delay(sensorValue);
}
else
{
digitalWrite(ledPin,LOW);
delay(sensorValue);
}
Serial.println(sensorValue);
}


Use the LDR code from the previous  page to turn on and off the motor.  It should turn on  if it sees room temperature, and turn off if it gets warmer than room temperature.  You may need to adjust the if statement as well as the variable names and comments to get this to work.

Demonstrate Potentiometer Controlling Buzzer

Materials:
  • 100K potentiometer
  • Buzzer
  • 5V power source
Summary:

Similar to the two previous programs, you are to build a control circuit where the potentiometer controls whether a buzzer is on or off.  The circuit should look similar to the one on the previous page except the middle pin of the potentiometer goes to the Arduino, the top pin goes to your 5V power supple, and the bottom pin goes to the ground.  ON the output side , the buzzer requires 24mA as you will need to use a transistor as part of you circuit to get it to work since the Arduino cannot supply this from one single pin.(Without a transistor the Arduino will only be able to output about 19MA.  It will still work without a transistor, it just won't be as loud)
#define sensorPin A0
#define ledPin 6
int sensorValue = 0;

void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);  //LED 1
}

void loop()
{
sensorValue = analogRead(sensorPin);
if(sensorValue>500)     // used half way point on potentiometer to trigger the switch at 500K ohms
{
digitalWrite(ledPin,HIGH);
delay(sensorValue);
}
else
{
digitalWrite(ledPin,LOW);
delay(sensorValue);
}
Serial.println(sensorValue);
}

Demonstrate Motion Sensor Controlling Relay

Materials:

Summary:
#define sensorPin A0
#define ledPin 6

int sensorValue = 0;

soid setup()
{
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
}

void loop()
{
sensorValue = analogRead(sensorPin);

if(sensorValue>950)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
delay(100);
Serial.println(sensorValue);
}

Lab 9 - Driving Motors and Other Output Devices

In this lab we are to experiment with different output devices to the Arduino microcontroller. 

Standard Interfacing Circuits

The Arduino provides up to 10mA per channel, and the micro ship is limited to about 50mA.  This means you can light about 4 to 5 LEDs from the Arduino.  Anything more will burn out you microprocessor.  To solve this problem we use transistors to boost current for our output devices and as switches for our pins.  For instance, the 2N3904 transistor rated to output 200mA and has a gain of 25.

So the transistor needs 8mA to output 200mA, because Current = 200 mA / 24 gain = 8 mA.

The microcontroller runs at 5 V, so we need a resistor that will provide us with at least 8mA.  There is a 0.7V voltage drop across the transistor, which reduces the overall supply to 4.3V.  We ned a resistor that is less than the maximum output:

Resistance = 4.3 V / 0.008 A = 550 Ohms

Resistors are manufactured in a variety of amounts. The closes resistor we have to 550 Ω is 470 Ω.  It is good practice to connect in parallel to the output device a back emf suppression diode, because devices like relays, solenoids, and motors produce a back emf when power is switched off. 

Darlington Transistors
 
The MPSA42 is a medium, power transistor that can handle up to 300V at 600mA of current, which is three times as much as our last.  Transistor only multiply or amplify the input current from the power source, so we increase the resistance to the base of the transistor.  The MPSA42 transistor needs about 20mA to turn on completely and this is more than what the Arduino can supply through channel.  To solve this problem we first connect a transistor that can handle the input of the microcontroller like the 2N3904 and connect the base of the MPSA42 to the emitter of the 2N3904.  When we connect the transistors collectors together the gain is further multiplied.  This arrangement of transistors is called a Darlington, named after the inventor.  The gain of a 2N3904 is 25 band the gain of a MPSA42 is 30, and the gain in the Darlington configuration os Total Gain = 25 * 30 = 750.  A few Darlington transistors for high current DC motors are: MPSA13 low power NPN 30V 1.2A ($0.1.0), MPSA64 low power PNP 30V 1.2A ($0.08), and TIP 120 medium power NPN 60V 5A ($0.24).  The package of transistors thus far have been TO-92 package, so now we will use the larger package TO- 220.

DC Motors

Brushed DC motors (BDC) used in many applications like toys and other hobbies, because they are easy to use , inexpensive, and abundant.  BDC motors are made of the same components: a stator, rotor, brushes, and a commuter.  The stator generates a stationary magnetic field that surrounds the rotor.  This field is generated by either permanent magnets or electromagnetic windings.  The different kinds of BDC motors are based on there construction of the stator or the way the electromagnetic windings are connected to the power source.  The rotor, also called the armature, is made up of one or more windings.  When these windings are energized they produce a magnetic field. The magnetic poles of this rotor field will be attracted to the opposite poles generated by the stator, causing the rotor to turn.  As the motor turns, the windings are constantly being energized in a different sequence so that the magnetic poles generated by the rotor do not overrun the poles generated in the stator.  This switching of the field is the rotor windings is called commutation.  Unlike other electric motor types, BDC do not require a controller to switch current in the motor windings.  Instead, the commutations of the windings of a BDC is done mechanically.  A segmented copper sleeve, called a commutator, resides on the axles of a BDC motor.  As the motor turns, carbon brushes slide over the commutator, coming in contact with different segments of the commutator.  The segments are attached to the different rotor windings, therefore, a dynamic magnetic field is generated inside the motor when a voltage is applied across the brushes of the motor.  Its is important to note that the brushes and commutator are the parts of a BDC motor that are most prone to wear because they are sliding past each other.  One downside to BDC motors is that the motor introduces a lot of noise on the power rails, which can affect the microcontroller and some cases can completely stop the control of a program functioning.  Electrical noise can be reduced by soldering suppression capacitors across the motor contacts

Basic Principal of PWM

Pulse width modulation is achieved with the help of a square wave whose duty cycle is changed to get a varying voltage output as a result of average value of waveform.     

Demonstrate Microcontroller Controlling signal Lamp

Materials:
  • 470Ω resistor
  • 3.3KΩ resistor
  • 2N3904 transistor
  • Signal lamp
  • 5V power supply
Summary:

WE are to build a circuit that uses the transistor to an output device under a load.  Using pin 6 as our signal and connected to the resistor to protect the transistor from burning out.  The base of the transistor is connected to the resistor, collector to the output device, and emitter to the ground.We are using a signal lamp powered by a 5V powersupply.  It is important to identify the transistor pins or else the desired outcome will not be achieved.  The signal lamp is programed to turn on for one second and turn off for one second.  We measure the voltage drop across the signal lamp, which is 5.2V.  We then replace the 470Ω resistor with a 3.3KΩ resistor, which is much larger.  The result is the signal light is turned on, but very dimly.  The new voltage drop across the signal lamp is 4.9V.  



Demonstrate Darlington Controlling signal Lamp

Materials:
  • 470 resistor
  • 3.3K resistor
  • MPSA13 transistor
  • 2N3904 transistor
  • MPSA42 transistor
  • Signal lamp
  • 5V power supply
Summary:

This lab is very similar to the previous lab, but we use the MPSA13 Darlington transistor, and the 2N3904 and MPSA42 to compare resistor change outs.  The MPSA13 Darlington transistor is the equivalent to the to 2N3904 and MPSA42 combo transistors, because the signal light did not change in brightness.



Demonstrate Microcontroller Controlling Motor

Materials:
  • 2.2K resistor
  • TIP 120 transistor
  • 1N4001 diode
  • BDC motor
  • 1.5V battery and battery holder
Summary:

IN this lab we use a medium power transistor to turn ON and OFF a BDC motor with an emf suppression diode.  Although, we could use a capacitor, but we will not need tot solder it directly to the BDC terminal, because we can just use a diode.

Behold the DC motor turns ON and OFF from Arduino controller program.  YA!!!
Yes, we used a digital square wave signal.

Demonstrate PWM signal driving Motor

Materials:
  • 2.2K resistor
  • TIP 120 transistor
  • 1N4001 diode
  • BDC motor
  • 1.5V battery and battery holder
Summary:

In this lab we will use a PWM signal, which sort of mimics an analog signal.  AS we know digital signals cannot be analog signals, right?  A digital signal sends two or more signal at different constant voltage levels to turn our little motor on and off.  An analog signal would be like a sine waveform that is constantly changing and never rests at one particular voltage level.  Well, PWM is a type of digital signal that copies the overall pattern of a sinewave, does so in tiny intervals of constant voltage levels, so when averaged together looks like an analog signal.  The key to controlling a PWM is setting a D.C., not direct current, but Duty Cycle.  A Duty Cycle is percentile of "pulses", which can look like a lopsided square wave.  But a square wave that looks symmetrical and is actually a 50:50 D.C.  And by adjusting the duty cycle you can sort of set a certain speed, besides the full blast speed of 1.5V or 5V ON mode. 


(Drops microphone) PEACE!!!!

Lab 8 - Bi-directional Motor Control

One transistor can allow us to turn a 1.5V DC motor on or off.  Reversing the direction, however, needs more a complex arrangement.  There are to approaches to control the direction of a DC motor.

One way it to use the Double Pole Double Throw relay switch.  The diagram for this lab contains a DPDT relay switch controlled by a TIP120 transistor to reverse the direction of the motor.  This approach requires a dual 5-Pin relay that control this process.  The first pin starting with the coil is the mechanism that does the physical switching once power is applied to these terminals.  The second pin is called the Normally Close for when the switch poles are not activated.  You can say this is the passive switch position when the is no power to the coil.  The third pin is called the Common and is the pole that moves or pivots when activated, also a power supply is suppose to go here too or a signal.  The fourth pin is called the Normally Open, because in its passive, unpowered state the poles of the switch are not touching it and are therefore an open circuit.  The fifth pin is called Not Connected and its function means just that, the pin is not connected to the switch, so we don't use this one.  It is very important to know the functions of every pin on the relay or else you will be super confused and randomly connect anything and hope something happens.

Another way to reverse directions for a DC motor is to use a circuit called an H-Bridge.  It is called this name because there are four switching elements at the corners of the "H" and the motor makes up the horizontal line of the H.  Usually the top part of the H is the positive pole and the bottom is the negative pole where power is supplied.  There are two other inputs on the left and right side of the H-Bridge.  The left input is connected to the two transistors located on the left side of the H from the top and bottom.  The right input has the same connection, but to the Right top and bottom transistors.  The H-Bridge contains two NPN transistors (MPSA 13), two PNP transistors (MPSA 64), four diodes (1N4001), and four resistors (3.3Kᘯ) to protect the transistors from burning out.  The switches are turned on in pairs from high left to lower right of the H, but never on the same side.  Anything that can carry a current will work such as: four SPST switches, one DPDT switch, relays, transistors, and MOSFETs.  I believe there are other applications besides reversing the direction of a DC motor.  The H-bridge can be configured to use all four switches independently and make a four quadrant device.        


Demonstrate DPDT Relay Controlling Motor

Materials:
  • 1KΩ resistor
  • TIP120 transistor
  • DPDT relay
  • DC motor
  • 1.5V C battery
  • Battery holder
  • Breadboard
  • Wires/Leads
  • 5V power supply
Summary:

We are to build the schematic shown in lab manual.  It consists of the ON/OFF switch lead connected to a 5V power supply to the 1KΩ resistor, which is then connected in series to the TIP120 transistor.  The collector pin is connected to the Common pin of the DPDT relay.  The emitter pin is then connected to a pin on the relay that powers the coil.  the opposite pin connect to the coil goes to the ground.  The 1.5V battery's positive terminal connects to the Common on the relay that is opposite of the collector connection.  The negative terminal on the battery goes to the ground.  The left Normally Closed pin of the relay is connected to the right Normally Open pin. The left Normally Open pin is connected to the right Normally Closed pin.  The DC motor is also connected to the left Normally Open pin and also to the right Normally Closed pin.  As we see here the Normally Open pi is connected to the opposite Normally Closed pin and vis versa to reverse the direction of the motors spinning.  But once the wire that is connected to the 5V power supply is disconnected the relay returns to its passive state and switches the direction of the motor.  The coil is thus activated whenever connected to a 5V power supply thus switching the direction of the motors spin like an On and OFF button.

Demonstrate H-Bridge Circuit Controlling Motor Using 5V Power Supply

Materials:
  • 4 x 3.3KΩ resistors
  • 2 x PNP transistors (MPSA64)
  • 2 x NPN transistors (MPSA13)
  • 4 x 1N4001 diodes
  • DC Motor
  • 1.5V battery and battery holder
  • Breadboard
  • Wires/Leads 
  • 5V power supply
Summary:

We build a very basic H-Bridge schematic with two inputs at the left and right side, and the DC motor is connected between the top and bottom half of the H-Bridge.  The bottom half of the H-Bridge circuit use the bottom portion of the breadboard's ground bus and the top half of the circuit is connected to the top portion of the breadboards ground bus.  Connecting the H-Bridge to bottom ground bus the top 5V power supply bus is very important.  The 1.5V batter continuously runs the DC motor, while connecting the 5V power supply's positive terminal to either the top or bottom half of the bread board reverses the direction of the DC motor.  This is very similar to the previous lab.



Demonstrate H-Bridge Circuit Controlling Motor Using Arduino

Materials:
  • PCB H-Bridge or Breadboard H-Bridge
  • 1.5V DC motor
  • Arduino
Summary:

This lab is very similar to the previous, but for a few minor differences The wire that connects the upper and bottom portion of the breadboard is now replaced by two more wires that are connected to the Arduino's pin 12 and pin 13.  Also the Arduinos ground pin is connected to the breadboard.  Pin 12 will be programed to turn ON for 2 seconds with a 1 second STOP delay and pin 13 will turn ON for 2 seconds with a 1 second STOP delay.

Supper cool!!!! Right!?!?!

Lab 6 - Transistor Switching

The transistor is like a relay in that it can switch a flow of electricity.  The components contains a piece of silicon divided in to three paths known as; collector, base emitter.  The collector receives current from power source.  The base controls the output of the collector.  The emitter sends out the current or signal.  The schematic symbol for a transistor looks like a combination of symbols that we have previously learned.  Three lines/leads connect to a circle and inside the circle looks like a relay switch in the shape of a "T" and a diode coming from the relay switch.  The transistor is always labeled as "Q" not as "T" as one would expect, because the letter "T" is already used for transformer.  How I think of it is the base receives a voltage signal of HIGH or LOW that the transistor mechanically interprets as ON or OFF.  The collector is like a tank of water, when the transistor is in OFF mode or LOW state, that collects the current and voltage before it is sent to the emitter.  The emitter is essentially a diode and amplifies the current called "gain".  Also diodes behave like a one way valve so that current will not travel in the reverse direction.  There are pros and cons for transistors just like the relay switch.  The transistor has a small footprint no moving parts.  Usually, they can only hand small amounts of current and voltage.  Pretty neat stuff in this lab so far :)

We are shown two types of transistors NPN and PNP, which are bipolar semiconductors.  There three layers of silicon that are sandwiched together in a transistor.  The P-type silicon has a positive charge and the N-type silicon has a negative charge.  The middle silicon type is the base, which allows a positive or negative charge to activate the transistor.  In a transistors passive state the NPN and PNP block electricity between the collector and the emitter just like a relay.  They also allow a tiny bit of current called leakage.

Transistor Basics:
  • Never apply a power supply directly across a transistor.  You WILL BURN IT OUT with too much current.  Always read the manufacturers specifications.
  • Protect a transistor with a resistor in series with either the emitter or collector, in the same way you would protect an LED. 
  • Avoid reversing the connection of a transistor between positive and negative voltages.
  • Sometimes a NPN transistor is more convenient in a circuit; sometimes a PNP happens to fit more easily.
  • They both function as switches and amplifiers, the only difference being that you apply a relatively positive voltage to the base of a NPN; and a relatively negative voltage to a PNP.
  • Remember that bipolar transistors only amplify current, and not voltage.  A small fluctuation of current through the base enables a large change in current between the emitter and collector.
  • Schematics show transistors with a circle around them, and sometimes do not.
  • Transistors com in various different sizes and configurations.  In many of them, there is no way to tell which wires connect to the emitter, collector, or base and some transistors have no parts number on them.  Before you through away the packaging/paperwork/labels that came with the transistor , check to see whether it identifies the terminals
  • If you forget which wire is which, some multi-meters have a function that will identify the emitter, collector, and base for you.

Demonstrate the Finger Switch Transistor
Materials:
  • 2 VOM's for measuring current
  • AC adapter, breadboard, wires/leads, and a DMM
  • 1 LED
  • Various resistors
  • 1 Pushbutton, SPST
  • 1 NPN Transistor, 2N2222 or 2N3904
Summary:

When the circuit is hooked up as shown on the diagram, and the button is in the OFF position, the LED lights up, but very dimly.  The LED is receiving a trick of electricity from the collector.  Even though the base is not activated the transistor sends a tiny amount of current through the emitter.  When the button is pushed the solid state switch opens and allows current to flow through the third pin, emitter, and the LED shines more brightly.  Wow!!!

To show that a finger can activate the transistor just as well as a resistor, we yank out R2 and hold two wires to our fingertip.  The LED lights up, but not as bright; unless you have sweaty hands or lick your finger tip.     





The Gain of the Transmitter

Materials:
  • R1: 180ᘯ
  • R2: 1Kᘯ
  • R3: 180ᘯ
  • R4: 1Kᘯ
  • P1: 100Kᘯ linear potentiometer
  • Q1: 2N3904 transistor
Summary:

The circuit diagram shows the potentiometer and transistor in parallel and have the same resistance in both loops.  The VOMs are connected in series between the potentiometer and base, and between the emitter and R3 to ground.  By measuring the current before the base and after the emitter we can determine the amount of gain Q1 is rated for.  First, we adjust the pot so that the input current to the base is 10µA and measure the out put current from the emitter.  We divide the output over the iput current to know our "Gain".  As we approach 100µA into the base the output current levels off at 14mA and the gain drops from about 200 to 175 and so on.









Friday, January 13, 2017

Lab 4 - Schematics, Ohm's Law, and Potentiometers

Description:

Schematics are very important to graphically communicate how a circuit is wired.  The power source, ground, and all kinds of components have symbols that represent their function.  I use schematic drawings a lot for solving voltage drops and total resistance in a circuit.  To figure out voltage, amperes, and resistance mathematically we need to use Ohm's Law.  Ohm's Law can be summarized as a simple equation that is Voltage equals Current times Resistance.  If one knows at least two measurements, this formula can be used to solve for the unknown.  For instance, we want to know which resistor makes the LED shine the brightest and we know in order for LED to shine it needs 2.5 volts and 20 milliamps.  A resistor soaks up a certain amount of volts from the power source and is divided by the resistor and LED.  The larger the resistor is the dimmer the LED will be.  There is another type of resistor called a potentiometer, which is a variable resistor.  Using a Philips screw driver we can change the resistance that can the LED shine or dim by turning a dial. 

Lab 3 - Using a Multimeter

Description:

The multimeter is a very important tool to verify if our components are working on the breadboard.  One of the things we can verify is continuity.  In other words to see if a the component or wire conducts electricity, so if it does our multimeter will make a beep sound.  The continuity setting can also tell us if there is an open on the circuit board.  Another setting we can use to verify out parts is measure voltage.  We can measure our power source or the individual components on a circuit board.  Using Kirchhoff's Law we can make sure the voltage drops across the components of a circuit board equal the power source.  There are two settings for measuring voltage, which are AC and DC.  The multimeter can also measure resistance.  Components like resistors will have different amounts of resistance, which can be determined by using the 4 Band Code.  The first two stripes of colors represent the first two digits in the number.  The third color tells you haw many zeros to add after the first two digits.  The fifth band tells you the percent tolerance.