Designing A Variable Intensity Visible Light Monochromator Engineering Essay

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

This project is about designing a Variable Intensity Visible Light Monochromator which is an optical device that transmits a mechanically selectable narrow band of wavelengths of light or other radiation.

The main idea is to use a PIC microcontroller with multicolor LEDs to build the system which will consist of eight multicolor LEDs that can be used in two different modes,

1) All LEDs operate together in 100 Hz frequency.

2) All LEDs will operate in sequence with 100 Hz frequency.

Also the user will have the ability to change the intensity and the color of the LEDs using external potentiometers and there will be an LCD to display the options that the system has.

Also the user will have the ability to control the system using the computer by a simple graphical user interface program using the MatLab program and the RS232 as the communication protocol.

CHAPTER ONE: INTRODUCTION

Technologies using monochromatic light have a wide range of application, from astrophysics and astronomy to forensic science. The term monochromatic derives from the Greek words monos, meaning one or sole, and chromos, meaning color. Monochromatic light, or one-color light, is essentially electromagnetic radiation derived from photon emissions from atoms. Photons propagate, or travel, as energy wave fronts of different lengths and levels of energy. Energy levels determine the frequency of light, and the length of a wave determines its color. The bands of light wavelengths that humans can see are called visible light.

Nature of Electromagnetic Waves

Light is an electromagnetic wave. Electromagnetic waves (EM Waves) are produced by charged particles when they vibrate. As the charged particles execute SHM, a sinusoidal electric field and a sinusoidal magnetic field are simultaneously produced. These two fields are mutually perpendicular to each other and constitute an electromagnetic wave. An e.m wave is able to propagate through vacuum without the presence of any medium. The figure below shows an electromagnetic wave.

http://h2physics.org/wp-content/uploads/2009/07/emwave2.jpg

Figure : Electromagnetic Waves [1] 

EM waves exhibit the following properties:

They consist of two sinusoidal fields - the Electric-field and Magnetic-field, which are oscillating in phase and at right angles to each other.

They are transverse waves.

All electromagnetic waves can travel through vacuum (or free space).

In vacuum, they travel with the same speed c = 3.00 x 108 ms-1.

All EM waves exhibit properties such as reflection, refraction, interference, diffraction and polarization.

Although all electromagnetic waves travel through vacuum with exactly the same speed c, they have a wide range of frequencies (or wavelengths). Their properties vary distinctly with frequencies. Based on their frequencies or wavelengths, they are given different names. The following figure shows the full spectrum of electromagnetic waves. Radio waves have the longest wavelengths and gamma waves have the shortest wavelengths. Note that visible light is in the wavelength range 4.0 x 10-7 - 7.0 x 10-7 m or 400 nm - 700 nm (violet to red region).

Figure : Electromagnetic Spectrum [2] 

Nature of Electromagnetic Waves

Ultraviolet (UV) light has shorter wavelengths than visible light. Though these waves are invisible to the human eye, some insects, like bumblebees, can see them.

The near ultraviolet, abbreviated NUV is the light closest to optical or visible light. The extreme ultraviolet, abbreviated EUV, is the ultraviolet light closest to X-rays, and is the most energetic

of the three types. The far ultraviolet, abbreviated FUV, lies between the near and extreme ultraviolet regions. It is the least explored of the three regions.

Though some ultraviolet waves from the Sun penetrate Earth's atmosphere, most of them are blocked from entering by various gases like Ozone. Some days, more ultraviolet waves get through our atmosphere. Scientists have developed a UV index to help people protect themselves from these harmful ultraviolet waves.

Figure : Ultra Violet Region of the Electromagnetic Spectrum [3] 

Optical Phenomena

Common optical phenomena are often due to the interaction of light from the sun or moon with the atmosphere, clouds, water, or dust and other particulates. One common example would be the rainbow, when light from the sun is reflected and refracted by water droplets. Some, such as the green ray, are so rare they are sometimes thought to be mythical. Others, such as Fata Morganas, are commonplace in favored locations.

Optical phenomena include those arising from the optical properties of the atmosphere ; of the rest of nature (Other phenonema); of objects, whether natural or human-made (Optical effects); and of our eyes (Entoptic phenomena).

There are many phenomena which result from either the particle

 or the wave  nature of light. Some are quite subtle and observable only by precise measurement using scientific instruments. One famous observation was of the bending of light from a star by the Sun  during a solar eclipse. This demonstrated that space  is curved. Theory of relativity

Dispersion (optics)

In optics

, dispersion is the phenomenon in which the phase velocity of a wave depends on its frequency, or alternatively when the group velocity depends on the frequency.

Media having such a property are termed dispersive media. Dispersion is sometimes called chromatic dispersion to emphasize its wavelength-dependent nature, or group-velocity dispersion (GVD) to emphasize the role of the group velocity.

