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 RB0-7 : Input/Output port B RC0-7 : Input/Output port C RD0-7 : Input/Output port D RE0-2 : Input/Output port E AN0-7 : Analog input port RX : USART Asynchronous Receive TX : USART Asynchronous Transmit SCK : Synchronous serial clock input SCL : Output for both SPI and I2C modes DT : Synchronous Data CK : Synchronous Clock SDO : SPI Data Out ( SPI mode ) SDI : SPI Data In ( SPI mode ) SDA : Data I/O ( I2C mode ) CCP1,2 : Capture In/Compare Out/PWM Out OSC1/CLKIN : Oscillator In/Ecternal Clock In OSC2/CLKOUT : Oscillator Out/Clock Out

MCLR : Master Clear ( Active low Reset ) Vpp : Programming voltage input THV : High voltage test mode control VREF+/- : Reference voltage SS : Slave select for the synchronous serial port T0CKI : Clock input to Timer0 T1OSO : Timer1 oscillator output T1OSI : Timer1 oscillator input T1CKI : Clock input to Timer1 PGD : Serial programming data PGC : Serial programming clock PGM : Low voltage programinng input INT : External interrupt RD : Read control for the parallel slave port WR : Write control for the parallel slave port CS : Select control for the parallel slave PSP0-7 : Parallel slave port VDD : Positive supply for logic and I/O pins Vss : Ground reference for logic and I/O pins

Key Features MAX Operating Frequency FLASH Program Memory (14-bit words) Data Memory (bytes) EEPROM Data Memory (bytes)

PIC16F873 20MHz

PIC16F874 20MHz

PIC16F876 20MHz

PIC16F877 20MHz

4K 192 128 RA0-5 (6) RB0-7 (8) RC0-7 (8)

4K 192 128 RA0-5 (6) RB0-7 (8) RC0-7 (8) RD0-7 (8) RE0-2 (3) 3 2 MSSP, USART PSP 8 Channels 35 Instructions 40 Pins

8K 368 256 RA0-5 (6) RB0-7 (8) RC0-7 (8)

8K 368 256 RA0-5 (6) RB0-7 (8) RC0-7 (8) RD0-7 (8) RE0-2 (3) 3 2 MSSP, USART PSP 8 Channels 35 Instructions 40 Pins

I/O Ports

Timers CCP Serial Communications Parallel Communications 10-bit Analog-to-Digital Module Instruction Set Pins (DIP)

3 2 MSSP, USART 5 Channels 35 Instructions 28 Pins

3 2 MSSP, USART 5 Channels 35 Instructions 28 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.

Command Clear Display Display and Cursor Home Character Entry Mode Display On/Off and Cursor Display/Cursor Shift Function Set Set CGRAM Address Set Display Address I/D: 1=Increment* 1=Display Shift S: On D: 1=Display On 1=Cursor U: Underline On 1=Cursor Blink B: On D/C: 1=Display Shift

Binary D7 0 0 0 0 0 0 0 1 D6 0 0 0 0 0 0 1 A D5 0 0 0 0 0 1 A A D4 0 0 0 0 1 8/4 A A D3 0 0 0 1 D/C 2/1 A A D2 0 0 1 D R/L 10/7 A A D1 0 1 I/D U x x A A D0 1 x S B x x A A

Hex 01 02 or 03 01 to 07 08 to 0F 10 to 1F 20 to 3F 40 to 7F 80 to FF

0=Decrement 0=Display Shift off* 0=Display Off* 0=Cursor Underline Off* 0=Cursor Blink Off* 0=Cursor Move

R/L: 1=Right Shift

0=Left Shift 0=4 bit 8/4: 1=8 bit interface* interface 2/1: 1=2 line mode 0=1 line mode* 0=5x7 dot 10/7: 1=5x10 dot format format* *=initialisation setting x=don't care

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 using chip p=16F628 ;tell assembler what chip we are ;include the defaults for the -302 ;suppress bank selection messages ;sets the configuration settings

include "P16F628.inc"

ERRORLEVEL 0, __config 0x3D18 (oscillator type etc.)

