Sunteți pe pagina 1din 41

PIC Informative PDF

Open source PDF.

What is the PIC?


The PIC was developed as a peripheral controller

PIC(Peripheral Interface Controller) is the IC which was developed to control peripheral devices,
alleviating the load from the main CPU.
Compared to a human being, the brain is the main CPU and the PIC is equivalent to the autonomic
nervous system.

The PIC is the small computer

The PIC, like the CPU, has calculation functions and memory, and is controlled by the software.
However, the throughput and the memory capacity are low. Depending on the kind of PIC, the
maximum clock operating frequency is about 20 MHz and the memory capacity (to write the program)
is about 1K to 4K words.
The clock frequency determines the speed at which a program is read and an instruction is executed.
The throughput cannot be judged with the clock frequency alone. It changes with the processor
architecture. However within the same architecture, the one with the highest clock frequency has the
highest throughput.
I use a 14-bit WORD for program memory capacity. An instruction is a word long. Program memory
is measured in BYTES, one byte is 8 bits. The bit is the smallest unit, and can have the value of 1 or 0.
The instruction word of the PIC16F84A is composed of 14 bits. 1K words is equal to 1 x 1,024 x 14 =
14,336 bits. To convert this to bytes divide it by 8 x 1024, (14,336 / 8 x 1024 = 1.75K bytes).

A memory capacity of 1G bytes = 1,024M bytes, 1M bytes = 1,024K bytes, 1K bytes = 1,024 bytes.
1K bytes is not equal to 1000 bytes. This is because the calculation is in binary (2 to the tenth power =
1,024).

When using the PIC it is possible to make the circuitry compact


The PIC is convenient for making calculations. The memory, the input/output ports and so on are
incorporated into the IC.
The efficiency and the functions are limited, but the PIC can do the job of many IC's with software.
So, the circuit can be compact.
Hardware of the PIC16F877
On these pages, I will explain the hardware specification of PICF877. The contents of the
explanation is the part which is different from PIC16F873. So, as for the basic specification,
refer to PIC16F873. As for the detailed specification, refer to PIC16F87x.
PIC16F877 is PIC which is placed in the higher rank of PIC16F873 and the capacity of the
program memory and so on is big capacity compared with 873. The function which is in 877, not
being in 873 is the function of the parallel communication. It is called PSP( Parallel Slave Port ).
Please refer to the following table about the function and the capacity.

RA0-5 : Input/Output port A MCLR : Master Clear ( Active low


RB0-7 : Input/Output port B Reset )
RC0-7 : Input/Output port C Vpp : Programming voltage input
RD0-7 : Input/Output port D THV : High voltage test mode control
RE0-2 : Input/Output port E VREF+/- : Reference voltage
AN0-7 : Analog input port SS : Slave select for the synchronous
RX : USART Asynchronous serial port
Receive T0CKI : Clock input to Timer0
TX : USART Asynchronous T1OSO : Timer1 oscillator output
Transmit T1OSI : Timer1 oscillator input
SCK : Synchronous serial clock T1CKI : Clock input to Timer1
input PGD : Serial programming data
SCL : Output for both SPI and I2C PGC : Serial programming clock
modes PGM : Low voltage programinng input
DT : Synchronous Data INT : External interrupt
CK : Synchronous Clock RD : Read control for the parallel
SDO : SPI Data Out ( SPI mode ) slave port
SDI : SPI Data In ( SPI mode ) WR : Write control for the parallel
SDA : Data I/O ( I2C mode ) slave port
CCP1,2 : Capture In/Compare CS : Select control for the parallel
Out/PWM Out slave
OSC1/CLKIN : Oscillator In/Ecternal Clock PSP0-7 : Parallel slave port
In VDD : Positive supply for logic and I/O
OSC2/CLKOUT : Oscillator Out/Clock Out pins
Vss : Ground reference for logic and
I/O pins
Key Features PIC16F873 PIC16F874 PIC16F876 PIC16F877

MAX Operating
20MHz 20MHz 20MHz 20MHz
Frequency

FLASH Program
Memory 4K 4K 8K 8K
(14-bit words)

Data Memory (bytes) 192 192 368 368

EEPROM Data Memory


128 128 256 256
(bytes)

RA0-5 (6) RA0-5 (6) RA0-5 (6) RA0-5 (6)


RB0-7 (8) RB0-7 (8) RB0-7 (8) RB0-7 (8)
I/O Ports RC0-7 (8) RC0-7 (8) RC0-7 (8) RC0-7 (8)
RD0-7 (8) RD0-7 (8)
RE0-2 (3) RE0-2 (3)

Timers 3 3 3 3

CCP 2 2 2 2

MSSP, MSSP, MSSP,


Serial Communications MSSP, USART
USART USART USART

Parallel Communications - PSP - PSP

10-bit Analog-to-Digital
5 Channels 8 Channels 5 Channels 8 Channels
Module

35 35 35
Instruction Set 35 Instructions
Instructions Instructions Instructions

Pins (DIP) 28 Pins 40 Pins 28 Pins 40 Pins

SFR ( Special Function Registers )

Configuration Bits

PSP ( Parallel Slave Port )


Refer to the 38/200 page of the data sheet.
The page number is the one when making this page.
PIC Tutorial Three - LCD Modules
For the first parts of this tutorial you require the Main Board and the LCD Board, the
later parts will also use the Switch Board, as written the tutorials use the LCD Board on
PortA and the Switch Board on PortB. Although the hardware diagram shows a 2x16
LCD, other sizes can be used, I've tested it with a 2x16, 2x20, and 2x40 - all worked
equally well. The intention is to develop a useful set of LCD routines, these will be used
in the later parts of the tutorials to display various information.

Download zipped tutorial files.

Binary
Command Hex
D7 D6 D5 D4 D3 D2 D1 D0
Clear Display 0 0 0 0 0 0 0 1 01
Display and Cursor
0 0 0 0 0 0 1 x 02 or 03
Home
Character Entry Mode 0 0 0 0 0 1 I/D S 01 to 07
Display On/Off and
0 0 0 0 1 D U B 08 to 0F
Cursor
Display/Cursor Shift 0 0 0 1 D/C R/L x x 10 to 1F
Function Set 0 0 1 8/4 2/1 10/7 x x 20 to 3F
Set CGRAM Address 0 1 A A A A A A 40 to 7F
80 to
Set Display Address 1 A A A A A A A
FF
I/D: 1=Increment* 0=Decrement R/L: 1=Right Shift 0=Left Shift
1=Display Shift 0=Display Shift 0=4 bit
S: 8/4: 1=8 bit interface*
On off* interface
D: 1=Display On 0=Display Off* 2/1: 1=2 line mode 0=1 line mode*
1=Cursor 0=Cursor 0=5x7 dot
U: 10/7: 1=5x10 dot format
Underline On Underline Off* format*
1=Cursor Blink 0=Cursor Blink
B:
On Off* *=initialisation
x=don't care
D/C: 1=Display Shift 0=Cursor Move setting
This table shows the command codes for the LCD module, it was taken from an
excellent LCD tutorial that was published in the UK magazine 'Everyday Practical
Electronics' February 1997 - it can be downloaded as a PDF file from the EPE website.
The following routines are an amalgamation of a number of routines from various
sources (including the previously mentioned tutorial), plus various parts of my own, the
result is a set of reliable, easy to use, routines which work well (at least in my opinion!).