The most familiar example of dispersion is probably a rainbow , in which dispersion causes the spatial separation of a white light into components of different wavelengths (different color ColorColor or colour is the visual perceptual property corresponding in humans to the categories called red, yellow, blue and others. Color derives from the spectrum of light interacting in the eye with the spectral sensitivities of the light receptors...s). However, dispersion also has an effect in many other circumstances: for example, GVD causes pulses  to spread in optical fiber s, degrading signals over long distances; also, a cancellation between group-velocity dispersion and nonlinear effects leads to soliton waves. Dispersion is most often described for light waves, but it may occur for any kind of wave that interacts with a medium or passes through an inhomogeneous geometry (e.g. a waveguide ), such as sound waves.

dispersion_(optics).gif

Figure : Dispersion Phenomena [4] 

There are generally two sources of dispersion: material dispersion and waveguide dispersion. Material dispersion comes from a frequency-dependent response of a material to waves. For example, material dispersion leads to undesired chromatic aberration in a lens  or the separation of colors in a prism . Waveguide dispersion occurs when the speed of a wave in a waveguide (such as an optical fiber) depends on its frequency for geometric reasons, independent of any frequency dependence of the materials from which it is constructed. More generally, "waveguide" dispersion can occur for waves propagating through any inhomogeneous structure (e.g. a photonic crystal ), whether or not the waves are confined to some region. In general, both types of dispersion may be present, although they are not strictly additive. Their combination leads to signal degradation in optical fiber s for telecommunication s, because the varying delay in arrival time between different components of a signal "smears out" the signal in time.

Material Dispersion in Optics

Material dispersion can be a desirable or undesirable effect in optical applications. The dispersion of light by glass prisms is used to construct spectrometer and spectroradiometers. Holographic gratings are also used, as they allow more accurate discrimination of wavelengths. However, in lenses, dispersion causes chromatic aberration, an undesired effect that may degrade images in microscopes, telescopes and photographic objectives.

The phase velocity (v), of a wave in a given uniform medium is given by

where (c) is the speed of light  in a vacuum and n is the refractive index of the medium. In general, the refractive index is some function of the frequency f of the light, thus n = n(f), or alternately, with respect to the wave's wavelength n = n(λ). The wavelength dependence of a material's refractive index is usually quantified by an empirical formula, the Cauchy or Sellmeier equations.

Optics can be the subject of the impact of dispersion desirable or undesirable in the applications of light. It is used for the dispersion of light from glass building workshop spectrometer and spectrometers. Also it used holographic gratings, as it allows more accurate discrimination of the waves. However, in lenses, dispersion causes chromatic aberration, an effect is undesirable that may degrade images in microscopes and telescopes and objectives of photography.

The phase speed (v), wave in the middle of a particular standardized by

where (c) is the speed of light in a vacuum and (n) is the refractive index of the average. In general, the refractive index is some function of the number and frequency of light, and thus n = n (f), or alternately, with respect to n a wave of wavelength n = (λ). Quantitative index is usually rely on the wavelength of the material and refraction of the trial version, or equations Kochi

Because of the Kramers-Kronig relations, the wavelength dependence of the real part of the refractive index is related to the material absorption, described by the imaginary part of the refractive index (also called the extinction coefficient). In particular, for non-magnetic materials (μ = μ0), the susceptibility   that appears in the Kramers-Kronig relations is the electric susceptibility. The most commonly seen consequence of dispersion in optics is the separation of white light into a color spectrum by a prism. From Snell's law Snell's law it can be seen that the angle of refraction  of light in a prism depends on the refractive index of the prism material. Since that refractive index varies with wavelength, it follows that the angle that the light is refracted by will also vary with wavelength, causing an angular separation of the colors known as angular dispersion.

spidergraph_dispersion.gif

Figure : Glass Component Mean Dispersion [5] 

For visible light, most transparent materials (e.g. glasses) have: or alternatively: that is, refractive index n decreases with increasing wavelength λ. In this case, the medium is said to have normal dispersion. Whereas if the index increases with increasing wavelength the medium has anomalous dispersion. At the interface of such a material with air or vacuum (index of ~1), Snell's law predicts that light incident at an angle θ to the normal  will be refracted at an angle arcsin(sin(θ)/n). Thus, blue light, with a higher refractive index, will be bent more strongly than red light, resulting in the well-known rainbow pattern.

Optical Spectrometer

The optical spectrometer is a precision instrument capable of an accuracy of measurement far greater than that found in most other areas of physical measurement. The function of the spectrometer is to disperse light into its various component wavelengths (or frequencies) and to determine the wavelength (or frequency) of each resolved component. The dispersive element is usually a diffraction grating but it could also be a glass prism.

Collimator, 2- Prism table, 3- Telescope

spectrometer.gif

Figure : Optical Spectrometer [6] 