registers

cblock 0x20 count count1 counta countb tmp1 tmp2 templcd templcd2 endc

;start of general purpose ;used in looping routines ;used in delay routine ;used in delay routine ;used in delay routine ;temporary storage ;temp store for 4 bit mode

LCD_PORT LCD_TRIS LCD_RS LCD_RW LCD_E

Equ Equ Equ Equ Equ org

PORTA TRISA 0x04 0x06 0x07 0x0000

;LCD handshake lines

movlw 0x07 movwf CMCON (make it like a 16F84) Initialise clrf clrf clrf count PORTA PORTB

;turn comparators off

SetPorts

bsf movlw movwf bcf call call clrf

STATUS, 0x00 LCD_TRIS STATUS, Delay100 LCD_Init count count, w Text 0x00 STATUS, Z NextMessage LCD_Char Delay255 count, f Message LCD_Line2 count count, w Text2 0x00 STATUS, Z EndMessage LCD_Char count, f Message2

RP0 RP0

;select bank 1 ;make all pins outputs ;select bank 0 ;wait for LCD to settle ;setup LCD ;set counter register to ;put counter value in W ;get a character from the ;is it a zero?

zero Message text table

movf call xorlw btfsc goto call call incf goto

NextMessage column zero Message2 text table

call clrf movf call xorlw btfsc goto call incf goto

;move to 2nd row, first ;set counter register to ;put counter value in W ;get a character from the ;is it a zero?

EndMessage Stop goto Stop ;endless loop

;Subroutines and text tables ;LCD routines ;Initialise LCD LCD_Init movlw call movlw call 0x20 LCD_Cmd 0x28 LCD_Cmd ;Set 4 bit mode ;Set display shift

movlw mode call movlw cursor command call call retlw ; command set routine LCD_Cmd movwf swapf andlw movwf bcf call movf andlw movwf bcf call call retlw LCD_CharD LCD_Char addlw movwf swapf andlw movwf bsf call movf andlw movwf bsf call call retlw LCD_Line1 column movlw call retlw movlw call retlw LCD_Line1W addlw

0x06 LCD_Cmd 0x0d LCD_Cmd LCD_Clr 0x00 templcd templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e Delay5 0x00 0x30 templcd templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e Delay5 0x00 0x80 LCD_Cmd 0x00 0xc0 LCD_Cmd 0x00 0x80

;Set display character

;Set display on/off and

;clear display

;send upper nibble ;clear upper 4 bits of W ;RS line to 0 ;Pulse the E line high ;send lower nibble ;clear upper 4 bits of W ;RS line to 0 ;Pulse the E line high

;send upper nibble ;clear upper 4 bits of W ;RS line to 1 ;Pulse the E line high ;send lower nibble ;clear upper 4 bits of W ;RS line to 1 ;Pulse the E line high

;move to 1st row, first

LCD_Line2 column

;move to 2nd row, first

;move to 1st row, column W

call retlw LCD_Line2W addlw call retlw

LCD_Cmd 0x00 0xc0 LCD_Cmd 0x00 0x0d LCD_Cmd 0x00 0x0c LCD_Cmd 0x00 0x01 LCD_Cmd 0x00 tmp1 tmp1, w 0x0f HEX_Table LCD_Char tmp1, w 0x0f HEX_Table LCD_Char 0x00 0xff d0 d'100' d0 d'50' d0 d'20' d0 0x05 count1 0xC7 counta 0x01 countb counta, f $+2 countb, f Delay_0 ;delay 255 mS ;delay 100mS ;delay 50mS ;delay 20mS ;delay 5.000 ms (4 MHz clock) ;delay 1mS ;Clear display ;Set display on/off and ;move to 2nd row, column W

LCD_CurOn movlw cursor command call retlw LCD_CurOff movlw cursor command call retlw LCD_Clr movlw call retlw movwf swapf andlw call call movf andlw call call retlw movlw goto movlw goto movlw goto movlw goto movlw movwf movlw movwf movlw movwf decfsz goto decfsz goto

;Set display on/off and

LCD_HEX