Tutorial 3.1 - requires Main Board and LCD Board.

This program displays a text message on the LCD module, it consists mostly of
subroutines for using the LCD module.

;LCD text demo - 4 bit mode


;Nigel Goodwin 2002

LIST p=16F628 ;tell assembler what chip we are


using
include "P16F628.inc" ;include the defaults for the
chip
ERRORLEVEL 0, -302 ;suppress bank selection messages
__config 0x3D18 ;sets the configuration settings
(oscillator type etc.)

cblock 0x20 ;start of general purpose


registers
count ;used in looping routines
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
tmp1 ;temporary storage
tmp2
templcd ;temp store for 4 bit mode
templcd2
endc

LCD_PORT Equ PORTA


LCD_TRIS Equ TRISA
LCD_RS Equ 0x04 ;LCD handshake lines
LCD_RW Equ 0x06
LCD_E Equ 0x07

org 0x0000

movlw 0x07
movwf CMCON ;turn comparators off
(make it like a 16F84)

Initialise clrf count


clrf PORTA
clrf PORTB
SetPorts bsf STATUS, RP0 ;select bank 1
movlw 0x00 ;make all pins outputs
movwf LCD_TRIS
bcf STATUS, RP0 ;select bank 0

call Delay100 ;wait for LCD to settle

call LCD_Init ;setup LCD

clrf count ;set counter register to


zero
Message movf count, w ;put counter value in W
call Text ;get a character from the
text table
xorlw 0x00 ;is it a zero?
btfsc STATUS, Z
goto NextMessage
call LCD_Char
call Delay255
incf count, f
goto Message

NextMessage call LCD_Line2 ;move to 2nd row, first


column

clrf count ;set counter register to


zero
Message2 movf count, w ;put counter value in W
call Text2 ;get a character from the
text table
xorlw 0x00 ;is it a zero?
btfsc STATUS, Z
goto EndMessage
call LCD_Char
incf count, f
goto Message2

EndMessage

Stop goto Stop ;endless loop

;Subroutines and text tables

;LCD routines

;Initialise LCD
LCD_Init movlw 0x20 ;Set 4 bit mode
call LCD_Cmd

movlw 0x28 ;Set display shift


call LCD_Cmd
movlw 0x06 ;Set display character
mode
call LCD_Cmd

movlw 0x0d ;Set display on/off and


cursor command
call LCD_Cmd

call LCD_Clr ;clear display

retlw 0x00

; command set routine


LCD_Cmd movwf templcd
swapf templcd, w ;send upper nibble
andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bcf LCD_PORT, LCD_RS ;RS line to 0
call Pulse_e ;Pulse the E line high

movf templcd, w ;send lower nibble


andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bcf LCD_PORT, LCD_RS ;RS line to 0
call Pulse_e ;Pulse the E line high
call Delay5
retlw 0x00

LCD_CharD addlw 0x30


LCD_Char movwf templcd
swapf templcd, w ;send upper nibble
andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bsf LCD_PORT, LCD_RS ;RS line to 1
call Pulse_e ;Pulse the E line high

movf templcd, w ;send lower nibble


andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bsf LCD_PORT, LCD_RS ;RS line to 1
call Pulse_e ;Pulse the E line high
call Delay5
retlw 0x00

LCD_Line1 movlw 0x80 ;move to 1st row, first


column
call LCD_Cmd
retlw 0x00

LCD_Line2 movlw 0xc0 ;move to 2nd row, first


column
call LCD_Cmd
retlw 0x00

LCD_Line1W addlw 0x80 ;move to 1st row, column W


call LCD_Cmd
retlw 0x00

LCD_Line2W addlw 0xc0 ;move to 2nd row, column W


call LCD_Cmd
retlw 0x00

LCD_CurOn movlw 0x0d ;Set display on/off and


cursor command
call LCD_Cmd
retlw 0x00

LCD_CurOff movlw 0x0c ;Set display on/off and


cursor command
call LCD_Cmd
retlw 0x00

LCD_Clr movlw 0x01 ;Clear display


call LCD_Cmd
retlw 0x00

LCD_HEX movwf tmp1


swapf tmp1, w
andlw 0x0f
call HEX_Table
call LCD_Char
movf tmp1, w
andlw 0x0f
call HEX_Table
call LCD_Char
retlw 0x00

Delay255 movlw 0xff ;delay 255 mS


goto d0
Delay100 movlw d'100' ;delay 100mS
goto d0
Delay50 movlw d'50' ;delay 50mS
goto d0
Delay20 movlw d'20' ;delay 20mS
goto d0
Delay5 movlw 0x05 ;delay 5.000 ms (4 MHz clock)
d0 movwf count1
d1 movlw 0xC7 ;delay 1mS
movwf counta
movlw 0x01
movwf countb
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0

decfsz count1 ,f
goto d1
retlw 0x00
Pulse_e bsf LCD_PORT, LCD_E
nop
bcf LCD_PORT, LCD_E
retlw 0x00

;end of LCD routines

HEX_Table ADDWF PCL , f


RETLW 0x30
RETLW 0x31
RETLW 0x32
RETLW 0x33
RETLW 0x34
RETLW 0x35
RETLW 0x36
RETLW 0x37
RETLW 0x38
RETLW 0x39
RETLW 0x41
RETLW 0x42
RETLW 0x43
RETLW 0x44
RETLW 0x45
RETLW 0x46

Text addwf PCL, f


retlw 'H'
retlw 'e'
retlw 'l'
retlw 'l'
retlw 'o'
retlw 0x00

Text2 ADDWF PCL, f


RETLW 'R'
RETLW 'e'
RETLW 'a'
RETLW 'd'
RETLW 'y'
RETLW '.'
RETLW '.'
RETLW '.'
RETLW 0x00

end

As usual, first we need to set things up, after the normal variable declarations and port
setting we reach 'call LCD_Init', this sets up the LCD module. It first waits for 100mS to
give the module plenty of time to settle down, we then set it to 4 bit mode (0x20) and set
the various options how we want them - in this case, Display Shift is On (0x28),
Character Entry Mode is Increment (0x06), and Block Cursor On (0x0D). Once the LCD
is setup, we can then start to send data to it, this is read from a table, exactly the same as
the LED sequencer in the earlier tutorials - except this time we send the data to the LCD
module (using LCD_Char) and use a 0x00 to mark the end of the table, thus removing the
need to maintain a count of the characters printed. Once the first line is displayed we then
sent a command to move to the second line (using call LCD_Line2), and then print the
second line from another table. After that we enter an endless loop to leave the display as
it is.

This program introduces a new use of the 'goto' command, 'goto $+2' - '$' is an
MPASM arithmetic operator, and uses the current value of the program counter, so 'goto
$+2' means jump to the line after the next one - 'goto $+1' jumps to the next line, and may
seem pretty useless (as the program was going to be there next anyway), but it can be
extremely useful. A program branch instruction (like goto) uses two instruction cycles,
whereas other instructions only take one, so if you use a 'nop' in a program it takes 1uS to
execute, and carries on from the next line - however, if you use 'goto $+1' it still carries
on from the next line, but now takes 2uS. You'll notice more use of the 'goto $'
construction in later tutorials, if you are checking an input pin and waiting for it to
change state you can use 'goto $-1' to jump back to the previous line, this saves allocating
a label to the line that tests the condition.

