Skip to content

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

    Lab 1

    Digital Signal Acquisition


    To acquire digital information INTO the TINAH Board from external digital sensors.



    1. Review the data sheets for the QRD1114 and LM311 components, which can be found in the downloads section.
    2. Read some of the online notes for the TINAH board, particularly for the digital inputs.

    NB: Though your lab books will not be handed in, it is essential that you keep good notes to help you later when you are building your robots. Keep detailed records of the code you’ve written, your circuits, what worked and what didn’t. We may ask to see your notes to evaluate part of your grade in the course.

    At some points in the lab you will be asked to demonstrate some part of your progress. This is marked by “Milestone” in the lab manual.   Make sure you show a TA that you have reached this milestone before going on.  Completion of Milestones will count for marks.

    Lab Announcements (to be discussed at start of lab session)

    • Introduce TAs  (Allison Schaap, Nick Geraedts, Matt Lam – all fizz alumni, all took phys 253, all TA’s last year)
    • At your workbench:
      • examine contents of the kit and get familiar with each item (battery packs to come)
      • oscilloscopes and other benchtop material
      • locker storage in cabinet just behind bench; all lab material
      • software on all PC’s:   Wiring / Solidworks / OMAX / OpenOffice/ Eagle CadSoft
    • Areas in the lab:
      • Common areas in the room  (Electronics at front, wiring and fasteners in middle, workstation/materials in back)
      • Off-limits areas (anything in locked or even closed cabinets… if in doubt, please ask first!)
      • Areas still in flux, but have a look around
    • First-aid kit / drinks and food outside / shoes at all times
    • All 5 labs have milestones – the time that your group completes the lab is recorded by the instructors and TAs.  You must get them to sign off before you complete the lab! 
    • About halfway through the lab:
      • soldering demo by one of the course instructors (1 person per team at a time)
      • sign-up for 10hr machine shop course no particular advantage early or later in term)




    1.   Connect your PC to the TINAH /Wiring Board and Download a program.

    You are free to use either the lab PCs or your own laptops for this and all of the labs.

    Follow the directions on the course website for setting up the programming environment and downloading a simple program onto the TINAH board:

    Note that the lab PCs all have Windows 7 installed, and have the current version of wiring (wiring-026) copied onto the desktop, but you will have to download and copy the “phys253wiringv1.exe” or “” file to the lab PCs.

    2.)  Connect a switch to one of the TINAH board’s digital inputs.

    The TINAH board uses a three-conductor connector for plugging in sensors.  The +5V pin may be used to power a sensor.  The sensor signal pin (top row) is the input to the TINAH Board (this must be in the range of 0 to 5 volts).  Finally, the ground pin (bottom row) connects to the system ground.

    Figure 1:  digital IO header pins on TINAH board.

    Things to watch out for:

    • Do not short the ground and 5V pins!   The board will reset and nothing will appear on your screen.
    • All digital inputs include a 47kΩ pull-up resistor.  That is, all digital inputs have a default level of +5V when nothing is connected.   For further info, read the Wikipedia article to learn more about pull-up and pull-down resistors.
    • You can use one of the switches in your kit, or you can use one of the switches on the “Student Lab Prototype Boards” given to each group.

    Write a short program to display the status of the switch (open / closed) on the LCD display of the board.

    3.)  Frequency counting.

    Set up the function generator to produce a square wave in the range of 0 to 5 V.  Run the signal through a LM311 comparator and wire the comparator output to one of the digital inputs of the TINAH  Board.

    DO NOT RUN THE FUNCTION GENERATOR OUTPUT DRECTLY INTO THE TINAH BOARD! This is protection of the digital inputs to the TINAH, and  is good practice to learn about buffering your active input signals.

    Write a short program to measure the frequency of this square wave.  Explore different frequencies to find the TINAH board’s limit at frequency counting.

    Optimize your program to have as few instructions as possible.  This may help raise the maximum frequency that the TNAH board will count.  Take advantage of the variety of functions you can find in the Wiring language.

    4.)  Converting an analog signal to a digital signal using a comparator.

    Wire up the QRD 1114 reflective sensor as described in this online reference page, but do not solder it. Instead, mount it on your solderless breadboard.

    Mount a comparator (LM311) on your solderless breadboard, and use the output of the QRD1114 as one input to the LM311, and the output of a voltage divider using a potentiometer for the other input  (see LM311 application notes and class notes).   In this way, the LM311 is used to compare the two voltage levels .

    Note that the output of the LM311 is open collector (see data sheet or read up on open collector outputs) which means that it will float at an undetermined value unless it is pulled up to the logic voltage.   Fortunately, the TINAH Board’s inputs are set up with internal pull-up resistors to handle open collector sources.   Examine this effect by measuring the voltage at the output of the LM311 under these conditions:

    • nothing connected to the output pin.
    • a pull-up resistor to 5V connected to the output pin
    • the TINAH digital input connected to the output pin
    • both a pull-up resistor and the TINAH digital input connected to the output pin.

    Wire the output of the LM311 to the TINAH Board and use the program you wrote for the microswitch to report the status of the optosensor on the LCD display.

    Use black electrical tape against the surface of your bench to generate a signal from the optosensor.  Use the oscilloscope or voltmeter to measure the signal and help you set a reference voltage with the potentiometer.

    Experiment with distance of the optosensor from the tape to get the best contrast (signal level over the tape vs. signal level over the bench surface).   This is a similar setup to what you will use for tape-following for your robots.


    1. Show your TA the frequency counting setup, and the max frequency recorded.
    2. Show your TA that your TINAH Board reports the optosensor status on the LCD display.

    Other Information

    • Items to watch out for when debugging your circuit (these points listed at the end of Lecture 1):
      • Circuit (LM311) and TINAH are not connected to a common ground.
      • The LM311 comparator output pin is not pulled up.
      • The power rail break in the proto board is not bridged.
      • The strobe pin of the LM311 is pulled low.
      • The ground pin of the LM311 is not grounded.