The collimator renders a parallel beam of light through the two coaxial cylindrical tubes. One end of the collimator has a slit through which light enters the tube and falls on lens L situated at the other end. Prism table is a circular plate fixed over a vertical stand of adjustable height. The free end of stand consists of a circular scale graduated in degrees from 0o to 360o along with verniers to enable to read the position of the prism. Telescope is meant for observing the spectrum and is mounted horizontally on a vertical stand attached to the circular scale. The telescope can be rotated about the prism table.

The telescope is turned towards a distant object and is focused to see a clear image of object. It is then brought in line with the collimator. A clear image of the slit is obtained by adjusting the screws in the collimator. The prism is kept over the prism table.

Prism

A prism is a portion of a transparent medium bounded by two plane faces inclined to each other at a suitable angle.

pism-refraction.gifrefractive-index-prism-angle-deviation-angle-relation.gif

Figure : Angle of Prism [7] 

Angle A between the two refracting surfaces ABQP and APRC is called the angle of prism. A ray of light suffers two refractions on passing through a prism.If KL be a monochromatic light falling on the side AB, it gets refracted and travels along LM. It once again suffers refraction at M and emerges out along MN. The angle through which the emergent ray deviates from the direction of incident ray is called angle of deviation'd'

The prism is placed over the table such that parallel rays from collimator falls on the sides AB and AC. Move the telescope in the position T1 to catch the brightest image of the slit formed by reflection of light at faces AB and AC. The cross wire is made to coincide with image and reading on the circular scale is noted. The telescope is turned to position T2 and the same procedure is repeated. If q is the difference between the two readings through which the telescope is turned then

http://content.tutorvista.com/physics_12/content/us/class12physics/chapter09/images/img225.gif

telescope.gif

Figure : Collimator [8] 

Fluor meter

An instrument used to measure the intensity and the wavelength distribution of the light emitted as fluorescence from a molecule excited at a specific wavelength or wavelengths within the absorption band of a particular compound. Characteristic fluorescence bands may be used to identify specific pollutants such as the poly nuclear aromatic hydrocarbons. Excitation spectra of impurities can be observed by scanning the wavelength of the excitation light which is incident on the sample over a range of wavelengths and observing the relative intensity of the fluorescence emitted at a given wavelength. These spectra are also characteristic of the impurity.

Czerny-Turner Configuration

The Czerny-Turner (CZ) monochromator consists of two concave mirrors and one plano diffraction grating (see Figure 9). Although the two mirrors function in the same separate capacities as the single spherical mirror of the Fastie-Ebert configuration, i.e., first collimating the light source (mirror 1), and second, focusing the dispersed light from the grating (mirror 2), the geometry of the mirrors in the Czerny-Turner configuration is flexible. By using an asymmetrical geometry, a Czerny-Turner configuration may be designed to produce a flattened spectral field and good coma correction at one wavelength. Spherical aberration and astigmatism will remain at all wavelengths. It is also possible to design a system that may accommodate very large optics.

Figure : Czerny-Turner Configuration [9] 

Monochromators

Monochromators are optical subassemblies used to isolate narrow portions of a light spectrum. They accept polychromatic input from a lamp or laser, and outputs monochromatic light. With monochromators, polychromatic light enters via a fixed port, such as a slit or optical fiber. Inside the monochromator, a dispersive element, grating, crystal prism, or mirror diffracts the light into its spectrum. If the monochromator can be rotated, the dispersive element is manual or motor-driven. The angle at which the element is rotated determines the wavelength of the output monochromatic light output, as well as the specific color of the light. 

