Thursday, March 28, 2024

Laser Demo in ‘C’

Here is a program to compute fast Fourier transform (FFT) output using C++. -- Manuj Arora

Software program

Fig. 4: Screenshot of program output showing amplification of photons
Fig. 4: Screenshot of program output showing amplification of photons

The above laser concepts have been taken into consideration while developing this program. The program is written in ‘C’ language and compiled using Turbo C integrated development environment. Turbo C has a good collection of graphics libraries. This program uses various ‘C’ graphics files including egavga.bgi, scri.chr, trip.chr and tscr.chr. All these files should be stored in the same folder as the executable file.

The different program outputs depict working of a laser as below:

Fig. 5: Program output showing release of photons
Fig. 5: Program output showing release of photons

Amplification of photons. The first program output screen demonstrates generation of multiple photons inside the laser due to amplification from a single photon (see Fig. 4).

Release of photons. The second screen demonstrates the stimulation process of an atom where a photon stimulates the atom to release more photons (refer Fig. 5). The arrows have been added in the actual screenshot to show the flow taking place.

- Advertisement -
Fig. 6: Program output showing the internal working of a laser
Fig. 6: Program output showing the internal working of a laser

Inside the laser. The third screen (Fig. 6) demonstrates the complete process that takes place inside the laser. Proper flow is presented in which photons energise by the application of power supply, amplify with stimulation of the atoms and exit the laser through the semi-silvered mirror. The symbols of the photon and the atom are displayed on the top left.

End of demo. The final screen prompts the user to press any key to exit the program.

Main functions used
Initgraph(&gd,&gm,”c:\\turboc3\\bgi”). Initialises the graphics system by loading a graphics driver from the disk and then putting the system into graphics mode. It also resets all the graphics settings (like colour, palette and current position) to their default values.

- Advertisement -

*gd. Specifies the graphics driver to be used.

*gm. Specifies the initial graphics mode, unless *gd = DETECT. When *gd = DETECT, initgraph sets the graphics mode to the highest resolution available for the detected driver.

Closegraph( ). Switches the screen back from graphics mode to text mode. It is called after getch( ) function so that the screen doesn’t clear until the user hits the key.

Void projectwork1( ). Demonstrates amplification of photons.

Void projectwork2( ). Demonstrates stimulation of an atom to release photons.

Void projectwork3( ). Demonstrates how laser works.

Void closing. Provides an exit screen to exit the program.

Download source code: click here


The author is a software developer in Amdocs Development Centre India Pvt Ltd, Pune

SHARE YOUR THOUGHTS & COMMENTS

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components

Calculators