This is a table of the LCD subroutines provided in these programs, you can easily add
more if you wish - for instance to set a line cursor rather than a block one, if you find you
are using a particular feature a lot you may as well make a subroutine for it.

LCD Subroutines
LCD_Init Initialise LCD Module
LCD_Cmd Sent a command to the LCD
Add 0x30 to a byte and send to the LCD
LCD_CharD
(to display numbers as ASCII)
LCD_Char Send the character in W to the LCD
LCD_Line1 Go to start of line 1
LCD_Line2 Go to start of line 2
LCD_Line1W Go to line 1 column W
LCD_Line2W Go to line 2 column W
LCD_CurOn Turn block cursor on
LCD_CurOff Turn block cursor off
LCD_Clr Clear the display
LCD_HEX Display the value in W as Hexadecimal
Tutorial 3.2 - requires Main
Board and LCD Board.
This program displays a text message on the top line and a running 16 bit counter on
the bottom line, with the values displayed in both decimal and hexadecimal , it consists
mostly of the previous subroutines for using the LCD module, plus an extra one for
converting from 16 bit hexadecimal to decimal.

;LCD 16 bit counter


;Nigel Goodwin 2002

LIST p=16F628 ;tell assembler what chip we are


using
include "P16F628.inc" ;include the defaults for the
chip
ERRORLEVEL 0, -302 ;suppress bank selection messages
__config 0x3D18 ;sets the configuration settings
(oscillator type etc.)

cblock 0x20 ;start of general purpose


registers
count ;used in looping routines
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
tmp1 ;temporary storage
tmp2
templcd ;temp store for 4 bit mode
templcd2

NumL ;Binary inputs for decimal


convert routine
NumH

TenK ;Decimal outputs from


convert routine
Thou
Hund
Tens
Ones
endc

LCD_PORT Equ PORTA


LCD_TRIS Equ TRISA
LCD_RS Equ 0x04 ;LCD handshake lines
LCD_RW Equ 0x06
LCD_E Equ 0x07

org 0x0000

movlw 0x07
movwf CMCON ;turn comparators off
(make it like a 16F84)
Initialise clrf count
clrf PORTA
clrf PORTB
clrf NumL
clrf NumH

SetPorts bsf STATUS, RP0 ;select bank 1


movlw 0x00 ;make all pins outputs
movwf LCD_TRIS
bcf STATUS, RP0 ;select bank 0

call LCD_Init ;setup LCD

clrf count ;set counter register to


zero
Message movf count, w ;put counter value in W
call Text ;get a character from the
text table
xorlw 0x00 ;is it a zero?
btfsc STATUS, Z
goto NextMessage
call LCD_Char
incf count, f
goto Message

NextMessage call LCD_Line2 ;move to 2nd row, first


column

call Convert ;convert to decimal


movf TenK, w ;display decimal
characters
call LCD_CharD ;using LCD_CharD to
convert to ASCII
movf Thou, w
call LCD_CharD
movf Hund, w
call LCD_CharD
movf Tens, w
call LCD_CharD
movf Ones, w
call LCD_CharD
movlw ' ' ;display a 'space'
call LCD_Char
movf NumH, w ;and counter in
hexadecimal
call LCD_HEX
movf NumL, w
call LCD_HEX
incfsz NumL, f
goto Next
incf NumH, f
Next call Delay255 ;wait so you can see the
digits change
goto NextMessage

;Subroutines and text tables

;LCD routines

;Initialise LCD
LCD_Init call Delay100 ;wait for LCD to settle

movlw 0x20 ;Set 4 bit mode


call LCD_Cmd

movlw 0x28 ;Set display shift


call LCD_Cmd

movlw 0x06 ;Set display character


mode
call LCD_Cmd

movlw 0x0c ;Set display on/off and


cursor command
call LCD_Cmd ;Set cursor off

call LCD_Clr ;clear display

retlw 0x00

; command set routine


LCD_Cmd movwf templcd
swapf templcd, w ;send upper nibble
andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bcf LCD_PORT, LCD_RS ;RS line to 0
call Pulse_e ;Pulse the E line high

movf templcd, w ;send lower nibble


andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bcf LCD_PORT, LCD_RS ;RS line to 0
call Pulse_e ;Pulse the E line high
call Delay5
retlw 0x00

LCD_CharD addlw 0x30 ;add 0x30 to convert to


ASCII
LCD_Char movwf templcd
swapf templcd, w ;send upper nibble
andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bsf LCD_PORT, LCD_RS ;RS line to 1
call Pulse_e ;Pulse the E line high

movf templcd, w ;send lower nibble


andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bsf LCD_PORT, LCD_RS ;RS line to 1
call Pulse_e ;Pulse the E line high
call Delay5
retlw 0x00

LCD_Line1 movlw 0x80 ;move to 1st row, first


column
call LCD_Cmd
retlw 0x00

LCD_Line2 movlw 0xc0 ;move to 2nd row, first


column
call LCD_Cmd
retlw 0x00

LCD_Line1W addlw 0x80 ;move to 1st row, column W


call LCD_Cmd
retlw 0x00

LCD_Line2W addlw 0xc0 ;move to 2nd row, column W


call LCD_Cmd
retlw 0x00

LCD_CurOn movlw 0x0d ;Set display on/off and


cursor command
call LCD_Cmd
retlw 0x00

LCD_CurOff movlw 0x0c ;Set display on/off and


cursor command
call LCD_Cmd
retlw 0x00

LCD_Clr movlw 0x01 ;Clear display


call LCD_Cmd
retlw 0x00

LCD_HEX movwf tmp1


swapf tmp1, w
andlw 0x0f
call HEX_Table
call LCD_Char
movf tmp1, w
andlw 0x0f
call HEX_Table
call LCD_Char
retlw 0x00

Delay255 movlw 0xff ;delay 255 mS


goto d0
Delay100 movlw d'100' ;delay 100mS
goto d0
Delay50 movlw d'50' ;delay 50mS
goto d0
Delay20 movlw d'20' ;delay 20mS
goto d0
Delay5 movlw 0x05 ;delay 5.000 ms (4 MHz clock)
d0 movwf count1
d1 movlw 0xC7 ;delay 1mS
movwf counta
movlw 0x01
movwf countb
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0

decfsz count1 ,f
goto d1
retlw 0x00

Pulse_e bsf LCD_PORT, LCD_E


nop
bcf LCD_PORT, LCD_E
retlw 0x00

;end of LCD routines

HEX_Table ADDWF PCL , f


RETLW 0x30
RETLW 0x31
RETLW 0x32
RETLW 0x33
RETLW 0x34
RETLW 0x35
RETLW 0x36
RETLW 0x37
RETLW 0x38
RETLW 0x39
RETLW 0x41
RETLW 0x42
RETLW 0x43
RETLW 0x44
RETLW 0x45
RETLW 0x46

Text addwf PCL, f