When selecting monochromators for an application, it is important to consider certain parameters and how they will affect the desired output. These parameters include bandpass, dispersion, resolution, acceptance angle, and blaze wavelength. Bandpass is the wavelength range in which the monochromator transmits. Dispersion, resolution, acceptance angle, and blaze wavelength are important parameters to consider when choosing monochromators. Dispersion in monochromators is the wavelength dispersing power, which is usually expressed as spectral range or slit width (nm/mm). Dispersion depends on the focal length, grating resolving power, and the grating order. Resolution is the minimum bandpass of the spectrometer, which is usually determined by aberrations in the optical system. With monochromators, the acceptance angle (f/#) is a measurement of the light-collecting ability and focal length / mirror diameter. Blaze wavelength is the wavelength of maximum intensity in the first order of monochromators.

Additional features to consider when choosing monochromators are nitrogen-purging abilities, vacuum capabilities, and fiber optic ready connection. Monochromators with a nitrogen purge feature have a port for nitrogen purging. Nitrogen purging is important because it allows monochromators to operate more deeply into ultraviolet (UV) light. Similarly, monochromators that operate with internal vacuum conditions are also able to extend their wavelength further into the ultraviolet range. Monochromators that have a fiber optic ready connection can be coupled with waveguides for the easier delivery of light output and data retrieval.

A range of accessories are available for use with monochromators, including cooled photo multiplier detectors, silicon detectors, light guides, arc lamp sources, and integrating sphere. Motorized drive monochromators are also available which can include electronic drivers to interface with software for automation.

Monochromator System Optics

To understand how a complete monochromator system is characterized, it is necessary to start at the transfer optics that brings light from the source to illuminate the entrance slit (see Figure 10). Here we have "unrolled" the system and drawn it in a linear fashion.

Figure : Monochromator Optics

Aperture Ratio (f/value, f/Number), and Numerical Aperture (NA)

The light gathering power of an optic is rigorously characterized by Numerical Aperture (NA). Numerical Aperture is expressed by:

Where μ is the refractive index (μ = 1 in air) and f/value by:

Table : Relationship between f/value, half-angle, and numerical aperture

f/value

f/2

f/3

f/5

f/7

f/10

f/15

n (degrees)

14.48

9.6

5.7

4.0

2.9

1.9

NA

0.25

0.16

0.10

0.07

0.05

0.03

Aperture Ratio (f/value, f/Number), and Numerical Aperture (NA)

In any spectrometer system a light source should be imaged onto an entrance slit (aperture) which is then imaged onto the exit slit and so on to the detector, sample, etc. This process inevitably results in the magnification or demagnification of one or more of the images of the light source. Magnification may be determined by the following expansions, taking as an example the source imaged by lens L1 in Figure 10 onto the entrance slit:

Similarly, flux density is determined by the area that the photons in an image occupy, so changes in magnification are important if a flux density sensitive detector or sample are present. Changes in the flux density in an image may be characterized by the ratio of the area of the object, S, to the area of the image, S', from which the following expressions may be derived:

These relationships show that the area occupied by an image is determined by the ratio of the square of the f/values. Consequently, it is the EXIT f/value that determines the flux density in the image of an object. Those using photographic film as a detector will recognize these relationships in determining the exposure time necessary to obtain a certain signal-to-noise ratio

Slit Height Magnification

Slit height magnification is directly proportional to the ratio of the entrance and exit arm lengths and remains constant with wavelength (exclusive of the effects of aberrations that may be present).

Note: Geometric magnification is not an aberration!

CHAPTER TO: ELECTRONIC PARTS

This chapter contains the main electronic parts that will be used in design of monochromator and the features of each one, the design procedures are illustrated in details in chapter three.

PIC microcontroller:

This powerful (200 nanosecond instruction execution), (only 35 single word instructions) CMOS FLASH-based 8-bit microcontroller packs Microchip's powerful PIC architecture into a 40-pin package.

The PIC16F877A features 256 bytes of EEPROM data memory, self-programming, an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, the synchronous serial port can be configured as either 3-wire Serial Peripheral Interface (SPI™) or the 2-wire Inter-Integrated Circuit (I²C™) bus and a Universal Asynchronous Receiver Transmitter (USART). All of these features make it ideal for more advanced level A/D applications in automotive, industrial, appliances and consumer applications.

PIC16F877A features:

PWM 10-bit

256 Bytes EEPROM data memory

ICD

25mA sink/source per I/O

Self Programming

Parallel Slave Port

I have used the PIC 16F877A microcontroller from microchip because it has all the modules that I wanted in my project.

Table : Microcontroller PIC16F877A features

Parameter name

Value

Program Memory Type

 Flash 

Program Memory

(KB) 14 

CPU Speed (MIPS) 

5 

RAM Bytes 

368 

Data EEPROM (bytes) 

256 

Digital Communication Peripherals 

1-A/E/USART, 1-MSSP(SPI/I2C) 

Capture/Compare/PWM Peripherals 

2 CCP 

Timers 

2 x 8-bit, 1 x 16-bit 

ADC 

8 ch, 10-bit 

Comparators 

2 

Temperature Range (C) 

-40 to 125 

Operating Voltage Range (V) 

2 to 5.5 

Pin Count

40

Figure : Monochromator Optics [10] 

LCD

I have used the HD44780 controller based LCDs as the LCD which I used to display the name of the project and to help the user to select the options that the device offer.

Figure : HD44780 controller based LCDs

Table : LCD Command Control Codes

Table : Standard LCD Characteristics Table

Multicolor LED:

The multicolor LED is a LED that contains three LEDs with RGB colors and with these LEDs you can have all the colors you need by Applying different voltages on these LEDs.

The Features:

256 color capability with red, green and blue chips

High intensity

Water clear lense

Reliable, rugged, long life

Low power requirement

VF (forward voltage): Red = 2V, Green = 3.5V, Blue = 3.5V

Luminous Intensity: 800 to 4000 mcd at 20mA

Figure : Multicolor Led [11] 

7805 Regulator:

The regulator is a devise that is used to keep the voltage at certain level (in this case 5 V) so that the other devices may operate in the best way they can.

Figure : 7805 Regulators [12] 

The Features:

Complete specifications at 1A load

Output voltage tolerances of ±2% at Tj= 25°C and ±4% over the temperature range (LM340A)

Line regulation of 0.01% of VOUT/V of ΔVIN at 1A load (LM340A)

Load regulation of 0.3% of VOUT/A (LM340A)

Internal thermal overload protection

Internal short-circuit current limit

Output transistor safe area protection

P+ Product Enhancement tested

2N1711 Transistor

The 2N1711 BJT transistor is used as a switch to handle the high currents that the multicolor LED require and which the PIC can't supply.

Figure : 7805 Regulators

The Features:

Emitter

Bases

Collector, connected to case

74HC08 AND Gate:

The 74HC/HCT08 are high-speed Si-gate CMOS devices and are pin compatible with low power Schottky TTL (LSTTL). They are specified in compliance with JEDEC standard no. 7A. The 74HC/HCT08 provide the 2-input AND function.

C:\Users\AL-OMARI\Desktop\STUDY\WORK\Osama\Texas-Instruments-SN74HC08N.jpeg

Figure : 74HC08 AND Gate [13] 

The Features:

Complies with JEDEC standard no. 8-1A

ESD protection:

HBM EIA/JESD22-A114-A exceeds 2000 V

MM EIA/JESD22-A115-A exceeds 200 V.

Specified from -40 to +85 °C and -40 to +125 °C.

Potentiometer:

Potentiometer is a variable resistor device that I used to change the voltage on the multicolor LED so I can have different color

Figure : Potentiometer [14] 

IC MAX 232

The MAX232 is an IC that is used to communicate through the RS232 protocol between PC and PIC microcontroller.

Figure : IC MAX232 [15] 

CHAPTER THREE: PROPLEM ANALYSIS

The aim of the project is to develop a monochromator for use within an optical process tomography system. The monochromator will be an electronic device that will be use super bright multicolor visible light LED's to produce differing single wave length of visible light on its output that will be fed into a light array and subsequently fired through transparent sections of pipeline. The single wavelength visible light that is produced must be able to be applied constantly or in a pulsed fashion and the intensity of the light is user adjustable. Also the instrument is stand alone and can be computer controlled.

The design are built with a visible light emission unit, pulsation mechanism, electronic switching, electronic switching mechanisms, electronic circuit to control light intensity, and both electromechanical and computer controlled user interface

PIC and LCD Programming

The PIC and LCD were programmed using C++ code then using CCS Compiler because it is a professional program and it gives the user a lot of possibilities, capabilities and libraries to use.

LCD Code

int i1;

lcd_cmd(x)

{

if (BIT_TEST(x,7)==1)

output_bit(PIN_C3,1);

else

output_bit(PIN_C3,0);

if (BIT_TEST(x,6)==1)

output_bit(PIN_C2,1);

else

output_bit(PIN_C2,0);

if (BIT_TEST(x,5)==1)

output_bit(PIN_C1,1);

else

output_bit(PIN_C1,0);

if (BIT_TEST(x,4)==1)

output_bit(PIN_C0,1);

else

output_bit(PIN_C0,0);

output_bit(PIN_C5 , 0);

output_bit(PIN_C4 , 1);

delay_ms(10);

output_bit(PIN_C4 , 0);

}

lcd_cmd_4bit(x)

{

if (BIT_TEST(x,7)==1)

output_bit(PIN_C3,1);

else

output_bit(PIN_C3,0);

if (BIT_TEST(x,6)==1)

output_bit(PIN_C2,1);

else

output_bit(PIN_C2,0);

if (BIT_TEST(x,5)==1)

output_bit(PIN_C1,1);

else

output_bit(PIN_C1,0);

if (BIT_TEST(x,4)==1)

output_bit(PIN_C0,1);

else

output_bit(PIN_C0,0);

output_bit(PIN_C5 , 0);

output_bit(PIN_C4 , 1);

delay_ms(10);

output_bit(PIN_C4 , 0);

if (BIT_TEST(x,3)==1)

output_bit(PIN_C3,1);

else

output_bit(PIN_C3,0);

if (BIT_TEST(x,6)==1)

output_bit(PIN_C2,1);

else

output_bit(PIN_C2,0);

if (BIT_TEST(x,5)==1)

output_bit(PIN_C1,1);

else

output_bit(PIN_C1,0);

if (BIT_TEST(x,4)==1)

output_bit(PIN_C0,1);

else

output_bit(PIN_C0,0);

output_bit(PIN_C5 , 0);

output_bit(PIN_C4 , 1);

delay_ms(10);

output_bit(PIN_C4 , 0);

}

lcd_char_4bit(x)

{

if (BIT_TEST(x,7)==1)

output_bit(PIN_C3,1);

else

output_bit(PIN_C3,0);

if (BIT_TEST(x,6)==1)

output_bit(PIN_C2,1);

else

output_bit(PIN_C2,0);

if (BIT_TEST(x,5)==1)

output_bit(PIN_C1,1);

else

output_bit(PIN_C1,0);

if (BIT_TEST(x,4)==1)

output_bit(PIN_C0,1);

else

output_bit(PIN_C0,0);

output_bit(PIN_C5 , 1);

output_bit(PIN_C4 , 1);

delay_ms(10);

output_bit(PIN_C4 , 0);

if (BIT_TEST(x,3)==1)

output_bit(PIN_C3,1);

else

output_bit(PIN_C3,0);

if (BIT_TEST(x,6)==1)

output_bit(PIN_C2,1);

else

output_bit(PIN_C2,0);

if (BIT_TEST(x,5)==1)

output_bit(PIN_C1,1);

else

output_bit(PIN_C1,0);

if (BIT_TEST(x,4)==1)

output_bit(PIN_C0,1);

else

output_bit(PIN_C0,0);

output_bit(PIN_C5 , 1);

output_bit(PIN_C4 , 1);

delay_ms(10);

output_bit(PIN_C4 , 0);

}

lcd_clear_4bit()

{

lcd_cmd_4bit(0x01);

}

lcd_next_line_4bit()

{

lcd_cmd_4bit(0xc0);

}

lcd_init_4bit()

{

lcd_cmd(0x28);

lcd_cmd_4bit(0x0e);

lcd_cmd_4bit(0x02);

lcd_cmd_4bit(0x01);

lcd_cmd_4bit(0x0c);

}

LCD Library

char x1[7]={'W','e','l','c','o','m','e'};

char x2[12]={'S','e','l','e','c','t',' ','M','o','d','e',':'};

char x3[4]={'1',')','P','C'};

char x4[13]={'2',')','S','t','a','n','d',' ','A','l','o','n','e'};

char x5[9]={'S','.','A','.',' ','M','o','d','e'};

char x6[7]={'P','C',' ','M','o','d','e'};

char x7[8]={'D','o','n','e',' ','B','y',':'};

char x8[14]={'L','a','t','e','f','a','h',' ','K','h','.',' ','B','.'};

char x9[9]={'0','0','0','5','2','0','0','5','3'};

char x10[14]={'S','u','p','e','r','v','i','s','e','d',' ','B','y',':'};

char x11[16]={'D','r','.',' ','R','.',' ','P','.',' ','J','e','n','n','e','r'};

int i=0;

LCD_Welcome()

{

lcd_clear_4bit();

for (i=0;i<7;i++)

lcd_char_4bit(x1[i]);

delay_ms(1000);

}

LCD_Select_mode()

{

lcd_clear_4bit();

for (i=0;i<12;i++)

lcd_char_4bit(x2[i]);

delay_ms(1000);

}

LCD_Op1()

{

lcd_clear_4bit();

for (i=0;i<4;i++)

lcd_char_4bit(x3[i]);

lcd_next_line_4bit();

for (i=0;i<13;i++)

lcd_char_4bit(x4[i]);

delay_ms(1000);

}

LCD_SA()

{

lcd_clear_4bit();

for (i=0;i<9;i++)

lcd_char_4bit(x5[i]);

}

LCD_PC()

{

lcd_clear_4bit();

for (i=0;i<7;i++)

lcd_char_4bit(x6[i]);

}

LCD_Done_By()

{

lcd_clear_4bit();

for (i=0;i<8;i++)

lcd_char_4bit(x7[i]);

delay_ms(1000);

}

LCD_Name1()

{

lcd_clear_4bit();

for (i=0;i<14;i++)

lcd_char_4bit(x8[i]);

lcd_next_line_4bit();

for (i=0;i<9;i++)

lcd_char_4bit(x9[i]);

delay_ms(2000);

}

LCD_Super_By()

{

lcd_clear_4bit();

for (i=0;i<14;i++)

lcd_char_4bit(x10[i]);

lcd_next_line_4bit();

for (i=0;i<16;i++)

lcd_char_4bit(x11[i]);

delay_ms(2000);

}

PIC Code

#include<16f877a.h>

#use delay(clock = 8000000)

#include<LCD_function_the_last.c>

#include<LCD_library.c>

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

int1 mode = 1; // for seq or all

int1 mode1 = 1; // for SA and PC

int mode11 = 0; // for SA and PC

int marker = 1; // for seq mode to know where i am

int counter = 0; // for counting the number of pulses for seq

void main()

{

output_bit(PIN_A0,1);

lcd_init_4bit(); // inital for LCD

LCD_Welcome(); // first msg ('Welcome')

LCD_Done_By(); // first msg ('Welcome')

LCD_Name1(); // first msg ('Welcome')

LCD_Super_By(); // first msg ('Welcome')

LCD_Select_mode(); // second msg ('Select Mode:')

LCD_Op1(); // third msg ('1)PC' , '2)Stand Alone')

port_b_pullups(true); // to activate pullup resistor on port B

while (true)

{

mode1 = input(PIN_B6);

if(mode1 == 1)

{

if (mode11 != 2)

{

LCD_SA();

mode11 = 2;

}

mode = input(PIN_B7);

if(mode == 1)

{

output_d(0xff);

delay_ms(5);

output_d(0x00);

delay_ms(5);

counter = 0;

marker = 1;

}

else

{

output_d(marker);

delay_ms(5);

output_d(0x00);

delay_ms(5);

counter++;

if (counter == 1000)

{

counter = 0;

rotate_left(&marker,1);

}

}

}

else

{

if (mode11 != 1)

{

LCD_PC();

mode11 = 1;

}

mode = getc();

if(mode == 1)

{

output_d(0xff);

delay_ms(5);

output_d(0x00);

delay_ms(5);

counter = 0;

marker = 1;

}

else

{

output_d(marker);

delay_ms(5);

output_d(0x00);

delay_ms(5);

counter++;

if (counter == 1000)

{

counter = 0;

rotate_left(&marker,1);

}

}

}

}

}

The Simulation

I have used the Proteus 7.4 portable program to simulate the electronic circuit, and below figure is the simulation result.

Figure : Built up Circuit by PROTOUS Software

MATLAB Code (Interface code)

function mono

function mono

SerialInit(1,1000); % the COM port number should exist on the pc that the code will run on it.

f1 = figure)'units','normalized',... % this function creats a figure.