Delay255 Delay100 Delay50 Delay20 Delay5 d0 d1

Delay_0

decfsz count1 ,f goto d1 retlw 0x00

Pulse_e

bsf nop bcf retlw

LCD_PORT, LCD_E LCD_PORT, LCD_E 0x00

;end of LCD routines HEX_Table ADDWF RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW addwf retlw retlw retlw retlw retlw retlw ADDWF RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW end PCL 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x41 0x42 0x43 0x44 0x45 0x46 PCL, f 'H' 'e' 'l' 'l' 'o' 0x00 PCL, f 'R' 'e' 'a' 'd' 'y' '.' '.' '.' 0x00 , f

Text

Text2

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 LCD_Cmd LCD_CharD LCD_Char LCD_Line1 LCD_Line2 Initialise LCD Module Sent a command to the LCD Add 0x30 to a byte and send to the LCD (to display numbers as ASCII) Send the character in W to the LCD Go to start of line 1 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 LCD_HEX Clear the display 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 using chip p=16F628 ;tell assembler what chip we are ;include the defaults for the -302 ;suppress bank selection messages ;sets the configuration settings

include "P16F628.inc"

ERRORLEVEL 0, __config 0x3D18 (oscillator type etc.)

registers

cblock 0x20 count count1 counta countb tmp1 tmp2 templcd templcd2 NumL

;start of general purpose ;used in looping routines ;used in delay routine ;used in delay routine ;used in delay routine ;temporary storage ;temp store for 4 bit mode ;Binary inputs for decimal

convert routine

NumH TenK ;Decimal outputs from

convert routine

endc LCD_PORT LCD_TRIS LCD_RS LCD_RW LCD_E Equ Equ Equ Equ Equ org

Thou Hund Tens Ones PORTA TRISA 0x04 0x06 0x07 0x0000 ;turn comparators off

;LCD handshake lines

movlw 0x07 movwf CMCON (make it like a 16F84)

Initialise

clrf clrf clrf clrf clrf

count PORTA PORTB NumL NumH

SetPorts

bsf movlw movwf bcf call clrf movf call xorlw btfsc goto call incf goto call call movf

STATUS, 0x00 LCD_TRIS STATUS, LCD_Init count count, w Text 0x00 STATUS, Z NextMessage LCD_Char count, f Message LCD_Line2 Convert TenK, w LCD_CharD Thou, w LCD_CharD Hund, w LCD_CharD Tens, w LCD_CharD Ones, w LCD_CharD ' ' LCD_Char NumH, w LCD_HEX NumL, w LCD_HEX NumL, f Next NumH, f Delay255

RP0 RP0

;select bank 1 ;make all pins outputs ;select bank 0 ;setup LCD ;set counter register to ;put counter value in W ;get a character from the ;is it a zero?

zero Message text table

NextMessage column

;move to 2nd row, first ;convert to decimal ;display decimal ;using LCD_CharD to

characters

call convert to ASCII movf call movf call movf call movf call movlw call movf hexadecimal call movf call incfsz goto incf Next call digits change

;display a 'space' ;and counter in

;wait so you can see the

goto

NextMessage

;Subroutines and text tables ;LCD routines ;Initialise LCD LCD_Init call movlw call movlw call mode movlw call cursor command movlw call call retlw ; command set routine LCD_Cmd movwf swapf andlw movwf bcf call movf andlw movwf bcf call call retlw LCD_CharD ASCII LCD_Char addlw movwf swapf andlw movwf bsf call movf andlw movwf Delay100 0x20 LCD_Cmd 0x28 LCD_Cmd 0x06 LCD_Cmd 0x0c LCD_Cmd LCD_Clr 0x00 templcd templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e Delay5 0x00 0x30 templcd templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e templcd, 0x0f LCD_PORT w ;Set display on/off and ;Set cursor off ;clear display ;wait for LCD to settle ;Set 4 bit mode ;Set display shift ;Set display character

;send upper nibble ;clear upper 4 bits of W ;RS line to 0 ;Pulse the E line high ;send lower nibble ;clear upper 4 bits of W ;RS line to 0 ;Pulse the E line high