retlw '1'
retlw '6'
retlw ' '
retlw 'B'
retlw 'i'
retlw 't'
retlw ' '
retlw 'C'
retlw 'o'
retlw 'u'
retlw 'n'
retlw 't'
retlw 'e'
retlw 'r'
retlw '.'
retlw 0x00

;This routine downloaded from http://www.piclist.com


Convert: ; Takes number in NumH:NumL
; Returns decimal in
; TenK:Thou:Hund:Tens:Ones
swapf NumH, w
iorlw B'11110000'
movwf Thou
addwf Thou,f
addlw 0XE2
movwf Hund
addlw 0X32
movwf Ones

movf NumH,w
andlw 0X0F
addwf Hund,f
addwf Hund,f
addwf Ones,f
addlw 0XE9
movwf Tens
addwf Tens,f
addwf Tens,f

swapf NumL,w
andlw 0X0F
addwf Tens,f
addwf Ones,f

rlf Tens,f
rlf Ones,f
comf Ones,f
rlf Ones,f

movf NumL,w
andlw 0X0F
addwf Ones,f
rlf Thou,f

movlw 0X07
movwf TenK

; At this point, the original number is


; equal to
; TenK*10000+Thou*1000+Hund*100+Tens*10+Ones
; if those entities are regarded as two's
; complement binary. To be precise, all of
; them are negative except TenK. Now the number
; needs to be normalized, but this can all be
; done with simple byte arithmetic.

movlw 0X0A ; Ten


Lb1:
addwf Ones,f
decf Tens,f
btfss 3,0
goto Lb1
Lb2:
addwf Tens,f
decf Hund,f
btfss 3,0
goto Lb2
Lb3:
addwf Hund,f
decf Thou,f
btfss 3,0
goto Lb3
Lb4:
addwf Thou,f
decf TenK,f
btfss 3,0
goto Lb4

retlw 0x00

end

Tutorial 3.3 - requires Main Board and LCD Board.

This program displays a text message on the top line and a running 16 bit counter on
the bottom line, just as the last example, however, instead of using the Delay calls this
version waits until the LCD Busy flag is clear. The LCD module takes time to carry out
commands, these times vary, and the previous tutorials used a delay more than long
enough to 'make sure' - however, the modules have the capability of signalling when they
are ready, this version uses that facility and avoids any unnecessary delays. I've also used
the LCD_Line2W routine to position the numbers further to the right and demonstrate the
use of the routine, another slight change is that the tables have been moved to the
beginning of program memory, this was done because it's important that tables don't cross
a 256 byte boundary, so putting them at the start avoids this.

;LCD 16 bit counter - using LCD Busy line


;Nigel Goodwin 2002

LIST p=16F628 ;tell assembler what chip we are


using
include "P16F628.inc" ;include the defaults for the
chip
ERRORLEVEL 0, -302 ;suppress bank selection messages
__config 0x3D18 ;sets the configuration settings
(oscillator type etc.)
cblock 0x20 ;start of general purpose
registers
count ;used in looping routines
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
tmp1 ;temporary storage
tmp2
templcd ;temp store for 4 bit mode
templcd2

NumL ;Binary inputs for decimal


convert routine
NumH

TenK ;Decimal outputs from


convert routine
Thou
Hund
Tens
Ones
endc

LCD_PORT Equ PORTA


LCD_TRIS Equ TRISA
LCD_RS Equ 0x04 ;LCD handshake lines
LCD_RW Equ 0x06
LCD_E Equ 0x07

org 0x0000
goto Start

HEX_Table ADDWF PCL , f


RETLW 0x30
RETLW 0x31
RETLW 0x32
RETLW 0x33
RETLW 0x34
RETLW 0x35
RETLW 0x36
RETLW 0x37
RETLW 0x38
RETLW 0x39
RETLW 0x41
RETLW 0x42
RETLW 0x43
RETLW 0x44
RETLW 0x45
RETLW 0x46

Text addwf PCL, f


retlw '1'
retlw '6'
retlw ' '
retlw 'B'
retlw 'i'
retlw 't'
retlw ' '
retlw 'C'
retlw 'o'
retlw 'u'
retlw 'n'
retlw 't'
retlw 'e'
retlw 'r'
retlw '.'
retlw 0x00

Start movlw 0x07


movwf CMCON ;turn comparators off
(make it like a 16F84)

Initialise clrf count


clrf PORTA
clrf PORTB
clrf NumL
clrf NumH

SetPorts bsf STATUS, RP0 ;select bank 1


movlw 0x00 ;make all pins outputs
movwf LCD_TRIS
movwf TRISB
bcf STATUS, RP0 ;select bank 0

call LCD_Init ;setup LCD

clrf count ;set counter register to


zero
Message movf count, w ;put counter value in W
call Text ;get a character from the
text table
xorlw 0x00 ;is it a zero?
btfsc STATUS, Z
goto NextMessage
call LCD_Char
incf count, f
goto Message

NextMessage movlw d'2'


call LCD_Line2W ;move to 2nd row, third
column

call Convert ;convert to decimal


movf TenK, w ;display decimal
characters
call LCD_CharD ;using LCD_CharD to
convert to ASCII
movf Thou, w
call LCD_CharD
movf Hund, w
call LCD_CharD
movf Tens, w
call LCD_CharD
movf Ones, w
call LCD_CharD
movlw ' ' ;display a 'space'
call LCD_Char
movf NumH, w ;and counter in
hexadecimal
call LCD_HEX
movf NumL, w
call LCD_HEX
incfsz NumL, f
goto Next
incf NumH, f
Next call Delay255 ;wait so you can see the
digits change
goto NextMessage

;Subroutines and text tables

;LCD routines

;Initialise LCD
LCD_Init call LCD_Busy ;wait for LCD to settle

movlw 0x20 ;Set 4 bit mode


call LCD_Cmd

movlw 0x28 ;Set display shift


call LCD_Cmd

movlw 0x06 ;Set display character


mode
call LCD_Cmd

movlw 0x0c ;Set display on/off and


cursor command
call LCD_Cmd ;Set cursor off

call LCD_Clr ;clear display

retlw 0x00

; command set routine


LCD_Cmd movwf templcd
swapf templcd, w ;send upper nibble
andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bcf LCD_PORT, LCD_RS ;RS line to 0
call Pulse_e ;Pulse the E line high

movf templcd, w ;send lower nibble


andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bcf LCD_PORT, LCD_RS ;RS line to 0
call Pulse_e ;Pulse the E line high
call LCD_Busy
retlw 0x00

LCD_CharD addlw 0x30 ;add 0x30 to convert to


ASCII
LCD_Char movwf templcd
swapf templcd, w ;send upper nibble
andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bsf LCD_PORT, LCD_RS ;RS line to 1
call Pulse_e ;Pulse the E line high

movf templcd, w ;send lower nibble


andlw 0x0f ;clear upper 4 bits of W
movwf LCD_PORT
bsf LCD_PORT, LCD_RS ;RS line to 1
call Pulse_e ;Pulse the E line high
call LCD_Busy
retlw 0x00

LCD_Line1 movlw 0x80 ;move to 1st row, first


column
call LCD_Cmd
retlw 0x00