'position',[.3 .3 .4 .4],...

'name','Monochromator',...

'menubar','none',...

'numbertitle','off',...

'color',[.3 .6 1]);

pic1 = imread('2.jpg'); % this function reads an a image and display it on the pushbutton

y = double(pic1);

pic1 = y/255;

p1 = uicontrol('units','normalized',... % this function creats a pushbutton on the figure

'position',[.05 .15 .405 .49],...

'style','pushbutton',...

'cdata',pic1,...

'callback',@All);

pic1 = imread('1.jpg'); % this function reads an a image and display it on the pushbutton

y = double(pic1);

pic1 = y/255;

p1 = uicontrol('units','normalized',... % this function creats a pushbutton on the figure

'position',[.55 .15 .405 .49],...

'style','pushbutton',...

'cdata',pic1,...

'callback',@seq);

t1 = uicontrol('units','normalized',... % this function creats a text box on the figure

'position',[.05 .86 .65 .1],...

'style','text',...

'fontsize',14,...

'string','Please Select The Mode of Operation ..',...

'backgroundcolor',[.3 .6 1]);

t2 = uicontrol('units','normalized',...% this function creats a text box on the figure

'position',[.05 .67 .4 .08],...

'style','text',...

'fontsize',14,...

'string','All at Once',...

'backgroundcolor',[.3 .6 1]);

