Photoresistor, Transistor, and LED s

Similar documents
Lab 2.2 Ohm s Law and Introduction to Arduinos

Lab 5: EBI and ADC: Digital Voltmeter

Digital Pins and Constants

1/Build a Mintronics: MintDuino

REQUIRED MATERIALS Epiphany-DAQ board Wire Jumpers Switch LED Resistors Breadboard Multimeter (if needed)

Arduino 101 AN INTRODUCTION TO ARDUINO BY WOMEN IN ENGINEERING FT T I NA A ND AW E S O ME ME NTO R S

Note. The above image and many others are courtesy of - this is a wonderful resource for designing circuits.

EECS 373 Midterm 2 Fall 2018

DEV-1 HamStack Development Board

Connecting LEDs to the ADB I/O

PIC Dev 14 Surface Mount PCB Assembly and Test Lab 1

Basic Input/Output Operations

Pre-Lab: Part 1 Using The Development Environment. Purpose: Minimum Parts Required: References: Handouts:

Robotics/Electronics Review for the Final Exam

IME-100 ECE. Lab 4. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE,

Lab 2 - Powering the Fubarino. Fubarino,, Intro to Serial, Functions and Variables

PIC Dev 14 Through hole PCB Assembly and Test Lab 1

CHAPTER 5. Voltage Regulator

Basic Interface Techniques for the CRD155B

Infrared Add-On Module for Line Following Robot

Digital Circuits. Page 1 of 5. I. Before coming to lab. II. Learning Objectives. III. Materials

Laboratory of Sensors Engineering Sciences 9 CFU

Lab 5: LCD and A/D: Digital Voltmeter

StenBOT Robot Kit. Stensat Group LLC, Copyright 2018

Procedure: Determine the polarity of the LED. Use the following image to help:

Lab 5: LCD and A/D: Digital Voltmeter

ENGR 40M Project 3c: Switch debouncing

IME-100 Interdisciplinary Design and Manufacturing

Robosoft Systems in association with JNCE presents. Swarm Robotics

SPDM Level 2 Smart Electronics Unit, Level 2

Lab-3: LCDs Serial Communication Analog Inputs Temperature Measurement System

INTERFACING HARDWARE WITH MICROCONTROLLER

Getting Started with STK200 Dragon

LABORATORY MANUAL Interfacing LCD 16x2, Keypad 4x4 and 7Segment Display to PIC18F4580

MICROPROCESSORS A (17.383) Fall Lecture Outline

Lab 2 - Powering the Fubarino, Intro to Serial, Functions and Variables

Arduino Uno. Arduino Uno R3 Front. Arduino Uno R2 Front

Thursday, September 15, electronic components

Thorlabs Model LD1100

ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015

Centre for Instrumentation, Control and Automation User s Guide to the MAD 2 Microcontroller Board

Features: Analog to Digital: 12 bit resolution TTL outputs, RS-232 tolerant inputs 4.096V reference (1mV/count) 115K max speed

Drexel University Electrical and Computer Engineering Department ECE 200 Intelligent Systems Spring Lab 1. Pencilbox Logic Designer

AVRminiV3.1 Manual. 1. AVRminiV3.1 Overview. 2. AVRminiV3.1 Features and Specifications Standard Features: 2.2. Optional Features:

PVK40. User's manual. Feature Rich Development and Educational Kit for 40-pin Microchip PIC microcontrollers

NAME EET 2259 Lab 3 The Boolean Data Type

EK307 Lab: Microcontrollers

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives:

keyestudio Keyestudio MEGA 2560 R3 Board

LED Knight Rider. Yanbu College of Applied Technology. Project Description

How-To: Make an RGB combination door lock (Part 1)

University of Hawaii EE 361L MPLab Quick Tutorial and Project 2.1 Last updated September 1, 2011

EXPERIMENT 7 Please visit to learn all features of arduino before you start the experiments

Collision Detection Device

Necessary software and hardware:

BV511 Hardware Guide ByVac ByVac Revision 1.0

