Starting from:
$40

$34

Lab #3 Optical Sensor Solution

This circuit detects when a light path is interrupted and when it is completed. Uses typically

include counting objects or events such as computing RPM’s of a rotating shaft with a “blade” that interrupts the light path every 1 or ½ cycles.

Figure 1: Optical Sensor that Reports ON/OFF

Voltage is measured at the output of the Potentiometer (VA). VCC and GND can be obtained from ports on the Nuvoton Nu-LB-NUC140 development board (Nuvoton).

  1. Background:

Light incident at the base of the optical sensor/transistor causes a much larger current Ic to flow. The transistor is appropriately doped so that when its base is exposed to light (visible or IR depending on the device) the incident photons generate a base current. When the NTE3100’s light path is not blocked it produces +5V at Vc. R1 is a current limiting resistor.

The concept of a buffer is interesting. In a circuit, it is possible that one component operates over a range of voltages that differs from other components. For example, a sensor might operate from 0V to 10V where any voltage above 5.0V is considered “1”. However, TTL devices operate from 0V to 5V, where “1” is 1.75V or greater. So a sensor value of “0” (4.5V) would be considered a “1” by TTL chips.

The solution to this mismatch is a buffer. This is a device that translates digital signals from one protocol to another. Just to confuse the issue, the term buffer is also used with regards to op- amps.

An ideal op-amp has low (zero) output resistance and high (infinite) input resistance. The low output resistance ensures that later circuits only “see” the op-amp’s output voltage looking back into the op-amp. That is, the output resistance of an op-amp is usually in series with the input resistance of the next downstream device. This relationship forms a classic voltage divider. Minimizing the op-amp’s output resistance maximizes the amount of input voltage seen by the next device.

A typical use of an op-amp buffer is to magnify by 1 a signal from a device with high output resistance into a low output resistance signal. Later circuits can then reference that signal as a low output resistance voltage source with minimal signal loss.

Volta

0 15

Time(ns)

x x+10


Figure 2: Transfer Diagram of a Hex Buffer

In reality the corners of the Input and Output signals are not square. If interested wire up a Hex buffer. Use a function generator to drive the buffer, an oscilloscope to observe the input and output signals and a power supply for the rail voltage.

Volts

V+

5

V -

0V

0 15

Time

x x+10


Figure 3: Transfer Diagram of a Schmitt Trigger

A Schmitt Trigger or Hex Schmitt Trigger is another type of buffer. Consider Figure 3 and estimate how the output would behave if the input had a “debounce” problem. That is, if the input quickly rises and falls several times then the output would also rise and fall. A Schmitt Trigger handles a partial loss of an input voltage by having two thresholds: V+ where any

voltage above this value turns the Schmitt Trigger ON; V- where any excursion less than V- turns the trigger OFF.

The input to a buffer is a signal from a transistor. The transistor is half of a photon coupled interrupter switch (NTE3100). The other half is an infrared emitting diode. A specification sheet for the NTE3100 is available on the course web site. Print this sheet and read it. The following background material should remind you about the basic principles of diodes and transistors. You will need to correlate the specs (which are sparse at best) to the actual device and you will need to design supporting circuitry.

Recall, diodes are non-linear devices. A forward biased diode exhibits a linear relationship between current and voltage until a threshold voltage is impressed across a diode, at which point current flows virtually un-impeded. The polarity of the threshold voltage determines if a diode is forward or reversed biased.

+V

1

Ir

  1. Forward Biased b) Reverse Biased

Figure 4: Typical Diode

R1 limits the current flow through the diode. An infrared emitting diode simply emits photons as well as enforcing a one-way flow of current. Your electronics textbook should have a pro-forma graph of a diode’s I-V relationship. This graph should show at what voltage a typical forward/reverse biased diode starts to allow forward/reverse current to flow unimpeded. Also, data sheets define the forward and reverse thresholds.

While a diode implements one-direction flow of current, a transistor acts as a multiplier or valve of current. When correctly biased a transistor can function in either its cutoff or its saturation region and exhibit switch like behavior.

In the NTE3100 little or no IR light on the base of the detector (transistor) allows no current to flow through the transistor. Therefore, its output at Vc presents a voltage equal to ground.


E

C

Figure 5: Electronic Devices in an Opto-Isolator Switch

If the base of the transistor detects IR photons then current flows through the transistor and the biasing resistor (R2 in Figure 1) develops a voltage. This voltage represents the ON-signal. The obverse is possible with a resistor at the transistor’s emitter. Circuit designers must match polarities of bits as they flow through a circuit. That is, a “1” at device A might be 0V while the same “1” at the next device B might be 5V. Again, the transistor can be configured so that OFF is ≥ 5V and ON is ≤0.7V.

