Thursday, April 07, 2011



PC Interfacing - Introducing Variables, Memory concept and Arithmetic



Variables

Variables are identifiers whose value may change during the course of execution of a program. An essential element in this process is having a piece of memory that we can call our own, that we can refer to using a meaningful name and where we can store an item of data. Each individual piece of memory so specified is called a variable.

Each variable will store a particular kind of data, which is fixed when we define the variable in our program. One variable might store whole numbers (that is, integers), in which case it couldn't be used to store numbers with fractional values. The value that each variable contains at any point is determined by the instructions in our program and, of course, its value will usually change many times as the program calculation progresses.

Although you can use variable names that begin with an underscore, for example _this and _that, this is best avoided, because there are potential clashes with standard system variables which have the same form. You should also avoid using names starting with a double underscore for the same reason.
Examples of good variable names are:
  • Price
  • discount
  • pShape
  • Value_
  • COUNT
Declaring Variables

A variable declaration is a program statement which specifies the name of a variable and the sort of data that it can store. For example, the statement,

int value;

declares a variable with the name value that can store integers. The type of data that can be stored in the variable value is specified by the keyword int. Because int is a keyword, you can't use int as a name for one of your variables.

A single declaration can specify the names of several variables but, as we have said, it is generally better to declare variables in individual statements, one per line. We will deviate from this from time to time, but only in the interests of keeping the code reasonably compact.

Initial Values for Variables

When you declare a variable, you can also assign an initial value to it. A variable declaration that assigns an initial value to a variable is called an initialization. To initialize a variable when you declare it, you just need to write an equals sign followed by the initializing value after the variable name. We can write the following statements to give each of the variables an initial value:

int value = 0;
int count = 10;
int number = 5;

In this case, value will have the value 0, count will have the value 10 and number will have the value 5. These three statements are each declarations, definitions and initializations.
There is another way of writing the initial value for a variable in C++ called functional notation. Instead of an equals sign and the value, you can simply write the value in parentheses following the variable name. So we could rewrite the previous declarations as:

int value(0);
int count(10);
int number(5);

If you don't supply an initial value for a variable, then it will usually contain whatever garbage was left in the memory location it occupies by the previous program you ran (there is an exception to this which we shall see later). Wherever possible, you should initialize your variables when you declare them. If your variables start out with known values, it makes it easier to work out what is happening when things go wrong. And if there's one thing you can be sure of, it's that things will go wrong.

Memory Concept

The sort of information that a variable can hold is determined by its data type. All data and variables in your program must be of some defined type. C++ provides you with a range of standard data types, specified by particular keywords. We have already seen the keyword int for defining integer variables. As part of the object-oriented aspects of the language, you can also create your own data types, as we shall see later. For the moment, let's take a look at the elementary numerical data types that C++ provides.


As we have said, integer variables are variables that can only have values that are whole numbers. The number of players in a football team is an integer, at least at the beginning of the game. We already know that you can declare integer variables using the keyword int. These are variables which occupy 4 bytes in memory and can take both positive and negative values.
C++ also provides another integer type, long, which can also be written as long int. In this case, we can write the statement,


long bigNumber = 1000000L, largeValue = 0L;

where we declare the variables bigNumber and largeValue with initial values 1000000 and 0 respectively. The letter L appended to the end of the values specifies that they are long integers. You can also use the small letter l for the same purpose, but it has the disadvantage that it is easily confused with the numeral 1.


Integer variables declared as long occupy 4 bytes and since this is the same as variables declared as int using Visual C++ 6.0, they have the same range of values.


The char data type serves a dual purpose. It specifies a one-byte variable that you can use to store integers, or to store a single ASCII character, which is the American Standard Code for Information Interchange. We can declare a char variable with this statement:


char letter = 'A';

This declares the variable letter and initializes it with the constant 'A'. Note that we specify a value which is a single character between single quotes, rather than the double quotes which we used previously for defining a string of characters to be displayed. A string of characters is a series of values of type char, which are grouped together into a single entity called an array. Because the character 'A' is represented in ASCII by the decimal value 65, we could have written this:


char letter = 65;      // Equivalent to A

to produce the same result as the previous statement. The range of integers that can be stored in a variable of type char is from -128 to 127.


We can also use hexadecimal constants to initialize char variables (and other integer types). A hexadecimal number is written using the standard representation for hexadecimal digits: 0 to 9, and A to F (or a to f) for digits with values from 10 to 15. It's also preceded by 0x (or 0X) to distinguish it from a decimal value. Thus, to get exactly the same result again, we could rewrite the last statement as follows:


char letter = 0x41;    // Equivalent to A

Variables of the integral types char, int, short or long, which we have just discussed, contain signed values by default. That is, they can store both positive and negative values. This is because the default type modifier for these types is the modifier signed. So, wherever we wrote char, int, or long, we could have written signed char, signed int, or signed long respectively.
If you are sure that you don't need to store negative values in a variable (for example, if you were recording the number of miles you drive in a week), then you can specify a variable as unsigned:


unsigned long mileage = 0UL;

Here, the minimum value that can be stored in the variable mileage is zero, and the maximum value is 4,294,967,295 (that's 232-1). Compare this to the range of -2,147,483,648 to 2,147,483,647 for a signed long. The bit which is used in a signed variable to determine the sign, is used in an unsigned variable as part of the numeric value instead. Consequently, an unsigned variable has a larger range of positive values, but it can't take a negative value. Note how a U (or u) is appended to unsigned constants. In the above example, we also have appended L to indicate that the constant is long. You can use either upper or lower case for U and L and the sequence is unimportant, but it's a good idea to adopt a consistent way of specifying such values.

 Arithmetic

The basic arithmetic operators we have at our disposal are addition, subtraction, multiplication and division, represented by the symbols +, -, * and / respectively. These operate generally as you would expect, with the exception of division, which has a slight aberration when working with integer variables or constants, as we'll see. You can write statements like this:


netPay = hours * rate - deductions;

Here, the product of hours and rate will be calculated, then deductions subtracted from the value produced. The multiply and divide operators are executed before addition and subtraction. We will discuss the order of execution more fully later in this chapter. The overall result of the expression will be stored in the variable netPay.


The minus sign used in the last statement applies to two operands - it subtracts one from another. This is called a binary operation because two values are involved. The minus sign can also be used with one operand to change the sign of its value, in which case it is called a unary minus. You could write this:


int A = 0; 
int B = -5;
A = -B;                        // Changes the sign of the operand

Here, A will be assigned the value +5, because the unary minus changes the sign of the value of the operand B.


Note that an assignment is not the equivalent of the equations you saw in high school algebra. It specifies an action to be carried out rather than a statement of fact. The statement,


A = A + 1;

means, 'add 1 to the current value stored in A and then store the result back in A'. As a normal algebraic statement it wouldn't make sense.







PC Interfacing - Application Borland C++ Builder



Creating project for welcome application

Now we will try to create a program that displays Welcome message on the screen.
Right now you should have C++Builder running and you should be looking at a blank form.
By default, the form is named Form1.  To the left of the form, the Object Inspector shows the properties for the form. Click on the title bar of the Object Inspector. The Caption property is highlighted. Type WELCOME ! to change the form’s caption.

Now click the Run button on the speedbar. (You could also press F9 or choose Run | Run from the main menu.) C++Builder begins to build the program. After a brief wait, the compiler status box disappears, the form is displayed, and the caption shows WELCOME!. In this case, the running program looks almost identical to the blank form. You may have noticed when the program was displayed because it is displayed in the exact location of the form in the Form Editor. You’ve just written your first C++ Windows program with C++Builder. It can be moved by dragging the title bar, it can be sized, it can be minimized, it can be maximized, and it can be closed by clicking the Close button.

If you still have the Hello World program running, close it by clicking the Close button in the upper-right corner of the window. The Form Editor is displayed again, and you are ready to modify the form (and, as a result, the program). To make the program more viable, we’re going to add text to the center of the window itself. To do this, we’ll add a text label to the form. First, click on the Standard tab of the Component Palette. The third component button on the palette has an A on it.  Click the label button and then click anywhere on the form. A label component is placed on the form.

Click on the title bar of the Object Inspector or on the Caption property and type WELCOME !. Now the label on the form shows Hello World!. As long as we’re at it, let’s change the size of the label’s text as well. Double-click on the Font property. The property will expand to show the additional font attributes below it. Locate the Size property under Font and change the font size to 24 . As soon as you press the Enter key or click on the form, the label instantly changes to the new size. To move a component, simply click on it and drag it to the position you want it to occupy. Once you have the label where you want it, you’re ready to recompile and run the program. Click the Run button again. C++Builder compiles the program again and, after a moment , the program runs. Now you see WELCOME! displayed in the center of the form .


Title Bar

The main section of the title bar displays the C++ Builder 5 name of the application, and the name of the program that is running. A C++ Builder program is called a project. When Bcb starts, it creates a starting project immediately, and it names the starting project, Project1. If or when you add other projects, they take subsequent names such as Project2, Project3, etc. This main section of the title bar is also used to move, minimize, maximize the top section of the IDE, or to close Bcb. On the right section of the title bar, there are four system buttons with the following roles a) Minimize window b) Maximize window c) Restores window d) Close window

