Visible light beam profile generator

Introduction

Visible light is varying in between 300 nm – 400 nm wave length range. For each source the beam profile of light appears differently. Here the light source is a LED . To generate the beam profile of the LED i used the PIC 16F877A micro controller with its special functions.  The device detects the visible light beam and inputs the analogue signal to the micro controller. Then the micro controller convert the appropriate analogue signal to a digital signal. That digital value can be interfaced to a display unit. Thereby one can view the variation of the beam intensity through different angles and in different distances and construct the profile of the beam.

Methodology

To catch the beam of the source a photo transistor (BPX43-5) which is working in the visible range was used. To amplify the output voltage of the photo transistor LM324 IC was used.
In order to detect the spatial dispersion of the light beam a suitable mechanism was needed. The source was determined to be rotated and shifted forward and backward when the detector is in fixed situation.
The analogue signal which was created by the phototransistor circuit was fed to the microcontroller through port A.The ADC (Analogue to Digital Conversion) function was applied here. The light beam was detected through different angles and different distances by the detector cicuit.
To that circulating and sliding system was created with two dc motors and L293D motor driver.That mechanism was mainly controlled by the PWM (Pulse Width Modulation) mode of the micro controller.
After rotating and sliding the source to a known angle and to a known distance the PWM mode should be stopped and start ADC part. Interrupt was given to break the PWM mode and continue ADC.

High level Design

Results and analysis

 

YouTube Video

YouTube Video

YouTube Video

YouTube Video

YouTube Video

YouTube Video

YouTube Video

 

The final target of this project was to display the variation of the intensity of the light beam in computer display through mathematical software. When the time period was over, the variation was able to display on a SSD. In order to generate the beam profile of the LED the detecting system may not be the most suitable method, but it still can give an accurate result. The main objective of detecting the light source was successfully obtained.
Adjusting a proper duty cycle on PWM mode was little hard for controlling the motor speed in slow rate. Combining the PWM and ADC functions with an interrupt was failed.

Discussion and conclusion

The designed of hardware parts were in working level, coding of PWM and ADC were successfully built and worked out accurately. But combining them and run them in one pic was failed due to weak coding of interrupt function. Interfacing the value to mathematical software was not being able to achieve.

Further Developments

Develop the detecting system and interfacing the intensity of the light beam to mathematical software are further developments.  Combining the PWM and ADC functions with an interrupt also a further development.

Improving of the whole project may create an effective invention for detecting light source and finding its’ beam profile.

Code listing

 PWM code

#include <pic.h>
#include <htc.h>

#define _XTAL_FREQ 4000000
__CONFIG(1,XT & WDTDIS & LVPDIS );
unsigned char i;
void main(){
TRISC=0;
               RC2=0;
CCPR1L=0×01;
CCP1CON=0x1F;
T2CON=0x0D;
PR2=0×01;
while(1){
}
}

ADC code

#include <pic.h>
#define _XTAL_FREQ 4000000
__CONFIG (1, XT & WDTDIS & LVPDIS);
unsigned int temp1;
unsigned int temp3;
void adc(){
temp1=0;
temp3=0;
ADCON0=0b00000001;
ADCON1=0b10001110;
GO=1;
while(GO){
}
temp1=(ADRESH<<8);
temp3=(ADRESL+temp1);
}
unsigned char SSD[]={0x3f, 0×06, 0x5b, 0x4f, 0×66, 0x6d, 0x7d, 0×07, 0x7f, 0x6f};
unsigned char dig[4];
void seperateSSD(unsigned int num){
    unsigned int temp=0;
unsigned char temp2=0;
dig[3]=(num/1000); // thousand’s digit
temp=(num%1000);
dig[2]=(temp/100);    // hundred’s digit
temp2=(temp%100); // 10′s digit
dig[1]=(temp2/10);
dig[0]=(temp2%10); // 1′s digit
}
unsigned int val;
unsigned int b;
void main(){
TRISA=1;
TRISB=0;
TRISD=0;
PORTD=0;
PORTB=0;
adc();
val=temp3;
seperateSSD(val);
while(1){
for(b=0;b!=4;b++){
PORTB=1<<b;
PORTD=SSD[dig[b]];
__delay_ms(5);
}
}
}