欢迎来到留学生英语论文网

客服信息

我们支持 澳洲论文代写 Assignment代写、加拿大论文代写 Assignment代写、新西兰论文代写 Assignment代写、美国论文代写 Assignment代写、英国论文代写 Assignment代写、及其他国家的英语文书润色修改代写方案.论文写作指导服务

唯一联系方式Q微:7878393

当前位置:首页 > 论文范文 > It Research

HW components and microcontroller

发布时间:2017-04-17
该论文是我们的学员投稿,并非我们专家级的写作水平!如果你有论文作业写作指导需求请联系我们的客服人员

1.1 Microcontroller

A microcontroller (also microcontroller unit, MCU or µC) is a small computer on a single integrated circuit consisting of a relatively simple CPU combined with support functions such as a crystal oscillator, timers, watchdog timer, serial and analog I/O etc. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for small or dedicated applications.

Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, remote controls, office machines, appliances, power tools, and toys. [3]

A microcontroller is so similar to the microprocessor inside a PC. Both microprocessor and microcontroller contain a Central Processing Unit, or CPU. The CPU executes instructions that perform the basic logic, math, and data moving function of a computer. To make a complete computer, a microprocessor requires memory for storing data and programs, and I/O interfaces for connecting external device like a keyboard and displays. In contrast, a microcontroller is a single-chip computer because it contains memory and I/O devices in addition to CPU. [4]

By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems. [3]

1.1.1 PIC Microcontroller

PIC is a family of Harvard architecture microcontrollers made by Microchip Technology, derived from the PIC1640 originally developed by General Instrument's Microelectronics Division. The name PIC initially referred to "Programmable Interface Controller". [3] or "Programmable Integrated Circuit".

PICs are popular with both industrial developers and hobbyists alike due to their low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development tools, and serial programming (and re-programming with flash memory) capability.[5]

PIC is used in this system because:

1. PIC are very versatile and can be used in practical projects such as burglar alarms, remote controls, clocks and just about anything that anyone can think about could use a single chip self contained computers.

2. The PIC language provides an easy way to write procedural box-and arrow diagrams to be included in documents, and it is sufficiently flexible to be quite useful for state charts, flow charts, simple circuit schematics and other kinds of illustration involving repetitive uses of simple geometric forms.

1.1.2 Types of the PIC's Pins:

The pins of the PIC 'for all PIC's ' are divided into pins that must be connected and pins that is optional.

1.1.2.1 pins that must be connected

1. M-CLR :

- M-CLR: the above line means this pin works using 0 'active low'.

- It means reset for the computer, it is active low and it's pin no.1.

- Reset for the computer means, reset for the program counter 'return to the begging of the executed code'.

- Logic 0 means reset for the PIC, this state was used when the PIC finishes executing the program.

- Logic 1 means, the PIC is active, this state was used while having infinite loop.

- Most of the time it is connected to the Vcc 'logic 1' to let the PIC works.

2. Oscillator:

- Oscillation: a periodic fluctuation between two things based on changes in energy[1].

- An oscillator is a mechanical or electronic device that works on the principles of oscillation[1].

- Computers, clocks, watches, radios, and metal detectors are among the many devices that use oscillators[1].

- The frequency at which an oscillator works is usually determined by a quartz crystal[1].

- When a direct current is applied to such a crystal, it vibrates at a frequency that depends on its thickness, and on the manner in which it is cut from the original mineral rock[1].

- Some oscillators employ combinations of inductors, resistors, and/or capacitors to determine the frequency. However, the best stability (constancy of frequency) is obtained in oscillators that use quartz crystals[1].

- Some oscillators are inside the microcontroller and these are called internal oscillator.

- Usually specified in megahertz (MHz), and is an important factor in determining the rate at which a computer can perform instructions.

1. Power supply:

- The power supply is usually a power supply unit, which converts the AC voltage into DC voltage level, which is needed to operate the device.

- The main function of the power supply is to provide the system with fixed voltage needed to keep the ratio of AC ripple of small levels, in addition to good stability and organization.

- Typical voltage for almost all PICs is (5 voltage) so there is limitation on the voltage of PIC that will be illustrated in the table below:

Table (3.1):"limitation on voltage of PIC"

Voltage value

(volt)

Effect of that voltage value

5.5 to 6

The PIC might be burnt 'it will damage'

5

The PIC is working "logic 1"

4.5

The PIC still working

2.5

The PIC will work but it may not execute all of the code instructions

Less than 2.5

The PIC will not work "logic 0"

- The number of power supply pins varies in accordance with the type of the PIC being used (e.g. PIC 18F452 has 4-pins"2VSS and 2VDD , VSS indicates to Ground, and VDD to 5 volt.

1.1.2.2 Pins That Is Optional

- It's called 8-bit controller.

- These pins are divided into groups that are called ports.

- Number of ports varies from one PIC MCU to another according to its type.

- Each port has a configuration register inside the PIC and it is called TRISE register.

- TRISE register is a data direction register that controls the direction of data (input or output) of each pin of that port. For example having TRISA cleared (0 which is the default) will configure all pins of PORTA as output.

- TRISE register always consists of 8-bits even if the port itself doesn't have 8-pins "e.g. 6-pins as in port a".

- '0' indicates that the pin is output and '1' indicates that the pin is input.

- An example of the TRISE register of port B is shown in the figure below:

To store values in the TRISE register it must be written in the hex form so either ($) or (0X) will be used before the value that will be stored.

In the system PIC 16F876A and PIC18F452 were used.

1.1.3 PIC 16F876A

· PIC 16F87XA

16F87XA

1 2 3 4

1. It is called the family number (F.N).

It specifies the size of data bus.

The 16-bits are divided as follows:

14-bits are for data transmission 'size of data', and 2-bits are for addresses therefore the PIC is divided into four sections as in the figure below:

a. Is the address of memory section (no.1)

It's produced by the two bits that are taken from the 16-bits as following:

The Probability of 2-bits is: 00,01,10,11.

b. These are called chip select and they are connected to the address decoder which is connected to the address bus. They work as the enable line "depending on the address comes to the decoder that will activate the specified section 'e.g. If the input of the decoder is 00 so the output will be 1000 as illustrated below :

So section no.1 'with address 00' will be activated.

This is a very useful way of fetching and storing data in the PIC because it's a quick and a simple one that saves time 'i.e. no long delay'.

2. F: means flash memory, which can be written on it and erased the data it contained for 100,000 times without any occurring damage.

Accessing this kind of memory is very quick so, that saves time.

There are two types of this memory with differences between them as illustrated in the table below:

Table (3.2):"differences between F and C "

symbol

name

No. of accessing time

Price

usage

F

Flash

100,000

More expensive than C

For development

C

Commercial

Only once

____

For commercial

The C memory could be used if there is no need to modify its stored data so the adjustment will cause a damage and loss of data.

1. 87X : it indicates the sequence of the PIC in its family.

4. A: means enhanced in the speed or in the memory,

For the ones that don't have the A in its name the speed of their crystal oscillator is 4 MHz but for the ones that have it is (4-20) MHz It affects the number of executed instructions because by increasing the frequency the number of executed instructions will increase.

PIC16F876A has 28-pins, as illustrated in the figure (3.5):

· 8 Pins for port B,C and D.

· 6 pins for port A.

· 3 pins for power supply: 2 pins for VSS(ground), and 1 pins for VDD(5 volt).

· 2 pins for the oscillator, OSC1 and OSC2.

· 1 pin for M-CLR.

Note that some of the pins of each PORT are multiplexed to do different functions when needed

1.1.4 PIC 18F452

1 2 3

1. To indicate the no. of data bits in the data bus which is equal to 18-bits so it's called PIC18XXXX due to its data bits.

2. It means flash memory "as illustrated in the previous PIC".

3. It indicates the sequence of the PIC in its family.

PIC 18F452 was used:

- As a microcontroller due high performance, low cost, low voltage and power, small footprint and ease-of-use.

- Because it supports, Flash program memory, Hardware timers, A\D conversion, Serial communications 'because of the presence of the built-in USART', and Lots of digital input and output pins.

PIC18F452 has 40-pins, as illustrated in the figure (3.6):

· 8 Pins for port B,C and D.

· 6 pins for port A.

· 3 pins for port E.

· 4 pins for power supply: 2 pins for Vss(ground), and 2 pins for VDD(5 volt).

· 2 pins for the oscillator, OSC1 and OSC2.

· 1 pin for M-CLR.

1.1.5 Microcontroller and PIC Features:

1.1.3.1 Microcontroller Features

- 100,000 erase/write cycle Enhanced Flash program memory typical.

- 1,000,000 erase/write cycle Data EEPROM memory typical.

- Data EEPROM Retention > 40 years.

- Self-reprogrammable under software control.

- In-Circuit Serial Programmingâ„¢ (ICSPâ„¢) via two pins.

- Single-supply 5V In-Circuit Serial Programming.

- Programmable code protection.

- Power saving Sleep mode.

- Selectable oscillator options.

- In-Circuit Debug (ICD) via two pins.

1.1.5.2 PIC16F876A High-Performance RISC CPU:

- Only 35 single-word instructions to learn 'only when using assembly for programming'.

- All single-cycle instructions except for program branches, which are two-cycle.

- Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle.

- Up to 8K x 14 words of Flash Program Memory, Up to 368 x 8 bytes of Data Memory (RAM), Up to 256 x 8 bytes of EEPROM Data Memory.

1.1.5.3 PIC18F852 High-Performance RISC CPU:

- C compiler optimized architecture/instruction set, Source code compatible with the PIC16 and PIC17 instruction sets.

- Up to 32K of flash program memory, up to 256 bytes of EEPROM Data Memory.

- Up to 10 MIPs operation, DC - 40 MHz clock input.

- Addressable USART module 'there is no banking here'.

1.1.5.4 Additional Features

Those features result because of the PIC technology "CMOS Technology":

- Low-power, high-speed Flash/EEPROM technology.

- Fully static design.

- Wide operating voltage range (2.0V to 5.5V).

- Commercial and Industrial temperature ranges.

- Low-power consumption.

· Inside a PIC there is an internal timer.

1.2 Capacitor

A capacitor is a passive electronic component consisting of a pair of conductors separated by a dielectric. When a voltage potential difference exists between the conductors, an electric field is present in the dielectric. This field stores energy and produces a mechanical force between the plates.

Capacitors are widely used in electronic circuits to block the flow of direct current while allowing alternating current to pass, to filter out interference, to smooth the output of power supplies, and for many other purposes. They are used in resonant circuits in radio frequency equipment to select particular frequencies from a signal with many frequencies. []

There are two types of capacitor:

a- Ceramic capacitor: is a capacitor constructed of alternating layers of metal and ceramic, with the ceramic material acting as the dielectric.

In this system a Ceramic capacitor was employed in three positions for:

1. Noise immunity.

A ceramic capacitor often has high frequency to avoid the system from being affected by external microwave; therefore it acts as a low pass filter that filters out interference.

2. Remove bouncing :

to avoid the repetition of reset operation.

b- Chemical capacitor:

It consists of a semi-liquid electrolyte solution in the form of a jelly 'electrode 'and very thin layer of oxide 'dielectric'.

Also called Electrolytic Capacitors generally used when very large capacitance values are required,

This system employs the Chemical capacitor in two positions for:

1. Smoothing: to help reduce the ripple voltage.

2. Voltage stabilization: to use the capacitor as a voltage source to the entire circuit to prevent the loss of PIC voltage that won't let it to work properly.

1.3 Resistor

A resistor is a two-terminal electronic component that produces a voltage across its terminals that is proportional to the electric current through it in accordance with Ohm's law:[]

V = IR

In this project there are two types of resistor:

1. Pull-up resistor:

- It's connected with the voltage source 'VCC '.

- It' used to protect the PIC input pins from being in the float state 'when the input pin doesn't have a value'.

2. Pull-down resistor:

- It's connected with the ground '0 volt '.

- It' used to protect the PIC input pins from being in the float state 'when the input pin doesn't have a value'.

1.4 Diode

In electronics a diode is a two-terminal electronic component that conducts electric current in only one direction. The term usually refers to a semiconductor diode, the most common type today, which is a crystal of semiconductor connected to two electrical terminals, a P-N junction.

The most common function of a diode is to allow an electric current in one direction (called the forward direction) while blocking current in the opposite direction (the reverse direction). This unidirectional behavior is called rectification, and is used to convert alternating current to direct current.

Diodes are used to regulate voltage (Zener diodes), and produce light (light emitting diodes). []

1.5 LED (Light Emitting Diode)

One of the most useful types of diodes is a LED. The LED produces light when it is forward-biased. The most common LEDs have a distinctive red color, although they may be amber, green, or blue.

The LED is a semiconductor device that emits incoherent light when forward-biased. The color of the light depends on the chemical composition of the semiconducting material.

The correct polarity of LED can usually be determined by observing that the longest terminal is the anode. If the terminals have been altered, then it is risky to try to determine polarity by observing the LED's internal. So a more dependable clue to the LED's polarity is the flat tab on the LED's base, which indicates the cathode. []

1.6 Voltage Regulator

A Voltage Regulator (also called a "regulator") an electrical regulator designed to automatically maintain a constant voltage level.[9] Voltage Regulator has only three legs and appears to be a comparatively simple device but it is actually a very complex integrated circuit. A regulator converts varying input voltage and produces a constant "regulated" output voltage. Voltage regulators are available in a variety of outputs, typically - 5 volts, 9 volts and 12 volts. The last two digits in the name indicate the output voltage. [10]

The most common part numbers start with the numbers 78 or 79 and finish with two digits indicating the output voltage. The number 78 represents positive voltage and 79 negative one. The 78XX series of voltage regulators are designed for positive input. And the 79XX series is designed for negative input.[11]

The "LM78XX" series of voltage regulators are designed for positive input. For applications requiring negative input the "LM79XX" series is used. See table (3.3).

Table (3.3):"Example of Voltage Regulator"

Name

Voltage

LM7805

+ 5 volts

LM7809

+ 9 volts

LM7812

+ 12 volts

LM7905

- 5 volts

LM7909

- 9 volts

LM7912

- 12 volts

Voltage regulators are very robust. They can withstand over-current draw due to short circuits and also over-heating. In both cases the regulator will shut down before damage occurs. The only way to destroy a regulator is to apply reverse voltage to its input. Reverse polarity destroys the regulator almost instantly. To avoid this possibility you should always use diode protection of the power supply. This is especially important when using nine volt battery supplies as it is common for people to 'test' the battery by connecting it one way and then the other. Even this short 'test' would destroy the regulator if a protection diode were not used.

Input voltage:

As a general rule the input voltage should be limited to 2 to 3 volts above the output voltage. The LM78XX series can handle up to 30 volts input, but the power difference between the input voltage/current ratio and output voltage/current ratio appears as heat. If the input voltage is unnecessarily high the regulator will get very hot. Unless sufficient heat-sinking is provided so the regulator will shut down. [12]

1.7 Real Time Clock (RTC)

A real-time clock (RTC) is a clock that keeps track of the current time even when the device is turned off. RTCs are present in almost any electronic device which needs to keep accurate time like computers and embedded system.

RTCs often have an alternate source of power, so they can continue to keep time while the primary source of power is off or unavailable, This alternate source of power is normally a lithium battery in older systems, but some newer systems use a super capacitor, because they are rechargeable and can be soldered.

Most RTCs use a crystal oscillator, in many cases the oscillator's frequency is 32.768 kHz. []

RTC has I2C protocol (IC to IC communication) that is used when 2-IC communicating with each other.

I2C protocol based on sending data serially in the presence of a serial clock.

RTC (DS1307) which has 8 pins was used in the system as illustrated in the figure below:

Note that SCL pin isn't responsible of time generating inside the RTC.

1.8 Liquid Crystal Display (LCD)

1.8.1 Definition and Mechanism of LCD

A liquid crystal display (LCD) is a thin, flat panel used for electronically displaying information such as text, symbols, numbers, images and moving pictures. Its uses include monitors for computers and televisions se figure (3.13) that shows a 16Ã-2 LCD.

It is an electronically-modulated optical device made up of any number of pixels filled with liquid crystals and arrayed in front of a light source (backlight) or reflector to produce images in color or monochrome.

LCD displays utilize two sheets of polarizing material with a liquid crystal between them. An electric current passed through the liquid causes the crystals to align so that light cannot pass through them. Each crystal, therefore, is like a shutter, either allowing light to pass through or blocking the light [1] as you can see in figure (3.14).

It can be configured to drive a dot-matrix liquid display under the control of a 4 or 8-bits microprocessor [2] ' this system uses 4-bit mode to reduce the number of PIC used pins that connect LCD to the PIC '.

Among its major features are its lightweight construction, its portability, and its ability to be produced in much larger screen sizes than are practical construction of cathode ray tube (CRT) display technology. Also its low electrical power consumption enables it to be used in battery-powered electronic equipment.

Since all the functions such as display RAM, character generator and liquid crystal driver, required for driving a dot-matrix liquid crystal display are internally provided on one chip, a minimum system can be interfaced with this controller\ driver [2]

1.8.2 LCD 16*2

This system includes LCD 16*2:

16 indicate to the number of columns and 2 indicate to number of rows. That means it can display 32 characters as maximum number of characters.

LCD will receive information from the PIC in ASCII form then the LCD's microcontroller will handle that.

LCD 16*2 has 14 pins as shown in the figure below:

Vss : it's connected to the ground (0 volt).

VDD: it's connected to the power supply (5 volts).

VEE : it's for contrast, It's connected to a 330Ω resistor in order to have high lucidity.

RS : it stands for register select that identifies that the coming information is either data for presenting or command for performing, so if the RS value is 0 that means its command otherwise it's data.

R\W: the R is for reading information from the LCD 'sending information to the PIC', and W is for writing data on the LCD ' receiving information from the PIC'. In this project the only need of the LCD is to write on it, so it will be always connected to the ground ' because W is active low'.

E: it means enable and its used to make the entire LCD either to work or not 'it's controlled by the PIC'.

D0 - D7 : for data that will be displayed on the LCD, but This system uses only 4-pins of the data 8-pins and they are: D7, D6, D5 and D4 , The remaining pins will be connected to the ground.

· Some of the LCDs have other pins that are used for backlight and marked by the (+ −) symbols, But this system didn't use them.

1.9 Keypad

1.9.1 Definition of keypad

A keypad is a set of buttons arranged in a block which usually bears digits and other symbols but not a complete set of alphabetical letters. If it mostly contains numbers then it can also be called a numeric keypad[2].

Keypads are found on many alphanumeric keyboards and on other devices such as calculators and telephones which require largely numeric input [3], keypad is the most widely used input devices of a microcontroller[2] see figure (3.16).

At the lowest level, keyboards are organized in a matrix of rows and columns. The CPU accesses both rows and column through ports; therefore, with a port of microcontroller, a 4X3 matrix of keys can be connected. When a key pressed, a row and column make a connection; otherwise, there is no connection between row and column[1].

1.9.2 Scanning and Identifying the Key Pressed[1]

A Figure (3.17) shows a 4X3 matrix connected to a port of the PIC (e.g. PortD). The rows (R1 through R4) are connected to output pins of the port and the columns (C1 through C3) are connected to input pins of it. Note that, only 7 pins of the port were used.

To detect a pressed key, first, the microcontroller initiates the value of pin 0 through 7 of PortD to zero, then it sends 1000 to R1 R2 R3 R4 and it reads the columns. If the data read from the columns is C1 C2 C3 =000, no key has been pressed and the process continues to next step, If the data read from the columns is C1 C2 C3 =100, this means that a key in the R1 row and C1 column has been pressed. That is '1' and if the data read from the columns is C1 C2 C3 =010, this means that a key in the R1 row and C2 column has been pressed. That is '2'.

All of these operations will occur in a subroutine (for e.g. it's called 'Check Column') before leaving this subroutine, microcontroller will set a variable (for e.g. it's called 'Key Pressed') to indicate that there is a key pressed.

Table (3.4) represents the meaning of each combination of data received at C1 C2 C3.

Table (3.4):"Key pressed"

· Notice that the value of the rows is input value and the value of columns is output value.

Two keys cannot be pressed at the same time; there is time different between presses a key with another key. The variable 'e.g. Key Pressed' indicates that there is a key pressed in this time. Before leaving the entire subroutine, if 'Key Pressed' has been set, the microcontroller Set the variable 'KeyAlreadyPressed'. This variable will not be cleared until this subroutine detect that there is no key pressed. So, if presses more than two key, only the first key will be read.

To see if any key is pressed, the columns are scanned over and over in an infinite loop until one of them has a 1 on it.

It's inefficient if the keypad being scanned without any intervals of time. This interval can be generated by timer.

See the figure below that illustrates the internal design of the 4Ã-3 keypad.

Both the rows and the columns are connected to PIC microcontroller.

Pull-down resistors of 10KΩ were used in the keypad as shown in the figure above for:

Case 1: when the key isn't pressed the resistor will prevent the connected pin from entering the floating state.

Case 2: when the key is pressed the resistor will protect the PIC from being burnt by high current value, therefore the current value won't exceed 20mA 'the allowable amount of current for PIC'.

In this project keypad used to give the policeman the ability to modify the allowed time duration for parking and to send the stored data to his laptop by entering a specific word 'password'.

1.10 Serial

1.10.1 Pc serial port

Serial ports are a type of computer interface that complies with the RS-232 standard. They are 9-pin connectors that relay information, incoming or outgoing, one byte at a time. Each byte is broken up into a series of eight bits, hence the term serial port. So the protocol that used in pc serial is RS-232.

· RS-232

Recommended Standard - 232 is a telecommunications standard for binary serial communications between devices. RS-232 uses positive and negative voltages, for example, RS-232 uses a voltage below minus five volts to represent a logic one and a voltage above five volts to represent a logic zero. []

1.10.2 Serial Communications Interface in PIC (USART)

USART stands for Universal Synchronous Asynchronous Receiver Transmitter, it can receive and transmit, and use Full duplex asynchronous operation, that means (both transmission and reception can occur at the same time), the most common use of the USART in asynchronous mode is to communicate to a PC serial port using the RS-232 protocol.

The USART outputs and inputs logic level signals on the TX and RX pins of the PIC.

The signals on the USART pins of the microcontroller use logic levels. This means that for a five volt supply, the signals will be close to five volts when they are high and close to ground when they are low. When communicating with other logic devices, these signals can be used directly.

USART has the following properties:

1. 8 bit data.

2. 1 stop bit.

3. No parity check.

1.10.3 MAX-232

To interface PIC with the PC a MAX232 is needed. This IC will be connected on one side to the Sub-D9 of the PC and on the other side to the PIC (USART).

It's required to interface to RS-232 voltage levels. The PIC should not be directly connected to RS-232 signals,

The data is not inverted even though RS-232 uses negative voltages to represent a logic one. Generally, when using the USART for RS-232 communications, the signals must be inverted and level shifted.

In this system a MAX-232 MAXIM that has 16 pins was used, see figure (3.20).

As illustrated in the figure above:

- 4-capacitors were used to produce a 12-volt output for pc serial port that is connected with it.

- There are 8-pins for serial connection; 4-pins for serial one and the others for serial two because of that we can connect another devices that need serial interfacing.

- Each serial consists of 2-TX for transmission and 2-RX for receiving between the connected devices but in our project there will be only one TX (for sending data from the PIC) and one RX(for receiving data by the PC).

1.11 And gate :

AND gate is a digital logic gate that implements logical conjunction, A HIGH output (1) results only if both the inputs to the AND gate are HIGH (1). If neither or only one input to the AND gate is HIGH, a LOW output results.

The input of the AND gate will be taken from the RFID reader.

The AND gate was used to recognize the input that is coming from the RFID readers.

上一篇:Evaluation of soya lecithin based extender for liquid storage of Nili-Ravi buffalo (Bubalus bubalis) 下一篇:Medical Device Regulations