t3 = uicontrol('units','normalized',...% this function creats a text box on the figure

'position',[.6 .67 .3 .08],...

'style','text',...

'fontsize',14,...

'string','Sequence',...

'backgroundcolor',[.3 .6 1]);

while (true)

SerialCMD(Val) ; % this function send a command to the PIC microcontroller

pause(.01);

end

function All(varargin)

SerialCMD(1);

end

function seq(varargin)

SerialCMD(00);

end

end

MATLAB Code (Serial code)

% COMPort: COM port number

% baudRate: baud rate

% inputBufferSize: size of serial input buffer

function SerialInit(COMPort,inputBufferSize)

global SerialPort

SerialPort=serial(['COM' num2str(COMPort)],'baudrate',9600,'InputBufferSize',inputBufferSize);

fopen(SerialPort);

end

function SerialCMD(CMD)

global SerialPort

CMD = uint8(CMD);

fwrite(SerialPort,CMD);

pause(.1);

end

function SerialClose

global SerialPort

fclose(SerialPort)

end

List of Parts

Table : List of Electronic Parts Used

Item No.

Component

Quantities

Description

1

Multicolor LED

8

LB-151 GBR

2

Battery

1

9 volt

3

Resistor

32

For standard application

4

BJT

8

2N7000

5

Potentiometer