LCD_Line2 movlw 0xc0 ;move to 2nd row, first


column
call LCD_Cmd
retlw 0x00

LCD_Line1W addlw 0x80 ;move to 1st row, column W


call LCD_Cmd
retlw 0x00

LCD_Line2W addlw 0xc0 ;move to 2nd row, column W


call LCD_Cmd
retlw 0x00

LCD_CurOn movlw 0x0d ;Set display on/off and


cursor command
call LCD_Cmd
retlw 0x00

LCD_CurOff movlw 0x0c ;Set display on/off and


cursor command
call LCD_Cmd
retlw 0x00

LCD_Clr movlw 0x01 ;Clear display


call LCD_Cmd
retlw 0x00
LCD_HEX movwf tmp1
swapf tmp1, w
andlw 0x0f
call HEX_Table
call LCD_Char
movf tmp1, w
andlw 0x0f
call HEX_Table
call LCD_Char
retlw 0x00

Delay255 movlw 0xff ;delay 255 mS


goto d0
Delay100 movlw d'100' ;delay 100mS
goto d0
Delay50 movlw d'50' ;delay 50mS
goto d0
Delay20 movlw d'20' ;delay 20mS
goto d0
Delay5 movlw 0x05 ;delay 5.000 ms (4 MHz
clock)
d0 movwf count1
d1 movlw 0xC7 ;delay 1mS
movwf counta
movlw 0x01
movwf countb
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0

decfsz count1 ,f
goto d1
retlw 0x00

Pulse_e bsf LCD_PORT, LCD_E


nop
bcf LCD_PORT, LCD_E
retlw 0x00

LCD_Busy
bsf STATUS, RP0 ;set bank 1
movlw 0x0f ;set Port for input
movwf LCD_TRIS
bcf STATUS, RP0 ;set bank 0
bcf LCD_PORT, LCD_RS ;set LCD for command mode
bsf LCD_PORT, LCD_RW ;setup to read busy flag
bsf LCD_PORT, LCD_E
swapf LCD_PORT, w ;read upper nibble (busy
flag)
bcf LCD_PORT, LCD_E
movwf templcd2
bsf LCD_PORT, LCD_E ;dummy read of lower
nibble
bcf LCD_PORT, LCD_E
btfsc templcd2, 7 ;check busy flag, high =
busy
goto LCD_Busy ;if busy check again
bcf LCD_PORT, LCD_RW
bsf STATUS, RP0 ;set bank 1
movlw 0x00 ;set Port for output
movwf LCD_TRIS
bcf STATUS, RP0 ;set bank 0
return

;end of LCD routines

;This routine downloaded from http://www.piclist.com


Convert: ; Takes number in NumH:NumL
; Returns decimal in
; TenK:Thou:Hund:Tens:Ones
swapf NumH, w
iorlw B'11110000'
movwf Thou
addwf Thou,f
addlw 0XE2
movwf Hund
addlw 0X32
movwf Ones

movf NumH,w
andlw 0X0F
addwf Hund,f
addwf Hund,f
addwf Ones,f
addlw 0XE9
movwf Tens
addwf Tens,f
addwf Tens,f

swapf NumL,w
andlw 0X0F
addwf Tens,f
addwf Ones,f

rlf Tens,f
rlf Ones,f
comf Ones,f
rlf Ones,f

movf NumL,w
andlw 0X0F
addwf Ones,f
rlf Thou,f

movlw 0X07
movwf TenK

; At this point, the original number is


; equal to
; TenK*10000+Thou*1000+Hund*100+Tens*10+Ones
; if those entities are regarded as two's
; complement binary. To be precise, all of
; them are negative except TenK. Now the number
; needs to be normalized, but this can all be
; done with simple byte arithmetic.

movlw 0X0A ; Ten


Lb1:
addwf Ones,f
decf Tens,f
btfss 3,0
goto Lb1
Lb2:
addwf Tens,f
decf Hund,f
btfss 3,0
goto Lb2
Lb3:
addwf Hund,f
decf Thou,f
btfss 3,0
goto Lb3
Lb4:
addwf Thou,f
decf TenK,f
btfss 3,0
goto Lb4

retlw 0x00

end

PIC LCD terms

LCD or LCM

Liquid Crystal Module (LCM) and Liquid Crystal Display (LCD) are often used
interchangeably. To be pedantic, LCD is the actual glass display, while LCM describes
the complete assembly (or module) including printed circuit board (PCB), electronics and
back-light. The most used term is LCD or Liquid Crystal Display.

Character or Graphic

LCD's can be broadly broken into two groups describing how the screen is laid out and
the normal format of sending data to the module.

Character

Typically displays discrete characters each 7x5 or 8x5 matrix, although other character
matrices are less commonly available. A character cursor and/or icons may also be
included on the display. Data is normally sent as text (with positioning and other
information). Some controllers will allow custom characters to be created or have font-
sets other than English available. While most controllers have near identical command
sets, there may be differences in the required timing of received instructions and good
design should make allowance to adjust timing.

Graphic

In a graphic display, the viewing area is laid out as a dot matrix, and data can be sent to
control each individual dot, although some controllers have an in-built character
generator to display alpha-numerics on the screen. Some modules have a controller on-
board, while others are 'pure driver' and require an external controller. Except in high
volume applications, it is rarely economical to use pure driver with an external controller.
As modules may have different controller options and it is important to specify the
controller you require as they are not generally compatible.

LCD type
TN

Twisted Nematic. Has a viewing range of approximately 90°. Has been largely
superseded by STN and is normally only used for high volume, low cost products or by
some hobbyist suppliers. Not recommended for general use.

HTN

High Twisted Nematic. Viewing range 100-110°. Not commonly available.

STN

Super Twisted Nematic. Viewing range 180°. Most common LCD type. The wide
viewing range and high contrast makes it a good choice for many applications.
Commonly available as very dark blue on yellow/green or grey background. As it is made
in volume, cost is comparable to lesser types in all except highest volume.
FSTN

Formulated STN or Filtered STN. An optically compensated film is added to STN, and is
used as a high contrast monochrome display. Normally makes the display 'negative', i.e.
'on' pixels are transparent. Used with CCFL backlight, can be paper-white with black
pixels.

Color STN

STN display with R/G/B filter to display colours.

TFT

Thin Film Transistor. Active type display for Notebook and other colour applications.

OLED

Organic Electro Luminescent. Not strictly a LCD, but can be used in place of LCD in
some applications (i.e. mobile phone colour displays). It is self illuminating and so has a
wide viewing and high contrast. Currently limited availability.

LCD Structure

The following LCD types are available according to the construction of the display.

Reflective

No backlight, with display illumination from ambient or external light source. They are
not suitable for use in a dark environment. Positive display ('on' pixels are dark)

Transflective

Allows light transmission from rear of the display, while retaining sufficient reflectivity
to use ambient light. The backlight can be switched off in bright locations to conserve
battery power or backlight service life. Normally positive display.

Transparent or Transmissive

Backlight is always required for viewing. Ambient light does not assist viewing. Negative
display.

Backlight

A backlight allows the LCD to be viewed in dark conditions.


LED - Light Emitting Diode

