Skip to content

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

    Lab 1 (2014)

     

     

    Digital Signal Acquisition

     

     

     

    Objective

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

     

     

    References

     

    Pre-Lab

    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 your code, your circuits, and what worked and what didn’t.   We may ask to see your notes to evaluate part of your grade in the course.

    Make sure you show a TA / Instructor that you have completed the Milestones, and that they have marked you off on the Master List at the front of the lab.  Completion of Milestones will count for marks.

     

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

    • Introduce TAs  (Koko, Andy, Dillon)
    • At your workbench, make sure to check out the following:
      • Use the Checklist to identify all components in your parts and tools kit.
      • Locker storage in the cabinet and 2 drawers behind your bench
    • Software on all PC’s:   Wiring v27 / Solidworks 2013 / OMAX / Eagle CadSoft / Matlab / Python /  MS + OpenOffice
    • Look at some of the areas in the lab:
      • First-aid kit /  food and drink outside / shoes at all times 
      • Electronics consumables at front of lab
      • Wiring, fasteners, and mech components in back
      • Off-limits areas (anything in locked or taped shut cabinets… if in doubt, please ask first!)
    • 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. you will be assigned a group time for the 10hr machine shop course.

     



    Lab

    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.

    Follow the directions on the course website for setting up the programming environment and downloading a simple program onto the TINAH board, as described in the Getting Started section on the TINAH page.

    Note that the lab PCs run Windows 7, and have an older version of wiring (wiring-027) copied onto the desktop.  They should already have the TINAH library copied into the correct folder – check to see if “phys253wiringv1.exe” or “phys253wiringv1.zip” is copied and extracted to the /libraries/ directory.

     

    2.  Connect a switch to one of the TINAH’s digital inputs. Write a short program to display the status of the switch (open / closed) on the LCD display of the board.

    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 the screen will likely blank out.
          • All digital inputs have an internal 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 on 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.

     

    3.  Converting an analog signal to a digital signal using a comparator.

    Read through all of the steps below first, then DRAW OUT ALL CIRCUITS ON PAPER FIRST.  This will hopefully solve many of your problems before you try to build your boards, and allows TAs/instructors to give you better help!

    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.

    As discussed in Lecture 1, 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 47kΩ  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 on a white sheet of paper 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.

    4.  Frequency counting – Write a short program to measure the frequency of a square wave.

    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 directly 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.

    5.  Examine the input voltage limits of the comparator.

    Note what happens to the output voltage as the input voltage gets close to the power rails values of the comparator.  See whether you continue to get the expected value, or whether it ends up generating unexpected values.  Note that regardless of whether you get an expected or unexpected output, you cannot rely on electrical components operating as desired once you exceed their operating parameters – it is only luck if you continue to get your expected values!

    6.  Sending info back to the Computer. 

     Use the Serial.print command to stream the output to the computer rather than the LCD screen (the instructions are here – they are very similar to outputting to the LCD screen).  Use the “Serial Monitor” feature described in the Wiring environment.   (This will be highly very useful for your ENPH 257 Thermo Lab, where you will likely want to record data to your computer using an Arduino board and an amplified signal from a thermocouple through an instrument amp circuit.   You will be using the INA2126, you can find the datasheet in the Downloads section)

    Milestones

    Show your TA/Instructor the following:

    1. TINAH Board reports the optosensor status on the LCD display and to the Serial Port Monitor.
    2. Schematic for your optosensor circuit (they will be looking at connections and component values).
    3. Frequency counting setup, and the maximum frequency recorded.

     

     

    Hints

    • 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 open-collector, and needs a pull-up resistor.
      • The power rail break in the Lab Prototype Board is not bridged.
      • The strobe pin of the LM311 is pulled low (can leave floating).
      • The ground pins of the LM311 (pins 1 and 4) are not grounded.

     

    End of page.