The next step is to decide if the logic state is derived from Vc or Ve. This in turn determines the placement and value of R2. Also, the value of R2 is constrained by the current ratings defined in the NTE3100 specifications sheet. This has been completed and is shown in Figure 6.

+5V

+5V

Figure 6: NTE3100 Circuit


Pre-lab Assignements :

      1. Familiarize yourself with the Technical Reference Manual, User Manual, schematics, and the Driver Reference Guide sections that discuss the ADC.
      2. Read the data sheets for the NTE3100, CD4050 Hex Inverter Buffer, resistor color code, on the course web site (on Canvas).
      3. Complete the Pre-lab Questions.

Note: Each student must conduct the labs by themselves. You are not allowed to copy codes/content or to pair-up with other students to complete the labs. Each student must demonstrate individual tasks (after completion) to the professor and teaching assistant to get the full marks for the demo.

    1. In-lab Tasks:
      1. Design and build the supporting circuitry for an interrupter module. Do not connect it to the Nuvoton GPIO pins. Test the interrupter module as standalone circuit.
      2. Wire a buffer and connect the interrupter to it. Verify that VC has appropriate voltages when the light path is both blocked and unblocked. Repeatedly block/unblock the light path. Is there a “debounce” problem? If the light path is not blocked, use the oscilloscope to measure VC.
      3. Hint. Ground all unused pins on the buffer.
      4. Now, complete Figure 6, by connecting it to the Nuvoton board and use the VCC/GND pins on the board as the circuit’s power supply.
      5. Write software for the M0 that counts the number of times the optical sensor is blocked/unblocked. Your design should include hardware and software so that the user can indicate when to start and stop the count. Also, the user should “know” when the counter is operating. One solution is to designate read start/stop buttons and status LED’s on the Nuvoton board.
      6. Write C-routines to include all the software requirements discussed in Lecture on Lab 3, including: (Software design needs to support)
        1. A separate start button
        2. A separate rest button to reset the counter
        3. A separate stop button using an external interrupt button
        4. A counter recording number of objects blocking the light.
        5. A heartbeat signal on the RGB LED
        6. One or all of the red LEDs toggle when a block is detected.
        7. Display the count on LCD or 7-segment or both.
      7. Go through the Lecture Notes for Lab 3, and complete any additional requirements presented during the lecture.

    1. Parts List:

The items on this list will NOT be repeated in the lab write-up but they are necessary for all labs.

      1. Hex Buffer
      2. Interruptible Light Path (NTE3100)
      3. Resistors
      4. Connector wires.
      5. USB to micro USB cable for programming

4 Deliverables:

      1. To sign-off: Demonstrate to your professor/lab instructor how your device functions as it is activated/deactivated and as the light path is blocked/unblocked.
      2. Lab Write-up. Follow the Lab Report Format as well as the rubric for Lab3. The report should include:
  1. Introduction including a summary of the lab tasks.
  2. In-Lab tasks, problems encountered, your solutions, including hardware and software.
  3. Include the explanation of how you characterized the interruptible light path and it should document the meanings of status LEDS and of start/stop.
  4. Discussion and conclusion.
  5. Program/code listing for each task.

NOTE: All the lab reports should be typed and turned in as a hard copy on time (check the syllabus for the due date), and a soft copy should be forwarded to the Teaching Assistant: Srikanth Ramadurgam on the due date and time


Pre-Lab Questions for Lab 3


Name:

Answer the following questions based on pre-lab assignments. These questions will help you to complete the programming assignments. Be sure to include your work and show units, as appropriate, on your answers. 2+2+2+4pts =10 points possible.

  1. Assume you are using all of the LEDs (RGB and the 4 red LEDs), the 7-segment display, the LCD screen, the keypad, and the external interrupt button. Which GPIO pins are available to be used as an external input. (i.e. determine which GPIO pins are being used by the peripherals listed above, these are unavailable for other use)


  1. There are 4 General Purpose I/O External interrupts (source IP is GPIO). List the Interrupt Name and which pins can be used with them (see TRM).


  1. Which driver would be the logical source of interrupt functions for the above interrupts? List one function provided by the driver that would allow you to setup an external interrupt. (see DrvX.c)
  1. Write a fragment of code to read an external input from pin GPA_6 and assign the value to LED_0 (GPC_12).


  1. Write a fragment of c-code to use the keypad to provide the start, stop and reset buttons

  1. Can this lab be accomplished without using interrupts?

More products