Menu Bar

Under the title bar, there is a range of words located on a gray bar; this is called the menu.  To use a menu, you click one of the words and the menu expands. Click File. There are four main types of menus you will encounter. When clicked, the behavior of a menu that stands alone depends on the actions prior to clicking it. Under the File menu, examples include Save, Close All or Exit. For example, if you click Close All, Bcb will find whether the project had been saved already. If it were, the project would be closed; otherwise, you would be asked whether you want to save it.

A menu that is disabled is not accessible at the moment. This kind of menu depends on another action or the availability of something else. A menu with three dots means an action is required in order to apply its setting(s). Usually, this menu would call a dialog box where the user would have to make a decision. A menu with an arrow holds submenu. To use such a menu, position the mouse on it to display its submenu.

Notice that on the main menu (and any menu), there is one letter underlined on each word. Examples are F in File, E in Edit, etc. The underlined letter is called an access key. It allows you to access the same menu item using the keyboard. In order to use an access key, the menu should have focus first. The menu is given focus by pressing either the Alt or the F10 keys. To see an example, press Alt.

Notice that one of the items on the menu, namely File, has its border raised. This means the menu has focus.

Press p and notice that the Project menu is expanded.
When the menu has focus and you want to dismiss it, press Esc.

Notice that the Project menu has collapsed but the menu still has focus. Press f then press o. Notice that the Open dialog displays.

On most or all dialog boxes that have either an OK, Open, or Save buttons, when you press Enter, the OK, Open, or Save button is activated. On the other hand, most of those dialog boxes also have a Cancel button. You can dismiss those dialogs by clicking Cancel or pressing Esc.

On some menu items, there is a combination of keys we call a shortcut. This key or this combination allows you to perform the same action on that menu using the keyboard. If the shortcut is made of one key only, you can just press it. If the shortcut is made of two keys, press and hold the first one, while you are holding the first, press the second key once and release the first key. Some shortcuts are a combination of three keys. To apply an example, press and hold Ctrl, then press S, and release Ctrl. Notice that the Save As dialog box opens. To dismiss it, press Esc.

Toolbar

A toolbar is an object made of buttons. These buttons provide the same features you would get from the menu, only faster. Under the menu, the IDE is equipped with a lot of toolbars. For example, to create a new project, you could click File _ New… on the main menu, but a toolbar equipped with the New button allows you to proceed a little faster.

By default, Bcb displays or starts with 6 toolbars. Every toolbar has a name. One way you can find out the name of a toolbar is to click and hold the mouse on its gripper bar and drag it away from its position


Saving and closing solution

A program in Borland C++ Builder is called a project. As an application, it is saved in a few steps. To save a project, on the Standard toolbar, click the Save All button.





PC Interfacing - Introduction Computers and Programming


Machine Language

The machine language (also known as machine code or native code) is a system of instructions for a specific processor or a data processing system which can be run without compilation process.
In contrast to assembly language or high level language , it is very hard for us to understand the   code , It can be read only by experts and usually they will try to understand machine code with the help of special programs which is called machine language monitors . 
 The machine code is usually generated from assembler or compiler from other programming languages.  Machine language can be programmed directly which means no assembler for the target processor is needed.
Normally if we want to program a processor we need an assembler to translate our program from a text file assembly program into binary machine instructions.
For the execution and translation of machine code on unsuitable processors, we can use emulators .

Assembly Language