Uses an array of LED's to illuminate the display. May be in a light box behind the display
for maximum brightness, or around the edge for thinner display, but lower brightness.
Low voltage DC supply. Usually yellow/green colour and other colours may be available,
but often high volume is required. Long life span and relatively high power consumption.

EL - Electroluminescent

Light generated by an electric field on a high molecular weight film. Normally


purple/blue or white. Requires a high voltage AC supply usually generated by an inverter.
Low power consumption, but limited life. Can be added to most modules without
increasing module thickness.

CCFL - Cold Cathode Fluorescent Lamp

Thin fluorescent tube along edge(s) of display. High brightness suited to graphic
modules. Requires a CCFL inverter to operate.

Light Guide

Not quite a back-light, but a module housing with apertures to shine light into, often from
surface mount (SMD) LEDs, which is then diffused across the rear of the LCD to
illuminate it.

Viewing Angle

Specifies the viewing direction to get the best contrast. The viewing angle is a function of
the orientation of the polarising film and is set during manufacture and cannot be altered
later. Important with TN displays due to the lower viewing angle range, and while still
specified for STN, it is a lot less important for most applications.

12 o'clock

Also called Top viewing. For displays that will be typically viewed from the direction of
the top edge. Typically this might be a panel mounted display that is installed below the
users eye-line.

6 o'clock

Also called Bottom viewing. A typical application would be in a hand-held unit where the
display is viewed from the bottom edge as the unit is held away from the user.
9 o'clock & 3 o'clock

While theoretically possible, I have never seen a display in either configuration.

Normal or Extended Temperature

The LCD glass used determines the temperature range the modules can be stored and
operated at. The values given below are most commonly used, but check with the
supplier the actual allowable extremes.

Normal Temperature

0°C ~ 50°C

Extended Temperature

-20°C ~ 70°C. Usually requires a negative voltage on the contrast pin.

Touch Panel

A transparent overlay is affixed to the display. When the overlay is touched, an electrical
signal identifies which area was pressed. Touch panels can be broadly grouped as
analogue or digital type.

Analogue

It can identify where the screen was touched according to X-Y co-ordinates. It is suitable
when there is a large number of 'hot-spots' or continuous co-ordinate input is required
(i.e. character recognition)

Digital

Uses short circuiting key switches at 'hot spots' on the screen. It is most suitable to use
when there is relatively few touch-pads and you wish to use key encoders or other
existing circuitry. Also more suited to finger tip entry.

Disclaimer
All information is provided in good faith, but without any warranty or guarantee as to
fitness to purpose. It is solely left to the discretion of the recipient or prospective user as
to the suitability of information or product supplied by Computronics for their
application.
Instruction set of PIC16 series

In PIC16 series, RISC(Reduced Instruction Set Computer) is adopted and the number of the
instructions to use is 35 kinds.
When clicking the mnemonic of each instruction, you can jump to the instruction specification.
The terminology explanation
Mnemonic : The assembler language which made an operation code plain
Operands : The specification part except the operation code
MSb : Most Significant bit
LSb : Least Significant bit
Flag : The field of the STAUS register

Mnemonic Instruction code


Operation explanation Flag
Operands

Byte-oriented file register operations

ADDWF f, d Add W and f C, DC, Z

ANDWF f, d AND W with f Z

CLRF f Clear f Z

CLRW - Clear W Z

COMF f, d Complement f Z

DECF f, d Decrement f Z

DECFSZ f, d Decrement f, Skip if 0

INCF f, d Increment f Z

INCFSZ f, d Increment f, Skip if 0

IORWF f, d Inclusive OR W with f Z

MOVF f, d Move f Z

MOVWF f Move W to f

NOP - No Operation

RLF f, d Rotate Left f through Carry C

RRF f, d Rotate Right f through Carry C

SUBWF f, d Subtract W from f C, DC, Z

SWAPF f, d Swap nibbles in f

XORWF f, d Exclusive OR W with f Z

Bit-oriented file register operations


Instructions of PIC16 series

Radix
In the software of the computer, hexadecimal is often used.
Decimal
In our daily life, 10 numbers from "0" to "9" are used.
In case of the count-up, after 9, the carry is done and becomes 10. We are using properly but
this is the count method of the number which the human being decided.
This seems to depend on that the fingers of the hand of the person is 10.

Binary
Only two values of "0" and "1" are used to express a condition by the digital world which
included a computer. These are sometimes expressed by "Low level " and "High level ", too.
Like 0 1 10, after 1, it is 10.

Hexadecimal
In the condition to be handling with the computer, it is a binary number but it is difficult to
understand for the person who is using the decimal.
163(Decimal) 10100011(Binary)
Therefore, a hexadecimal is used as the expression which it is easy for the person to
understand. As for the hexadecimal, 16 numbers are used for 1 digit. It is from 0 to 9 that it is
expressed by the figure. So, six of the remainder are expressed by the alphabet.
10 A, 11 B, 12 C, 13 D, 14 E, 15 F
The figure has begun with 0. Therefore, 10 of the figure shows the 11th and 15 shows the
16th.
16 kinds of conditions are expressed by 4 bits in the binary. Oppositely, the hexadecimal is
used because that it is possible to express 16 by 4 bits. There is the octal which is expressed
by 3 bits. In case of the hexadecimal, 1 byte is expressed by 2 digits.
Also, it puts "h" to distinguish the hexadecimal from the decimal. h is the initial of
hexadecimal(16).
It shows in 00h or H'00' or 0x00. However, an expression isn't unified.

The correspondence of radix


The correspondence of Binary, Decimal and Hexadecimal is as follows.
Decimal Binary Hexdecimal Decimal Binary Hexdecimal
0 0 0h 100 1100100 64h
1 1 1h 127 1111111 7Fh
2 10 2h 128 10000000 80h
3 11 3h 200 11001000 C8h
4 100 4h 255 11111111 FFh
5 101 5h 256 100000000 100h
6 110 6h 300 100101100 12Ch
7 111 7h 400 110010000 190h
8 1000 8h 500 111110100 1F4h
9 1001 9h 511 111111111 1FFh
10 1010 Ah 512 1000000000 200h
11 1011 Bh 600 1001011000 258h
12 1100 Ch 700 1010111100 2BCh
13 1101 Dh 800 1100100000 320h
14 1110 Eh 900 1110000100 384h
15 1111 Fh 1000 1111101000 3E8h
16 10000 10h 1023 1111111111 3FFh
17 10001 11h 1024 10000000000 400h
18 10010 12h 2000 11111010000 7D0h
19 10011 13h 2047 11111111111 7FFh
20 10100 14h 2048 100000000000 800h
The change of Binary, Decimal and Hexadecimal can make simple if you use the function
electronic calculator which is attached to the Windows.
When changing without using the calculator, it is possible to do in the following way.
It is possible to change simply if dividing 4 bits.
It is easier if learning a binary pattern to Fh from Ah.
EX. 111000100100010000100 1C4884h
It is possible to change 1 digit of the hexadecimal into the binary in the order.
EX. 5F37Bh 1011111001101111011
This is troublesome a little.
First, you write a decimal value every bit like the following figure. Total the
decimal value of the bit of "1".
EX.

512 + 256 + 128 + 8 + 4 + 1 = 909


