EasyPIC2 Manual - MikroElektronika

Transcription

EasyPIC2 Manual - MikroElektronika
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
About EasyPIC2: System supports 8,14, 18, 28, and
40-pin microcontrollers Each jumper, element and pin
is clearly marked on the board. Most of the industrial
applications can be tested on the board: temperature
controllers, counters, timers etc. EasyPIC2 also
includes practical examples in PASCAL, BASIC, C,
and assembly.
easy-PIC 2
Manual
May 2004.
Features:
Choose between external or USB power supply. With USB power supply, you don’t need
external supply.
Very fast and flexible USB programmer on
board. The key feature is expandability. By
downloading new software, you will be able to
program new MCUs in coming years.
Temperature sensor DS1820 allows you to
measure temperature with 0.5 C accuracy.
RS232 communication with selectable TX and
RX for smaller microcontrollers.
For presentation purposes, RA2 and RA3, are
pointed out and can be used for measuring
voltage set by potentiometers P2 and P3.
Port A is connected to the resistor network, if
switch is not in ON position, the appropriate
pin has neither pull-up or pull-down resistor
attached. This is very important, because it
enables using A port in analog mode as AD
converter, and yet it can be used as ordinary
digital I/O port.
Setting PORT jumper to the upper position sets
the pins of the appropriate port to logical one
(pull-up). If jumper is set to the lower postion,
pins are set to logical zero (pull-down). It is
very inportant to put pin on pull-up if you
expect logical zero on input and vice versa.
Prototype area in which you can place your
additional components. The back side of the
board has pin marks to make the connecting
easier.
32 buttons allow you to control every pin on
your microcontroller.
You can chose how pressing the button will
affect the pin, high state or low state.
See all the signals - each pin has LEDs.
Seven segment digits in multiplex mode for
displaying the results.
Turns ON/OFF LEDs on A, B, C, D and E ports.
You can chose which port you want LEDs to be
connected to. Also, you can choose w h i c h
digit you want to be on. In certain applications,
it is important to remove all unnecessary connections from pins - DIP switches let you disconnect all LEDs and digits from MCU pins.
Set LCD contrast according to your needs.
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
EASY PIC 2
Development tool for Microchip PIC MCUs
CONTENTS
Installation of the EasyPIC2 Development System
page 2
Programming the Microcontrollers in the
Development System with USB programmer on board
page 3
Installation of PICFlash software and Programming
the Microcontroller
page 7
Description of the Development System
page 7
Power Supply
page 7
LED Diodes
page 8
Buttons
page 9
LCD Display
page 10
Seven-segment Display
page 11
A/D Conversion
RS232 Communication
page 12
page 13
Digital Termometer - DS1820
page 14
Pull-up, Pull-down Resistors on Ports
Direct Access to Ports
page 15
page 16
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
2
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
INSTALLATION OF THE SYSTEM
Development System package contains development system, serial cable, USB
cable, and two CDs (LCD and a temperature sensor DS1820 are optional when
ordering the package). Installing the system takes 6 steps:
Step no.1
Step no.2
Step no.3
Step no.4
Step no.5
Step no.6
External Power
Supply AC/DC
9-12V
Insert the CD-ROM supplied in the drive before connecting the
EasyPIC2 development system.
Connect EasyPIC2 with computer via USB cable. EasyPIC2 will
use power supply from your PC and start the demo program.
Install USB driver. Please follow the procedure described on the
following page.
Copy PICFLASH software from CD to your HDD.
Copy program examples to your HDD.
Install MPLAB or some other compiler.
USB on-board
programmer
Supply Select:
USB or external
power supply
Figure
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
1.
3
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
EASY PIC 2
Development tool for Microchip PIC MCUs
INSTALLATION OF THE USB DRIVER
Step no.1.
After connecting the EasyPIC2 and PC via
USB cable, you will get a message about
your new hardware and the New Hardware
dialog will be displayed.
Step no.2.
Select ‘Install from a list or a
specific location..’ and click on
NEXT.
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
Figure
2.
Figure
3.
Figure
4.
4
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
EASY PIC 2
Development tool for Microchip PIC MCUs
Step no.3 Browse to the
folder ‘Driver’ on CD, and
select the appropriate folder for
your operation system. Include
the folder in the search, and
click on NEXT.
Figure
5.
Figure
6.
Step no.4 PC will find USB
programmer on board and start
to copy driver files to HDD.
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
5
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
EASY PIC 2
Development tool for Microchip PIC MCUs
Step no.4 To complete the
installation of USB driver, click on
Finish button.
Figure
Figure
7.
8.
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
6
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
EASY PIC 2
Development tool for Microchip PIC MCUs
INSTALLATION OF PICFLASH SOFTWARE AND PROGRAMMING THE MICROCONTROLLER
Step no.1 Copy the file PICFLASH.exe from CD to your hard drive. It is recommended to create the folder
PIC with subfolder PICFLASH for simplicity’s sake (i.e. C:\PIC\PICFLASH). After the program is copied to
the mentioned folder, installation is complete. You may want to create shortcut to the program on your desktop
if you plan to use it frequently.
Step no.2. Start
PICFLASH by clicking
the icon
Step no.3. Select the
appropriate MCU by clicking the option Device.
After you select the wanted
MCU, PICFLASH will
make the necessary adjustments for working with the
specified controller.
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
7
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
Step no.4. Click the option LOAD HEX which
opens up the browse window from the following
figure. By double-clicking the file, appropriate
HEX file will be loaded into programmer’s
buffer.
Step no.5. Click the Write button to start the
programming.
DESCRIPTION OF THE DEVELOPMENT SYSTEM
POWER SUPPLY
For all the elements in the development system to work properly, it
is required to have stabilized +5V. With EasyPIC2 system, it is
achieved by using the power stabilizer LM7805. Also, you can
select USB power supply which allows EasyPIC2 to work
without external power supply.
TO-220
2
Transformator
~ B80C1000
220V~
9V~
~
1 23
1
+
LM
7805
C1
LM7805
2
+5V
3
C2
C3
R
C1 = 22µF, C2 = 100nF,
C3 = 10µF, R = 1K
Figure
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
9.
8
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
LED DIODES
The system has 32 diodes, connected to port A, B,
C, D and E pins. These diodes are ordinarily used
in the first phase of the work, but they are also
used for the later indications of the program flow.
Each set of the diodes can be turned on and off
using the SW3 switch. The way to connect the
LED diodes with a microcontroller is shown on
the following figure.
NOTE: LED diodes turn on with a logical one. It
means that a microcontroller must have a logical
one on a pin for diode to emit light.
RA0
RA1
RA2
RA3
RA4
RA5
RE0
RE1
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
RB0
RB1
RB2
RB3
RB4
RB5
RB6
RB7
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
RC0
RC1
RC2
RC3
RC4
RC5
RC6
RC7
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
RD0
RD1
RD2
RD3
RD4
RD5
RD6
RD7
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
LED
330Ω
ON
SW3
PORTD
PORTC
PORTB
PORTA-E
5V
Figure
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
10.
9
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
BUTTONS
System has one RESET button and 32 buttons for simulating the system inputs which are connected to
the pins RE0, RE1 and ports A, B, C, and D. Graphic scheme of the buttons-controller connection is
shown in the following figure.
+5V
10K
T2
T3
RB7/PGD
RA0/AN0
RB6/PGC
RA1/AN1
RB5
RA2/AN2/Vref-
RB4
RA3/AN3/Vref+
RB3/PGM
RA4/TOCKI
Reset
T1
MCLR/Vpp/THV
RB1
RE1/WR/AN6
+5V
RE2/CS/AN7
Vdd
4MHz
Vss
PIC16F877
RE0/RD/AN5
+5V
Buttons
connected
to 5V
Tasteri
suare
prilikom
aktiviranja
when activated
povezani
na 5V
RB2
RA5/AN4
OSC1/CLKIN
OSC2/CLKOUT
RB0/INT
Vdd
Vss
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RCO/T1OSO/T1CKI
RC7/RX/DT
RC1/T1OSI
RC6/TX/CK
RC2/CCP1
RC5
RC3
RC4
RD0/PSP0
RD3/PSP3
RD1/PSP1
RD2/PSP2
Figure
11.
The mark above every button represents the name of the pin which the button is connected to. In order to
use a button, appropriate pin of A, B, C and/or D ports must be designated as input. Jumper in the lower
left corner of the development system defines if the active value of a pin is 0 or 5 V. If the jumper is set
to “up”, then activating a certain button will bring logical one to the pin, while “down” position will bring
logical zero.
Buttons can be
connected to :
5V
0V
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
10
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
LCD DISPLAY
Standard LCD display (2x16 characters) is supplied.
However, it is not a limitation, because any display
having the same type of communication can be
used. Display contrast can be adjusted using the
potentiometer in the lower left corner of the development system. LCD display connects to the port B.
Following figure shows how to connect the LCD to
port B of the PIC16F877 Microcontroller.
+5V
RA5/AN4
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
Vdd
Vss
+5V
PIC16F877
Reset
10ΚΩ
MCLR/Vpp/THV
RA0/AN0
RA1/AN1
RA2/AN2/VrefRA3/AN3/Vref+
RA4/TOCKI
4MHz
OSC1/CLKIN
OSC2/CLKOUT
RCO/T1CKI
RC1/T1OSI
RC2/CCP1
RC3
RD0/PSP0
RD1/PSP1
RB7/PGD
RB6/PGC
RB5
RB4
RB3/PGM
RB2
RB1
D7
D6
D5
D4
E
RS
RB0/INT
Vdd
Vss
RD7/PSP7
RD6/PSP6
RD5/PSP5
m i Kroe lek t ron i ka
RD4/PSP4
RC7/RX/DT
RC6/TX/CK
RC5
RC4
RD3/PSP3
RD2/PSP2
D7 D6 D5 D4 D3 D2 D1 D0
E R/W RS Vee Vdd Vss
+
1
+5V
LCD contrast
Kontrast
LCD-a
Figure
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
12.
11
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
SEVEN-SEGMENT DISPLAY
Seven-segment display consists of four digits which
are refreshed and displayed using port B in combination with port A. Using the DIP switch SW2, you
can enable or disable specific digits.
For example, let’s assume we need to enable display
of the first digit on the left. By turning the fourth
switch (SW2) to (ON), digit of the seven-segment
display (DIS1, leftmost digit) will be showing value
defined by values of port B pins (picture 18). Procedure is similar with digits DIS2, DIS3 and DIS4.
The following figure shows how to connect the
seven-segment display to the microcontroller.
10ΚΩ
TR4
10ΚΩ
TR3
10ΚΩ
TR2
ON
10ΚΩ
SW2
1
3
2
TR1
4
8888
g
+5V
RB7/PGD
RA0/AN0
RB6/PGC
330Ω
RA1/AN1
RB5
330Ω
RA2/AN2/Vref-
RB4
RA3/AN3/Vref+
RB3/PGM
330Ω
RA4/TOCKI
RB2
330Ω
RA5/AN4
RB1
330Ω
RE2/CS/AN7
Vdd
Vss
OSC1/CLKIN
OSC2/CLKOUT
PIC16F877
RE1/WR/AN6
+5V
330Ω
MCLR/Vpp/THV
RE0/RD/AN5
4MHz
K a
e d K
Reset
10K
f
RB0/INT
Vdd
Vss
330Ω
c dp
g
f
K a
e d K
b
c dp
g
f
K a
e d K
b
c dp
g
f
K a
e d K
b
c dp
h
g
f
e
d
c
b
a
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RCO/T1OSO/T1CKI
RC7/RX/DT
RC1/T1OSI
RC6/TX/CK
RC2/CCP1
RC5
RC3
330Ω
b
RC4
RD0/PSP0
RD3/PSP3
RD1/PSP1
RD2/PSP2
Figure
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
13.
12
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
ANALOG TO DIGITAL CONVERTER
Microcontroller PIC16F877 which is supplied with the system, has
implemented 10-bit A/D converter. For presentation purposes, two
pins, RA2 and RA3, are pointed out and can be used for measuring
voltage set by potentiometers P2 and P3.
If you want to measure values of potentiometer P2, you need to set
the jumper accordingly. SW1 switch RA2 must be turned off (lower
position). Example from the fig. 20 illustrates measuring voltage of
potentiometers P2 and P3, and also shows the position of SW1
switch.
Moving the potentiometer changes
Pomeranjem
potenciometra
the
voltage on RA3
Moving the potentiometer changes
Pomeranjem
potenciometra
the
voltage on RA2
menja se napon na RA2
menja se napon na RA3
These switches must be set to
Ovi
moraju
biti u
OFF
in prekidaèi
order to read
analog
values
of RA2
andkako
RA3 pins
položaju
OFF
bi se
+5V
+5V
mogle èitati analogne
vrednosti pinova RA2 i RA3
5K
5K
RA0
RA1
AN3
RA2
RA3
10κΩ
RA2
10κΩ
RA3
10κΩ
RA4
10κΩ
10ΚΩ
+5V
MCLR/Vpp/THV
RB7/PGD
RA0/AN0
RB6/PGC
RA1/AN1
RB5
RA2/AN2/Vref-
RB4
RA3/AN3/Vref+
RB3/PGM
RA4/TOCKI
RE1/WR/AN6
+5V
RE2/CS/AN7
Vdd
Vss
OSC1/CLKIN
OSC2/CLKOUT
10κΩ
RE1
10κΩ
ON
GND
SW1
RB0/INT
Vdd
Vss
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
4MHz
RCO/T1OSO/T1CKI
RC7/RX/DT
RC1/T1OSI
RC6/TX/CK
RC2/CCP1
RC5
RC3
RE0
RB1
PIC16F877
RE0/RD/AN5
10κΩ
RB2
RA5/AN4
Reset
RA5
5V
1 2 3 4 5 6 7 8
AN2
10κΩ
RC4
RD0/PSP0
RD3/PSP3
RD1/PSP1
RD2/PSP2
Figure
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
14.
13
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
RS232 COMMUNICATION
RS232 communication is used for communication between two devices within 10m
distance. It is commonly used for data
transfer with computer.
Jumpers RX and TX select the pin which
the communicaton will be attached to. If
DIP40 or DIP28 MCUs are used, they
should be connected to RC6 and RC7, and
in case of DIP18 MCU, use the pins RB1
and RB2.
Figure below shows the connection
between computer and the development
system.
10K
Reset
+5V
MCLR/Vpp/THV
RA0/AN0
RB7/PGD
RB6/PGC
RA1/AN1
RA2/AN2/VrefRA3/AN3/Vref+
RA4/TOCKI
RB5
RB4
RB3/PGM
+5V
+5V
4MHz
10µF
22µF
+
Vcc
V+
Vss
C1-
+
22µF
C2+
C2V-
T1out
16F84
10µF
9SUB-D
pin SUB-D
connector
konektor
9 pinski
1
6
2
7
3
8
4
9
5
C1+
T2out
R2in
R1in
R1out
T1in
RE1/WR/AN6
RE2/CS/AN7
Vdd
Vss
PIC16F877
RA5/AN4
RE0/RD/AN5
OSC1/CLKIN
OSC2/CLKOUT
RCO/T1CKI
RC1/T1OSI
RC2/CCP1
RC3
RD0/PSP0
RD1/PSP1
RB2
RB1
RB0/INT
Vdd
Vss
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RC7/RX/DT
RC6/TX/CK
RC5
RC4
RD3/PSP3
RD2/PSP2
RC6
RB2 RC7 RB1
T2in
R2out
MAX232
serijski
kabl (1 on 1)
serial cable
(1 na 1)
1
6
2
7
3
8
4
9
5
Receives
data (Rx)
prima
podatke
(Rx)
Transmits
data (Tx)
šalje
podatke
(Tx)
Figure
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
15.
14
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
DIGITAL THERMOMETER DS1820
DS1820 digital thermometer, with temperature range of -55 to 125 C,
can be used for measuring enviroment temperature and for experiments.
It is very accurate and easy to connect. It plugs in the 3-pin socket,
beneath the power connector of the development system. Figure below
shows how to connect digital thermometer and the Microcontroller on
the development system.
Digital temperature value is sent either to RA5 or RE2 pin, depending
on the position of jumper, set above DS1820 chip. Half-circle line drawn
on the board marks the orientation of DS1820.
Primer povezivanja digitalnog
termometra DS1820
DS1820
+5V
Vdd
DQ
GND
MCLR/Vpp/THV
RB7/PGD
RA0/AN0
RB6/PGC
RA1/AN1
RB5
RA2/AN2/Vref-
RB4
RA3/AN3/Vref+
RB3/PGM
RA4/TOCKI
RA5
RE1/WR/AN6
RE2
+5V
RE2/CS/AN7
Vdd
Vss
OSC1/CLKIN
OSC2/CLKOUT
4MHz
Reset
D7 D6 D5 D4 D3 D2 D1 D0
RB0/INT
Vdd
Vss
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RCO/T1OSO/T1CKI
RC7/RX/DT
RC1/T1OSI
RC6/TX/CK
RC2/CCP1
RC5
RC3
+
c
RB1
PIC16F877
RE0/RD/AN5
T empe rat ura
23 . 5 stepen i
RB2
RA5/AN4
10ΚΩ
-55
OC
4,7ΚΩ
+125
RC4
RD0/PSP0
RD3/PSP3
RD1/PSP1
RD2/PSP2
D7
D6
D5
D4
E R/W RS Vee Vdd Vss
1
+5V
LCD contrast
Kontrast
LCD-a
E
RS
Figure
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
16.
15
EASY PIC 2
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
Development tool for Microchip PIC MCUs
PUL-UP / PULL-DOWN RESISTORS ON PORTS
Setting jumper to the upper position sets the pins of the appropriate port to logical one
(pull-up). If jumper is set to the lower postion, pins are set to logical zero (pull-down).
Figure below illustrates the situation when pins of port A are predefined to logical one
and port B to logical zero.
5V
Port B is on PULL-DOWN
resistors, which means that the
pins are set to logical zero by
default, until we set different
values.
GND
10κΩ
10κΩ
10κΩ
10κΩ
10κΩ
10κΩ
10κΩ
10κΩ
RB0 RB1 RB2 RB3 RB4 RB5 RB6 RB7
Figure
Figure
17.
18.
5V
Port A is connected to the resistor network, using
SW1. If SW1switch is not in ON position, the
appropriate pin has neither pull-up nor pull-down
resistor attached. This is very important, because it
enables using A port in analog mode as AD converter.
GND
SW1
DIP system switches provide great flexibility.
Through their use, port pins can be connected to
various elements of the system:
1 2 3 4 5 6 7 8
10κΩ
10κΩ
10κΩ
10κΩ
10κΩ
10κΩ
10κΩ
10κΩ
SW1- turn on /turn off PULL-UP or PULLDOWN resistors of A port and RE0 and
RE1 pins of E port.
RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1
SW2 - turn on /turn off seven-segment displays.
SW3 - turn on /turn off LED diode on A, B, C, D
and E ports.
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
16
MikroElektronika
Tools-C
Compilers-B
Books
www.mikroelektronika.co.yu
EASY PIC 2
Development tool for Microchip PIC MCUs
DIRECT ACCESS TO PORTS
All PIC pins can be defined as either input or output.
Port pins can be accessed directly from the right side of the development system by using
the flat cable. In this manner, values from external elements can be transferred to ports,
both ways.
For technical support please contact us :
E-mail: [email protected]
PIC, PICmicro, and MPLAB is a registered and protected trademark of the Microchip Technology Inc. USA. Microchip logo
and name are the registered tokens of the Microchip Technology. Copyright 2003, Microchip Technology Inc. Windows is a
Registered trademark of Microsoft Corp.
All other tokens mentioned in the book are the property of the companies to which they belong.
PIC, AVR, MC68HC11, i8051, PSoC development systems
www.mikroelektronika.co.yu
17