You are not logged in

Log in into our community

Log in so you acess some hidden content

* Fields are required.

Register into our community!

Sign up now for some good content

* Fields are required.

Lost something?

Enter your username or email to reset your password.

* Fields are required.

Light Sensors

Posted on : Sun , 01 2015 by : virusi

Necessary Knowledge :


Basic ADC knowledge.

Voltage Divider knowledge.

Basic Rtos knowledge.

Basic UVision knowledge.

Basic C Langugage knowledge.

Basic Hardware knowledge.

THEORY ON LIGHT SENSORS :


The Light Sensor is a passive devices that convert this “light energy” whether visible or in the infra-red parts of the spectrum into an electrical signal output. Photoelectric devices can be grouped into two main categories :

– those which generate electricity when illuminated(Photo-voltaics or Photo-emissives,etc)

o Photo-emissive Cells – These are photodevices which release free electrons from a light sensitive material such as caesium when struck by a photon of sufficient energy.

o Photo-voltaic Cells – These photodevices generate an emf in proportion to the radiant light energy received and is similar in effect to photoconductivity.

o Photo-junction Devices – These photodevices are mainly true semiconductor devices such as the photodiode or phototransistor which use light to control the flow of electrons and holes across their PN-junction.

– those which change their electrical properties in some way(Photo-resistors or Photo-conductors)

o Photo-conductive Cells – These photodevices vary their electrical resistance when subjected to light.

What are the main photodetector characteristics?

Sensitivity – the sensitivity of a photodetector is the relationship between the light falling on the device and the resulting output signal.

Spectral Response – relative sensitivity of a photoconductive cell is dependent on the wavelength (color) of the incident light. Each photoconductor material type has its own unique spectral response curve or plot of the relative response of the photocell versus wavelength of light.

Resistance Tolerance – The sensitivity of a photocell is defined as its resistance at a specific level of illumination.

Dark Resistance – the dark resistance is the resistance of the cell under zero illumination lighting conditions.

Temperature Coefficient of Resistance – Each type of photoconductive material has its own resistance versus temperature characteristic.

Speed of Response – Speed of response is a measure of the speed at which a photocell responds to a change from light-to-dark or from dark-to-light.

Let’s take a look at some application where we can use Photoconductive cells:
Analog Applications :

– Camera Exposure Control.

– Photocopy Machines – density of toner.

– Automated Rear View Mirror.

– Automatic Gain Control – modulated light source.

Digital Applications :

– Night Light Control.

– Oil Burner Flame Out.

– Street Light Control.

– Position Sensor.

PRACTICAL EXAMPLE :


In this practical example will use a Light Intensity Sensor Module 5528 that will be connected to a LPC17XX board.
LESensorImg
Fig.1 Light Sensor Module.

We have 3 pins to connect to our board:

– 1 Pin GND – should be connected to the board GND.

– 2 Pin VCC – should be connected to the board VCC( 3.3V or 5V).

– 3 Pin SIG – should be connected to the ADC input on out board.

This light sensor is a Photo-resistors Light sensor which will change his resistance depending on the amount of light that will be exposed. Our goal is to read the output voltage and transform it into resistance and depending on the resistance value we can estimate the light intensity.
Code:

1. Configure the MCU (initialize the System, ADC, Port).

static void PortInit(void)
 {
	Port_Pin_Cfg_str Port_Pin_Cfg[] = { channel_PINSEL1 , Port_Pin_Nr_P8 , Port_Pin_FNC_01 };

	/* Configure P 2.00... P 2.07 as output */
	LPC_GPIO2->FIODIR |= ((1UL << 0u)|(1UL << 1u)|
  						  (1UL << 2u)|(1UL << 3u)|
                          (1UL << 4u)|(1UL << 5u)|
                          (1UL << 6u)|(1UL << 7u)) ;
	/* turn off all the LEDs */            
	LPC_GPIO2->FIOCLR = 0x000000FF;		

	/* configure port P0.23 as ADC input */
	Port_Pin_Sel_Configuration(Port_Pin_Cfg);
 }

 static void AdcInit()
 {
	/* enable adc */
	adc_cfg_str adc_cfg[] = { channel_AD0CR_ADC0 , 0 };
	adc_init(adc_cfg);
 }

 /*
 	1. Initialize clocks 
	2. Initialize and create Rtos Tasks	
	3. Initialize Ports
	4. Initialize the ADC
 */
 static void ConfigureMCU(void)
 {
 	/* Initialize clocks */
	SystemInit(); 
	/* Initialize I/O for LED's output*/
	PortInit();
	/* Adc Init */
	AdcInit();
	/* Initialize Rtos */
    RtosInit();
 }

 int main (void) 
 {
	ConfigureMCU();
	
	while(1)
	{
		/* do nothing */
	}
 }  

2. Initialize and configure a 500ms task.

const portTickType	delay = ( 500 / portTICK_RATE_MS );
static void RtosInit(void)
 {
	xTaskCreate( fnc_500msTask, "500msTask", delay, NULL , 1 , NULL );

	/* Start the scheduler so the tasks start executing. */
	vTaskStartScheduler(); 
 } 

3. In the 500ms task read data from adc and convert ADC value to Light Sensor Resistance.

uint16_t ADCVal = 0U;
 double RLightSensor = 0U; 
 double VoltageVal = 0U;

 static void fnc_500msTask(void *pvParameters)
 {
 	portTickType xLastWakeTime;
 	xLastWakeTime = xTaskGetTickCount();

   	for(;;)
   	{
		ADCVal = adc_get_adc_cycle(channel_AD0CR_ADC0);
		VoltageVal = (double)((3.3/4095.0)*ADCVal);
		RLightSensor = (4095.0-ADCVal)*10/ADCVal;

		/* delay task for 500ms */	
	   	vTaskDelayUntil( &xLastWakeTime, delay );
		/* Allow the other sender task to execute. */
		taskYIELD();
   	}
 } 

Download Link :


Interested in a working version of this project download Light sensor example.

External Links :


– More info on Light sensors here.

– Light sensor classification and examples here.

Last updated on Mon , 07 2015
SHARE THIS PAGE :

This page is waiting for your comment.

Share and Leave a comment.

You must be logged in to post a comment.

Back to Top