This is terrible a little, too.
Subtract the maximum number of power of
two(1,2,4,8,16,32,64,128,256,512,1024,...) which can be subtracted from the
decimal number.
It makes the bit which corresponds to the number of power of two which
could be subtracted to "1".
Subtract the number of power of two which could be subtracted from the
remainder more.
Hereinafter, repeat similar subtraction until the remainder passes away.
The row of "1" and "0" by above result is a binary number.
EX. "582"
582 - 512 = 70
70 - 64 = 6
6-4=2
2-2=0

Change a decimal into the binary first and change a result into the
hexadecimal more.
In case of the example(D B) which was shown above, 582 = 1001000110
246h.

When changing directly, there is a way of dividing by the value of 4 bits.


582 / 256 = 2 remainder 70
70 / 16 = 4 remainder 6
The result is 246h.
Change a hexadecimal into the binary first and change a result into the
decimal more.
In case of the example(B D) which was shown above, 38Dh = 111000
= 909

When changing directly, there is a way of multiplying the value of 4 bits.


3 x 256 = 768
8 x 16 = 128
The result is 768 + 128 + 13(Dh) = 909.
Still, it is easy to calculate using the function electronic calculator.

2's Complement
The 2's complement is the one which shows negative numerical value.
For example, "-1" of the decimal number is 11111111 when showing by the binary with byte.
It is as follows when confirming.

The overflow occurs but the numerical value becomes zero.


A binary addition is done from the lower rank figure like the decimal number. When there is a
carry, it calculates a higher rank figure including it.

To use a negative value, there is a condition.


The numerical value which it is possible to show at the byte is 256 kinds of 0 to 255.
However, when using the negative value, it becomes 255 kinds of - 127 to +127. The reason
why the numbers are few is because 10000000 isn't used. The row of these bits shows -0 but
in the calculation, it can not use. Most significant bit 7 is used as the sign bit which shows
negative or positive. The type with numerical value must be considered when processing it.
For example, it is 10000001 when showing -127 in the binary number. It becomes 129,
supposing that this is only plus numerical value.

A change into the 2's complement is done as follows.

I attempt to change 56 into -56 as the example.


(1) Subtract 1 from the value 56 - 1 = 55
(2) Change this into the binary 55 00110111
(3) It makes 0 and 1 opposite 00110111 11001000
11001000 is the binary number which shows -56.

It is as follows when confirming.

The answer became zero.

General format for instructions


The format for instructions of PIC16 series is the following three kinds. The instructions are written in
the program memory and one instruction is composed of 14 bits. These 14 bits are called a word.
Byte-oriented file register operations
The instructions of this format are the instructions which processes a byte unit.

OPECODE : The code to distinguish a instruction is written.

d (Destination select) It specifies the register which stores the execution result of the instruction.
: d=0 : It specifies working register ( W reg ).
d=1 : It specifies file register which is specified by f.
In case of the assembler language, d is written in W or F.
(EX) ADDWF COUNT,W ( d=0 when writing W )
ADDWF COUNT,F ( d=1 when writing F )

f (Register file) : It specifies the address of the register which is dealt with for the instruction.
f can specify an address from 0(00h) to 127(7Fh) because it is 7 bits.
In case of PIC16F84A, because the register memory is 80 bytes including SFR,
it is possible to be specified by f if being 7 bits.
When writing by the assembler language, the label is put to the register and
uses.
( COUNT is the label of the
(EX) ADDWF COUNT,F
register)

Bit-oriented file register operations


The instructions of this format are the instruction which processes a bit unit.

OPECODE : The code to distinguish a instruction is written.

b (Bit address) : It specifies the bit position of the register file.


Because the register file is a byte, it can specify all bit positions with 3-bit b.

f (Register file) : It specifies the address of the register which is dealt with for the instruction.
f can specify an address from 0(00h) to 127(7Fh) because it is 7 bits.
In case of PIC16F84A, because the register memory is 80 bytes including SFR,
it is possible to be specified by f if being 7 bits.
When writing by the assembler language, the label is put to the register and
uses.

Literal and control operations


The instructions of this format do the processing which used the fixed number (k) which was
written in the instruction.
There are two instruction types and fixed number (k) is 11 bits about GOTO and CALL
instruction.
Soldering
The soldering is the basic work for electronic circuit engineering. I will introduce the
tools for soldering below.
The sufficient attention is necessary during work, because soldering handles a high
temperature.
Pay attention to the handling of the soldering iron sufficiently, because it becomes
burn, fire more, carelessly.

Soldering iron
Soldering iron is a necessary instrument when you solder.
Solder is hardening in a normal temperature, but solder can melt easily by using the
soldering iron and the parts and wiring materials can be fixed to the printed wiring
board(PWB).
The important piont is temperature of the soldering iron.
For soldering, it needs to become the temperature of the object(PWB, parts, wire etc) to
solder melting temperature.
However, the temperature of soldering iron must not be too high. The electronic
component gets damage with high temperature. So, you need to solder in a short time.
Sometimes, the loose contact of soldering occurs. It is difficult to confirm only by
looking at. When the temperature of the object is not enough, the loose contact will be
occured.
At the end of assembling of the electronic circuit, you need to check the soldered
contact with circuit tester etc.

Electric power (Calorific value is decided with this)


There are various kind of soldering irons. I am using 3 kinds of soldering irons.

25W type
I am usually using this type. This type is convenient when solder the
parts on PWB.
80W type
I use this type when I solder the parts to thick copper plate.
In case of thick copper plate, the heat is easy to escape and the
temperature rise is difficult.
15W type
I use this type for the part which is easy to break by the heat.

Usually, 25W type is enough.


The tip of iron
The soldering is done at the tip of iron. So, the
tip of iron is very important.
There is the type that the tip of soldering iron is
made of copper stick. But I don't recommend
that type.
Because, the copper stick rusts easily by heat
and it becomes difficult to convey heat.
Also the tip of copper stick melts with solder. It
becomes difficult to sloder.
I recommend the one that is using a special
metal for tip. It is difficult to rust and melt.
The tip of iron must keep clean.
When it get dirty, it becomes difficult to
convey heat.

There are many shape of tips. The tip which fit


to the DIP type IC is used to remove the ICs.
All of the solder on the pins can be melt at
same time then it easy to remove the IC.
I do not have such kind of soldering iron.

Usually the soldering iron is heated by electricity.


However, there is the soldering iron heated by gas.
It is convenient to carry.

Soldering iron stand


The soldering iron becomes high temperature.
Therefore it can't be placed on the desk directly.
The stabilized soldering iron stand is necessary.

When making the electronic circuit, sometime I forgot the existence of soldering iron,
because I have devoted to the parts, wiring etc. It was serious when I noticed, desk was
burning.
You need to choose the iron stand with appropriate weight which can hold iron stably.
Also you need to choose the iron stand that fit the form of iron.

Usually I wipe the tip of iron with moistened sponge. Therefore I use the iron stand with
the place for sponge. This is your taste.

Solder
The solder is the alloy of lead and tin.
As for good solder, the containment rate
of tin is high. The finish of soldering is
beautiful. The price is a little bit high.
There are several kinds of solder, solder wire(
thread form solder ) is convenient for electronic
circuit making.
This solder wire is doing the structure of the pipe and flux is included inside. Flux melts
together with the solder and the solder becomes easy to attach to the component leads.
There is some thickness of solder wire. I am usually using the one that diameter is 0.5
mm. The containment rate of the tin is 60%.