;add 0x30 to convert to ;send upper nibble ;clear upper 4 bits of W ;RS line to 1 ;Pulse the E line high ;send lower nibble ;clear upper 4 bits of W

bsf call call retlw LCD_Line1 column movlw call retlw movlw call retlw LCD_Line1W addlw call retlw addlw call retlw

LCD_PORT, LCD_RS Pulse_e Delay5 0x00 0x80 LCD_Cmd 0x00 0xc0 LCD_Cmd 0x00 0x80 LCD_Cmd 0x00 0xc0 LCD_Cmd 0x00 0x0d LCD_Cmd 0x00 0x0c LCD_Cmd 0x00 0x01 LCD_Cmd 0x00 tmp1 tmp1, w 0x0f HEX_Table LCD_Char tmp1, w 0x0f HEX_Table LCD_Char 0x00 0xff d0 d'100' d0 d'50' d0 d'20' d0

;RS line to 1 ;Pulse the E line high

;move to 1st row, first

LCD_Line2 column

;move to 2nd row, first

;move to 1st row, column W

LCD_Line2W

;move to 2nd row, column W

LCD_CurOn movlw cursor command call retlw LCD_CurOff movlw cursor command call retlw LCD_Clr movlw call retlw movwf swapf andlw call call movf andlw call call retlw movlw goto movlw goto movlw goto movlw goto

;Set display on/off and

;Set display on/off and

;Clear display

LCD_HEX

Delay255 Delay100 Delay50 Delay20

;delay 255 mS ;delay 100mS ;delay 50mS ;delay 20mS

Delay5 d0 d1

movlw movwf movlw movwf movlw movwf decfsz goto decfsz goto

0x05 count1 0xC7 counta 0x01 countb counta, f $+2 countb, f Delay_0

;delay 5.000 ms (4 MHz clock) ;delay 1mS

Delay_0

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

;end of LCD routines HEX_Table ADDWF RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW addwf retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw PCL 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x41 0x42 0x43 0x44 0x45 0x46 PCL, f '1' '6' ' ' 'B' 'i' 't' ' ' 'C' 'o' 'u' 'n' 't' 'e' , f

Text

retlw retlw retlw

'r' '.' 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 andlw addwf addwf addwf addlw movwf addwf addwf swapf andlw addwf addwf rlf rlf comf rlf movf andlw addwf rlf movlw movwf NumH,w 0X0F Hund,f Hund,f Ones,f 0XE9 Tens Tens,f Tens,f NumL,w 0X0F Tens,f Ones,f Tens,f Ones,f Ones,f Ones,f NumL,w 0X0F Ones,f Thou,f 0X07 TenK ; ; ; ; ; ; ; ; Lb1: movlw 0X0A 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. ; Ten

addwf decf btfss goto Lb2: addwf decf btfss goto addwf decf btfss goto Lb4: addwf decf btfss goto retlw

Ones,f Tens,f 3,0 Lb1 Tens,f Hund,f 3,0 Lb2 Hund,f Thou,f 3,0 Lb3 Thou,f TenK,f 3,0 Lb4 0x00 end

Lb3:

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 using chip LIST p=16F628 ;tell assembler what chip we are ;include the defaults for the -302 ;suppress bank selection messages ;sets the configuration settings

include "P16F628.inc"

ERRORLEVEL 0, __config 0x3D18 (oscillator type etc.)

registers

cblock 0x20 count count1 counta countb tmp1 tmp2 templcd templcd2 NumL

;start of general purpose ;used in looping routines ;used in delay routine ;used in delay routine ;used in delay routine ;temporary storage ;temp store for 4 bit mode ;Binary inputs for decimal

convert routine

NumH TenK ;Decimal outputs from

convert routine

endc LCD_PORT LCD_TRIS LCD_RS LCD_RW LCD_E Equ Equ Equ Equ Equ org goto HEX_Table ADDWF RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW RETLW addwf retlw retlw retlw retlw

