Light Sensor: Photodiode

The light sensor used is the BPW34. This is a high speed and high sensitive silicon PIN photodiode in a miniature flat plastic package. A photodiode is designed to be responsive to optical input. Due to its waterclear epoxy the device is sensitive to visible and infrared radiation. The large active area combined with a flat case gives a high sensitivity at a wide viewing angle.

Photodiodes can be used in either zero bias or reverse bias. Diodes have extremely high resistance when reverse biased. This resistance is reduced when light of an appropriate frequency shines on the junction. Hence, a reverse biased diode can be used as a light detector by monitoring the current running through it. Coupled to a 10Kohm resistor, and given the specification of the BPW34 a simple relationship between lux (light intensity) and voltage is given by

lux = 1333 * Vo

Exercise 5 - Analog Input (Measure Light Intensity)

Objective

  • Learn Analog Input

  • Learn more about Class and Object

In this exercise, we will measure the light intensity using a Photodiode and the EMANT300, a Data Acquisition Module.

Class, objects, methods, properties

We will use cars to illustrate the above concepts.

  • Cars have registrations numbers to differentiate one car from another.

  • Cars can be described by their make or their color

  • Cars can be driven forward and in reverse.

We have two cars, SFL8772 is a Grey Toyota while SCU7056 is a Gold Honda.

In C# terminology, we would say that

  • Car is a class

  • SFL8772 and SCU7056 are objects and instances of the Car Class.

  • SFL8772.Color = Grey; SCU.Color = Gold

Color is property of the Car Class

  • SFL8772.Make = Toyota; SCU.Make = Honda

Make is another property of the Car Class

  • SFL8772.Drive(forward); SCU7056.Drive(reverse)

Drive is a method of the Car Class.

  • To identify the property, we put a dot or '.' between the object and the property and assign an appropriate value.

  • The difference between method and property is that a method is associated with a task.

  • A method may or may not require parameters like forward or reverse to be passed.

In your previous exercises, you have used the Console class and the methods ReadLine and Writeline to allow your program to interact with the user using the computer monitor and keyboard.

To perform Data Acquisition, we have provided a class called EMANT300 which works with the EMANT300 Data Acquisition Module and allows your program to interact with the physical world.

  1. Create a new C# console project. Name the project ReadLight

  2. Add the highlighted lines to the generated source code.

  3. Uncomment (remove //) the following line if you are using the simulator

// DAQ.Simulation = true;

If you are using the simulator rather than the actual hardware, please read Appendix A now on instructions to program the simulator. The simulator must be running before you start your own program.

Program 5.1 Measure Light Intensity

using System;
using Emant;

namespace ReadLight

{

///
/// Summary description for Class1.
///

 class Class1
 {
 ///
 /// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)

  {

  double volt, lux;
  Emant300 DAQ = new Emant300();

  // DAQ.Simulation = true;
  DAQ.Open();
  volt = DAQ.ReadAnalog(Emant300.AIN.AIN0,Emant300.AIN.COM);
  lux = 1333 * volt;
  Console.WriteLine(lux);
  DAQ.Close();
  }

 }