Solder sucker
The failure of soldering occurs often. In this case, the part or the wiring must be
removed.
I will introduce the instruments that can be used for desoldering.

Solder pump
This is the tool that can be absorbed the melted solder with the repulsion power of the
spring that was built in with the principle of the piston.
The usage is shown below.
Push down the knob of the upper part of the pump against to spring until it is locked.
Melt the solder of the part that wants to absorb solder with iron.
Apply the nozzle of the pump to the melted solder part.
Push the release knob of pump.
Then the plunger of the pump is pushed up with the power of spring and solder is
absorbed inside the pump.
You need to do this operation quickly, otherwise the part gets damage by the heat. A
little practice is needed.

Desoldering wire
This is made of thin copper net wire like a screen cable in a coaxial cable.
Like water inhales to cloth, the solder is absorbed to the net wire by a capillary tube
phenomenon.
The usage is shown below.
Apply the desoldering wire to the part that wants to take solder.
Apply the soldering iron from the top and Melt the solder.
The melted solder is absorbed to desoldering wire with a capillary tube phenomenon. At
this time you absorb solder while shifting desoldering wire.
When the solder can not be removed in the once, remove repeatedly while shifting the
desoldering wire.

There are several kinds of width of desoldering wire. I am using the one with 2mm
width.

MPLAB IDE
MPLAB IDE is a Windows-based Integrated Development Environment (IDE) for the
Microchip Technology Incorporated PICmicro® microcontroller (MCU) families.
MPLAB IDE allows you to write, debug, and optimize PICmicro MUC applications for
firmware product designs. MPLAB IDE
Includes a text editor, simulator, and project manager. MPLAB IDE also supports the
MPLAB-ICE and PICMASTERÒ emulators, PICSTART® Plus and PRO MATE® II
programmers, and other Microchip or third party development system tools.

MPLAB IDE provides functions that allow you to:


• Create and Edit Source Files
• Group Files into Projects
• Debug Source Code
• Debug Executable Logic Using the Simulator or Emulator(s)

The MPLAB IDE allows you to create and edit source code by providing you with a full-
featured text editor. Further, you can easily debug source code with the aid of a Build
Results window that displays the errors found by the compiler, assembler, and linker
when generating executable files.

The MPLAB IDE also provides feature-rich simulator and emulator environments to
debug the logic of executables. Some of the features are:

• A variety of windows allowing you to view the contents of all data and program
memory locations

• Source Code, Program Memory, and Absolute Listing windows allowing you to view
the source code and its assembly-level equivalent separately and together (Absolute
Listing)

• The ability to step through execution, or apply Break, Trace, Standard,or Complex
Trigger points

Power Supply Documentation


Use this information to add in your project documentation. This will help you for projects
documentation pages. Information is not copyrighted so use it as per your way, then pass
it on.

Power supply

The power supply used here supplies the required voltages to the respective devices
where it is connected. For microcontroller IC PIC 16F877A , 5V 1A supply is required.
Using bridge rectifier this requirement is fulfilled. Capacitor filter is used to remove the
unwanted ripples. But as we know output of the bridge rectifier is not accurate hence
voltage regulator IC LM 7805 is used for accurate output.

A DC power supply which maintains the output voltage constant irrespective of A.C
mains fluctuations or load variations is known as regulated DC power supply. It is also
referred as full-wave regulated power supply as it uses four diodes in bridge fashion with
the transformer. This laboratory power supply offers excellent line & load regulations &
output voltages +5V and 12 V output currents up to one amp.

Step-down transformer:

The transformer rating is 230 V AC at primary & 12-0-12, 1 Amps across secondary
winding. This transformer has a capability to deliver a current of 1 Amp which is more
than enough to drive any electronic circuit or varying load. The 12 V AC appearing
across the secondary is the RMS value of the waveform and the peak value would be 12x
1.414 =16.8 volts. This value limits our choice of rectifier diode is 1n4007 which is
having PIV rating more than 16 volts.

Rectifier stage

The two diodes D1 & D2 are connected across the secondary winding of the transformer
as full-wave rectifier. During the positive half cycle of secondary voltage the end of A of
the secondary winding becomes positive and end B negative. This makes the diode D1
forward biased and diode D2 reverse biased. Therefore, diode D1 conducts while diode
D2 does not. During the negative half-cycle, end A of the secondary winding becomes
negative and end B positive. Therefore diode D2 conducts while diode D1 does not. Note
that current across the center tap terminal s in the same direction for both half-cycles of
input AC voltage. Therefore, pulsating DC obtained at point C with respect to ground.

Filter stage

Here capacitor C1 is used for filtering purpose and connected across the rectifier output.
It filters the AC components present in the rectified DC and gives steady DC voltage. As
the rectifier voltage increases it charges the capacitor and also supplies current to the
load. as the rectifier voltage increases it charges the capacitor and also supplies curent to
load. When capacitor is charged to the peak value of the rectifier voltage rectifier voltage
starts to decrease. As the next voltage peak immediately recharges the capacitor the
discharge period is of very small duration .Due to this continuous charge -discharge cycle
very little ripple is observed in the filtered output. Moreover, output voltage is higher as it
remains substantially near the peak value of rectifier output voltage. This phenomenon is
also explained in other form as: The shunt capacitor offers a low reactance path to the AC
components of current & open ckt to DC component. During positive half cycle the
capacitor stores the energy in the form of electrostatic field. During negative half cycle
the filter capacitor releases stored energy to the load.

Voltage regulation stage

Across the point 'D' and ground there is rectified and filtered DC. In the present circuit
KIA 7812 three terminal voltage regulator IC is used to get +12V and KIA 7805 voltage
regulator IC is used to get +5v regulated DC output. In there terminals pin 1 is input i.e.
rectified & filtered DC is connected to this pin. Pin 2 is common pin and is grounded.
The pin 3 gives the stabilized DC output to the load. The circuit shows two more
decoupling capacitors C2 & C3 which provides ground path to the high frequency noise
signals. Across the point 'E' and 'F' with respect to ground +5v & +12 V stabilized or
regulated DC output is measured, which can be connected to the required circuit.

The LM78XXX series of three terminal positive voltage regulators is available with
several fixed output voltage making them useful in a wide range of applications. When
used as a zener diode/resistor combination replacement, the LM 78XX usually results in
an effective output impedance improvement of two orders of magnitude and lower
quiescent current. These regulators can provide local on card regulation eliminating the
distribution problems associated with single point regulation. The voltages available
allows the LM 78XX to be used in logic system, instrumentation, and other solid state
electronic equipment. The LM78XX is available in the plastic TO-92(Z) package, the
plastic SO-8 (M) package and chip sized package (8-bump micro SMD) using national
micro SMD package technology. With adequate heat seeking the regulator can deliver
100ma output current. Current limiting is included to limit the peak output current to a
safe value. If internal power dissipation becomes too high for the heat sinking provided
the thermal shutdown circuit takes over preventing the IC from over heating.

S-ar putea să vă placă și