3

1 KΩ

6

QUARTZ CRYSTAL

1

8MHz

7

MICRO CONTROLLER

1

PIC 16F887A

8

CAPASITOR

2

20 pf

9

SWITCH

3

ON-OFF Switches

10

Serial adapter

1

RS232 adpter

11

Serial cable

1

Male - female

12

LED

1

Starting LED

13

Voltage Regulator

1

From 9 to 5 V

14

Pins

4

To connect the jumpers on them

15

LCD

1

16X2 character

16

PCB Board

1

10X10 cm

CHAPTER FOUR: DESGIN IMPLEMENTATION

The implementation of the designed circuit and electronics parts will be present in this chapter; also it contains the pictures of each step of actual work.

Circuit built up.

I used a PCB circuit to make the Monochromator device so that it can be more reliable and functional to the user to use it in a real-time application without being afraid of losing the connection between any two parts on the device.

Also I used a 40pin socket so I can protect the PIC from the heat of soldering and to make it possible for the user to reprogram the PIC if required to modify anything on the Code.

Also I used a voltage regulator that converts 9dc V to 5dc V so that I can use the device on battery which will allow the standalone mode to be used.

Procedures for building the circuit:

Figure : PCB Circuit

I started building the circuit by connecting the 40 pin DIP to PCB with the 8 Mhz Oscillator, Voltage regulator from 9V dc to 5V dc and then the resistors to PORT C and PORT D which will protect the PIC microcontroller from any high current (figure 19).