An assembly language is a special programming language , which is written in a human readable form for a specific processor. Each computer architecture has its own assembly language.
program in assembly language is also known as assembler code. It has a special compiler or also known as assembler. It converts the assembly language directly to executable machine language. The process to convert back the machine code to human-readable assembly code is called disassembly . However after this process some information such as identifiers and comments could not be recovered, as this information already lost during compiling process and it makes us difficult to understand the program.
When we program a computer in assembly language, the full range of computer hardware and chip program can be directly exploited. It is because assembly language programs works very well since they are often much smaller and faster than higher level programs that have a similar degree of complexity.  Nowadays assembly language is rarely used, unless the programs are very critical (for example, the programming for device drivers of graphics cards ) or completely new technologies whereby the high-level language libraries are still not exist. In principle, nowadays most machines use high-level programming.  Other disadvantage of assembly code is there are higher error rate (due to the complexity.


High Level Language

A high-level programming is a programming language , which allows the writing of a computer program in an abstract language (it is understandable for humans).
The first computers were using programs in machine code instruction. This is merely a sequence of numbers. The processors will interpret the sequence of commands. These commands consist of simple instructions such as arithmetic, memory access, etc. The first innovation was the invention of assembly languages ​​. It is not abstract, but the command is represented in text form.

In the end of 1950 , computer was so powerful that translation software programs could significantly facilitate the input. Fortran , Algol , and Lisp was the first generation of high level languages:
§  Fortran - FOR mula TRAN slation = formula translation
§  ALGOL - ALGO rithmic L anguage = language algorithms
§  LISP - LIS t P rocessing for list processing
These first generation of higher-level languages ​​contain abstract elements such as conditional statements ("if X is true, then do y") and loops ("while x, leads from y"). This make the program are more readable.

Most "modern" programming languages ​​( BASIC , C , C + + , C # , Pascal - known by the IDE Borland Delphi and Lazarus IDE - and Java ) are the languages ​​of the third generation .

Comparison between assembly language and high – level language
High-level programming
Assembly language
Syntax often adapted to human ways of thinking
Space-saving, highly compressed syntax
Mostly machine-independent
Only on a particular type of processor running
Loss of speed through abstraction (trend)
Machine-oriented commands increase the speed
Abstract, machine-independent data types (integer, float, ...)
Data types of the processor ( byte , word , long word)
Several control structures ( if , while ,...)
Jump instructions, macros
Data structures (field record)
Only simple types
Extensive semantic analysis is possible
Only basic semantic analysis is possible
Example:
  A: = 2; FOR I: = 1 TO 20 LOOP A: = A * I; END LOOP; PRINT (A);
Example:
      . ST ST START: MOV R1, # 2 MOV R2, # 1 M1: CMP R2, # 20 BGT M2 MUL R1, R2, R2 JMP INI M1 M2. JSR PRINT END

Borland C++ Builder

C++Builder is Borland’s hot new rapid application development (RAD) product for writing C++ applications.
With C++Builder you can write C++ Windows programs more quickly and more easily than was ever possible before. You can create Win32 console applications or Win32 GUI (graphical user interface) programs.
When creating Win32 GUI applications with C++Builder, you have all the power of C++ wrapped up in a RAD environment. What this means is that you can create the user interface to a program (the user interface means the menus, dialog boxes, main window, and so on) using drag-and drop techniques for true rapid application development.
You can also drop OCX controls on forms to create specialized programs such as Web browsers in a matter of minutes.
C++Builder gives you all of this, but you don’t sacrifice program execution speed because you still have the power that the C++ language offers you.

Object Oriented programming (OOP)

OOP is a new technique in software development. By emphasizing software reusability in program coding, OOP has the potential of increasing programmer productivity while reducing the cost of software maintenance. It does this by treating data as objects capable of manipulating themselves and gives great importance to relationships between objects.
C++ is one of the widely-used OOP languages today. C++ provides classes for declaring objects. In fact, before it was called C++ this programming language was called C with classes.

Wednesday, January 12, 2011

Tuesday, January 12, 2010

Autotronics - Sensor

Introductions


- A technical component which can detect a special physical condition or chemical characteristic (e.g. light, temperature, pressure, humidity) and change it to electrical signal

- Input -> physical or chemical effects

- Output -> electrical signal.

- Biological term -> receptor

- Sensors can be divided into 2 groups which can be differentiated by the applications and the form of creations.

- Active sensor

         o Created base on the measurement principal of electrical energy i.e. electro dynamic or piezo electric.

         o It doesn’t need any electrical energy.

- Passive sensor

         o Consists of passive components
   
         o The act of the sensor is depend on the changing of the parameter value of the passive components.

        o E.g. resistor thermometer



Applications

- Light ray -> light, X ray.

- Sounds -> the changing of the sound.

- Temporal -> time between 2 recordings

- Spectral -> width of band , number of bands

- Used in medicine and biology -> CCD Sensors

- Automation -> provide signals



Virtual sensor

- Realised by software.

- Measure the calculated values which can be collected by the real sensors.

- Used by applications where the real sensor is very expensive.



Digital Sensor

- Used in automation field.

- E.g. AC converter

- Get the digital signal directly.

- High linearity

Monday, January 11, 2010

Autotronics - Relays

Introductions


- Electrically operated switch

- Use electromagnet to operate switching mechanism.

- Necessary to control a circuit by a low-power signal.

- Help to control several circuits using one signal.


Basic Design and Operation

- It works using the principal of electromagnet.

- Consist of :-

          o A coil of wire surrounding a soft iron core

          o Iron yoke provides a low reluctance for magnetic flux

          o A movable iron armature.

          o Sets of contacts

- When the electric current passed through the coil, magnetic field attracts the armature.

- Movement of movable contacts makes or breaks a connection with a fixed contact.

- When current is off the armature will return back to its original position by a force.

- The force is normally provided by spring or gravity.

- In low voltage application -> relays operate quickly to reduce noise.

- In high voltage application -> relays operate quickly to reduce arcing.



Types of Relays

- Latching relay

          o Has 2 relaxed states

          o Also called as impulse, keep, stay

          o When the current is switched off, the relay remains in its last state.

           o It consumes power only for an instant while is being switched, and it retains its last setting across a power outage.

           o A current pulse in opposite polarity will change the state.


- Reed relay

          o Set of contacts inside a vacuum or inert gas filled glass tube.

          o It protects against atmospheric corrosion.

          o Capable of faster switching speeds than larger types of relays.

          o Have low switch current and voltage ratings.


- Mercury-wetted relay

          o Contacts are wetted with mercury.

          o Used to switch low voltage signals due to low contact resistance.

          o Used for high-speed counting and timing applications.

          o Position sensitive and must be mounted vertically.


- Polarized relay

        o Placed the armature between the poles of a permanent magnet to increase sensitivity.

         o Used to detect faint pulses and correct telegraphic distortion.



Applications

 to switch on many circuits using only one control circuit at the same time.

 To switch on a high voltage circuit using a low voltage circuit.

 To separate 2 conductors with different characteristics in a circuit.



Advantages

 high switching load.

 don't need any coolant

 can be shorted without losing its function.

 It can switch from small signals until high frequency power.



Disadvantages

 high delay time

 sensitive to vibration.

 Life span is depend on the mechanical components.

 It can create noise during switching.
Autotronics - Notes

Friday, January 08, 2010

Autotronics - Transistor

Introductions


- Active electronic devices used as switches and amplifier for electrical signal.

- Can usually be found as part of electronic switches in the application of communication technique, power electronics and computer system.

- Nowadays transistors are widely applied in integrated circuit especially in microelectronic industries.

- Made of silicon material with at least 3 terminals for connection to an external circuit.

- A voltage or current applied to one pair of transistor’s terminals changes the current flowing through another pair of terminals.

- There are 2 types of transistors which are bipolar transistor and field effect transistor.

- Both of them can be differentiated by the way signal is controlled.

- Bipolar transistor :-

      o The most commonly used transistor

      o Become the transistor of choice for many analogue circuits due to their great linearity and ease of manufacture.

- MOSFET

      o Widely used in digital circuits because of their utility in low-power devices

      o Usually in CMOS configuration.



Simple Operation

- The common usage as amplifier by controlling its output in proportion to the input signal.

- This action is due to its gain properties which enable it to use a small signal applied between one pair of its terminal to control a much larger signal at another pair of terminals.

- Another common application of transistor is as switch.

- Used to turn current on or off in a circuit as an electrically controlled switch.



a) Bipolar transistor

- Control electron (negative charge carrier) and hole (positive charge carrier) by manipulating the principal of generation and recombination of electron in a crystal.

- The principal is basically same as diode whereby electron and hole play a big role.

- A bipolar transistor has terminals labelled as base, collector and emitter.

- A small current at the base terminal(that is flowing from the base to the emitter) can control or switch a much larger current between the collector and the emitter terminals.

- Controlled by manipulating the electrical current.

- The contacts are Base, Emitter and Collector.

- Small control current is applied at the Base-Emitter path.

- The characteristic of NPN-transistor and PNP-transistor can be differentiated by the structure of the transistor.

- Bipolar transistor is basically a self block whereby without control from the small current at the Base-Emitter path, current can’t flow through the Collector-Emitter path.





Field Effect Transistor

- Field Effect Transistor (FET)

- Also known as uni polar transistor is controlled by manipulating voltage across it.

- The contacts are known as Gate, Drain and Source.

- In metal oxide semiconductor FET (MOSFET) there is an extra contact which is called as Bulk, where it is connected to Source.

- The resistance and also the current across the Drain-Source path are controlled by the voltage and also electric field at gate.

- The controlled current in the Drain-Source Canal can flow in both position rather than Collector current in bipolar transistor which can flow only in one direction.



Junction Field Effect Transistor (JFET)

- Normally JFET is a self conductive transistor.

- When there is no voltage at gate, the path between Source and Drain become conductive.

- But if voltage is applied at the Gate the conductivity between Source and Drain will reduce.

- There are 2 types of JFET i.e. N-Canal and P-Canal.

- N-Canal transistor can be recognized by referring to the arrow symbol which direction is showing into the transistor.

- For P-Canal the arrow will point in the opposite direction.

- JFET is normally used in special application such as microphone amplifier due to the complexity of the control.



Metal-Oxide Semiconductor – Field-Effect-Transistor

- This transistor is known as MOSFET due to the structure of semiconductor layer at the Gate.

- But nowadays poly silicon is used as the material at gate.

- MOSFET is normally used for charge transport which is suitable for use at very high frequencies e.g. microwave frequencies.



Special Type of Transistor

- Beside the normal type of transistors there are other types of transistors for special usage such as Bipolar transistor with isolated Gate electrode.

- This type of transistor is widely used in power electronic area where by it is actually a combination of MOS- and bipolar technology in a same package.

- Due to its capability it has been used in power electronic area to replace thyristor.

- Fototransistor is actually an optically sensitive bipolar transistor which has same application as other opto-coupler devices.

- The control of the transistor is not by the Base-emitter current but it is controlled by light.

- Light act similar as the Base current at the PN-junction.

- In some of the LCD display monitor, thin film transistors are used to control every pixel on the monitor.

- These FET is actually transparent. They are used to control the contrast, colour and the brightness of the monitor for each pixel.

- Therefore for each monitor more than million thin film transistors are used for this purpose.

- In programmable storage disk such as EPROMs and EEPROMs special MOSFET (floating gate) are used as prime storage element.

- By manipulating the electrical charge which are stored in the floating gate, the transistor can be switched on and off and also information of one bit can also be stored.



Applications


Digital Circuit

- Here transistors are used mainly in the making of integrated circuit in the RAM-Storage, Flash-Storage, microcontroller, microprocessor and logic gate.

- Normally there are about 1 billion of transistors on a substrat which are made of silicon.


Analogue Circuit

- In the analogue circuit transistors are used as operational amplifier, signal generator and also as reference voltage source.

- To convert between analogue to digital or vice versa Analogue-digital converter and digital-analogue converter are used frequently.

- The number of transistors used are about 100 to 10000.
Autotronics - Diodes

Introduction


- electronic component which let current flow through a conductor in one direction and act as an insulator in the opposite direction.

- can be thought as an electronic version of check valve.

- act as a rectifier to convert AC current to DC current and remove modulation from radio signals in radio receivers.

- The term of diode related to the semiconductor characteristics of PN junction .



The Construction of Semiconductor Diode

- made of impurities P-N semiconductor material (mostly Silicon, Germanium, Galliumarsenide and Sillicon carbide).

- The conductivity of a conductor is depend on the polarity of potential difference i.e. Anode (p-type semiconductor) and Cathode (n – type semiconductor) or the direction of the current flowing across it.

- The PN junction is an area where the action of diode takes place.

- Here the positive charge carriers (holes) from the P-type semiconductor and the negative charge carriers (electron) from the n-type semiconductor combine together.

- The crystal conducts current in a direction from p-type (anode) to the n-type side(cathode) but not in opposite direction.



Mechanical Model of Diode

- The function of diode can be represented as a simple check valve.

- When the pressure( potential difference) of the check valve (diode) is given in the opposite direction the current flow will be blocked.

- Enough pressure must be given in this direction until the spring of the check valve spoil to let the current flow.

- The voltage which is needed to let current flow is called threshold voltage or forward voltage drop.

- To reach this situation voltage at such value must be put in the direction of forward voltage so that diode will become conductive at certain position.


Semiconductor Diode

- made of semiconductor material such as silicon which has been added with impurities in it.

- The impurities is very important to create region on one side which contains negative charge carriers (electrons) i.e. n-type semiconductor.

- On another side it is a region which contains positive charge carriers (holes), called p-type semiconductor.

- Each of these regions are attached by diodes terminals

- between them there is a border which is called PN junction where here all actions of diode takes place.

- Currents flow in a direction from p-type side (anode) to the n-type side (cathode) but not in the opposite direction.

- Another type of semiconductor diode is the Schottky Diode which is formed from the contact between a metal and a semiconductor rather than by p-n junction.





Current – voltage Characteristic

- The behaviour of a semiconductor diode can be observed by the current-voltage characteristic.

- The shape of the curve in the graph is influenced by the transport of charge carriers through the depletion layer in the p-n junction.

- At first when the p-n junction is created the electrons from the N-type region diffuse into the p-type region where there are more holes (places for electron in which no electron is present).

- When an electron from the n-type region combines together with a hole, both electron and hole disappear.

- Now on the N-side, there is a static positively charged donor and on the P-side there is a negatively charged acceptor.

- Therefore right now the area around the P-N junction becomes depleted of charge carriers and thus behaves as an insulator.

- However the width of the depletion region can grow with limit.

- Each time the electron-hole recombines, a positively-charged ion is left behind in N-type region and negatively charged ion is left in the P-type region.

- This process happens continuously and more ions are created.

- After some time an increasing electric field develops in the depletion region and make the process slower and finally stop the recombination process.

- Now there is a built-in potential across the depletion area.

- Now let say if we put an external voltage across the diode with the same polarity as the built-in potential

- the depletion area will act as an insulator to prevent any electric current flow.

- This phenomenon is called reverse bias.

- However if the polarity of the external voltage is put in the opposite direction of the built in potential, the recombination process happen again to create a current flow through the p-n junction.

- For silicon diodes the built-in potential is approximately 0.6V.

- Thus if an external current passed through the diode about 0.6V will be developed across the diode such that the P-doped region is positive with respect to the N-typed region.

- Therefore the diode is said to be turned on as it has forward bias.



Types of Semiconductor Diode

- There are several types of diode

- differentiated by geometric scaling, doping level, choosing the right electrodes and the application of diodes.

- Normally these diodes are made of doped silicon

- rarely germanium.


a) Avalanche Diodes

