Skip to content

This page is archived material from a previous course. Please check for updated material.

    Lab 3

    Analog Input and Digital Output



    To acquire a signal from an analog sensor into the TINAH Board


    1. Read the notes on the TINAH Analog Input pins, and be sure to note the following:
      1. The labeling on the Analog Input pins is incorrect, the pin labeled “7” is actually “0”, and vice-versa.
      2. Knob 6 and Knob 7 are connected to Analog Inputs 6 and 7 by default.  To gain access to the analog inputs on lines 6 and 7 and bypass either of the knobs, shift the position of the two jumpers next to the knobs.
    2. Design a circuit to use a voltage follower circuit to connect the potentiometer to the analog input of the TINAH board.  This allows the voltage going into the TINAH board to be linear with respect to the TINAH Board’s 0 – 5V analog input range.
      1. NB:  you could connect the potentiometer directly up to the analog input, and generally this is an acceptable solution in 95% of your applications, but this doesn’t create a truly linear relationship between 0-5V and the potentiometer position, because there is a 47kohm pull-up resistor connected to 5V on each analog input inside the TINAH board.  The voltage follower circuit you design will avoid the offset caused by the 47kohm pull-up resistor.
      2. As an aside, try to derive the exact relationship between potentiometer position and TINAH Board input voltage if the 10 kohm potentiometer is connected directly to the TINAH Board input.  It’s more complicated than you might expect.  Does this problem become better or worse when usinga larger potentiometer (100 kOhm or higher)
    3. The TINAH Board’s A/D resolution is 10 bits. Determine the resolution to which you will be able to measure the angular position of the pot.


    1. Read analog inputs from the two knobs. Write and execute a short program to display the analog value of the two TINAH knobs on the LCD screen.
    2. Understand the power limits of the TL082 chip. Wire up the voltage follower circuit you designed in the pre-lab for reading in the potentiometer input.  Connect the signal to a TL082 op-amp wired as a voltage follower, but power the TL082  from 0  to  5 V.
      1. Note about 5V: Either use the 5V from the external power supply (found on your student prototype boards) , or use the 5V from the TINAH board 5V rail.Avoid using both 5V sources in different areas on your circuit, and above all DO NOT CONNECT 5V from TINAH with 5V on the external power supply!  Any small differences in the power supply 5V line and the TINAH 5V line connected through a wire means that current will flow from one to the other, with no resistor to limit the current, and something will eventually get hotThe 5V line on the TINAH board is generally used as a reference for 5V in different circuits, but can be used as a source of power for several small-powered components on the board, with a maximum of ~ 200mA.
      2. Simultaneously look at the input voltage from the potentiometer and the output voltage from the TL082.  Note what happens to the output voltage as the input voltage gets close to the power rails values (close to 0V, or close to 5V) .  Check with your TAs/instructors if the effect is not clear to you.   The TL082 is not a rail-to-rail op-amp, and is the reason why you need to power your op-amps with voltages that exceed the highest input and output voltages from the op-amp.
    3. Read analog inputs from a potentiometer.
      1. Switch the power of the op-amp (from 0V low and +5V high) to a larger range (from -15V low  to +15V high)
      2. Use a zener diode as described during the lecture to protect the board.
        1. Overvoltage protection. Use a zener diode to make sure the signal is in the range 0 to 5V before plugging it into the TINAH Board.    The zener diodes available in the lab are BZX79C5V, rated for 0.5 Watt of power.  Work out an appropriate resistor value for placing in line with the output value if the input of the circuit.  See how to use zener diodes as voltage clamps for overvoltage protection [The Circuit Designer’s Companion, pg. 120, Tim Williams]
      3. Put the output of this protected TL082 op-amp into a TINAH board analog input.
      4. Modify your program to display the angular position of the pot on the LCD screen
    4. Read analog inputs from an external signal. Use the function generator to produce a sine wave that goes in the range 1V to 4V.    Connect the signal through a voltage follower in the same way as done for the potentiometer, and connect to the TINAH board input.
    5. Generate a digital output signal. Write a program to generate a high signal on one of the TINAH board’s digital output line when the input analog voltage exceeds 2.5V, and a digital low signal when it goes below 2.5V.  See the instructions here for how to create a digital output signal from one of the PWM signals:
      1. Hardware Description of PWM Output Pins
      2. Software Example  of using PWM output Pins as digital output lines (in this case, the example uses PWM pin #4)
    6. Find the upper limit of analog input sampling time.     Display both the sine wave and the digital output on the oscilloscope, and explore the frequency limit at which the digital output signal no longer matches the frequency of the sine wave.  Compare this with your results from Lab 1 for sampling on the digital input lines.  Hook up the output of your IR detector circuit (from Lab 2) to an analog input.  Write a program to display IR amplitude readings on the LCD display.
    7. Use the pull-up resistor on the analog input line. Wire the output of a QRD1114 optosensor directly to an analog input.    Write a program to display the value of the sensor on the LCD display.     Note that this setup takes advantage of the 5V rail to power the IR LED, as well as the 47 kOhm resistor on the TINAH board analog input, as shown in the figure below:

    Figure:  QRD1114 connection to TINAH Board. [From HandyBoard Manual ]

    8.  Analog Input from IR Emitter Circuit. Hook up the output of your IR detector circuit (from Lab 2) to an analog input.  Write a program to display IR amplitude readings on the LCD display.


    • Show the TA/Instructor the maximum frequency you can record from the function generator from step (4).
    • Show the TA/Instructor that you can read the amplitude of the IR beacon on the TINAH LCD display.