The Switching Circuit:

Second I connected the transistors which will drive the multicolor LEDs as the microcontroller cannot provide enough current to drive them by itself.

C:\Users\AL-OMARI\Documents\Bluetooth Exchange Folder\DSC00337.JPG

Figure : Switching Circuit

I used the bc547 transistor to make the switching of the multicolor LED so it can operate on the 100 Hz frequency and because the multicolor LED draw a high current which the PIC can't handle.

LCD

Third I connected the LCD to the microcontroller and tested it and I managed to write an S.A.Mode on it.

C:\Users\AL-OMARI\Documents\Bluetooth Exchange Folder\DSC00338.JPG

Figure : Connecting LCD

C:\Users\AL-OMARI\Documents\Bluetooth Exchange Folder\DSC00339.JPG

Figure : LCD Testing

I used a 16X2 LCD to make it easier for the user to use the monochromator in both modes the stand alone and the PC. Also it will display the current mode of operation. I used Libraries that I wrote by myself so that the code can be more professional.

Pins of LED

Fourth I connected the Pins where the LEDs are going to be connected and I connect each row of these PINs on parallel so that the LEDs may have the same voltages and work on an appropriate way.

C:\Users\AL-OMARI\Documents\Bluetooth Exchange Folder\DSC00341.JPG

Figure : Pin Implementing

Transistor

Here is a picture for the transistor after I connected the PINS to them.

C:\Users\AL-OMARI\Documents\Bluetooth Exchange Folder\DSC00342.JPG

Figure : Transistors

Potentiometer

Fifth I connected the potentiometer to a connecting leads then I connected them to the circuit

.C:\Users\AL-OMARI\Documents\Bluetooth Exchange Folder\DSC00343.JPG

Figure : Potentiometer

MAX232

I used the MAX232 IC to make it possible for the Pic to communicate to the PC serially in the PC mode and it is used because the PC serial communication port operate in +-15 V and the PIC operate on 0-5 V so it's used to convert the voltage to an appropriate level so that the PIC may use it.

Assembly

Sixth I assembled the potentiometer and the pushbutton to the case.

Figure : Potentiometer and Pushbutton Assembling

Installing

Eighth I installed the board in the case

Figure :

CHAPTER FIVE: RESULTS AND CONCLUSIONS

The Modes of Operation

In this project we have to modes of operation, the first one is the stand alone mode and the second one is the computer control mode.

Stand Alone mode:

The stand alone mode is the mode where the device can be used by itself and it will allow the user to take the device to places where the PC can't be moved to some hard places and it have two different modes the first one is to make the LEDs turn on one by one and the other mode is to make them all turn on at the same time.

PC mode:

The PC mode is the mode where you can control the device using a computer program (Matlab) with a simple interface to make it easier to the user to control the device.

osama2.jpg

Figure : PC Mode Interface

Final Design Result

Figure : Final Design Result

Some Problems

I have faced many problems during the building process of the circuit and here are a summary of them:

The PIC didn't work:

The Problem: was that when I connect the Vcc the ground and the oscillator to the PIC it didn't work at all

The Solution: I forgot to connect the master clear PIN to Vcc so it was floating and the PIC remain in the Reset mode.

The LED didn't work:

The Problem: When I connect the LED to a transistor it didn't work.

The Solution: I made a mistake of switching the connection between the collector and the emitter.

The LCD didn't work appropriately:

The Problem: The LCD displays a wrong Letter on the screen.

The Solution: There was losing in connection in one of the data cables of the LCD so it remains zero which caused a wrong data to be transmitted to the LCD.

The continuous lose in the connecting Cables:

The Problem: The cables were got disconnected all the time.

The Solution: I used a PCB (Printed Circuit Board) which has a permanent connection that didn't get lose when you move them.

The number of PINs where not enough:

The Problem: I didn't have one complete port to use it for the data bur of the LCD.

The Solution: I used the LCD in the 4 - bit mode which reduced the number of PINs needed by the data bus of the LCD to 4 instead of 8 PINs.

Recommendations

Change the PCB into a printed PCB which will reduce the number of wires and make it possible to start the production of this device.

Shortening the LEDs wires because they sometimes affect the performance of the microcontroller which leads to restart the microcontroller.

We can change the serial communication to USB so that it might be faster.

This project has a wide range of applications and it has been done in an excellent way so it could be presented to some companies that are interested of it.

Writing Services

Essay Writing
Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing
Service

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision
Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.