Thou Hund Tens Ones PORTA TRISA 0x04 0x06 0x07 0x0000 Start PCL 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x41 0x42 0x43 0x44 0x45 0x46 PCL, f '1' '6' ' ' 'B' , f

;LCD handshake lines

Text

retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw Start

'i' 't' ' ' 'C' 'o' 'u' 'n' 't' 'e' 'r' '.' 0x00 ;turn comparators off

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

SetPorts

bsf movlw movwf movwf bcf call clrf movf call xorlw btfsc goto call incf goto movlw call call movf

STATUS, 0x00 LCD_TRIS TRISB STATUS, LCD_Init count count, w Text 0x00 STATUS, Z NextMessage LCD_Char count, f Message d'2' LCD_Line2W Convert TenK, w LCD_CharD Thou, w

RP0

;select bank 1 ;make all pins outputs ;select bank 0 ;setup LCD ;set counter register to ;put counter value in W ;get a character from the ;is it a zero?

RP0

zero Message text table

NextMessage column

;move to 2nd row, third ;convert to decimal ;display decimal ;using LCD_CharD to

characters

call convert to ASCII movf

call movf call movf call movf call movlw call movf hexadecimal call movf call incfsz goto incf call goto

LCD_CharD Hund, w LCD_CharD Tens, w LCD_CharD Ones, w LCD_CharD ' ' LCD_Char NumH, w LCD_HEX NumL, w LCD_HEX NumL, f Next NumH, f Delay255 NextMessage

;display a 'space' ;and counter in

Next digits change

;wait so you can see the

;Subroutines and text tables ;LCD routines ;Initialise LCD LCD_Init call movlw call movlw call movlw mode call movlw cursor command call call retlw ; command set routine LCD_Cmd movwf swapf andlw movwf bcf call movf LCD_Busy 0x20 LCD_Cmd 0x28 LCD_Cmd 0x06 LCD_Cmd 0x0c LCD_Cmd LCD_Clr 0x00 templcd templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e templcd, w ;Set display on/off and ;Set cursor off ;clear display ;wait for LCD to settle ;Set 4 bit mode ;Set display shift ;Set display character

;send upper nibble ;clear upper 4 bits of W ;RS line to 0 ;Pulse the E line high ;send lower nibble

andlw movwf bcf call call retlw LCD_CharD ASCII LCD_Char addlw movwf swapf andlw movwf bsf call movf andlw movwf bsf call call retlw LCD_Line1 column movlw call retlw LCD_Line2 column movlw call retlw addlw call retlw addlw call retlw

0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e LCD_Busy 0x00 0x30 templcd templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e templcd, w 0x0f LCD_PORT LCD_PORT, LCD_RS Pulse_e LCD_Busy 0x00 0x80 LCD_Cmd 0x00 0xc0 LCD_Cmd 0x00 0x80 LCD_Cmd 0x00 0xc0 LCD_Cmd 0x00 0x0d LCD_Cmd 0x00 0x0c LCD_Cmd 0x00 0x01 LCD_Cmd 0x00

;clear upper 4 bits of W ;RS line to 0 ;Pulse the E line high

;add 0x30 to convert to ;send upper nibble ;clear upper 4 bits of W ;RS line to 1 ;Pulse the E line high ;send lower nibble ;clear upper 4 bits of W ;RS line to 1 ;Pulse the E line high

;move to 1st row, first

;move to 2nd row, first

LCD_Line1W

;move to 1st row, column W

LCD_Line2W

;move to 2nd row, column W

LCD_CurOn movlw cursor command call retlw LCD_CurOff movlw cursor command call retlw LCD_Clr movlw call retlw

;Set display on/off and

;Set display on/off and

;Clear display

LCD_HEX

movwf swapf andlw call call movf andlw call call retlw movlw goto movlw goto movlw goto movlw goto movlw movwf movlw movwf movlw movwf decfsz goto decfsz goto

