Internship training report
-
Upload
gheethu-maria-joy -
Category
Documents
-
view
526 -
download
0
Transcript of Internship training report
Industrial training report
Dept.of ECE, VJCET 1
CHAPTER 1
INTRODUCTION
1.1 WHAT IS A MICROCONTROLLER?
Basically, a microcontroller is a device which integrates a number of the components of a
microprocessor system onto a single microchip and optimised to interact with the outside world
through on-board interfaces; i.e. it is a little gadget that houses a microprocessor, ROM (Read
Only Memory), RAM (Random Access Memory), I/O (Input Output functions), and various
other specialized circuits all in one package. On the other hand, a microprocessor is normally
optimised to co-ordinate the flow of information between separate memory and peripheral
devices which are located outside itself. Connections to a microprocessor include address,
control and data busses that allow it to select one of its peripherals and send to or retrieve data
from it. Because a microcontrollers processor and peripherals are built on the same silicon, the
devices are self-contained and rarely have any bus structures extending outside their packages.
So a microcontroller incorporates onto the same microchip the following components:
The CPU core
Memory (both ROM and RAM)
Parallel digital I/O
Microcontrollers will also combine other devices such as:
A Timer module to allow the microcontroller to perform tasks for certain time periods.
A serial I/O port to allow data to flow between the microcontroller and other devices such
as a PC or another microcontroller.
An ADC to allow the microcontroller to accept analogue input data for processing.
1.2 WHAT IS AN EMBEDDED SYSTEM?
An embedded system is some combination of computer hardware and software, either
fixed in capability or programmable, that is specifically designed for a particular kind of
application device. Industrial machines, automobiles, medical equipment, cameras, household
appliances, airplanes, vending machines, and toys (as well as the more obvious cellular phone
and PDA) are among the myriad possible hosts of an embedded system. Embedded systems that
are programmable are provided with a programming interface, and embedded systems
Industrial training report
Dept.of ECE, VJCET 2
programming is a specialized occupation. Also, an embedded system is a special-purpose
computer system designed to perform one or a few dedicated functions, sometimes with real-
time computing constraints. It is usually embedded as part of a complete device including
hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal
computer, can do many different tasks depending on programming.
1.3 CISC and RISC PROCESSORS
1.3.1 CISC Processors
Complex Instruction Set Computing such as 8051, 8085, x86. More no. of instructions and they
are more complex. The control unit and the instruction decoder occupy most of chip space.
Reduced space for registers.
1.3.2 RISC Processors
Reduced Instruction System Computing such as PIC, Power PC. The number of instructions
is minimized. Addressing modes are fewer. Memory reference instructions are minimized
Processing is register intensive. Each instruction is executed in a single cycle .
1.4 HARVARD AND VON NEUMANN ARCHITECTURES
The Von Neumann architecture is representative of most computer architectures. The most
distinguishing feature of the Von Neumann computer is that it stores both data and instruction
information in the same memory. The Harvard architecture computer stores instructions and data
in separate memory. Many microcontroller architectures are Harvard architectures.
Figure 1.4 VON-NEUMANN AND HARDVARD ARCHITECTURES
Industrial training report
Dept.of ECE, VJCET 3
CHAPTER 2
MEMORY ORGANISATION
1. Three memory blocks
2. Program memory – 14 bit
3. Data memory – 8 bit
4. Internal EEPROM data memory -8 bit
2.1 CPU REGISTERS
Working register
7 0
Status register
IRP RP1 RP0 TO PD Z DC C/B
7 0
Bank Switching
RP1 RP0 BANK
0 0 BANK0
0 1 BANK1
1 0 BANK2
1 1 BANK3
Industrial training report
Dept.of ECE, VJCET 4
CHAPTER 3
PIC PIN DIAGRAM AND 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
a l te red f rom previous devices of th i s fami l y. Vol t ages appl ied to the p in
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)
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 Crystal
Figure 3.1 Pin diagram of PIC
Industrial training report
Dept.of ECE, VJCET 5
CHAPTER 4
INSTRUCTION SET CLASSIFICATION
Single bit manipulations
BCF f,b :- Clear bit b of register f, where b = 0 to 7
BSF f,b :- Set bit b of register f, where b = 0 to 7
Move instructions
MOVLW k w = k (literal value) , where k=0x00,D‟0‟,B‟0000‟
MOVWF f f = w (working reg. to reg.)
MOVF f ,w w = f (reg. to working reg.)
Arithmetic Instructions
ADDLW k w = w + k
ADDWF f ,d d = f + w
SUBLW k w = k -w
SUBWF f ,d d = f – w
INCF f, d d = f + 1
DECF f, d d = f – 1
Logical Instructions
ANDLW k w = w AND k
ANDWF f ,d d = w AND f
IORLWk w = w IOR k
IORWF f ,d d = w IOR f
XORLWk w = w XOR k
XORWF f ,d d = w XOR f
COMF f ,d d = NOT f
Industrial training report
Dept.of ECE, VJCET 6
Rotate Instructions
RLF f, d rotate F left through the carry bit
RRF f ,d rotate F right through the carry bit
Clear ,Swap
CLRW W = 0(Clear working reg.)
CLRF f f = 0(Clear any reg.)
SWAPF f ,d swap nibbles of f
Conditional branch Instructions
BTFSC f,b Test bit b of register f ,skip if clear
BTFSS f,b Test bit b of register f ,skip if set
DECFSZ f ,d Decrement f ,skip if zero.
INCFSZ f ,d Increment f ,skip if zero.
Branch Instructions
GOTO label Go to labeled instruction
CALL label Call labeled subroutine
RETURN Return from subroutine
RETLW k Return from subroutine ,putting literal value in W.
RETFIE Return from interrupt service routine
Other Instructions
CLRWDT clear watchdog timer
SLEEP go into standby mode
NOP no operation
Industrial training report
Dept.of ECE, VJCET 7
CHAPTER 5
PORTS
A port is a group of pins on a microcontroller on which the desired combinations of zeros
and ones can be set simultaneously or the present status can be read.
PIC16F73 has 3 ports:- PORTA - 6 bit, PORTB - 8 bit, PORTC - 8 bit
TRIS REGISTERS:-TRIS registers are control registers for ports. TRIS registers are in BANK1.
TRISA control register for PORTA. TRISB control register for PORTB. TRISC control
register for PORTC. If a bit of TRIS Register = 1,corresponding PORT pin will be configured as
inputIf a bit of TRIS Register = 0,corresponding PORT pin will be configured as output.
PORT A :- 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.
Clearing a TRISA bit (=0) will make the corresponding PORTA pin an output. Multiplexed with
5-channel 8-bit ADC (PA0, PA1, PA2, PA3, PA5).
PORT B :- 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.
Clearing a TRISB bit (=0) will make the corresponding PORTB pin an output. Three pins of
PORTB are multiplexed with the Low Voltage. Programming function; RB3/PGM, RB6/PGC
and RB7/PGD.Four of PORTB‟s pins, RB7:RB4, have an interrupt onchange feature.RB0/INT is
an external interrupt input pin.Each of the PORTB pins has a weak internal pull-up. A single
control bit can turn on all the pull-ups.
PORT C :- 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.Clearing a TRISC bit (=0) will make the corresponding PORTC pin an output.
Industrial training report
Dept.of ECE, VJCET 8
CHAPTER 6
TIMERS
PIC16F73 has 3 Timers :- TIMER0 - 8 bit, TIMER1 - 16 bit,TIMER2 - 8 bit.
TIMER0 MODULE:- Timer0 operation is controlled through the OPTION_REG register
Timer mode is selected by clearing bit T0CS (OPTION_REG<5>). In Timer mode, the Timer0
module will increment every instruction cycle (without prescaler). If the TMR0 register is
written, the increment is inhibited for the following two instruction cycles. The user can work
around this by writing an adjusted value to the TMR0 register.Counter mode is selected by
setting bit T0CS (OPTION_REG<5>). In Counter mode, Timer0 will increment, either on every
rising or falling edge of pin RA4/T0CKI. The incrementing edge is determined by the Timer0
Source Edge Select bit T0SE (OPTION_REG<4>). Clearing bit T0SE selects the rising edge.
The prescaler is mutually exclusively shared between the Timer0 module and the Watchdog
Timer. The prescaler is not readable or writable.
TIMER1 MODULE:- The Timer1 module is a 16-bit timer/counter consisting of two 8-
bit registers (TMR1H and TMR1L), which are readable and writable. The TMR1 Register pair
(TMR1H:TMR1L) increments from 0000h to FFFFh and rolls over to 0000h. The TMR1
Interrupt, if enabled, is generated on overflow, which is latched in interrupt flag bit TMR1IF
(PIR1<0>). This interrupt can be enabled/disabled by setting/clearing TMR1 interrupt
enable bit TMR1IE (PIE1<0>). Timer1 can operate in one of two modes: As a timer, As a
counter.The operating mode is determined by the clock select bit, TMR1CS (T1CON<1>).
In Timer mode, Timer1 increments every instruction cycle. In Counter mode, it
increments on every rising edge of the external clock input. Timer1 can be enabled/disabled by
setting/clearing control bit TMR1ON (T1CON<0>). Timer1 also has an internal “RESET input”.
This RESET can be generated by either of the two CCP modules as the special event trigger
.When the Timer1 oscillator is enabled (T1OSCEN is set), the RC1/T1OSI/CCP2 and
RC0/T1OSO/T1CKI pins become inputs. That is, the TRISC<1:0> value is ignored and these
pins read as „0‟.
Industrial training report
Dept.of ECE, VJCET 9
EXAMPLE : READING A 16-BIT FREE-RUNNING TIMER
MOVF TMR1H, W ; Read high byte
MOVWF TMPH
MOVF TMR1L, W ; Read low byte
MOVWF TMPL
MOVF TMR1H, W ; Read high byte
SUBWF TMPH, W ; Sub 1st read with 2nd read
BTFSC STATUS,Z ; Is result = 0
GOTO CONTINUE ; Good 16-bit read
MOVF TMR1H, W ; Read high byte
MOVWF TMPH
MOVF TMR1L, W ; Read low byte
MOVWF TMPL ; Re-enable the Interrupt (if required)
CONTINUE ; Continue with your TIMER
TIMER2 MODULE :- Timer2 is an 8-bit timer with a prescaler and a postscaler. It can be
used as the PWM time-base for the PWM mode of the CCP module(s). The TMR2 register is
readable and writable, and is cleared on any device RESET. The input clock (FOSC/4) has a
prescale option of 1:1, 1:4 or 1:16, selected by control bits T2CKPS1:T2CKPS0 (T2CON<1:0>).
The Timer2 module has an 8-bit period register, PR2. Timer2 increments from 00h until
it matches PR2 and then resets to 00h on the next increment cycle. PR2 is a readable and
writable register. The PR2 register is initialized to FFh upon RESET. The match output of TMR2
goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to generate a TMR2
interrupt (latched in flag bit. TMR2IF, (PIR1<1>)). Timer2 can be shut-off by clearing control
bit TMR2ON (T2CON<2>) to minimize power consumption.
Industrial training report
Dept.of ECE, VJCET 10
CHAPTER 7
PIC16F73 INTERRUPTS
Interrupts are mechanisms of a microcontroller which makes it possible to respond to
some events at the moment when they occur, regardless of what microcontroller is doing at the
time.Each interrupt changes the flow of program execution,after executing an interrupt
subprogram (interrupt service routine) it continues from the same point.
GIE PEIE T0IE INTE RBIE T0IF INTF RBIF Table 8.1 INTCON register
RBIF: RB Port Change Interrupt Flag bit
INTF: RB0/INT External Interrupt Flag bit
T0IF: TMR0 Overflow Interrupt Flag bit
RBIE: RB Port Change Interrupt Enable bit
INTE: RB0/INT External Interrupt Enable bit
T0IE: TMR0 Overflow Interrupt Enable bit
PEIE: Peripheral Interrupt Enable bit
GIE: Global Interrupt Enable bit
Industrial training report
Dept.of ECE, VJCET 11
CHAPTER 8
USART
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 configured as 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 integrated circuits, serial EEPROMs, etc.The USART can be
configured in the following modes: Asynchronous (full duplex), Synchronous - Master (half
duplex), Synchronous - Slave (half duplex).
EXAMPLE : TRANSMITTING „G‟ WITH 9600 BAUD RATE
MOVLW 0X24
BANKSEL TXSTA
MOVWF TXSTA
BANKSEL RCSTA
MOVLW 0X80
MOVWF RCSTA
BANKSEL SPBRG
MOVLW 0X19
MOVWF SPBRG
LAB1:
NOP
BANKSEL TXREG
MOVLW „G‟
MOVWF TXREG
Industrial training report
Dept.of ECE, VJCET 12
BANKSEL TXSTA
LAB:BTFSS TXSTA,1
GOTO LAB
GOTO LAB1
NOP
END
Industrial training report
Dept.of ECE, VJCET 13
CHAPTER 9
PIC16F73 ADC
The Analog-to-Digital (A/D) Converter module has five inputs for the 28-pin devices and
eight for the other devices.The analog input charges a sample and hold capacitor. The output of
the sample and hold capacitor is the input into the converter. The converter then generates a
digital result of this analog level via successive approximation. The A/D conversion of the
analog input signal results in a corresponding 10-bit digital number.
The A/D module has four registers.
• A/D Result High Register (ADRESH)
• A/D Result Low Register (ADRESL)
REGISTERS
• A/D Result Low Register (ADRESL)
• A/D Control Register0 (ADCON0)
• A/D Control Register1 (ADCON1)
Industrial training report
Dept.of ECE, VJCET 14
CHAPTER 10
INTERFACING
(10.1) LCD INTERFACING
Figure 10.1 LCD display
The LCD used in our project is a 16*2 LCD. It can display 16 characters on a single line.
RS (Register Select) Pin :- The Register Select (RS) pin of the LCD is used to select the register
which is to be used to read or write data. A LOW level on this pin will select the instruction
command code register, allowing the user to send command such as clear display, cursor at home
etc. A HIGH on this pin will select the data register allowing the user to send data to be
displayed on the LCD.We also use RS = 0 to check the busy flag bit to see if the LCD is ready to
receive information. The busy flag is D7 and can be read when R/W = 1 and RS = 0, as follows:
if R/W = 1, RS = 0. When D7 = 1(busy flag = 1), the LCD is busy taking care of internal
operations and will not accept any new operation. When D7 = 0, the LCD is ready to receive new
information.
R/W (Read or Write) Pin :- R/W input allows the user to write information to the LCD or read
information from it. R/W = 1 when reading; R/W = 0 when writing.
E (Enable) Pin :- The enable pin is used by the LCD to latch information presented to its data
pins. When data is supplied to data pins, a high-to-low pulse must be applied to this pin in order
for the LCD to latch in the data present at the data pins. This pulse must be a minimum of 450 ns
wide.
Industrial training report
Dept.of ECE, VJCET 15
D0 – D7 pins :-To display letters and numbers, we send ASCII codes for the letters A – Z, a- z
and numbers 0 – 9 to these pins while making RS = 1. To give commands to the LCD, we send
binary code of the commands to these pins while making RS = 0.
COMMAND CODE(HEX) FUNCTION
0X01 Clear display screens
0X02 Return home
0X04 Decrement cursor (shift cursor to left)
0X06 Increment cursor (shift cursor to right)
0X05 Shift display right
0X07 Shift display left
0X08 Display OFF, cursor OFF
0X0A Display OFF, cursor ON
0X0C Display ON, cursor OFF
0X0E Display ON, cursor blinking OFF
0X0F Display ON, cursor blinking
0X10 Shift cursor position to left
0X14 Shift cursor position to right
0X18 Shift the entire display to the left
0X1C Shift the entire display to the right
0X80 Force cursor to beginning of first line
0xC0 Force cursor to beginning of second line
0X38 2 lines and 5x7 matrix
(10.2) GSM (GLOBAL SYSTEM FOR MOBILE COMMUNICATION) INTERFACING
Figure 10.2 GSM interfacing
Industrial training report
Dept.of ECE, VJCET 16
Here a GSM mobile hand set is used. GSM networks are originally from the most popular
standard for mobile phones in the world. GSM differs from its predecessors in that both
signaling and speech channels are digital, and thus is considered a second generation (2G)
mobile phone system. This has also meant that data communication was easy to build into the
system. GSM is a cellular network, which means that mobile phones connect to it by searching
for cells in the immediate vicinity. GSM networks operate in a number of different frequency
ranges .Most 2G GSM networks operate in the 900 MHz or 1800 MHz bands. The controller
communicates with the mobile phone by AT comments. The Main AT commands to
communicate via a serial interface with the GSM subsystem of the phone
(10.3) RFID INTERFACING
Radio-frequency identification (RFID) is the use of an object (typically referred to
as an RFID tag) applied to or incorporated into a product, animal, or person for the purpose of
identification and tracking using radio waves. Some tags can be read from several maters away
and beyond the line of sight of the reader.
Figure 10.3 RFID Interfacing
Most RFID tags contain at least two parts. One is integrated circuits for storing and
information, modulating and demodulating a radio frequency (RF) signal, and other specialized
functions. The second is an antenna for receiving and transmitting the signal.
(10.4) KEYBOARD INTERFACING
Keyboards are organized in matrix of rows and coloumns.CPU access both rows and
columns through ports. So an 8X8 keyboard can be connected to a PIC through 2 ports. There
Industrial training report
Dept.of ECE, VJCET 17
are mainly 2 methods to ckeck the key pressed:- 1.Interrupt method 2.Keyboard scanning
method.By this techniques microcontroller can perform both key press detection & key
identification.
Figure 10.4 Keyboard interfacing
Industrial training report
Dept.of ECE, VJCET 18
CHAPTER 11
INTRODUCTION TO MPLAB IDE
MPLAB IDE (IDE:-Integrated Development Environment) is a software program that runs on
your PC to provide a development for your embede system design.
Steps :-
Select device
Create project
Select Language tools
Put files in project
Create code
Build project
Test code with Simulator
How to start:-
LIST P=PIC16F73
#INCLUDE “PIC16F73.INC”
CBLOCK 0X20
REGISTERS
ENDC
ORG 00H
PROGRAM
END
Industrial training report
Dept.of ECE, VJCET 19
CHAPTER 12
CONCLUSION
I would like to say that this training program is an excellent opportunity for me and
experience the things that we would have never gained through going straight into a job. I am
grateful to the entire team of Quest Innovative Solutions, Kochi for giving me this wonderful
opportunity.
As a result of the PIC microcontroller training program, students have been exposed
to engineering applications using embedded applications. These applications enable to
experience the problem solving process and many practical issues that certainly arises in real
world and industrial applications. This training is just a beginning step for student to further
research and develop more complex applications using advance microcontroller such as dsPIC
microcontrollers in the future after their completion of their study.
The main objective of the industrial training is to provide an opportunity to students
to identify, observe and practice how engineering is applicable in the real industry. It is not only
to get experience on technical practices but also to observe management practices and to interact
with fellow workers.
Industrial training report
Dept.of ECE, VJCET 20
REFERENCES
1. www.wikipaedia.com
2.www.questinnovativesolution.com
3.Muhhammad M.Mazidi ,‟PIC 18 And Embeded C‟,Pearson education
4.www.engineersgarage.com
5.www.microchip.com
6. extremeelectronics.co.in
7. microcontroller.circuitlab.org
Industrial training report
Dept.of ECE, VJCET 21
APPENDIX
Industrial training report
Dept.of ECE, VJCET 22
Industrial training report
Dept.of ECE, VJCET 23
Industrial training report
Dept.of ECE, VJCET 24
Industrial training report
Dept.of ECE, VJCET 25
Industrial training report
Dept.of ECE, VJCET 26
Industrial training report
Dept.of ECE, VJCET 27
Industrial training report
Dept.of ECE, VJCET 28