Professional Radio GM Series. Controlhead Service Information

AVR Board Setup General Purpose Digital Output

Week 9: Design a Night Light. The experimental procedure Is not in the lab manual

- Open-source and open-hardware modular robotic platform specially created for educational purposes.

ARDUINO MICRO WITHOUT HEADERS Code: A000093

Digital and Analogue Project Report

Adafruit 1-Wire GPIO Breakout - DS2413

Problem Score 1 / 27 2 / 19 3 / 16 4 / 14 code check off 5 / 22 /2 Total /100

Omega MP. Multi-Programming Shield for Atmel Microcontrollers. User Manual

ARDUINO MEGA 2560 REV3 Code: A000067

Experiment 10 Fall 2012

Introduction to Embedded Systems

GE-INTERNATIONAL JOURNAL OF ENGINEERING RESEARCH VOLUME -3, ISSUE -5 (May 2015) IF ISSN: ( )

The PUMPKIN LIGHT LED

Unit 2. Computer Control. PIC stands for PROGRAMMABLE INTERFACE CONTROLLER. A PIC chip takes in input signals and then controls output transducers

Hitec Digital Servos Operation and Interface

ARDUINO UNO REV3 SMD Code: A The board everybody gets started with, based on the ATmega328 (SMD).

Introduction to Arduino. Wilson Wingston Sharon

Project 17 Shift Register 8-Bit Binary Counter

Basic Electronic Toolkit for under $40

Lab Course Microcontroller Programming

Micro-Controllers. Module 2: Outputs Control and Inputs Monitoring. IAT Curriculum Unit PREPARED BY. August 2008

IME-100 ECE. Lab 3. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE,

Display Real Time Clock (RTC) On LCD. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

