microcontrolador asbo hc-11 - punto flotante s.a.  · web viewedu-pic is offered as a ... with 35...

14

Click here to load reader

Upload: lamtruc

Post on 01-Nov-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

EDU-PIC 16F84 ModuleUser Manual

Index   : 1. I

ntroduction 22. G

eneral Description 23. D

igital ports 3

3.1 Leds and microswitches 43.2 Relay 43.3 Header 16x (keypad port 4 x 4) 53.4 LCD port 5

4. Connecting the system. Step by step 65. Technical specifications 8

5.1 General spec 85.2 Lay out 95.3 Electronics diagram 105.4 Contents of CD 11

Apendix: How to connect an LCD, and a 4 x 4 keypad 11

1. Introduction   :

The philosophy of design of the EDUPIC 16F84 module, was to put in one board many useful interfaces available to the user, and, at the same time diminish costs using only the most widely used components. The EDUPIC module integrates a FLASH memory programmer for the 16F84 but may function as well in AUTORUN mode for field applications.

Making use of Microchips’s MPLAB software tool, EDUPIC connects to a PC COM1 serial port via a DB9 cable. MPLAB integrates an editor, assembler, simulator and linker, but it may as well integrate more tools, like a programmer, an emulator and a compiler. WINPIC is another freeware tool which is used to program the 16F84 FLASH memory. Both software tools function on any Windows system, including 98, 2000, Millenium and XP.

EDU-PIC is offered as a KIT, and includes all needed software and hardware items for it’s immediate functioning: a wall transformer, a serial DB9 cable and a CD. This manual includes all technical specification of the EDUPIC module, such as an electronic diagram, and a lay out diagram. To have your EDUPIC system immediately functioning, please go directly to Chapter 4: Connecting the system.

In case of any question regarding this system, please call us at (52)(55) 56-53-58-01. We also have an online help in msn: [email protected].

Juan Martínez, Punto Flotante, S.A., april 2006

2. General Description

The EDUPIC system was designed to provide the user with a programmer and also a field applications system. Typical applications include robotics, access control systems, home security and industrial automation.

The LAY OUT diagram of the module, and the pin assignment in 16F84 are shown below.EDU-PIC 16F84 Punto Flotante, S.A. 2006

1

Page 2: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

The module design is based on the 18 pin 16F84 microcontroller. It has two sections: the 16F84 programmer, and the microcontroller with interfaces such as leds, microswitches, and a relay connected to it’s ports. The programmer is controlled from the PC via the serial port, using the standard ICSP (in circuit serial programming). ICSP uses three pins of the 16F84: RB6, RB7 and MCLR. The jumpers S1, S2, and S3 connects these three pins either to the programmer section or the microcontroller section.

The overal characteristics of the module are listed below:

16F84 microcontroller operating at 4 Mhz. 1K bytes FLASH, 64 bytes EEPROM, 68 bytes RAM y 1 timer/counter. CMOS technology with very low consumption: only 2 ma. at 5 volt. Harvard arquitecture, with an instruction set of only 35 instructions. 16F84 programmer integrated to module, via a serial cable with DB9 to connect a PC. 8 leds connected to port B, useful for testing or filed applications purposes. 4 microswitches connected to port A, useful for testing or field applications purposes Low power RELAY contacts, ready to activate external devices. LCD port with an standard 14 pin connector. Keypad 4 x 4 port with an 8 pin connector 16x header to provide conection to external interfaces. Watch dog circuit ready to be programmed to provide an automatic reset if the 16F84 loses control. SLEEP mode for very low consumtion, <1 uA of the module. Timer/counter to provide for delays, real time clock and event counter. Interrupt system, generated from several sources, among them the timer, the EEPROM and the port B signals. CODE PROTECTION programmming mode, to avoid possible stealing of code.

EDU-PIC 16F84 Punto Flotante, S.A. 2006

2

Page 3: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

The block diagram of the controller is shown below:

CONTENTS OF CD

Included in CD is MPLAB IDE, a professional development software tool, and WINPIC, a 16F84 programmer software. Also included, are complete data sheets and documentation of module. EDUPIC connects to a PC COM1 port through a serial cable. Any Windows plataform may be used, including 98, 2000, Millenium and XP.

16F84 pin signal description is as follows:

Pin Name Type Function16 OSC1/CLKIN Input Signal 1 of Xtal oscilator15 OSC2/

CLKOUTOutput

Señal 2 del Xtal oscilator

4 MCLR Input Master reset. In programming mode, 12 to 13 volt signal.17 RA0 Bi Input/Output port bit18 RA1 Bi Input/Output port bit1 RA2 Bi Input/Output port bit2 RA3 Bi Input/Output port bit3 RA4/T0CLK1 Bi Input/Output port bit. May be also configured to be an input clock signal for TMR0.6 RB0/INT Bi Input/Output port bit. May be also configured to be an external interrupt.7 RB1 Bi Input/Output port bit8 RB2 Bi Input/Output port bit9 RB3 Bi Input/Output port bit10 RB4 Bi Input/Output port bit11 RB5 Bi Input/Output port bit12 RB6 Bi Input/Output port bit. In programming mode, clock input to sincronize serial data.13 RB7 Bi Input/Output port bit. In programming mode, serial data.5 Vss 5 V. Voltage source.14 Vdd GND Ground

3. Digital ports :

The 16F84 chip has two digital ports: port A with 5 available pins and port B with 8 available pins. Both are bidirectional signals and may be configured as inputs or outputs, as needed, through registers TRISA and TRISB. In the EDUPIC module, 4 microswitches has been connected to port A and 8 leds to port B. Please note that all these signal are also available in the HEADER 16x of module, so that the user may connect external devices. Finally, a relay has been connected to bit RA0 in port A. Many of the pins are used for multiple functions, depending on the interface used. However, an LCD and a 4 x 4 keypad may be simultaneously connected without interferance with each other.

EDU-PIC 16F84 Punto Flotante, S.A. 2006

3

Page 4: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

PORT PIN IN HEADER 16x FUNCTIONPORT ARA0 PIN 1 ACTIVATE/DEACTIVATE RELAYRA1 PIN 3 MICROSWITCH A1, LCD CONTROLRA2 PIN 5 MICROSWITCH A2, LCD CONTROLRA3 PIN 7 MICROSWITCH A3RA4 PIN 9 MICROSWITCH A4PORT BRB0 PIN 2 LED B0, DATA0 LCD, KEYPAD Y1RB1 PIN 4 LED B1, DATA1 LCD, KEYPAD Y2RB2 PIN 6 LED B2, DATA2 LCD, KEYPAD Y3RB3 PIN 8 LED B3, DATA3 LCD, KEYPAD Y4RB4 PIN 10 LED B4, DATA4 LCD, KEYPAD X1RB5 PIN 12 LED B5, DATA5 LCD, KEYPAD X2RB6 PIN 14 LED B6, DATA6 LCD, KEYPAD X3RB7 PIN 16 LED B7, DATA7 LCD, KEYPAD X4

To program direction of bits, the user may use the following lines as an example.

PORTA BSF STATUS,RP0 ;CHOSE REGISTER BANK 1MOVLW 0x1E ;RA0=OUTPUT, RA1..RA4=INPUTSMOVWF TRISA ;PROGRAM DIRECTION OF BITS

PORTB BSF STATUS,RP0 ;CHOSE REGISTER BANK 1MOVLW 0x00 ;RB0..RB7=OUTPUTSMOVWF TRISB

13.1LEDS AND MICROSWITCHES:

Electronic diagrams of leds and microswitches are shown below. All port pins in A and B ports are also available in header 16x for use in external interfaces.

13.2 RELAY

