Lab 4 Report

Document Sample
Lab 4 Report Powered By Docstoc
					 Lab 9 Report

   IET 645

Drew Henderson
      and
 Rick Wagoner

 Spring, 2006
Objective
The purpose of this lab was to introduce the concept of the phototransistor device, and reinforce
the utilization of the A/D converter for reading voltage changes. While the setup was
comparatively simple, the concepts behind the utilization of these devices mimic those necessary
to support various input devices and sensors, such as alarms, optical mice, and robotics.

Setup
The setup for this lab was straightforward: connect a phototransistor in line between a 5v source
and ground, with port AN7 connected to the emitter, as is the resistor to ground (see Setup 9).
Voltage is checked by comparing the voltage at the emitter to ground. Eight LED’s are
connected to port B, and are used to represent the binary value of the voltage.

Lab 91
For this lab, we used the program provided, Program 91a, and a voltmeter to display the value
read from the input port and to measure the actual voltage, respectively. The flowchart
associated with the program can be seen in Flowchart 91a. This program operates by first
turning on A/D, waiting 105 s for the charge pump to stabilize, then writing the octal value 37
to the AD control register (ADCTL) to specify port E7, and multiple conversions. At this point,
the program loops until a value is available. The program loads the value into the A register, and
outputs it to port B, which shows up on the LED’s. The program then returns to the loop,
waiting for input.

We recorded the following values in the associated states:

                                                      Calculated     Measured
               State           Binary Value (dec)     Voltage        Voltage
               Room light      00101110 (39)          0.76v          0.98v
               Dimmer light    00010111 (23)          0.45v          0.44v
               Darkened        00000001 (1)           0.02v          0.01v

The lab instructions indicated the maximum voltage should be approximately 5v. Our maximum
voltage was considerably less than that. In later experimenting – involving setting the board
higher, so as to be closer to the light – we were able to get the binary value of 01110001, with a
measured voltage of 2.2v.

For the last exercise of this lab, we modified the program, as seen in Program 91b (and
accompanying Flowchart 91b), to output the pattern of $ff when the value read fell below 1.
The only difference between this program and 91a is the addition of a compare between the
value read and $01. If it is less than that, representing no light, it branches to DARK, and all the
LED’s are turned on, then returning to the loop. If the value is not less than $01, it proceeds as
the previous program: output the value to port B, and return to the loop.
Setup 9
                 5v

                  C                 100
                               B0
                                    100
                      E        B1
   AN7                    V0        100
                               B2
                                    100
          4.7K                 B3
                                    100
                               B4
                                    100
                               B5
                                    100
                               B6
                                    100
                               B7
Program 91a

*
*      Phototransistor Lab
*
*      Register Equates
PORTB        equ   $1004               ;   PORTB
ADCTL        equ   $1030               ;   Analog Control Register
ADR4         equ   $1034               ;   CH8 Analog Result
OPTION       equ   $1039               ;   Analog Enable Register
*
*      Setup the A/D Converter
             org   $0100               ; program starts here
             ldaa #$80                 ; Turn A/D on
             staa OPTION                     ;

              ldy    #30               ; delay for 105 microseconds for
delay105      dey                      ; the charge pump to
              bne    delay105          ; stabilize

              ldaa   #$37              ; select PE7, multi conversions
              staa   ADCTL             ; setup A/D

*
*      read analog value and display
*
loop          ldaa   ADCTL             ; wait for CCF
              bpl    loop

              ldaa   ADR4              ; load result
              staa   PORTB             ; display result
              bra    loop
Flowchart 91a
                   Start



                Turn on A/D



                 30  Y


                [Y – 1]  Y



                   Y > 0?      yes

                       no
                Ininitalize
                A/D control
                Register


                    Value      no
                    from
                    A/D?
                       yes

                [$1034]  A


                [A]  Port B
Program 91b
*      Phototransistor Lab
*
*      Register Equates
PORTB        equ   $1004               ;   PORTB
ADCTL        equ   $1030               ;   Analog Control Register
ADR4         equ   $1034               ;   CH8 Analog Result
OPTION       equ   $1039               ;   Analog Enable Register
*
*      Setup the A/D Converter
             org   $0100               ; program starts here
             ldaa #$80                 ; Turn A/D on
             staa OPTION                     ;

              ldy    #30               ; delay for 105 microseconds for
delay105      dey                      ; the charge pump to
              bne    delay105          ; stabilize

              ldaa   #$37              ; select PE7, multi conversions
              staa   ADCTL             ; setup A/D

*
*      read analog value and display
*
loop          ldaa   ADCTL             ; wait for CCF
              bpl    loop

              ldaa   ADR4              ; load result
              cmpa   #$01
              bls    DARK
              staa   PORTB             ; display result
              bra    loop

DARK          ldaa   #$ff
              staa   PORTB
              bra    loop
Flowchat 91b


                                         Start



                                     Turn on A/D



                                       30  Y


                                     [Y – 1]  Y



                                         Y > 0?      yes

                                             no
                                      Ininitalize
                                      A/D control
                                      Register


                                          Value     no
                                          from
                                          A/D?
                                             yes

                                      [$1034]  A



                                        [A] < 1?     no

                                             yes

                                       $FF  A


                                     [A]  Port B




Conclusion
This lab provided us with the opportunity to perform additional work with the A/D converter via
the use of a phototransistor. The values output to the LED’s , when multiplied by 0.0195
(determined by the 5v range with 8-bit conversion), closely matched the observed values via the
voltmeter.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:7
posted:7/27/2012
language:
pages:7