Top Banner
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 Pro- gram 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
16
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: nx-887_e

NX-887 : PIC16F887 microcontroller Experiment Board���1

NX-887PIC16F887 Microcontroller Experiment Board

Copyright 2009-2010 by Innovative Experiment Co.,Ltd.

Feature��Support PIC16F8xx/18F (PIC16F887 on-board). It comes with 8KWords Pro-

gram memory, 20MHz clock and provides 33 I/O port

��Support HS oscillator modes

��Select mode RUN/PROGRAM with one switch

��Connect to PX-200 for downloading program with USB port via ICD2 jack

��RS-232 serial port interface circuit

��3-digit multiplexed LED display

��32-Bit LED monitor

��LCD connector

��1Hz- 1kHz pulse generator

��4 of 0-5V Voltage source for A/D experiment

��DS18B20 : 1-Wire Temperature sensor on-board.

��Matrix switch 4x3

Packing List��Experiment board

��Documentation

��PX-200 USB Flash PIC microcontroller In-System Programmer with USB cable

and software in CD-ROM

��12Vdc Adaptor

��16x2 LCD module with cable

��RS-232 serial port cable

��Wire jumper box set

Page 2: nx-887_e

2����NX-887 : PIC16F887 microcontroller Experiment Board

1. NX-887 Schematic Description1.1 Microcontroller section

The heart of this section is PIC16F887 microcontroller. It is programmed with via In-

System Programming (ISP) via ICD2 jack by PX-200 programmer board (included in thispackage) and can select operation mode (Run/Program) by a MODE switch

�������

���������

�� �� ��

� �������

���

�������

�������

������

������

���

�����

�� �����

�� ��

�� ��

����� ���

�����

��

!���

!��

��

�������

�"�

�"��

�#

�"�

�"

�"�

�"

�"�

�"�����

��

��

��

��

��

���������

����

����

��

���

���

���

��

���

��

���

���

���������

���������

������$�

���������%&'�

�� ��� ��%&'

�������

�������

� ����

�"�

�"�

�"�

�"

�"����(

�"

�"�

�"�����

�"�

�"�

� ����

� ��

����������

������������������

�"�

���

�"�

����������)

���������$)

������!

����������

������$����

�� ���(�

������!�����(

������!�!����$�

� ����

�� ���

���

��

���

��

���

���

���

����(�(�

����(�(�

����(�(�

���(�(

����(�(�

�� �(�(

����(�(�

����(�(�

� ����

���

���

��

���

��

���

���

���

#

�*

�*�

�*�

�*�

�*�

�* �������

�*��������

�*��������

� ����

��

��

�* ��

��

��

��

��

��

#

�#

�*� ���

���

��������

�*����

���

���

����

Page 3: nx-887_e

NX-887 : PIC16F887 microcontroller Experiment Board���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 cannotuse 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 monitorOn experiment bord provides 32-bit of active high LED monitors . Each channel

connectd current-limit resistor for protect LED current through.

���������

������

������� �

�����

������������� ��������������������

���������

������

�� �����

�����

���

��

��

���

���

���

���

��� �

��

��

��

��

��

��

�����������

������

���������

�����

���������

������

���������

�����

���

��

��

���

���

���

���

��� �

��

��

��

��

��

��

��

1.3 7-segment LED displayThis board provides 3-digit of 7-segment common cathode LEDs. All LED connect in

multiplex and connect current-limit resistor in each segment.

������ ������ ������

���������������� ���������������������

���

���������

����� ����� ����� �����

���

����

�����

���

����

�������

Page 4: nx-887_e

4����NX-887 : PIC16F887 microcontroller Experiment Board

1.4 0 to +5V Reference VoltageSource

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.

���

�����

���

����

���

����

���

�����

���

�� � � ��

������������

������

������

������

�����

��

��

��

��

1.5 Switch inputSwitch is the type of input device for

microcontroller experiment. Four normally-open

pushbuttons are made available via connec-

tors. The buttons are wired in an active-low

configuration, with an pull-up resistor.

1.6 4x3 Matrix Switch or KeypadThis 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 #.

���

� �

� �

� �

����

��������� �������

���������

���

����

����

����

���

����

�����

���� �����

� ��

���

Page 5: nx-887_e

NX-887 : PIC16F887 microcontroller Experiment Board���5

1.7 Pulse GeneratorThe 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.

��

��

��

��

� � � ��

�����������

� ��

�����

����

���

��

�����

���

�����

����������

����

1.8 LCD module connectorAt this connector can connect with 16-charac-

ters 2-lines LCD module that bundle in experiment

board set. It prepare variable resisitor for LCD’s con-

trast adjustment.

��

��

��

��

��

��

��

��

��

��

��

��

��

��

����

�����

�������

���

���������

�����

����

�����

1.9Piezo speakerSounding device on this experiment board is

Piezo speaker. It may connect with 1 to 470mF elec-

trolytic capacitor for amplify sound level. The

piezospeaker has resonance frequency at 2 to 3 kHz.

If the resonance frequecncy apply to the piezo

speaker, it lounds maimum.

Page 6: nx-887_e

6����NX-887 : PIC16F887 microcontroller Experiment Board

1.10 DS18B20 1-Wire Temperarture sensorFor supporting the 1-Wire interface experiment, NX-887 board provides a popular 1-

Wire device; DS18B20 the temperature sensor include the pull-up resistor ready to interface

witn the microcontroller.

���������

��

���

���

������������

������

1.11 RS-232 circuitRS-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 RS-

232 serial port very easy.

�����������

��

� �

���

� ����������

�����������

���������

���������

��������

���������

� �

���

���

��

����������

���

Page 7: nx-887_e

NX-887 : PIC16F887 microcontroller Experiment Board���7

1.12 Preparing the Solderless BreadboardMost experiments will involve components placed in the solderless breadboard.

The breadboard on this experiment board size is 2.5x7 Inches and provides 800 point-

contacts. Detail of breadboard shows in the figure below (the figure is example, size,

number of row, point contacts may be change).

� � �� �� �� ��

� � �� �� �� ��

� � �� �� �� ��

� � �� �� �� ��

2. Using experiment board2.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

Page 8: nx-887_e

8����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 CD-

ROM. Computer must available at least one USB port for connecting with PX-200 Program-

mer.

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

Page 9: nx-887_e

NX-887 : PIC16F887 microcontroller Experiment Board���9

3. Software installation3.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 Welcomewindow. Click on the Next button to License agreement window. Choose I accept theterms 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.

Page 10: nx-887_e

10����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.

Page 11: nx-887_e

NX-887 : PIC16F887 microcontroller Experiment Board���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 JX-

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

Page 12: nx-887_e

12����NX-887 : PIC16F887 microcontroller Experiment Board

4. C programming developementfor 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.

Page 13: nx-887_e

NX-887 : PIC16F887 microcontroller Experiment Board���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 Nextbutton to next step.

Page 14: nx-887_e

14����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—){

__delay_ms(1);}

}void main(){

TRISD0 = 0;while(1){

RD0 = 1;Delay_ms(500);RD0 = 0;Delay_ms(500);

}}

�������� � � �� ������� ����� ���� �������� �� ��� ���� ��������� ����� �����

������������ ����!��"#� ���$�%&��$�����������

Page 15: nx-887_e

NX-887 : PIC16F887 microcontroller Experiment Board���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.

������������ ���� ���������������������������� ��!"�#�� �$%�&��'�(�)*'���+,-��$��������������.�����/0���$����� �������#�'�1

Page 16: nx-887_e

16����NX-887 : PIC16F887 microcontroller Experiment Board

4.2 Downloading codeIn 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.

�������������������