- It conducts in the reverse direction when the reverse bias voltage exceeds the breakdown voltage.

- Normally they are mistakenly called Zener diodes due to electrical similarity.

- Avalanche diode break down by different mechanism, the avalanche effect.

- It is designed to break down at a well defined reverse voltage without being destroyed.

- The only practical difference is that the two types have temperature coefficients of opposite polarities.


b) Crystal diode

- It is a type of point-contact diode.

- It consists of a thin or sharpened metal wire pressed against a semiconducting crystal, typically galena or a piece of a coal.

- The wire forms the anode and the crystal forms the cathode.

- This type of diode is used normally as a crystal radio receivers.

- But nowadays crystal diode are generally obsolete, but may be available from a few manufacturers.


c) Constant current diode

- It is actually a JFET with the gate shorted to the source and function like a two-terminal current limiter analogue to the Zener diode, which is limiting voltage.

- Current is allowed to pass through then to rise to a certain value, and then level off at a specific value.

- It is also called CLDs, constant-current diode, diode-connected transistors or current-regulating diodes.


d) Esaki or tunnel diode

- It has a region of operation showing negative resistance caused by quantum tunnelling, thus allowing amplification of signals and very simple bistable circuits.

- This diode is also the type most resistant to nuclear radiation.


e) Gunn diode