tmp1 tmp1, w 0x0f HEX_Table LCD_Char tmp1, w 0x0f HEX_Table LCD_Char 0x00 0xff d0 d'100' d0 d'50' d0 d'20' d0 0x05 count1 0xC7 counta 0x01 countb counta, f $+2 countb, f Delay_0 ;delay 255 mS ;delay 100mS ;delay 50mS ;delay 20mS ;delay 5.000 ms (4 MHz ;delay 1mS

Delay255 Delay100 Delay50 Delay20 Delay5 clock) d0 d1

Delay_0

decfsz count1 ,f goto d1 retlw 0x00 Pulse_e bsf nop bcf retlw bsf movlw movwf bcf bcf bsf bsf swapf flag) bcf movwf bsf bcf LCD_PORT, LCD_E LCD_PORT, LCD_E 0x00 STATUS, RP0 0x0f LCD_TRIS STATUS, RP0 LCD_PORT, LCD_RS LCD_PORT, LCD_RW LCD_PORT, LCD_E LCD_PORT, w LCD_PORT, LCD_E templcd2 LCD_PORT, LCD_E LCD_PORT, LCD_E ;set bank 1 ;set Port for input ;set bank 0 ;set LCD for command mode ;setup to read busy flag ;read upper nibble (busy

LCD_Busy

;dummy read of lower

nibble

busy

btfsc goto bcf bsf movlw movwf bcf return

templcd2, 7 LCD_Busy LCD_PORT, LCD_RW STATUS, RP0 0x00 LCD_TRIS STATUS, RP0

;check busy flag, high = ;if busy check again ;set bank 1 ;set Port for output ;set bank 0

;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 andlw addwf addwf addwf addlw movwf addwf addwf swapf andlw addwf addwf rlf rlf comf rlf movf andlw addwf rlf movlw movwf NumH,w 0X0F Hund,f Hund,f Ones,f 0XE9 Tens Tens,f Tens,f NumL,w 0X0F Tens,f Ones,f Tens,f Ones,f Ones,f Ones,f NumL,w 0X0F Ones,f Thou,f 0X07 TenK ; At this point, the original number is

; ; ; ; ; ; ; Lb1: movlw addwf decf btfss goto Lb2: addwf decf btfss goto addwf decf btfss goto Lb4: addwf decf btfss goto retlw 0X0A Ones,f Tens,f 3,0 Lb1 Tens,f Hund,f 3,0 Lb2 Hund,f Thou,f 3,0 Lb3 Thou,f TenK,f 3,0 Lb4 0x00 end

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. ; Ten

Lb3:

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 fontsets 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 onboard, 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 Operation explanation Operands Byte-oriented file register operations ADDWF ANDWF CLRF CLRW COMF DECF DECFSZ INCF INCFSZ IORWF MOVF MOVWF NOP RLF RRF SUBWF SWAPF XORWF f, d Add W and f f, d AND W with f f Clear f Clear W C, DC, Z Z Z Z Z Z Instruction code Flag

f, d Complement f f, d Decrement f f, d Decrement f, Skip if 0 f, d Increment f f, d Increment f, Skip if 0 f, d Inclusive OR W with f f, d Move f f Move W to f No Operation

Z

Z Z

f, d Rotate Left f through Carry f, d Rotate Right f through Carry f, d Subtract W from f f, d Swap nibbles in f f, d Exclusive OR W with f Bit-oriented file register operations

C C C, DC, Z

Z

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 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 10001 10010 10011 10100 0h 1h 2h 3h 4h 5h 6h 7h 8h 9h Ah Bh Ch Dh Eh Fh 10h 11h 12h 13h 14h

Decimal 100 127 128 200 255 256 300 400 500 511 512 600 700 800 900 1000 1023 1024 2000 2047

Binary 1100100 1111111 10000000 11001000 11111111 100000000 100101100 110010000 111110100 111111111 1000000000 1001011000 1010111100 1100100000 1110000100 1111101000 1111111111 10000000000 11111010000 11111111111

Hexdecimal 64h 7Fh 80h C8h FFh 100h 12Ch 190h 1F4h 1FFh 200h 258h 2BCh 320h 384h 3E8h 3FFh 400h 7D0h 7FFh 800h

2048 100000000000

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 fullfeatured 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.

Sign up to vote on this title
UsefulNot useful