BASIC Stamp 1 Project Board (#27112) Development / Education Platform for the BASIC Stamp 1

EDUCATION EXPERIENCES WITH A USB INTERFACE

Note that FLIP is an Atmel program supplied by Crossware with Atmel s permission.

Educato. Assembly Instructions

Manual Main PCB Small-MIDI 4

ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL

Laboratory 1 Introduction to the Arduino boards

Embedded Systems and Software

Touch Control Switch + - R6 R4 R8 R7 CAT# Grading. Assembly Instructions by Earl D. Gates SUNY Oswego Fall Conference 2007.

LDR_Light_Switch1 -- Overview

Lab 01 Arduino 程式設計實驗. Essential Arduino Programming and Digital Signal Process

Light Dependent Resistor Circuit by VK4ION

CV Arpeggiator Rev 2 Build Documentation.

Create moving images in forward and reverse with your Arduino when you connect a motor to an H-bridge and some still images BATTERY POTENTIOMETER

Button Code Kit. Assembly Instructions and User Guide. Single Button Code Entry System

M32 Development Board

Physical Computing Self-Quiz

Web Site: Forums: forums.parallax.com Sales: Technical:

Arduino 05: Digital I/O. Jeffrey A. Meunier University of Connecticut

AXE Stack 18. BASIC-Programmable Microcontroller Kit. An inexpensive introduction to microcontroller technology for all ability levels

Transcription:

PH-1 Photoresistor, Transistor, and LD s Purpose: To introduce photoresistors, LD s, FT s, and transistors used as power switching devices To become familiar with the capability of the Atmega 128 to measure the change of resistance of a sensor using analog-to-digital conversion. To build and experiment with a light-controlled switch omponents: Qty. Item Qty. Item 1 10 kω resistor 1 22 kω resistor 1 Solderless readboard 1 470 Ω resistor 1 Photoresistor 1 220 Ω resistor 1 2N3904, NPN transistor 1 red or green LD 1 Atmel Atmega 128, STK500 & STK 501 interface boards, and programming cable. Introduction: A photoresistor is simply a resistor whose resistance depends on the amount of light incident upon it. They are used to make light-sensitive switching devices. Photoresistors are often made from cadmium sulfide (ds). The resistance of a ds photoresistor varies inversely to the amount of light incident upon it. In other words, its resistance will be high in the dark and low in the light. The LD behaves like an ordinary diode except that when it is forward biased, it emits light. The LD s forward voltage drop is higher than an ordinary diode. Typical LD s require 5 to 15mA to reach full brightness, but are not designed to handle more than about 20 ma of current (though some can handle upwards of 80 ma or more). You will therefore always need to provide a resistor in series with an LD to limit the current to about 20 ma or less, or else you will burn it out. Also, don t make the mistake of trying to substitute an LD where a standard diode is called for! Look at the schematic diagram to see which kind of component is needed. Procedure 1. Measure the photo-resistor s resistance in the ambient lighting of the lab. Once this is recorded, repeat the measurement, only this time, cover the cell with your hand. These two extremes will be used in calculations later on. 2. To verify the behavior of the LD, construct the circuit shown in Figure 1, and vary the supply voltage between 1 to 5 volts at 1-volt increments. At each voltage, measure the voltage across the LD and the 470 Ω resistor and enter the values into the following table. The LD current can be calculated by applying Ohm s law across the resistor. A similar table should be entered into the lab report with all voltage values and comments. Remember I=R/ for current top flat or notch + + 470 Ω side anode + - cathode - LD

PH-2 Figure 1. LD and typical circuit. Note that the anode lead is longer than the cathode. Sometimes there may be a flat on the cathode side of the LD to help you distinguish anode from cathode. 1 2 3 4 5 Table 1. LD circuit measurements (Refer to Figure 1) supply, LD, R, urrent, ma omment on LD brightness Figure 2 shows a simple light-controlled-ld. The circuit should turn-off the LD as the photo resistor is covered. xplain the theory of operation of this circuit. ased on the information obtained above, what is a good supply voltage to use? (Hint: should be high enough so that enough current flows through the LD when the photo resistor has low resistance, and yet should be low enough so that the current is not enough to turn on the LD when the photo resistor has high resistance.) uild the circuit and check its function. R ds ds Figure 2. Light-controlled LD Figure 3. Light-controlled using a transistor switch The Light-ontrolled Switch Using a Transistor A transistor can be added to the light-controlled-switch circuit to improve its sensitivity and to eliminate the half-on-half-off state of the LD. A rudimentary circuit to do so is shown above in Figure 3 (you don t have to build this circuit). Here the photoresistor controls the transistor s base current, which is then amplified by the transistor. The collector current of the transistor, in turn, controls the LD. Unfortunately, this circuit may not function properly, because when the photoresistor is in the dark state, (and the LD is supposed to be turned off), the base current may be large enough that the LD may stay lit! Prove this, by calculating the collector current for the circuit in Figure 3 when =10, RdS=100 kω, Rc=220 Ω and hfe=100. Figure 4 shows an improved circuit. This is the circuit that you will build and experiment with next.

PH-3 Rc ds R1 2N3904 Figure 4. Improved Light-ontrolled Switch Using a Transistor With a properly selected resistor R1, the voltage at the base of the transistor in the dark state is less than 0.7, and therefore the transistor is in the cut-off state. As the photoresistor s resistance decreases (as the result of an increase in light intensity), the base voltage increases. Once the base voltage reaches 0.7, the base current starts to flow, and any further decrease in the photoresistor s resistance causes an increase of base current. This base current increment will be amplified by the current gain of the transistor. Procedure The following procedure is the instructions to build the circuit in figure 4. Remember that you cannot just select any resistor, try some of the values that you have found in the previous labs since we do not have all the different resistor values available. This procedure for a light transistor switch should be clear in your report with calculations. 1. hoose the supply voltage. The supply voltage is often a predetermined value rather than a design choice. For example, if a battery is to be used, the voltage will likely be 3, 6, 9, or 12 volts. In the following calculation and in later circuit construction, use any voltage of your choice between 6 to 15, this will be called. 2. Select R1. First, measure the value of the photo resistor s resistance (call it Ron) at which you would like the LD to be turned on. The resistance value can be that for when the photoresistor is covered or uncovered, it s up to you. The value of R1 should be such that 0.7 = *R1/(R1+Ron). A variable resistor (trim pot) can be used so that the turn-on value can be adjusted. 3. Select Rc, the current limiting resistor. With this resistor, the collector current is limited to Imax=(- LD - 0.4)/R, where LD is the voltage drop across the LD, and 0.4 is a typical saturation voltage between the collector and emitter. Select R so that the LD current is limited to be less than 20 ma (preferably 5-10 ma). Using Rc, construct and test the circuit. Using the Atmega 128 to Make a Programmable Light-ontrolled Switch The circuit in Figure 4 is very simple, but it suffers from the disadvantage that once R1 is chosen and the circuit is constructed, you re stuck with its performance unless you physically remove R1 and replace it with a different value. That is not too serious if we are dealing with one circuit on a breadboard, but suppose this circuit were part of a product that you were manufacturing, say 1000 per day. If you wanted to change the performance of the device, you would have to modify the assembly drawings, circuit board artwork, component inventory, rework the entire work-in-process, etc. That would be a big deal! Here we will use the Atmega 128 to make a light-controlled switch whose performance can be modified by simply reprogramming the microcontroller.

PH-4 Procedure 1. uild the part of the circuit in shown in Figure 5 below labeled A. onnect the 10k resistor to pin P0 on the STK500 board using a jumper from the pin to the solderless breadboard. Don t forget that you need to supply power to the Atmega 128. You may use the +5 from any TG pin on the STK500 or STK501 boards for your circuit; however, be sure to double check the voltage on the pin you wish to use with a voltmeter before connecting it to your circuit. Likewise, you may use a pin labeled GND for ground. The voltage on P0 will either be 0 or 5. Which of these will turn the transistor on? When the transistor turns on, is it saturated? ased on your earlier measurements on the LD and the characteristics of the transistor, what are i b, and i c when P0 is at 5? 2. Using your last two labs as a guide compile (build) and run the link Test Program (Appendix A), which can be found on the Lab 106 network drive >> Lab 4 >> link Test Files >> blink_test.c. For your convenience we have also included the global.h file you used last week in the same folder. Tips: Read through the code in blink_test.c, and xplain how the PORT output is toggled by using the ^= operator. When creating a new project save it to the desktop and move it to a US flash drive once you complete the lab. Your code may not compile if you save it directly to the US drive. How did you setup (configure) your last two programs? Why? How does that apply here? Have you included all the libraries (#includes) required for your program to compile? Remember to build your program! This step creates your hex file. If you re trying to program your chip but can t find a hex file double check to ensure you didn t skip this step. oth programming the chip and outputting data to the terminal happen on the same serial port. You can t do both at the same time. This means that if your programming dialog window is still open you won t be able to establish a terminal emulation session. Nor can you reprogram the chip unless you ve disconnected your terminal (In HyperTerminal this can be accomplished by clicking on the hang up icon). You need a jumper cable between P0 & P1 to the receive and transmit pins for the serial spare port you re using. If you don t remember which one goes where consult lab two or the pinout for the Atmega128. If you re not getting any output on the screen double check that you ve made this crucial connection.

PH-5 ds 5 Atmega 128 STK500 & STK501 220Ω Pinout for transistor 2N3904 22k Pin PF0 Pin P0 P15 10k 2N3904 A Figure 5. Light-controlled switch using the Atmega 128. The photoresistor (in ) is part of a voltage divider, the output of which is connected to pin PF0, one of the pins that can be used for analog-todigital conversion. Pin P0 is connected to the base of a transistor (in A), which is used as a switch for illuminating the LD when the light level on the photoresistor is beyond a certain threshold value. 3. When you have successfully completed step 2, build the circuit in shown in Figure 5, and compile and run the Photoresistor and A/D test program in Appendix A. onnect the microcontroller to Hyperterminal as described in the intro to Atmega 128 lab. Reset the microcontroller by pressing the reset button on the STK500 or by cycling the power. What happens when you cover the photoresistor? What range of values are shown in the communications window? What voltage do these correspond to? Now try using the 10-bit reading instead of the 8- bit one. Remember to change the declaration of level to an unsigned 16-bit integer so it can handle the extra bits. State the differences you observe between the two methods. 4. When you have successfully completed step 3, write a program that will turn the LD on when you cover the photoresistor with your hand. (Hint: add a test in the While loop that compares the value of level with a value slightly higher than that value for when the photoresistor is covered. xperiment with the threshold value.) Display the state of your LD on the terminal window. What changes need to be made to the software (note: no need to change any hardware) if you want to have the LD stay on under ambient light conditions and turn off when a shadow falls on the photoresistor (i.e. the opposite function to what you programmed in step 4. Appendix A link test program: // link test program // Put your name here // Put the date here // This program turns on an off the P0 output with a 500ms delay //----- Include Files --------------------------------------------------------- #include <avr/io.h> // include I/O definitions (port names, pin names, etc) #include <avr/interrupt.h> // include interrupt support #include "global.h" // include our global settings #include "timer.h" // include timer function library (timing, PWM, etc) //----- Function Declarations-------------------------------------------------- void init(void); //----- egin ode ------------------------------------------------------------ int main(void)

PH-6 init(); // initialize everything while(1) PORT ^= 0x01; timerpause(500); } return 0; } // end main() void init(void) // initialize our libraries // toggle output bit P0 // pause for 500ms timerinit(); // initialize the timer system // Setup Digital I/O DDR = 0xff; // set PORT to all outputs PORT = 0xff; // set all output pins to high } // end init() Photoresistor and A/D test program: // Photoresistor and A/D test program // Put your name here // Put the date here // This program reads the voltage associated with a voltage divider // that contains a photoresistor and continuously prints the output // to the Atmega 128 Serial Port //----- Include Files --------------------------------------------------------- #include <avr/io.h> // include I/O definitions (port names, pin names, etc) #include <avr/interrupt.h> // include interrupt support #include "global.h" // include our global settings #include "uart.h" // include uart function library #include "rprintf.h" // include printf function library #include "timer.h" // include timer function library (timing, PWM, etc) #include "a2d.h" // include A/D converter function library #include "vt100.h" // include T100 terminal support //----- Function Declarations-------------------------------------------------- void init(void); //----- egin ode ------------------------------------------------------------ int main(void) u08 level; // declare unsigned 8-bit integer init(); // initialize everything // print a little intro message so we know things are working vt100learscreen(); vt100setursorpos(1,1); rprintf("welcome to the Photoresistor Laboratory!\r\n"); while(1) // sample a2d channel and print them to the terminal vt100setursorpos(2,1);

PH-7 level = a2donvert8bit(0); // use a2donvert10bit(channel#) to get a 10bit a2d reading rprintf("light Level: %d \r\n", level); } return 0; } // end main() void init(void) // initialize our libraries uartinit(); // initialize the UART (serial port) uartsetaudrate(9600); // set the baud rate of the UART rprintfinit(uartsendyte); // make all rprintf statements use uart for output timerinit(); // initialize the timer system // Setup Digital I/O DDR = 0xff; // set PORT to all outputs PORT = 0xff; // turn off all outputs DDRF = 0x00; // configure a2d port (PORTF) as input PORTF = 0x00; // turn off pull-up resistors on PORTF a2dinit(); // turn on and initialize A/D converter // set the a2d prescaler (clock division ratio) // - a lower prescale setting will make the a2d converter go faster // - a higher setting will make it go slower but the measurements // will be more accurate // - other allowed prescale values can be found in a2d.h a2dsetprescaler(ad_prsal_di32); // set the a2d reference // - the reference is the voltage against which a2d measurements are made // - other allowed reference values can be found in a2d.h a2dsetreference(ad_rfrn_a); } // end init()