- It is similar to tunnel diode in that it is made of materials such GaAs or InP that exhibit a region of negative differential resistance.

- With appropriate biasing, dipole domains form and travel across the diode, allowing high frequency microwave oscillators to be built.


f) Light emitting diode (LED)

- In a diode formed from a direct band-gap semiconductor, such as gallium arsenide, carriers that cross the junction emit photons when they recombine with the majority carrier on the other side.

- Depending on the material, wavelengths (or colors) from the infrared to the near ultraviolet may be produced.

- The forward potential of these diodes depends on the wavelength of the emitted photons: 1.2 V corresponds to red, 2.4 V to violet.

- The first LEDs were red and yellow, and higher-frequency diodes have been developed over time.

- All LEDs produce incoherent, narrow-spectrum light; “white” LEDs are actually combinations of three LEDs of a different color, or a blue LED with a yellow scintillator coating.

- LEDs can also be used as low-efficiency photodiodes in signal applications. An LED may be paired with a photodiode or phototransistor in the same package, to form an opto-isolator.


Laser diodes

- When an LED-like structure is contained in a resonant cavity formed by polishing the parallel end faces, a laser can be formed.

- Laser diodes are commonly used in optical storage devices and for high speed optical communication.


Peltier diodes

- These diodes are used as sensors, heat engines for thermoelectric cooling.

- Charge carriers absorb and emit their band gap energies as heat.


Photodiodes

- All semiconductors are subject to optical charge carrier generation.

- This is typically an undesired effect, so most semiconductors are packaged in light blocking material.

- Photodiodes are intended to sense light(photodetector), so they are packaged in materials that allow light to pass, and are usually PIN (the kind of diode most sensitive to light).

- A photodiode can be used in solar cells, in photometry, or in optical communications.

- Multiple photodiodes may be packaged in a single device, either as a linear array or as a two-dimensional array.

- These arrays should not be confused with charge-coupled devices.


Point-contact diodes

- These work the same as the junction semiconductor diodes described above, but their construction is simpler.

- A block of n-type semiconductor is built, and a conducting sharp-point contact made with some group-3 metal is placed in contact with the semiconductor.

- Some metal migrates into the semiconductor to make a small region of p-type semiconductor near the contact.

- The long-popular 1N34 germanium version is still used in radio receivers as a detector and occasionally in specialized analog electronics.


PIN diodes

- A PIN diode has a central un-doped, or intrinsic, layer, forming a p-type/intrinsic/n-type structure.

- They are used as radio frequency switches and attenuators.

- They are also used as large volume ionizing radiation detectors and as photodetectors.

- PIN diodes are also used in power electronics, as their central layer can withstand high voltages.

- Furthermore, the PIN structure can be found in many power semiconductor devices, such as IGBTs, power MOSFETs, and thyristors.



Schottky diodes

- Schottky diodes are constructed from a metal to semiconductor contact.

- They have a lower forward voltage drop than p-n junction diodes.

- Their forward voltage drop at forward currents of about 1 mA is in the range 0.15 V to 0.45 V, which makes them useful in voltage clamping applications and prevention of transistor saturation.

- They can also be used as low loss rectifiers although their reverse leakage current is generally higher than that of other diodes.

- Schottky diodes are majority carrier devices and so do not suffer from minority carrier storage problems that slow down many other diodes — so they have a faster “reverse recovery” than p-n junction diodes.

- They also tend to have much lower junction capacitance than p-n diodes which provides for high switching speeds and their use in high-speed circuitry and RF devices such as switched-mode power supply, mixers and detectors.


Super Barrier Diodes

- Super barrier diodes are rectifier diodes that incorporate the low forward voltage drop of the Schottky diode with the surge-handling capability and low reverse leakage current of a normal p-n junction diode.


Gold-doped diodes

- As a dopant, gold (or platinum) acts as recombination centers, which help a fast recombination of minority carriers.

- This allows the diode to operate at signal frequencies, at the expense of a higher forward voltage drop.

- Gold doped diodes are faster than other p-n diodes (but not as fast as Schottky diodes).


Snap-off or Step recovery diodes

- The term step recovery relates to the form of the reverse recovery characteristic of these devices.

- After a forward current has been passing in an SRD and the current is interrupted or reversed, the reverse conduction will cease very abruptly (as in a step waveform).

- SRDs can therefore provide very fast voltage transitions by the very sudden disappearance of the charge carriers.


Transient voltage suppression diode (TVS)

- These are avalanche diodes designed specifically to protect other semiconductor devices from high-voltage transients.

- Their p-n junctions have a much larger cross-sectional area than those of a normal diode, allowing them to conduct large currents to ground without sustaining damage.


Varicap or varactor diodes

- These are used as voltage-controlled capacitors.

- These are important in PLL (phase-locked loop) and FLL (frequency-locked loop) circuits, allowing tuning circuits, such as those in television receivers, to lock quickly, replacing older designs that took a long time to warm up and lock.

- A PLL is faster than an FLL, but prone to integer harmonic locking (if one attempts to lock to a broadband signal).

- They also enabled tuneable oscillators in early discrete tuning of radios, where a cheap and stable, but fixed-frequency, crystal oscillator provided the reference frequency for a voltage-controlled oscillator.


Zener diodes

- Diodes that can be made to conduct backwards.

- This effect, called Zener breakdown, occurs at a precisely defined voltage, allowing the diode to be used as a precision voltage reference.

- In practical voltage reference circuits Zener and switching diodes are connected in series and opposite directions to balance the temperature coefficient to near zero.

- Some devices labeled as high-voltage Zener diodes are actually avalanche diodes (see above).

- Two (equivalent) Zeners in series and in reverse order, in the same package, constitute a transient absorber (or Transorb, a registered trademark).