A relay of 12 volts, with contacts of 220 VCA @ 0.2 amperes may be activated from bit RA0 as shown. If RA0 = 1, the relay will close it’s contacts and LED L4 will light on.

EDU-PIC 16F84 Punto Flotante, S.A. 2006

4

Page 5: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

3.3 HEADER 16 X. (INLUDES PORT FOR A MATRIX KEYPAD 4 X 4)

3.4. LCD PORT

There is an standard connector fot an LCD in the EDUPIC module. This connector has 14 pins as shown in the table below. It is possible to connect an LCD to this port and, in parallel, also connect a keypad to the header 16x, using lines RB0…RB7, thanks to the fact that both devices can operate at different time slots.

EDU-PIC 16F84 Punto Flotante, S.A. 2006

5

Page 6: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

LCD EDUPIC FUNCION LCD EDUPIC FUNCION1 Ground 8 DB1 RB1 DATA2 5 volts. 9 DB2 RB2 DATA3 INT Intensity control 10 DB3 RB3 DATA4 RS RA1 0=command 1=data 11 DB4 RB4 DATA5 R/W GROUN

D0=write in LCD 1=read 12 DB5 RB5 DATA

6 EN RA2 Enable pulse 13 DB6 RB6 DATA7 DB0 RB0 DATA 14 DB7 RB7 DATA

4. Connecting the system. Step by step.

STEP 1: COMPONENT CHECK AND INICIAL TEST OF MODULE

Please check that the kit includes: EDUPIC module, wall transformer, serial cable and CD. You will need a PC with Windows 98, Proffesional, Millenium or XP operating system. In the wall transformer, move the 220 VDC selector to it’t proper position and the output voltage selector to 7.5 volts. Connect the wall transformer to EDUPIC. Jumpers S1, S2 and S3 must be in the AUTORUN position. Once the module is with its power on, a program loaded in the FLASH memory should start running, flashing the leds.

STEP 2: INSTALL PROGRAMS MPLAB IDE AND WINPIC FROM CD TO YOUR PC:

Create a folder with the name EDUPIC in the desktop of your PC. Insert CD in drive. Open the contents and copy all folders and files to the EDUPIC folder.

Execute file MPLAB660.zip and then the instalation program. Please take note at the following windows that will appear during instalation:

window: you choose:SOFTWARE LICENSE I ACCEPT NEXTSELECT DESTINATION MPLAB IDE NEXTSHORTCUTS? YES NEXTADD TO DESKTOP? YES NEXTVIEW READ ME FILES? NO NEXT

Now, the program looks for hardware devices such as programmers or emulators in the USB ports. As this is not the case, simply ignore every warning refering to these USB drivers. Then the following text will appear:

INSTALATION COMPLETED FINISHRESTART SYSTEM OK

Once your PC is restarted, open the WINPIC folder and execute winpicpr.zip. Do the extract to the subfolder WINPIC. Make a direct access of WINPIC.exe in your desktop.

STEP 3: DISABLE WRITE PROTECTION IN FILES.

Before editing or assembling any program in MPLAB, you must disable the write protection in the folder “files16F84”. This protection is enabled because the files were copied directly from an only readable CD.

Open folder “files16F84”. Select “edit” and “select all”. Once all files are shadowed, right click your mouse in any file and select “properties”. Disable de “only read” protection in the small square. Then give a click in “apply” and “close”. If you skip this step, MPLAB would be unable to edit or assemble any file and will display an arror message.

EDU-PIC 16F84 Punto Flotante, S.A. 2006

6

Page 7: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

STEP 4: CONNECT MODULE TO PC.

Please take a look at the picture above and identify the components, the 16F84 microcontroller, the wall transformer connector, the serial port DB9 connector and the jumpers S1, S2 and S3. S1, S2 and S3 must be now in the PROGRAM position. Connect the wall transformer. The power LED L3 should light on. The DB9 connector should fit on COM1 or COM2 in the PC side and in the serial connector in EDUPIC on the other side.

STEP 5: CONFIGURE WINPIC. TRANSFER AND EXECUTE A FILE

Execute WINPIC from your desktop. Select option “device,config” and then “part”=”16F84A”. Then select “oscillator”= “XT,XTAL”, “code protection”=“off”, “power up timer=“disabled”, and “watch dog enable”=“disabled”. In option “interface”, “interface type”=“JDM programmer”, “on port”=“COM1”.

Working now on the option “code”, chose “file”, and “load and program device” and then select path C:\EDUPIC\files16F84. Select file “contador.hex”. First, the file is transferred to WINPIC buffer, then automatically, data is transferred to the FLASH memory. Once the memory is succesfully programmed, WINPIC will display: “program finished, no errors”. In case that an error message is displayed, please revise your connections, the position of jumpers S1, S2 and S3, and the configuration of WINPIC.

Select option “device” and “reset/disconnect ICSP/go”. This command will execute the program. You will immediately see a binary count flashing in the LEDS of EDUPIC. You may as well push F9 to execute the program. Following the same procedure, load the file “demof84.hex”. This program will display a rotating pattern in LEDS. Take note that when you load a new program, the FLASH memory is automatically erased before being programmed.

STEP 6: EXECUTION OF PROGRAM IN AUTORUN MODE

The last program loaded in the FLASH memory of the 16F84 may be now executed in AUTORUN mode. Disconnect the serial cable from the computer and move jumpers S1, S2, and S3 to the “Autorun” position”. If necessary, push the reset button. The program will run automatically.

STEP 7: CONFIGURE MPLAB, EDIT, ASSEMBLE AND SIMULATE A PROGRAM.

Execute MPLAB IDE from your desktop. Chose “configure”, “select device” and “16F84”. Now select “file”, “open” and select the path C.\EDUPIC\files16f84. select file “demof84.asm”. Listing of this file is shown below.

; File DEMOF84.ASM; Assembly code for PIC16F84 microcontroller

; Enciende leds del puerto B con un patrón de rotación; Oscilador Cristal de 4 Mhz. Cada LED enciende durante 0.5 seg.

; Configuración del CPU; 16F84, Oscilador cristal 4 Mhz,; watchdog timer off, power-up timer on; incluye archivo p16f84.inc

EDU-PIC 16F84 Punto Flotante, S.A. 2006

7

Page 8: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

processor 16f84include <p16f84.inc>__config _XT_OSC & _WDT_OFF & _PWRTE_ONJ equ H'1F' ; localidad 1F es JK equ H'1E' ; localidad 1E es K

; Programa

org 0 ; origen de memoria flash =0

movlw B'00000000' ; w := 00000000 tris PORTB ; puerto B=0 (bits son salidas)movlw B'00000001' ; movwf PORTB ; port B =1bcf STATUS,C ;carry=0mloop: rlf PORTB,f ;rotate left PORT B (incluye carry)movlw D'200' ;modify this value to ‘4’ to perform simulationmovwf J ; J := wjloop: movwf K ; K := wkloop: decfsz K,f ; K = K-1, skip next if zerogoto kloopdecfsz J,f ; J = J-1, skip next if zerogoto jloopgoto mloop

end

This program will flash LEDS in EDUPIC with a rotating pattern. Before performing simulation, modify the value shown from ‘200’ to ‘4’. This is necessary to escalate the time base, otherwise the simulation would last too long because the speed of the simulator is much lower that the real time speed of the program.

Select “project”, “quickbuild demof84.asm”. Once the program is assembled, select “debugger”, “select tool”, “MPLAB SIM”. Now push F6 to position a green arrow in the starting line of the program and push F7 to run step by step each instruction. To look at the file registers, select “view”, “file registers” and a window will display the value of each file register in the system. Go on with the simulation, looking at the change in the value of the file registers.

To finish simulation, modify again the value ‘4’ to ‘200’ and assemble the program again. Once the program is assembled without errors, you may use WINPIC to transfer it to EDUPIC, as explained in former paragraphs.

5. Technical specifications

5.1 General specifications

Processor: 16F84A microcontroller @ 4 Mhz, with low consumption CMOS technology.Arquitecture: Harvard, with both, code (14 bit) and data (8bit) memories separated. Pipeline proccesing.Instruction set: RISC (reduced instruction set computer), with 35 instructions, 14 bit word length.Memory: 1K FLASH (14 bit), 68 RAM (8bit), 64 EEPROM (8 bit).Read/write capacity: 10,000 cycles in FLASH memory, up to 10,000,000 in EEPROMDigital ports: port A with 5 bits, port B with 8 bits, a total of 13 bits programmable as inputs or outputs.Pull up resistors: available in port B, when programmed as inputs.Digital outputs to LEDS: 8 bits connected to LEDS in port B.Output capacity: each port bit can sink or source up to 25 ma.Digital inputs to microswitches: a total of 4 connected to port A.Output to relay: relay model RAS-1210, contacts 220 VAC @ 0.2 A. Screw connector.Header: 16 pins, with all signals of port A and B available, plus ground and Vcc.Keypad port: 8 signals available in header 16x, for a 4 x 4 matrix keypad.LCD port: 14 pin molex connector, ready for a standard 16 x 1 or 16 x 2 LCD.Other functions: power on reset, timer/counter, watch dog, code protection, sleep.Timer /counter: 8 bit with a 8 bit prescaler.Interrupts: 4 sources of interrupt: external interrupt, overflow in timer/counter, change of level in RB4…RB7, and write

complete in EEPROM.

EDU-PIC 16F84 Punto Flotante, S.A. 2006

8

Page 9: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

Dimensions: 10 cms x 7.5 cms, fiber glass board, thru hole.Power: normal < 2 ma @ 5v. In SLEEP mode only 15 uA.Power supply: wall transformer, 300 ma @ output voltage selector: 6, 7.5, 8 or 9 volt.16F84 FLASH memory programmer: integrated to module, programming is made using a PC and a serial cable connected

to the target module executing WINPIC software.Development tools: MPLAB IDE, editor, assembler, simulator and linker. WINPIC, 16F84 programing software.

5.2 LAY OUT

EDU-PIC 16F84 Punto Flotante, S.A. 2006

9

Page 10: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

EDU-PIC 16F84 Punto Flotante, S.A. 2006

10

Page 11: MICROCONTROLADOR ASBO HC-11 - Punto Flotante S.A.  · Web viewEDU-PIC is offered as a ... with 35 instructions, 14 bit word length. Memory: 1K FLASH (14 bit), 68 RAM (8bit ... MPLAB

5.3 Contents of CD.

1. Test files (folder)2. WINPIC (folder, programmer for 16F84)3. WINZIP (carpeta, ZIP files).4. X14 architecture (folder, flash player 6.0 presentation)5. Manual 16F84 (document PDF)6. Watch Dog 16F84 (document PDF)7. Manual PICCLITE compiler (document PDF) 8.MPLAB Simulator (document PDF)9.PIC 16F84 EEPROM (document PDF)10.PIC 16F84 instruction set (document PDF)11.PIC Microcontrollers (document PDF)12.PIC Serial programmming ICSP (document PDF)13.PIC Book (document PDF)14.EDUPIC Manual 2006 (document PDF)15.MPLAB IDE 6.60 ( ZIP file)16.PICCLITE Setup (ANSI C Compiler)17.AdBdRdr60 (Adobe Reader)18.Pk Reader

APPENDIX: HOW TO CONNECT AN LCD AND A 4 X 4 MATRIX KEYPAD:

PLEASE REFER TO PROJECTS IN SITE: www.puntoflotante.net/projects.htm

EDU-PIC 16F84 Punto Flotante, S.A. 2006

11