NX-887 : PIC16F887 microcontroller Experiment Board l 1
NX-887 PIC16F887 Microcontroller Experiment Board Copyright 2009-2010 by Innovative Experiment Co.,Ltd.
Feature l Support PIC16F8xx/18F (PIC16F887 on-board). It comes with 8KWords Program memory, 20MHz clock and provides 33 I/O port l Support HS oscillator modes l Select mode RUN/PROGRAM with one switch l Connect to PX-200 for downloading program with USB port via ICD2 jack l RS-232 serial port interface circuit l 3-digit multiplexed LED display l 32-Bit LED monitor l LCD connector l 1Hz- 1kHz pulse generator l 4 of 0-5V Voltage source for A/D experiment l DS18B20 : 1-Wire Temperature sensor on-board. l Matrix switch 4x3
Packing List l Experiment board l Documentation l PX-200 USB Flash PIC microcontroller In-System Programmer with USB cable and software in CD-ROM l 12Vdc Adaptor l 16x2 LCD module with cable l RS-232 serial port cable l Wire jumper box set
2 l NX-887 : PIC16F887 microcontroller Experiment Board
1. NX-887 Schematic Description 1.1 Microcontroller section The heart of this section is PIC16F887 microcontroller. It is programmed with via InSystem Programming (ISP) via ICD2 jack by PX-200 programmer board (included in this package) and can select operation mode (Run/Program) by a MODE switch SW1 POWER
+V
D1-D4 1N4001x4
IC1 7805
J1 DC input
C3 47/16V
C2 0.1/50V
DC input : 16-20Vdc
+5V
C1 220/25V
K1 ICD2 (RJ11-6)
PORT B RB7 RB6
RB7 40
RB6
39 Vpp +5V
R1 1k
R2 1k
RB7
RB6
IC2 PIC16F887 LED1 RUN
SW3 MODE
R4 1k
SW2 RESET
1
14
RA2/AN2/VrefRA1/AN1 RA0/AN0
RA0
C6 22pF
XTAL1 20MHz
MCLR
RE2 RE1 RE0
PORT C
OSC1 OSC2
C7 22pF 7 6 5 4 3
RA5 RA4 RA3 RA2 RA1 2 RA0
PORT E RE2/AN7/CS RE1/AN6/WR RE0/AN5/RD
C5 0.1/50V
31
13
RA5 RA4 RA3 RA2 RA1
RB0/INT
11
12
PORT A
RB4 RB3/LVP RB2 RB1
32
+5V
RA5/AN4/SS RA4/T0CKI RA3/AN3/Vref+
38 37 RB4 36 RB3 35 RB2 34 RB1 33 RB0/INT RB5
RB7 RB6 RB5
+5V
LED2 PROG.
R3 4.7k
C4 0.1/50
10 RE2 9 RE1 8 RE0
26 RC7 25 RC6 24 RC5 23 RC4 18 RC3 17 RC2 16 RC1 15 RC0
RC7/RxD/DT* RC6/TxD/CK* RC5/SDO RC4/SDI/SDA RC3/SCK/SCL RC2/CCP1 RC1/T1OSI/CCP2 RC0/T1OSO/T1CKI
PORT D 30 RD7 29 RD6 28 RD5 27 RD4 22 RD3 21 RD2 20 RD1 19 RD0
RD7/PSP7 RD6/PSP6 RD5/PSP5 RD4/PSP4 RD3/PSP3 RD2/PSP2 RD1/PSP1 RD0/PSP0
NX-887 : PIC16F887 microcontroller Experiment Board l 3
Experiment board provide 5 port groups, Port A (RA0-RA5), Port B (RB0-RB7), Port C (RC0-RC7), Port D (RD0-RD7 and Port E (RE0-RE2). However in 28-pin microcontroller cannot use Port D and E connector Oscillator mode for microcontroller is HS mode, fixed frequency at 20MHz On the experiment board provide +5V for supply the experiment circuit and all circuit on the experiment board.
1.2 LED monitor On experiment bord provides 32-bit of active high LED monitors . Each channel connectd current-limit resistor for protect LED current through. LED125-LED132 RED x8
LED117-LED124 RED x8
LED109-LED116 RED x8
LED101-LED108 RED x8
D15
D7
D15
D7
D14
D6
D14
D6
D13
D5
D13
D5
D12
D4
D12
D4
D11
D3
D11
D3
D10
D2
D10
D2
D9
D1
D9
D1
D0
D8 R109-R116 510 x8
D0
D8 R101-R108 510 x8
R109-R116 510 x8
R101-R108 510 x8
LED Monitor active high 16 bit (UPPER)
1.3 7-segment LED display This board provides 3-digit of 7-segment common cathode LEDs. All LED connect in multiplex and connect current-limit resistor in each segment.
DSP201-DSP203 : LED 7 SEGMENTS COMMON CATHODE P201 SEGMENT
a b c d e f g dp P202 R201-R208 DIGIT 220x8
3 2 1
a b c d e f g dp
DSP203
common
DSP202
common
DSP201
common
4 l NX-887 : PIC16F887 microcontroller Experiment Board
1.4 0 to +5V Reference Voltage Source
VR404 10k
VR403 10k
VR402 10k
VR401 10k +5V
For support analog experiment, NX-887 experiment board provides 4 channels of 0 to 5V analog voltage source to supply analog voltage for ADC circuit. V4
V3
1.5 Switch input
V2
V1
+5V
Switch is the type of input device for microcontroller experiment. Four normally-open pushbuttons are made available via connectors. The buttons are wired in an active-low configuration, with an pull-up resistor.
R301 10k*8
S304 ,! S303 , S302 ,
,! , ,
S301 ,
,
1.6 4x3 Matrix Switch or Keypad This circuit consist of 12 push-button switch connect in matrix configuration. It is defined 4 rows and 3 columns. The pull-up resistors are connected at column lines. The switch position are defined in telephone keypad format, number 0 to 9, * and #.
+5V R402 10k *4
S405-S420 Keypad 4x3
P402 ROW +5V
1
2
3
ROW1
4
5
6
ROW2
7
8
9
ROW3
*
0
#
ROW4 COL3 COL2 COL1 P403 COLUMN
NX-887 : PIC16F887 microcontroller Experiment Board l 5
1.7 Pulse Generator The NX-887 experiment board’s pulse generator provides a selectable square-wave output of 1 Hz, 10 Hz, 100 Hz, and 1 kHz. Frequency selection is by the push-button near the pulse generator output (an LED indicates current frequency). Be sure that the output of the pulse generator is connected to an input pin only, as this output is driven both high and low.
FREQUENCY (Hz) 1 10 100 1k
C501 0.1/50V R501 10k
LED501-504 RED x4
R502 510
1 4
2 7
S501 FREQ.
IC501 PGX4100
6 5 3
8
P501 OUT VR701 10k
1.8 LCD module connector At this connector can connect with 16-characters 2-lines LCD module that bundle in experiment board set. It prepare variable resisitor for LCD’s contrast adjustment.
1.9Piezo speaker
RS RW E D0 D1 D2 D3 D4 D5 D6 D7
K701
UIC-LCD RW D0 D2 D4 D6
SP601 Piezo Speaker
Sounding device on this experiment board is
piezospeaker has resonance frequency at 2 to 3 kHz. If the resonance frequecncy apply to the piezo speaker, it lounds maimum.
+
Piezo speaker. It may connect with 1 to 470mF electrolytic capacitor for amplify sound level. The
-
P602
PIEZO
RS E D1 D3 D5 D7
+5V
6 l NX-887 : PIC16F887 microcontroller Experiment Board
1.10 DS18B20 1-Wire Temperarture sensor For supporting the 1-Wire interface experiment, NX-887 board provides a popular 1Wire device; DS18B20 the temperature sensor include the pull-up resistor ready to interface witn the microcontroller.
R901 2.2k
+5V 3 V++
P901 DQ
2 DQ GND 1 IC901 DS18B20
1.11 RS-232 circuit RS-232 serial port interface to microcontroller, This experiment board provides the TxD and RxD pin to MAX232 circuit for interface serial port. Experimenter can interface RS232 serial port very easy.
+5V C902 10/50V 16 2 C903 K901 10/50V 1 IC902 SERIAL PORT MAX232 3 1 6 7 2 7 3 8 8 4 5 6 15 C905 10/50V
C901 10/50V
4 5 10 9
C904 10/50V TxD RxD GND P902 SERIAL DATA
NX-887 : PIC16F887 microcontroller Experiment Board l 7
1.12 Preparing the Solderless Breadboard Most experiments will involve components placed in the solderless breadboard. The breadboard on this experiment board size is 2.5x7 Inches and provides 800 pointcontacts. Detail of breadboard shows in the figure below (the figure is example, size, number of row, point contacts may be change).
A B C D E
#
#
# A B C D E
F G H I J
#
#
#
#
#
#
F G H I J
#
#
#
2. Using experiment board 2.1 Preparation 2.1.1 Before using, user must prepare some tool and software following : 1. MPLAB IDE : MPLAB Integrated Development Environment (IDE) is a free, integrated toolset for the development of embedded applications employing Microchip's PIC and dsPIC microcontrollers. MPLAB IDE runs as a 32-bit application on Microsoft Windows is easy to use and includes a host of free software components for fast application development and super-charged debugging. MPLAB IDE also serves as a single, unified graphical user interface for additional Microchip and third party software and hardware development tools. Moving between tools is a snap, and upgrading from the free software simulator to hardware debug and programming tools is done in a flash because MPLAB IDE has the same user interface for all tools. 2. HI-TECH C Compiler PRO for PIC10/12/16 in Lite mode : HI-TECH C compiler for PIC10/12/16 MCUs implements the optimizations of Omniscient Code Generation (OCG) - a whole-program compilation technology - to provide denser code and better performance for development on PIC10/12/16 MCUs. HI-TECH Software has provided this freeware compiler, HI-TECH C Compiler for PIC10/12/16 MCUs (Lite mode), as a low-cost tool for hobbyists and students, however the license allows its use for commercial purposes as well. It is ideal as a teaching tool for an introduction into the ‘C’ language and
8 l NX-887 : PIC16F887 microcontroller Experiment Board
embedded programming on a PIC10/12/16 MCUs device. Upgrading to PRO mode, contact www.htsoft.com or www.microchip.com. 3. PICkit2 programming software :It is downloader software from Microchip. A user can download this free of charge at www.microchip.com. This tool requires the .HEX file from C compiler and download to the flash memory of PIC microcontroller via ICSP (In-Circuit Serial Programmer). Al l software tools are bundled together with the experiment board in a CDROM. Computer must available at least one USB port for connecting with PX-200 Programmer. 2.1.2 Create the C project file with HI-TECH C compiler via MPLAB IDE 2.1.3 Compile or Build your project file for getting the HEX file. 2.1.4 Prepare DC adpator 9 to 16V 500mA.
2.2 Procedure 2.2.1 Constuct the circuit on breadboard of the NX-887 experiment board. 2.2.2 Connect PX-200 with USB port. 2.2.3 Open the PICkit2TM Programming Softwaresoftware. 2.2.4 Connect NX-887 boar with PX-200 by ICD cable at ICD jack. 2.2.5 Supply voltage to the NX-887 board. 2.2.6 Press MODE switch for changing to PROGRAM mode, red LED is on. 2.2.7 Select the Device family command of the PICkit2TM Programming Software to Mid-range device. PX-200 will detect the target device autommatically. The PIC16F887 microcontroller will be detected and ready to program. 2.2.8 Open the HEX file. 2.2.9 Erase and blank check data in the microcontroller. 2.2.10 Program all code into the microcontroller 2.2.11 Verify programming 2.2.12 After programming completed, press MODE switch to RUN mode. Microcontroller will run your program.
NX-887 : PIC16F887 microcontroller Experiment Board l 9
3. Software installation 3.1 MPLAB IDE and HI-TECH C Compiler installtion (1) Download the MPLAB IDE installation file from www.microchip.com. Get the MPLAB_IDE_8_33.zip (The number of version may vary) or from CD-ROM which is bundled with the PIC Station-3 board. Extract this file to your computer. (2) Double click file Setup.exe to start the installation. You meet the Welcome window. Click on the Next button to License agreement window. Choose I accept the terms of the license agreement box following click on the Next button.
(3) Setup type window appears. Choose the installtion type to Complete and click on the Next button to Choose the destination location window. The default location is C:\Program Files\Microchip. We recommended to use default location. Click on the Next button.
(4) In the current, MPLAB IDE has many development tools add-in. Developer must accept all License agreement.
10 l NX-887 : PIC16F887 microcontroller Experiment Board
(5) After that, the installation start and wait for installtion to complete.
(6)After that, the HI-TECH C compiler installtion dialogue box appears to ask the installtion. Click on the Yes button.
(7) HI-TECH C Compiler installtion window appears. Click on the Next button.
NX-887 : PIC16F887 microcontroller Experiment Board l 11
(8) The License agreement window appears. It inform the version of compiler as Free HI-TECH C PRO for PIC10/12/16. Click on the Next button.
(9) Installation start. Wait for installtion to complete.
3.2 PICkit2 Programming software installtion (1) Download the installation file from www.microchip.com. Get the PICkit 2 v2.61.00 Setup A.zip (number of verion may vary) or from CD-ROM which is bundled with the JXPIC100 experiment board. Extract this zip file to your computer. (2) Double click file setup.exe in PICkit 2 v2.61.00 Setup A folder to start the installation. Click on the Next button to accept every installtion steps until the installation is completed.
12 l NX-887 : PIC16F887 microcontroller Experiment Board
4. C programming developement for PIC microcontroller After install all software tools ready, this chapter explain about how to develop C programming for PIC16F887 by using HI-TECH C Compiler and MPLAB IDE. The first example is LED blinking at RD0 pin of PIC16F887.
4.1 Developing steps (1) Open MPLAB and select menu Project Ă Project Wizard. The Welcome window appears. Click on the Next button.
(2) Choose device number as PIC16F887. Click on the Next button.
NX-887 : PIC16F887 microcontroller Experiment Board l 13
(3) Select compiler tools as HI-TECH Universal ToolSuite. Click on the Next button.
(4) Define the target folder and project. Click on the Browse button to defiene the target folder and project. In this example define to led_blink. Atfer that, click on the Next button.
(5) The Add exist files window appears. Not add any file now. Click on the Next button to next step.
14 l NX-887 : PIC16F887 microcontroller Experiment Board
(6) Summary window appears to report all information of the developed project file. Click on the Finish button.
#include <pic.h> #define _XTAL_FREQ 20000000 __CONFIG(HS & WDTDIS & LVPDIS); void Delay_ms(unsigned int tick) { while(tickâ&#x20AC;&#x201D;) { __delay_ms(1); } } void main() { TRISD0 = 0; while(1) { RD0 = 1; Delay_ms(500); RD0 = 0; Delay_ms(500); } }
Listing 1 : Example C code for getting start the PIC16F887 programming development with MPLAB and HI-TECH C compiler
ÅíҴѺ¶Ñ´ä» à» ¹¡Òü¹Ç¡ä¿Å led_blink.C ࢠҡѺä¿Å â»Ãà¨ç¡µ â´Â¤ÅÔ¡àÁÒÊ »ÁØ ¢ÇÒ·ÕÃè Ò¡Òà Source Files áÅ ÇàÅ×Í¡ÃÒ¡Òà Add File... µÒÁÃÙ» NX-887 : PIC16F887 microcontroller Experiment Board l 15
(7) The main window of MPLAB is opened. Select menu File à New. The editor window is appeared and create the new source code. Type the code following the Listing 1. (8) Save file as led_blink.C (must define .C extension) to same folder of project file. (9) Click on thr right button mouse at Source Files à Add Files ... Next, select led_blink.C file to add with target project file.
(10) Compile the project file by selecting menu Project à Build All or click on the button. (11) Compilation result reports at Build window. After compilation is completed, the completed message ********** Build successful! ********** will be appeared on last line of Build window.
If there is error, you must back to edit and correct already first. (12) The HEX file; led_blink.hex is created and located to same project folder. Next, use this HEX file to download to PIC16F887 microcontroller on the NX-887 board.
16 l NX-887 : PIC16F887 microcontroller Experiment Board
4.2 Downloading code In this example explain about how to downloading the HEX file to NX-887 board with PX-200 progemmer by using PICkit2 software. (1) Connect the PX-200 programmer board with computer’s USB port. (3) Connect the PX-200 board with NX-887 at ICD jack. Press MODE switch to PROGRAM mode. The mode indicator is red. (4) Open the PICkit2 software. It check the communication. It must detect PIC16F887. (5) Select menu File à Import Hex and select the led_blink.hex file.
(5) Click on the Write button for downloading the hex file to PIC16F887 target.
(6) After downloading is finished, Press MODE switch on NX-887 board to RUN mode (Green LED on). PIC16F887 will reset and run the program. Connect a wire between RD0 pin with LED monitor on NX-887 board. You will see LED blink.
INNOVATIVE EXPERIMENT