Post on 16-Nov-2014
description
TWO MONTHS INDUSTRIAL TRAINING
REPORT
Submitted for partial fulfillment of award of
BACHELOR OF ELECTRONICS & COMMUNICATION
ENGINEERING
Maharishi Markandeshwar Engineering College
Submitted by:
Sagar Kathuria
Roll no-1106631
E.C.E,7th sem. M.M Engg College
ACKNOWLEDGEMENT
First of all I would like to thank almighty GOD who has given this wonderful gift
of life to us. He is the one who is guiding us in right direction to follow noble path
of humanity. In my six weeks industrial training it is a wonderful experience to be
a part of NETMAX TECHNOLOGIES where I have opportunity to work under
brilliant minds. I owe my deep regards for the supporting and kind staff authorities
who are helping me in my lean patches during these six weeks. The knowledge I
am gaining throughout my studies have the practical implementation during this
period. I am grateful to all the staff of NETMAX and for their timely support and
sharing of their experience with me. I would like to express my heartiest concern
for Mr . ROHIT KHOSLA for his able guidance and for his inspiring attitude,
praiseworthy attitude and honest support. Not to forget the pain staking efforts of
our college training and placement cell and specially my training and placement
officer Mr. Manjeet Singh Ladher. Last but not the least I would express my
utmost regards for the electronics and communication department of our Institute.
CONTENTS
1) Company profile
2) Embedded Systems
What is Embedded System
Applications
Difference between microprocessor & micro controller
Types of microcontroller Architectures
Difference between CISC & RISC
3) PIC microcontrollers
PIC 16F73 features
Pin diagram of PIC16F73
Pin description of PIC16F73
Core Architecture
Electrical Characterstics
4) Programming of PIC
Compiler Used-mikroC
Features
Projects
Functionality
5) Programming and Interfacing
Advantages of C over Assembly language programming
Project no. 1- LED interfacing and its blinking(port
programming)
Project no. 2- seven segment interfacing and display
Project no. 3- Interfacing and control of stepper motor
with PIC 16F73
Project no. 4-LCD interfacing and display with PIC
16F73
Project no. 5-Builtin ADC of PIC16F73(Temperature
Monitoring)
Project no. 6-To study switching action of PIC pins.
Project no. 7-Interfacing of keyboard matrix
Project no. 8-Serial communication [b/w PC &
Microcontroller]
6)Power system design
Unregulated power supplies
Regulated power supplies
Bench supply diagram
COMPANY PROFILE
Netmax Technologies is an organization which is established in the field of Network Support, Network training and Embedded systems. It provides support and training in the field of networking solutions (CISCO, LINUX) and embedded systems (Micro controller based design, Electronics system design).
In Education, it has strategic alliance with REDHAT Inc. It is also NOVELL EDUCATION PARTNER with which it provides NOVELL and SUSE LINUX courses. Netmax technologies also conduct courses in CADENCE based design tools.
Netmax Technologies also provide Technical Research & Development support and consultancy to some Electronics companies.
Their clients for R&D support in field of embedded systems are:
1) Recorders and Medicare ltd Chandigarh.
2) TELEBOX India ltd.
3) Lotus Machines Pvt. Ltd. Chandigarh.
4) Impearl Electronics Pvt. Ltd. Chandigarh.
5) KANTA Electrical Ltd. Mohali.
The partial list of our clients for network field is as below:
1) CEDTI, Mohali
2) Premier ISP, Chandigarh
3) Innovative Solutions, Chandigarh
4) Emmtel ISP, Chandigarh
5) NIPER, Mohali
6) Navik Technologies, Chandigarh
7) Software Technology Parks India, Mohali
8) Glide Internet Services
9) Rana Group
10) IDS
11) HFCL Infotel Ltd.
12) Targus technologies pvt ltd
13) STPI, Mohali
14) BBMB
15) The Tribune
16) Quark
17) Ind Swift
Support Area (Networking Solutions)
a) LINUX / UNIX networks
b) SUN networks
c) CISCO devices (Routers, Switches, Firewalls, Cache Engine, RAS etc)
d) Bandwidth Manager software and hardware
e) Radio Links
f) Security Solutions
Design Services (Embedded Systems)
a) AVR family
b) MCS 51
c) ELECTRONIC SYSTEM DESIGN
Network Training
a) CISCO CCNA, CCNP
b) RED HAT LINUX
c) SUN SOLARIS
d) WINDOWS 2000, 2003
Netmax Technologies is a leader in education services and developer of innovative embedded solutions. To meet the demands of Post PC era Netmax provides complete solutions as well as design-to-order services to satisfy its customers.
EMBEDDED SYSTEM
What is Embedded System?
Embedded system employs a combination of software & hardware to perform a specific function. It is a part of a larger system which may not be a “computer”Works in a reactive & time constrained environment.
Any electronic system that uses a CPU chip, but that is not a general-purpose workstation, desktop or laptop computer is known as embedded system. Such systems generally use microprocessors; microcontroller or they may use custom-designed chips or both. They are used in automobiles, planes, trains, space vehicles, machine tools, cameras, consumer and office appliances, cell phones, PDAs and other handhelds as well as robots and toys. The uses are endless, and billions of microprocessors are shipper every year for a myriad of applications.
In embedded systems, the software is permanently set into a read-only memory such as a ROM or flash memory chip, in contrast to a general-purpose computer that loads its programs into RAM each time. Sometimes, single board and rack mounted general-purpose computers are called "embedded computers" if used to cont
Embedded System Applications :-
Consumer electronics, e.g., cameras, cell phones etc. Consumer products, e.g. washers, microwave ovens etc. Automobiles (anti-lock braking, engine control etc.) Industrial process controller & defense applications. Computer/Communication products, e.g. printers, FAX machines etc. Medical Equipments. ATMs Aircrafts
DIFFERENCE BETWEEN MICROPROCESSORS AND
MICROCONTROLLERS:
A Microprocessor is a general purpose digital computer central
processing unit(C.P.U) popularly known as CPU on the chip.
The Microprocessors contain no RAM, no ROM, and no I/P
O/P ports on the chip itself.
On the other hand a Microcontroller has a C.P.U(microprocessor)
in addition to a fixed amount of RAM, ROM, I/O ports and a timer
all on a single chip.
In order to make a Microprocessor functional we must add RAM,
ROM, I/O Ports and timers externally to them,i.e any amount of
external memory can be added to it.
But in controllers there is a fixed amount of memory which makes
them ideal for many applications.
The Microprocessors have many operational codes(opcodes) for
moving data from external memory to the C.P.U
Whereas Microcontrollers may have one or two operational codes.
DISADVANTAGES OF MICROPROCESSORS
OVER MICROCONTROLLERS
System designed using Microprocessors are bulky
They are expensive than Microcontrollers
We need to add some external devices such as PPI chip, Memory,
Timer/counter chip, Interrupt controller chip,etc. to make it
functional.
TYPES OF MICROCONTROLLER ARCHITECTURE:
There are two types of Microcontroller architecture designed for embedded system development. These are:
1)RISC- Reduced instruction set computer
2)CISC- Complex instruction set computer
DIFFERENCE BETWEEN CISC AND RISC:
CISC stands for Complex Instruction Set Computer. Most PC's use CPU based on this architecture. For instance Intel and AMD CPU's are based on CISC architectures. Typically CISC chips have a large amount of different and complex instructions. In common CISC chips are relatively slow (compared to RISC chips) per instruction, but use little (less than RISC) instructions. MCS-51 family microcontrollers based on CISC architecture.
RICS stands for Reduced Instruction Set Computer. The philosophy behind it is that almost no one uses complex assembly language instructions as used by CISC, and people mostly use compilers which never use complex instructions. Therefore fewer, simpler and faster instructions would be better, than the large, complex and slower CISC instructions. However, more instructions are needed to accomplish a task. Atmell’s AVR microcontroller based on RISC architecture.
PIC
MICROCONTROLLER
PIC 16 SERIES-PIC16F73
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
"Peripheral Interface Controller".
It is available in different configurations viz 8bit,16 bit,32 bit with instructions set
as given below :
Under 8 bit comes-PIC10 xxxx, PIC12 xxxx, PIC16 xxxx, PIC18 xxxx.(12 bit
instruction set)
Under 16 bit comes-PIC24H,DSPIC30,DSPIC33. (14 bit instruction set)
Under 32 bit comes-PIC32xxxx. (16 bit instruction set)
PICs are popular with 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.
Special Microcontroller Features:
• High performance RISC CPU.
• Only 35 single word instructions to learn.
• 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).
• Interrupt capability (up to 12 sources).
• Eight level deep hardware stack.
• Direct, Indirect and Relative Addressing modes.
• Processor read access to program memory.
• Power-on Reset (POR).
• Power-up Timer (PWRT) and Oscillator Start-up Timer (OST).
• Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable
operation.
• Programmable code protection
• Power saving SLEEP mode
• Selectable oscillator options
• In-Circuit Serial Programming (ICSP) via two pins.
Peripheral Features:
• Timer0: 8-bit timer/counter with 8-bit prescaler.
• Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP
via external crystal/clock.
• Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler.
• Two Capture, Compare, PWM modules
- Capture is 16-bit, max. resolution is 12.5 ns
- Compare is 16-bit, max. resolution is 200 ns
- PWM max. resolution is 10-bit.
• 8-bit, up to 8-channel Analog-to-Digital converter.
• Synchronous Serial Port (SSP) with SPI (Master mode) and I2C(Slave).
• Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI).
• Parallel Slave Port (PSP), 8-bits wide with external RD, WR and CS controls
(40/44-pin only).
• Brown-out detection circuitry for Brown-out Reset (BOR).
CMOS Technology:
• Low power, high speed CMOS FLASH technology.
• Fully static design.
• Wide operating voltage range: 2.0V to 5.5V.
• High Sink/Source Current: 25 Ma.
• Industrial temperature range.
• Low power consumption:
- < 2 mA typical @ 5V, 4 MHz
PIN DIAGRAM
PIN DESCRIPTION
MCLR-(pin 1)
PIC16F7X devices have a noise filter in the MCLR Reset path. The filter will detect and ignore small pulses. It should be noted that a WDT Reset does not drive MCLR pin low. The behavior of the ESD protection on the MCLR pin has been altered from previous devices of this family. Voltages applied to the pin that exceed its specification can result in both MCLR Resets and excessive current beyond the device specification during the ESD event. For this reason, Microchip recommends that the MCLR pin no longer be tied directly to VDD.
RESET
The PIC16F7X differentiates between various kinds of RESET:
Power-on Reset (POR) MCLR Reset during normal operation MCLR Reset during SLEEP WDT Reset (during normal operation) WDT Wake-up (during SLEEP) Brown-out Reset (BOR)Some registers are not affected in any RESET condion. Their status is unknown on POR and unchanged n any other RESET. Most other registers are reset to a RESET state” on Power-on Reset (POR), on the MCLR and WDT Reset, on MCLR Reset during LEEP, and Brown-out Reset (BOR). They are not affected by a WDT Wake-up, which is viewed as the resumption of normal operation. The TO and PD bits are set or cleared differently in different RESET situations, as indicated
PORTA –(pin 2 to 7)and the TRISA Register-
PORTA is a 6-bit wide, bi-directional port. The corresponding data direction register is TRISA. Setting a TRISA bit (= ‘1’) will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a Hi-Impedance
mode). Clearing a TRISA bit (= ‘0’) will make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin).
Reading the PORTA register reads the status of the pins, whereas writing to it will write to the port latch. All write operations are read-modify-write operations. Therefore, a write to a port implies that the port pins are read, the value is modified and then written to the port data latch.
GND –(pin 8)
Provide Ground to it.
OSC1/CLKIN-(pin 9)
Oscillator crystal input/external clock source input
OSC2/CLKOUT-(pin 10)
Oscillator crystal output. Connects to crystal or resonator in CrystalOscillator mode. In RC mode, the OSC2 pin outputs CLKOUTwhich has 1/4 the frequency of OSC1, and denotes the instructioncycle rate.
Oscillator:- CRYSTAL OSCILLATOR/CERAMIC RESONATORS In XT, LP or HS modes, a crystal or ceramic resonator is connected to the OSC1/CLKIN and OSC2/CLKOUT pins to establish oscillation. The PIC16F7X oscillator design requires the use of a parallel cut crystal. Use of a series cut crystal may give a frequency out of the crystal manufacturers specifications. When in HS mode, the device can accept an external clock source to drive the OSC1/CLKIN pin.
OSCILLATOR TYPES
The PIC16F7X can be operated in four different oscillator modes:
LP Low Power Crystal XT Crystal/Resonator
HS High Speed Crystal/Resonator RC Resistor/Capacitor
PORTC and the TRISC Register(pin 11 to 18)
PORTC is an 8-bit wide, bi-directional port. The corresponding data direction register is TRISC. Setting a TRISC bit (= ‘1’) will make the corresponding PORTC pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISC bit (= ‘0’) will
make the corresponding PORTC pin an output (i.e., put the contents of the output latch on the selected pin).
PORTC is multiplexed with several peripheral functions PORTC pins have Schmitt Trigger input buffers. When enabling peripheral functions, care should be taken in defining TRIS bits for each PORTC pin.
Vss(pin 19)
Ground reference for logic and I/O pins
Vdd(pin 20)
Positive supply for logic and I/O pins
PORTB and the TRISB Register(pin 21 to 28)
PORTB is an 8-bit wide, bi-directional port. The corresponding data direction register is TRISB. Setting a TRISB bit (= ‘1’) will make the corresponding PORTB pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISB bit (= ‘0’) will make the corresponding PORTB pin an output (i.e., put the contents of the output latch on the selected pin).
Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset.
CORE ARCHITECTURE
Figure 2.1: Showing a typical microcontroller device and its different subunits
The PIC architecture is distinctively minimalist. It is characterized by the
following features:
Separate code and data spaces (Harvard architecture)
A small number of fixed length instructions
Most instructions are single cycle execution (4 clock cycles), with single
delay cycles upon branches and skips
A single accumulator (W), the use of which (as source operand) is implied
(i.e. is not encoded in the opcode)
All RAM locations function as registers as both source and/or destination of
math and other functions.
A hardware stack for storing return addresses
A fairly small amount of addressable data space (typically 256 bytes),
extended through banking
Data space mapped CPU, port, and peripheral registers
The program counter is also mapped into the data space and writable (this is
used to implement indirect jumps).
Unlike most other CPUs, there is no distinction between memory space and
register space because the RAM serves the job of both memory and registers, and
the RAM is usually just referred to as the register file or simply as the registers
ELECTRICAL CHARACTERISTICS
Absolute Maximum Ratings †Ambient temperature under bias...................................... .-55 to +125°C
Storage temperature.................................................... -65°C to +150°C
Voltage on any pin with respect to VSS (except VDD, MCLR. and RA4) ......................................... -0.3V to (VDD + 0.3V)
Voltage on VDD with respect to VSS............................. -0.3 to +6.5V
Voltage on MCLR with respect to VSS (Note2)..........................0 to +13.5V
Voltage on RA4 with respect to Vss ..................................0 to +12V
Total power dissipation (Note 1)................................................1.0W
Maximum current out of VSS pin................................................300 mA
Maximum current into VDD pin .....................................................250 mA
Input clamp current, IIK (VI < 0 or VI > VDD)............................ ± 20 mA
Output clamp current, IOK (VO < 0 or VO > VDD) ...................... ± 20 mA
Maximum output current sunk by any I/O pin..................................25 mA
Maximum output current sourced by any I/O pin ............................25 mA
Maximum current sunk by PORTA, PORTB, and PORTE (combined) (Note 3).....................................200 mA
Maximum current sourced by PORTA, PORTB, and PORTE (combined) (Note 3) ..............................................200 mAMaximum current sunk by PORTC and PORTD (combined) (Note 3) ..................................................................200 mAMaximum current sourced by PORTC and PORTD (combined) (Note 3).............................................................200 mA
Note 1: Power dissipation is calculated as follows: Pdis = VDD x {IDD - Σ IOH} + Σ {(VDD - VOH) x IOH} + Σ(VOl x IOL)2: Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up. Thus,a series resistor of 50-100Ω should be used when applying a “low” level to the MCLR pin, rather than pullingthis pin directly to VSS.3: PORTD and PORTE are not implemented on the PIC16F73/76 devices.
PROGRAMMING OF PIC
COMPILER USED -
mikroC
Introduction to mikroC
mikroC is a powerful, feature rich development tool for PICmicros. It is designed to provide the programmer with the easiest possible solution for developing applications for embedded systems, without compromising performance or control.
mikroC IDE
PIC and C fit together well: PIC is the most popular 8-bit chip in the world, used in a wide variety of applications, and C, prized for its efficiency, is the natural choice for developing embedded systems. mikroC provides a successful match featuring highly advanced IDE, ANSI compliant compiler, broad set of hardware libraries, comprehensive documentation, and plenty of ready-to-run examples.
Features
mikroC allows you to quickly develop and deploy complex applications:
Write your C source code using the built-in Code Editor (Code and Parameter Assistants, Syntax Highlighting, Auto Correct, Code Templates, and more…)
Use the included mikroC libraries to dramatically speed up the development: data acquisition, memory, displays, conversions, communications… Practically all P12, P16, and P18 chips are supported.
Monitor your program structure, variables, and functions in the Code Explorer.
Generate commented, human-readable assembly, and standard HEX compatible with all programmers.
Inspect program flow and debug executable logic with the integrated Debugger.
Get detailed reports and graphs: RAM and ROM map, code statistics, assembly listing, calling tree, and more…
We have provided plenty of examples for you to expand, develop, and use as building bricks in your projects. Copy them entirely if you deem fit – that’s why we included them with the compiler.
Projects
mikroC organizes applications into projects, consisting of a single project file (extension .ppc) and one or more source files (extension .c). You can compile source files only if they are part of a project.
The project file carries the following information:
project name and optional description, target device, device flags (config word), device clock,
New Project
The easiest way to create project is by means of New Project Wizard, drop-down menu Project › New Project. Just fill the dialog with desired values (project name and description, location, device, clock, config word) and mikroC will create the appropriate project file . Also, an empty source file named after the project will be created by default. mikroC does not require you to have source file named same as the project, it’s just a matter of convenience.
Edit Project
Later, you can change project settings from the drop-down menu Project › Edit Project. You can rename the project, modify its description, change chip, clock, config word, etc.
To delete a project, simply delete the folder in which the project file (extension .ppc) is stored.
Add/Remove Files from Project
A project can contain any number of source files (extension .c). The list of relevant source files is stored in the project file (extension .ppc).
To add source file to your project, select Project › Add to Project from the drop-
down menu, or click the Add to Project Icon . Each added source file must be self-contained, i.e. it must have all the necessary definitions after preprocessing.
To remove file(s) from your project, select Project › Remove from Project from the
drop-down menu, or click the Remove from Project Icon .
Note: For inclusion of the header files (extension .h), use the preprocessor directive #include. See File Inclusion for more information.
Extended functionality of the Project Files tab
By using the Project Files' new features, you can reach all the output files (.lst, .asm) by a single click. You can also include in project the library files (.mcl), for libraries, either your own or compiler default, that are project-specific.
Libraries (.mcl) now have different, more compact format, compared to mikroC version 2. This, however, means that library formats are now incompatible. The users that are making transition from version 2 to 5, must re- build all their previously written libraries in order to use them in the new version. All the source code written and tested in previous versions should compile correctly on version 5.0, except for the asm{} blocks, which are commented in the asm section of help.
Project Level Defines:
Project Level Defines(.pld) files can also be added to project. Project level define files enable you to have defines that are visible in all source files in the project. A file must contain one definition per line in the following form:
<symbol>[=[<value>]] <symbol (a,b)>[=[<value>]]
Define a macro named symbol. To specify a value, use =<value>. If =<value> is omitted, 1 is assumed. Do not enter white-space characters immediately before "=". If a white- space character is entered immediately after "=", the macro is defined as zero token. This option can be specified repeatedly. Each appearance of symbol will be replaced by the value before compilation.
There are two predefined project level defines see predefined project level defines..
Also mikroC has some pre defined functions:
Commonly used is
1). Delay_ms(time)-it provides a delay of spcified time in ms.
Its internal code is similar to code given below:
Void delay_ms()
{int I;
While (i !=0)
{
i--;
}
Also PIC has a internal TRIS register which controls the flow of insructions from the corresponding port.
PROGRAMMING AND INTERFACING
Advantages of C over Assembly language programming:
Knowledge of the processor instruction set is not required.
Details like register allocation and addressing of memory and data is managed
by the compiler.
Programs get a formal structure and can be divided into separate functions.
Programming and program test time is drastically reduced, this increases
efficiency.
Keywords and operational functions can be used that come closer to how
humans think.
The supplied and supported C libraries contain many standard routines such as
numeric conversions.
Reusable code: Existing program parts can be more easily included into new
programs, because of the comfortable modular program construction
techniques.
The C language based on the ANSI standard is very portable. Existing
programs can be quickly adapted to other processors as needed.
PROJECT NO-1
LED INTERFACING AND ITS BLINKING(PORT
PROGRAMMING)
the interfacing of LED is shown in the figure above.it is given Vcc through
resistors of 330E.
also a darlington pair IC is also used i.e.ULN 2803 which shift the dc level of
volage coming from port of pic microcontroller.
Now to glow the desired LED ,proper hexadecimal code for its binary is
programmed in pic.eg.to glow alternative LED’s the binary code will be10101010
and its corresponding hexadecimal code will be 0xAA.
So,0xAA is fed to controller with coding.
Also PIC has a internal TRIS register which controls the flow of insructions from the corresponding port i.ee PORT will behave as input(if =1) and as output(if=0).
CODING FOR BLINKING
void main()
{
PORTC = 0; // Initialize PORTC
TRISC = 0; // Configure PORTC as output
while(1)
{
PORTC = OxAA; // gives code 10101010 to PORTC
Delay_ms(1000); // one second delay
}}
Thus LED Blinking practical is done sucessfully.
PROJECT NO-2
SEVEN SEGMENT INTERFACING AND DISPLAY
A Seven segment display consists of seven LED’s arranged in pattern of digit like
8
We use a bcd to seven segment decoder which saves pin of microcontroller from
seven(one for each Led) to four.So we have to give bcd code for desired digit to be
displayed on it.
Now also we can display more then one seven segment display simultaneously.but
it will take a number of pins of controller.So we use two pins from controller to
control the display of seven segment one by one from same port such that it
appears to be displaying simultaneously.
Tdis is done by providing a very small delay such that our eyes cant even detect
the change over from one display to another.
CODING FOR DISPLAY
void main()
{
TRISB=0xf0;
TRISC=0xf0;
PORTC=0x00;
while(1)
{
PORTB=0x00 ; //code for 0
delay_ms(1000);
PORTB=0x08 ; //code for 1
delay_ms(1000);
PORTB=0x04 ; //code for 2
delay_ms(1000);
PORTB=0x0c ; //code for 3
delay_ms(1000);
PORTB=0x02 ; //code for 4
delay_ms(1000);
PORTB=0x09 ; //code for 5
delay_ms(1000);
PORTB=0x06 ; //code for 6
delay_ms(1000);
PORTB=0x0e ; //code for 7
delay_ms(1000);
PORTB=0x01 ; //code for 8
delay_ms(10000);
PORTB=0x09 ; //code for 9
delay_ms(10000);
}
}
the above program will display 0 to 9 on one seven segment display with a delay of
one second between it.\
NOW TO DISPLAY ON FOUR DISPLAYS CONNECTED..
CODE IS
void main()
{
TRISB=0xf0;
TRISC=0xf0;
PORTC=0x00;
while(1)
{
PORTB=0x00 ; //code for 0
PORTC=0xfe ; //DISPLAYS ON FIRST 11111110
delay_ms(100);
PORTB=0x08 ; //code for 1
PORTC=0xfd ; //DISPLAYS ON SECOND 11111101
delay_ms(100);
PORTB=0x04 ; //code for 2
PORTC=0xfb ; //DISPLAYS ON THIRD 11111011
delay_ms(100);
PORTB=0x0C ; //code for 3
PORTC=0xf7 ; //DISPLAYS ON FIRST 11110111
delay_ms(100);
}
}
Thus program for both single seven segment and multiple seven segment displays
has been studied.
PROJECT NO-3
INTERFACING AND CONTROL OF STEPPER MOTOR WITH PIC 16F73
Stepper motor are those which rotates in steps.like all motors it is also based on
electromagnetic induction i.e. electric field produces a magnetic field whose
variation causes a torque which rotates the motor.
A stepper motor is a brushless, synchronous electric motor that can divide a full
rotation into a large number of steps. The motor's position can be controlled
precisely, without any feedback mechanism (see open loop control). Stepper
motors are similar to switched reluctance motors, which are very large stepping
motors with a reduced pole count, and generally are closed-loop commutated.
Fundamentals of Operation
Stepper motors operate much differently from normal DC motors, which rotate when voltage is applied to their terminals. Stepper motors, on the other hand, effectively have multiple "toothed" electromagnets (a.k.a. phases) arranged around a central gear-shaped piece of iron. The electromagnets are energized by an external control circuit, such as a microcontroller. To make the motor shaft turn, first one electromagnet is
given power, which makes the gear's teeth magnetically attracted to the electromagnet's teeth. When the gear's teeth are thus aligned to the first electromagnet, they are slightly offset from the next electromagnet. So when the next electromagnet is turned on and the first is turned off, the gear rotates slightly to align with the next one, and from there the process is repeated. Each of those slight rotations is called a "step." In that way, the motor can be turned a precise angle.
Now to run the motor we have to feed the binary code to turn on the current of that winding…
For pair 1st-00000011(binary)-0x03
For pair 2nd-00000110(binary)-0x06
For pair 3rd -000001100(binary)-0x0c
For pair 4th -00011000(binary)-0x09
CODE IS
void forward();
void reverse();
int i;
void main()
{
TRISB=0xf0;
PORTB=0x00;
while(1)
{
forward();
delay_ms(400);
reverse();
delay_ms(400);
}
}
void forward()
{
for(i=0;i<=50;i++)
{
PORTB=0x03;
delay_ms(70);
PORTB=0x06;
delay_ms(70);
PORTB=0x0c;
delay_ms(40);
PORTB=0x09;
delay_ms(40);
}
}
void reverse()
{
for(i=0;i<=50;i++)
{
PORTB=0x09;
delay_ms(40);
PORTB=0x0c;
delay_ms(40);
PORTB=0x06;
delay_ms(40);
PORTB=0x03;
delay_ms(40);
}
}
The above code will rotate the motor first in forward direction and then in reverse
direction.
Thus,stepper motor has been studied successfully.
PROJECT NO-4
LCD INTERFACING AND DISPLAY
LCD stands for Liquid Crystal Display.to run it via PIC 16F73,we need command
signals and vcc to drive it.now the signal that is required to display character is
produced by an IC which is already embedded on it.its name is HD44780.
HD44780+LCD=an intelligent controller.
The function of each of the connections is shown in the table below:-
Pins 1 & 2 are the power supply lines, Vss & Vdd. The Vdd pin should be connected
to the positive supply & Vss to the 0V supply or ground.
Although the LCD module data sheets specify 5V D.C. supply (at only a few
milliamps), supplies of 6V & 4.5V both work well, and even 3V is sufficient for some
modules. Consequently, these modules can be effectively and economically powered
by batteries.
Pin 3 is a control pin, Vee, which is used to alter the contrast of the display. Ideally,
these pin should be connected to a variable voltage supply. A preset potentiometer
connected between the power supply lines, with its wiper connected to the contrast pin
is suitable in many cases, but be aware that some modules may require a
negative potential; as low as 7V in some cases. For absolute simplicity, connecting
this pin to 0V will often suffice.
PIN NO. NAME FUNCTION
1 Vss Ground
2 Vdd +ve supply
3 Vee contrast
4 RS Register select
5 R/W Read/Write
6 E Enable
7 D0 Data Bit 0
8 D1 Data Bit 1
9 D2 Data Bit 2
10 D3 Data Bit 3
11 D4 Data Bit 4
12 D5 Data Bit 5
13 D6 Data Bit 6
14 D7 Data Bit 7
Three command control inputs. When this line is low, data bytes transferred to the display are treated as commands, and data bytes read from the display indicate its status. By setting the RS line high, character data can be transferred to and from the module.
Pin 5 is (R/W) line. This line is pulled low in order to write commands or character data to the module, or pulled high to read character data or status information from its registers.
Pin 6 is Enable (E) line. This input is used to initiate the actual transfer of commands or character data between the module and the data lines. When writing to the display, data is transferred only on the high to low transition of this signal. However, when reading from the display, data will become available shortly after the low to high transition and remain available until the signal falls low again.
Pins 7 to 14 are the eight data bus lines (D0 to D7). Data can be transferred to and from the display, either as a single 8-bit byte or as two 4-bit “nibbles”. In the latter case, only the upper four data lines (D4 to D7) are used. This $-bit mode is beneficial when using a microcontroller, as fewer I/O lines are required.
Connections are shown as below
CODING
void main()
{
TRISB = 0; // PORTB is output
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
Lcd_Out(1, 5,"HELLO"); // Print text to LCD, 1nd row, 5tH column
}
The above code will display HELLO on LCD.
The functions like Lcd_Init(),Lcd_cmd,Lcd_out are predefined functions in
mikroC which initialize,gives command and displays respectively.
Now also it is possible to scroll the characters on LCD. I ts code is as follows:
Coding for scrolling
char *text = "SAGAR" ;
char *text1 = "KATHURIA" ;
void main()
{
TRISB = 0; // PORTB is output
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
Lcd_Out(1, 5,text); // Print text to LCD, 2nd row, 1st column
Lcd_Out(2, 5,text1);
while(1)
{
Lcd_Cmd(LCD_SHIFT_LEFT);
delay_ms(1000);
} }
It will shift the character to the left with a delay of 1 sec between it.
Thus LCD display and scroll is studied successfully.
PROJECT NO-5
BUILT IN ADC OF PIC16F73(TEMPERATURE MONITORING)
PIC16F73 consists of 5 internal ADC .
AD are available in different configurations according to their bit channels.viz 8
bit(costs Rs.120),10bit(costs Rs.600),12 bit(costs Rs.1200-2000) ,14 bit(costs
Rs.2000-4000),16bit(costs Rs.4000-25000),24bit(costs >25000).
These are externally connected to microcontroller like AT89s51 which don’t have
inbuilt ADC.
Now as PIC 16xxx has got the feature of inbuilt ADC.so,there is no need to
connect externally.PIC16XXX is featured with 8 bit ADC.
So can convert an analog value to 8 bit binary or from 0 to 255 in decimal range.
The 8-bit analog-to-digital (A/D) converter module has five inputs for the PIC16F73/76 and eight for the PIC16F74/77.The A/D allows conversion of an analog input signal to a corresponding 8-bit digital number. The output of the sample and hold is the input into the converter, which generates the result via successive approximation. Theanalog reference voltage is software selectable to either the device’s positive supply voltage (VDD), or the voltage level on the RA3/AN3/VREF pin.The A/D converter has a unique feature of being able to operate while the device is in SLEEP mode. To operate in SLEEP, the A/D conversion clock must be derived from the A/D’s internal RC oscillator.The A/D module has three registers. These registersare:• A/D Result Register (ADRES)• A/D Control Register 0 (ADCON0)• A/D Control Register 1 (ADCON1)The ADCON0 register, shown in Register 11-1, controls the operation of the A/D module. The ADCON1 register, shown in Register 11-2, configures the functions of the port pins. The port pins can be configured as analog inputs (RA3 can also be a voltage reference), or as digital I/O.
ADC HARDWARE CONNECTION
From 4th pin we are gaetting Analog input.
ADCON0 REGISTER (ADDRESS 1Fh)
R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 U-0 R/W-0
ADCS1 ADCS0 CHS2 CHS1 CHS0 GO/DONE -------- ADONbit 7 bit 0
bit 7-6 ADCS1:ADCS0: A/D Conversion Clock Select bits00 = FOSC/201 = FOSC/8
10 = FOSC/3211 = FRC (clock derived from the internal A/D module RC oscillator)bit 5-3 CHS2:CHS0: Analog Channel Select bits000 = channel 0, (RA0/AN0)001 = channel 1, (RA1/AN1)010 = channel 2, (RA2/AN2)011 = channel 3, (RA3/AN3)100 = channel 4, (RA5/AN4)101 = channel 5, (RE0/AN5)(1)110 = channel 6, (RE1/AN6)(1)111 = channel 7, (RE2/AN7)(1)bit 2 GO/DONE: A/D Conversion Status bitIf ADON = 1:1 = A/D conversion in progress (setting this bit starts the A/D conversion)0 = A/D conversion not in progress (This bit is automatically cleared by hardware whenthe A/D conversion is complete)bit 1 Unimplemented: Read as '0'bit 0 ADON: A/D On bit1 = A/D converter module is operating0 = A/D converter module is shutoff and consumes no operating current
ADCON1 REGISTER (ADDRESS 9Fh)
U-0 U-0 U-0 U-0 U-0 R/W-0 R/W-0 R/W-0— — — — — PCFG2 PCFG1 PCFG0
bit 7-3 Unimplemented: Read as '0'bit 2-0 PCFG2:PCFG0: A/D Port Configuration Control bits.
PCFG2:PCFG0 RA0 RA1 RA2 RA5 RA3 RE0(1) RE1(1) RE2(1) VREF
000 A A A A A A A A VDD
001 A A A A VREF A A A RA3010 A A A A A D D D VDD
011 A A A A VREF D D D RA3100 A A D D A D D D VDD
101 A A D D VREF D D D RA311x D D D D D D D D VDD
A = Analog inputD = Digital I/O
So,ADC will be provided analog input from different channels and
correspondingly these registers are set.
The following steps should be followed for doing anA/D conversion:1. Configure the A/D module:• Configure analog pins / voltage reference /and digital I/O (ADCON1)• Select A/D input channel (ADCON0)• Select A/D conversion clock (ADCON0)• Turn on A/D module (ADCON0)2. Configure A/D interrupt (if desired):• Clear ADIF bit• Set ADIE bit• Set PEIE bit• Set GIE bit
3. Wait the required acquisition time.4. Start conversion:• Set GO/DONE bit (ADCON0)5. Wait for A/D conversion to complete, by either:• Polling for the GO/DONE bit to be cleared(interrupts disabled)OR• Waiting for the A/D interrupt6. Read A/D result register (ADRES), clear bitADIF if required.7. For next conversion, go to step 1 or step 2, asrequired. The A/D conversion time per bit isdefined as TAD. A minimum wait of 2TAD isrequired before next acquisition starts
Now,coding to display voltage through temperature sensor
unsigned char ch;
unsigned int adc_rd;
char *text;
long tlong;
void main()
{
INTCON = 0; // disable all interrupts
TRISB = 0; // PORTB is output
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
LCD_Cmd(LCD_CURSOR_OFF); // send command to LCD (cursor off)
LCD_Cmd(LCD_CLEAR); // send command to LCD (clear LCD)
text = "netmax"; // assign text to string
LCD_Out(1,1,text); // print string a on LCD, 1st row, 1st column
text = "LCD example"; // assign text to string
LCD_Out(2,1,text); // print string a on LCD, 2nd row, 1st column
ADCON1 = 0x82; // configure VDD as Vref, and analog channels
TRISA = 0xFF; // designate PORTA as input delay_ms(7000);
text = "voltage:"; // assign text to string
while (1)
{
delay_ms(300) ;
adc_rd = ADC_read(0); // get ADC value from 2nd channel
LCD_Out(2,1,text); // print string a on LCD, 2nd row, 1st column
tlong = (long)adc_rd * 4610; // covert adc reading to milivolts
tlong = tlong / 255; // 0..1023 -> 0-5000mV
ch = tlong / 1000; // extract volts digit
LCD_Chr(2,9,48+ch); // write ASCII digit at 2nd row, 9th column
LCD_Chr_CP('.');
ch = (tlong / 100) % 10; // extract 0.1 volts digit
LCD_Chr_CP(48+ch); // write ASCII digit at cursor point
ch = (tlong / 10) % 10; // extract 0.01 volts digit
LCD_Chr_CP(48+ch); // write ASCII digit at cursor point
ch = tlong % 10; // extract 0.001 volts digit
LCD_Chr_CP(48+ch); // write ASCII digit at cursor point
LCD_Chr_CP('V');
delay_ms(3000) ;
delay_ms(1);
}
}
PROJECT NO-6
TO STUDY SWITCHING ACTION OF PIC PINS.
As in AT89s51,the way of addressing pins is by p0.0,p0.1…..so on.
Similarly in PIC it is possible to address pins using
Syntax:
PORT( NAME).F(0 to 7)
Now pin can be put ON or OFF according to via resistor.
Internally,when pin is high its flip flop is sat.when external switch is closed ,it
forces no current or voltage to enter to pin and also lowers the pin from 1 to 0.
Thus when switch is pressed ,the pin becomes zero.so ,implementing this in
practical.
The swiches whose one end are connected to pins of nontroller are shown on next
page
The coding will be as follos:
#define s0 PORTC.F0
#define s1 PORTC.F1
#define s2 PORTC.F2
#define s3 PORTC.F3
#define s4 PORTC.F4
void main()
{
TRISB=0x00; \\ PORT B AS OUTPUT
TRISC=0xff; \\PORT C as input
PORTC=0xff; \\ ALL F/F’S TO SET
do
{
if(s0==0) \\1st switch is pressed
{
PORTB=0x80; \\1st LED glows
delay_ms(600);
}
if(s1==0) \\2nd switch is pressed
{
PORTB=0x40; \\2nd LED glows
delay_ms(600);
}
if(s2==0) \\3rd switch is pressed
{
PORTB=0x20; \\3rd LED glows
delay_ms(600);
}
if(s3==0) \\4th switch is pressed
{
PORTB=0x10; \\4th LED glows
delay_ms(600);
}
else
{
PORTB=0xff;
}}
while(1);
}
Thus switching action is studied.
PROJECT NO-7
INTERFACING OF KEYBOARD MATRIX
As in last practical,we use one switch per pinof controller.So,to use 8 pins for 8
switches.
While if it is desired to have more options for a pin,a matrix is formed in which
row and column are made such that each pin can contol more than one switch or
vice versa.
h/w connection are
The coding for keyboard (4*4) matrix is as follows:
#define row0 PORTC.F0
#define row1 PORTC.F1
#define row2 PORTC.F2
#define row3 PORTC.F3
#define col0 PORTC.F4
#define col1 PORTC.F5
#define col2 PORTC.F6
#define col3 PORTC.F7
void main()
{
TRISB=0x00;
TRISC=0xff;
PORTC=0xff;
LCD_INIT(&PORTB);
LCD_OUT(1,1,"SWITCH=");
do
{
LCD_OUT(1,8," ");
if(row0==0 && col0==0)
{
lcd_out(1,8,"k0");
delay_ms(600);
}
if(row0==0 && col1==0)
{
lcd_out(1,8,"k1");
delay_ms(600);
}
if(row0==0 && col2==0)
{
lcd_out(1,8,"k2");
delay_ms(600);
}
if(row0==0 && col3==0)
{
lcd_out(1,8,"k3");
delay_ms(600);
}
if(row1==0 && col0==0)
{
lcd_out(1,8,"k4");
delay_ms(600);
}
if(row1==0 && col1==0)
{
lcd_out(1,8,"k5");
delay_ms(600);
}
if(row1==0 && col2==0)
{
lcd_out(1,8,"k6");
delay_ms(600);
}
if(row1==0 && col3==0)
{
lcd_out(1,8,"k7");
delay_ms(600);
}
if(row2==0 && col0==0)
{
lcd_out(1,8,"k8");
delay_ms(600);
}
if(row2==0 && col1==0)
{
lcd_out(1,8,"k9");
delay_ms(600);
}
if(row2==0 && col2==0)
{
lcd_out(1,8,"k10");
delay_ms(600);
}
if(row2==0 && col3==0)
{
lcd_out(1,8,"k11");
delay_ms(600);
}
else
{Lcd_out(1,8," ");}
}
while(1);
}
Tfus,the keyboard matrx practical is performed.
PROJECT NO-8
SERIAL COMMUNICATION(B/W PC AND MICROCONTROLLER)
To send data via single line through a bit stream is known as serial communication.
Reception is of type SIPO-Serial Input Parallel Output.
Transmission is of type PISO-Parallel Input Serial Output.
Clock used in serial communication is called BAUD RATE.
PIC has two buffers and it allows full duplex communication.to change settings we
have to re configure TXSTA register
The Universal Synchronous Asynchronous Receiver Transmitter (USART) module is one of the two serial I/O modules. (USART is also known as a Serial Communications Interface or SCI.) The USART can be configuredas a full duplex asynchronous system that can communicate with peripheral devices, such as CRT terminals and personal computers, or it can be configured as a half duplex synchronous system that can communicate with peripheral devices, such as A/D or D/A integratedcircuits, serial EEPROMs, etc.
The USART can be configured in the following modes:• Asynchronous (full duplex)• Synchronous - Master (half duplex)• Synchronous - Slave (half duplex)
Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have to be set in order to configure pins RC6/TX/CK and RC7/RX/DT as the Universal Synchronous Asynchronous Receiver Transmitter.
TXSTA: TRANSMIT STATUS AND CONTROL REGISTER (ADDRESS 98h
R/W-0 R/W-0 R/W-0 R/W-0 U-0 R/W-0 R-1 R/W-0
CSRC TX9 TXEN SYNC — BRGH TRMT TX9D
bit 7 CSRC: Clock Source Select bit Asynchronous mode: Don’t care Synchronous mode: 1 = Master mode (Clock generated internally from BRG) 0 = Slave mode (Clock from external source)
bit 6 TX9: 9-bit Transmit Enable bit 1 = Selects 9-bit transmission 0 = Selects 8-bit transmissionbit 5 TXEN: Transmit Enable bit 1 = Transmit enabled 0 = Transmit disabledNote: SREN/CREN overrides TXEN in SYNC mode.
bit 4 SYNC: USART Mode Select bit 1 = Synchronous mode 0 = Asynchronous mode
bit 3 Unimplemented: Read as '0'
bit 2 BRGH: High Baud Rate Select bit Asynchronous mode: 1 = High speed 0 = Low speed Synchronous mode: Unused in this mode
bit 1 TRMT: Transmit Shift Register Status bit 1 = TSR empty 0 = TSR full
bit 0 TX9D: 9th bit of transmit data. Can be parity bit
now in mikroC UART terminal also work as shown as
Now coding
1).to transmit data..
void main()
{
usart_init(2400);
while(1)
{
usart_write('s');
usart_write('a');
usart_write('g');
usart_write('a');
usart_write('r');
delay_ms(600);
}
}
2).to transmit as well as read
unsigned int i;
void main()
{
usart_init(2400);
while(1)
{
if(usart_data_ready() )
{
i= usart_read();
usart_write('i');
}
usart_write('s');
usart_write('a');
usart_write('g');
usart_write('a');
usart_write('r');
delay_ms(600);
}
3). To send an array
unsigned char arr[] =("sagar$");
void display(unsigned char*s);
void main()
{
Usart_Init(2400);
while(1)
{
display(arr);
delay_ms(600);
}
}
void display(unsigned char*s)
{
while(*s!='$')
{
usart_Write(*s);
delay_ms(10);
s++;
}
}
Thus serial communication has been studied successfully.
POWER SYSTEM DESIGN
First part of electronics ckts. is power. The main power supply is in AC but mostly
electronic ckts. work with DC. So a system is required to convert ac to dc and
these sources should able to produce stable supplies.
Power supplies may be used in. may be of different types such as regulated,
unregulated, smps etc.
Unregulated power supplies
These are the power supplies in which the out put is not constant. That it is
varies with input voltage, load, and also effected by the environment conditions
such as temperature, etc. so these are the variable supplies. Commonly these
supplies are not employed as there efficiency is very less. The unregulated
power can be obtained using rectifying circuit after AC supply.
Regulated power supplies
These are the power supplies in which the output voltage is constant, i.e. the
out put voltage is independent of the input voltage, load and other external
conditions. So to obtain the regulated voltage using different regulators. The
regulator voltage is mainly the DC voltage, it may AC to or DC to DC voltage.
A better approach to power supply design is to use enough capacitance to
reduce ripple to low level, then use an active feedback circuit to eliminate the
remaining ripple and dependence of output voltage on input, load and
environment conditions. These active devices are known as Regulators. These
regulators can be used to produce negative and positive voltage of required
value.
The voltage regulators are of three types:-
1) Constant positive voltage regulators
2) Constant negative voltage regulators
3) Variable voltage regulators
Constant positive voltage regulators:- These are the regulators which are able
to produce positive and constant voltage. Some of them are given below:-
S. no. Name of regulator Output voltage
1 LM 7805 5v
2 LM 7810 10v
3 LM 7812 12v
4 LM 7815 15v
These regulators are used according to the required voltage need.
Constant negative voltage regulators:- These are also the constant output voltage
regulator but there output is negative in polarity. These regulators are also
employed according to voltage requirements. Some of them are given below with
there outputs:-
S. no Name of regulator Output voltage
1 LM7905 -5v
2 LM7910 -10v
3 LM7912 -12v
4 LM7915 -15v
Variable voltage regulators:- These are the regulator whose output voltage can be
varied according to the desired need. These regulators again of two types i.e.:-
Positive
Negative
The output of these regulators can be varied by varying the resistance of the
variable resistance which is connected to the adjustable pin the regulators. So these
are the most commonly used regulators in the electronic industry as wide range of
stable voltage can be obtained from single chip by varying the resistance connected
to the adjustable pin of the regulators. The most commonly variable regulators
are:-
LM317 (it is positive regulator)
LM 337(it is negative regulator)
There description is given below:-
LM317 3-Terminal Adjustable Regulator:-
General Description:
The LM317 series of adjustable 3-terminal positive voltage regulators is capable of
supplying in excess of 1.5A over a 1.2V to 37V output range. They are
exceptionally easy to use and require only two external resistors to set the output
voltage. Further, both line and load regulation is better than standard fixed
regulators. Also, the LM117 is packaged in standard transistor packages which are
easily mounted and handled. In addition to higher performance than fixed
regulators, theLM317 series offers full overload protection available only in IC’s.
Included on the chip are current limit, thermal overload protection and safe area
protection. All overload protection circuitry remains fully functional even if the
adjustment terminal is disconnected. Normally, no capacitors are needed unless the
device is situated more than 6 inches from the input filter capacitors in which case
an input bypass is needed. An optional output capacitor can be added to improve
transient response.
The adjustment terminal can be bypassed to achieve very high ripple rejection
ratios which are difficult to achieve with standard voltage, supplies of several
hundred volts can be regulated as long as the maximum input to output differential
is not exceeded, i.e., avoid short-circuiting the output.
Also, it makes an especially simple adjustable switching regulator, a
programmable output regulator, or by connecting a fixed resistor between the
adjustment pin and output, theLM317 can be used as a precision current regulator.
Supplies with electronic shutdown can be achieved by clamping the adjustment
terminal to ground which programs the output to 1.2V where most loads draw little
current.
Typical application:
U 1L M 3 1 7 / C Y L
V I N3
ADJ
1
V O U T2
R 12 2 0 E
C 1. 1 u F
C 2. 1 u F
R 25 k
VOUTVIN
Features
1. Guaranteed 1% output voltage tolerance (LM317A)
2. Guaranteed max. 0.01%/V line regulation (LM317A)
3. Guaranteed max. 0.3% load regulation (LM317)
4. Guaranteed 1.5A output current
5. Adjustable output down to 1.2V
6. Current limit constant with temperature
7. P+ Product Enhancement tested
8. 80 dB ripple rejection
9. Output is short-circuit protected
Packages of LM317
Application Hints:
In operation, the LM317
develops a nominal 1.25V
reference voltage, VREF,
between the output and
adjustment terminal. The
reference voltage is impressed
across program resistor R1 and, since the voltage is constant, constant current I1
then flows through the output set
resistor R2, giving an output voltage of
Since the 100μA current from the adjustment terminal represents an error term, the
LM317 was designed to minimize IADJ and make it very constant with line and
load changes. To do this, all quiescent operating current is returned to the output
establishing a minimum load current requirement. If there is insufficient load on
the output, the output will rise.
PROTECTION DIODES:-When external capacitors are used with any IC regulator it is sometimes necessary
to add protection diodes to prevent the capacitors from discharging through low
current points into the regulator. Most 10μF capacitors have low enough internal
series resistance to deliver 20A spikes when shorted. Although the surge is short,
there is enough energy to damage parts of the IC. When an output capacitor is
connected to a regulator and the input is shorted, the output capacitor will
discharge into the output of the regulator. The discharge current depends on the
value of the capacitor, the output voltage of the regulator, and the rate of decrease
of VIN. In the LM317, this discharge path is through a large junction that is able to
sustain 15A surge with no problem. This is not true of other types of
The bypass capacitor on the adjustment terminal can discharge through a low
current junction. Discharge occurs when either the input or output is shorted.
Internal to the LM317 is a 50resistor which limits the peak discharge current.
No protection is needed for output voltages of 25V or less and 10μF capacitance.
Figure 3 shows an LM317 with protection diodes included for use with outputs
greater than 25V and high values of output capacitance.
Bench supply diagram
L 2
I N D U C TO R A U D I O _ 0
1234
56
U 6
L M 3 3 7 / TO 2 2 0
ADJ
1
V I N2
V O U T3
J 7
C O N 3
123-V S
D 41 N 4 0 0 7
12
D 3
1N40
0712
C 8
2 2 0 0 u F 5 0 V
C 1 42 2 0 0 u F 5 0 V
J 8
C O N 3
123
C12
10uF
25V T
ANT
D 51 N 4 0 0 7
1 2
C 1 5
470u
F 50V
C 1 1
1 0 4
D 21 N 4 0 0 7
12
R 8
R
C 1 71 0 4
R 1 7
R
C 9
470u
F 50V
U 5L M 3 1 7 / TO 2 2 0
V I N3
ADJ
1
V O U T2
C13
10uF
25V T
ANT
-V S
R16
1K 1W
R12
1K 1W
C 1 0
C A P
- +
B R 1B R I D G E
2
1
4
3
C 1 6C A P
R 1 0P O TR 9
R
R 1 1
R
R 1 4P O TR 1 3
R
R 1 5
R
L 1
I N D U C TO R A U D I O _ 0
123 4
56
V S
BIBLIOGRAPHY
Wikipedia MicroC Manuals www.talkingelectronics.com www.howstuffworks.com The Art of Electronics (Book)