Advertisement

Light Tracker. -PIC

, Posted by ADMIN at 10:11 AM

Light Tracker.

A simple light tracker using 2 light sensors. Light tracker is typical use for maximum energy receiving of solar panel or making light following robot. In this example, two LLS05-A light sensors is used. The sensor is given linear output from illuminance. Figure below shown the concept of how it work, it works by finding balance between the two sensors

The schematic.

The schematic is very simple. Output of the two sensers connect to PIC analog channel 0 and analog channel 1 as a figure shown below. The microcontroller performs ADC conversion for both channel and compare the value. If the value of both ADC are not the same or close enough, the microcontroller will activate a servo motor that is connected to PORTB.0 pin.

The code .

/*
 * Project name:
     Light Tracker sample
 * Copyright:
      Nicholas Sirirak
 * Description:

 * Test configuration:
     MCU:             PIC16F886
     Dev.Board:       -
     Oscillator:      HS, 16.0000 MHz
     Ext. Modules:    -
     SW:              mikroC PRO v3.2
 * NOTES:

*/
unsigned int ADC_value, ADC_value1;

void main () {
char i;
PORTB = 
0;
TRISB = 
0;
ANSELH = 
0;
ANSEL = 
3;                      //PORTA 0 and 1 are analog input
TRISA = 3;
while (1){
      ADC_value = 
0;
      ADC_value1 = 
0;
      
for(i = 0; i< 8; i++){
      ADC_value += ADC_Read(
0);   // Read analog value from channel 0
      ADC_value1 += ADC_Read(1);  // Read analog value from channel 1
      delay_ms(1);
      }
      ADC_value = ADC_value >> 
3;
      ADC_value1 = ADC_value1 >> 
3;
      
if( ADC_value > (ADC_value1 + 50)) {
         PORTB.F0 = 
1;
         delay_us(
1480);           //move one direction
         PORTB.F0 = 0;
         delay_ms(
20);
         }
      
else if (ADC_value1 > (ADC_value + 50)) {
               PORTB.F0 = 
1;
               delay_us(
1520);    //move another direction
               PORTB.F0 = 0;
               delay_ms(
20);
               }
}

}
//



--
With Regards,

s.m.sethupathy,
sms communication,
Tanjore -1.


mobile :9944 186 173           
      www.questionpaperlink.co.cc
      www.sethu-panguvarthagam.blogspot.com






Currently have 0 comments: