® A large number of useful peripherals, ready-to-use practical code examples and a broad set of add-on boards make MikroElektronika development systems fast and reliable tools that can satisfy the needs of experienced engineers and beginners alike. User manual Development system EasyPIC 6 TO OUR VALUED CUSTOMERS , ZDQW WR H[SUHVV P\ WKDQNV WR \RX IRU EHLQJ LQWHUHVWHG LQ RXU SURGXFWV DQG KDYLQJ FRQ¿GHQFH LQ MikroElektronika. It is our intention to provide you with the best quality products. Furthermore, we will continue to improve our performance to better suit your needs. Nebojsa Matic General Manager The Microchip® name and logo, PIC® and dsPIC® are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. All other trademarks mentioned herein are property of their respective companies and are only used for the purpose of LGHQWL¿FDWLRQRUH[SODQDWLRQDQGWRWKHRZQHU¶VEHQH¿WZLWKQRLQWHQWWRLQIULQJH 3 page EasyPIC6 Development System TABLE OF CONTENTS Introduction to EasyPIC6 Development System............................................................................................. 4 Key Features ................................................................................................................................................. 5 1.0. Connecting the System to your PC......................................................................................................... 6 2.0. Supported Microcontrollers...................................................................................................................... 7 3.0. On-Board Programmer............................................................................................................................ 8 4.0. mikroICD (Hardware In-Circuit Debugger)............................................................................................. 10 5.0. Power Supply.......................................................................................................................................... 11 6.0. RS-232 Communication Interface........................................................................................................... 12 7.0. PS/2 Communication Interface............................................................................................................... 13 8.0. ICD Connector........................................................................................................................................ 13 9.0. USB Communication.............................................................................................................................. 14 10.0. DS1820 Temperature Sensor............................................................................................................... 15 11.0. A/D Converter....................................................................................................................................... 16 12.0. LEDs..................................................................................................................................................... 17 13.0. Push Buttons........................................................................................................................................ 18 14.0. Keyboards............................................................................................................................................ 19 15.0. 2x16 LCD Display................................................................................................................................. 20 16.0. On-Board 2x16 LCD Display................................................................................................................. 21 17.0. 128x64 Graphic LCD Display................................................................................................................ 22 18.0. Touch Panel.......................................................................................................................................... 23 19.0. I/O Ports................................................................................................................................................ 24 20.0. Port Expander ...................................................................................................................................... 26 MikroElektronika page 4 EasyPIC6 Development System Introduction to EasyPIC® 6 Development Board The EasyPIC6 development system is an extraordinary development tool suitable for programming and experimenting with PIC® microcontrollers from MICROCHIP®. The board includes an on-board programmer with mikroICD® support (In-Circuit Debugger) providing DQLQWHUIDFHEHWZHHQWKHPLFURFRQWUROOHUDQGWKH3&<RXDUHVLPSO\H[SHFWHGWRZULWHDFRGHLQVRPHRIRXUFRPSLOHUVJHQHUDWHDKH[¿OH and program your microcontroller using the 3,&ÀDVK® programmer. Numerous on-board modules, such as 128x64 graphic LCD display, 2x16 LCD display, on-board 2x16 LCD display, keypad 4x4, port expander etc., allow you to easily simulate the operation of the target device. Full-featured and userfriendly development board for PIC microcontrollers High-Performance USB 2.0 On-Board Programmer Hardware In-Circuit Debugger for step by step debugging at hardware level Port Expander provides easy I/O expansion (2 additional ports) using serial interface On-Board 2x16 serial LCD Display Graphic LCD display with backlights The 3,&ÀDVKprogram provides a complete list of all supported microcontrollers. The latest version of this program with updated list of supported microcontrollers can be downloaded from our website www.mikroe.com 3DFNDJHFRQWDLQV Development board: CD: Cables: Documentation: (DV\3,& product CD with appropriate software 86%FDEOH (DV\3,& manual, mikroICD manual, 3,&ÀDVK manual, ,QVWDOOLQJ86%GULYHUV manual and (OHFWULFDO6FKHPDWLF of the (DV\3,&development system 6\VWHPVSHFL¿FDWLRQ Power supply: over a DC connector (7V to 23V AC or 9V to 32V DC); or over a USB cable (5V DC) Power consumption: up to 40mA (depending on how many on-board modules are currently active) Size: 26,5 x 22cm (10,43 x 8,66inch) Weight: ~417g (0.919lbs) MikroElektronika 5 1 2 3 4 5 6 7 8 9 page EasyPIC6 Development System 10 11 12 28 13 27 14 26 25 15 24 23 22 21 20 19 Key Features 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Power supply voltage regulator On-board programmer USB connector USB 2.0 programmer with mikroICD support DS1820 temperature sensor socket External MICROCHIP debugger (ICD2 or ICD3) connector USB communication connector A/D converter test inputs PS/2 connector On-board 2x16 LCD display DIP switches to enable pull-up/pull-down resistors Port pins’ pull-up/pull-down mode selection I/O port connectors PIC microcontroller sockets 18 17 16 14. Touch panel controller 15. Port expander 16. 128x64 graphic LCD display connector 17. 128x64 graphic LCD display contrast potentiometer 18. Touch panel connector 19. Menu keypad 20. Keypad 4x4 21. Push buttons to simulate digital inputs 22. Logic state selector 23. Protective resistor ON/OFF jumper 24. Reset button 25. 36 LEDs to indicate pins’ logic state 26. Alphanumeric LCD display contrast adjustment 27. Alphanumeric LCD display connector 28. RS-232 communication connector MikroElektronika page 6 EasyPIC6 Development System 1.0. Connecting the System to your PC 6WHS Use the USB cable to connect the EasyPIC6 development system to your PC. One end of the USB cable provided with a connector of the USB B type should be connected to the development system as shown in Figure 1-2, whereas the other end of the cable (USB A type) should be connected to your PC. When establishing a connection, make sure that jumper J6 is placed in the USB position as shown in Figure 1-1. DC connector USB connector 1 2 J6 power supply selector )LJXUHConnecting USB cable (jumper J6 in the USB position) Power OFF/ON switch )LJXUHPower supply 6WHS Follow the instructions for installing USB drivers and the 3,&ÀDVK programmer provided in the relevant manuals. It is not possible to program PIC microcontrollers without having these devices installed. In case that you already have some of the MikroElektronika’s compilers installed on your PC, there is no need to reinstall the 3,&ÀDVKprogrammer as it will be automatically installed along with compiler installation. 6WHS Turn on your development system by setting the power supply switch to the ON position. Two LEDs marked as ‘POWER’ and ‘USB LINK’ will be automatically turned on to indicate that your development system is ready for use. Use the 3,&ÀDVK programmer to dump a code into the microcontroller and employ the board to test and develop your projects. 127( If you use some additional modules, such as LCD, GLCD, extra boards etc., it is necessary to place them properly on the development system before it is turned on. Otherwise, they can be permanently damaged. )LJXUHPlacing additional modules on the board MikroElektronika 7 page EasyPIC6 Development System 2.0. Supported Microcontrollers The (DV\3,& development system provides eight separate sockets for PIC microcontrollers in DIP40, DIP28, DIP20, DIP18, DIP14 and DIP8 packages. These sockets allow supported devices in DIP packages to be plugged directly into the development board. There are two sockets for PIC microcontrollers in DIP18 package provided on the board. Which of these sockets you will use depends solely on the pinout of the microcontroller in use. The EasyPIC6 development system comes with the microcontroller in a DIP40 package. Jumpers next to the sockets are used for selecting functions of the microcontroller pins: Jumper Position J22 RA0 - I/O pin 9&$3¿OWHUFDSDFLWRUIRU) J23 9&$3¿OWHUFDSDFLWRUIRU) RA0 - I/O pin J16 RA5 VCC J13 OSC - RA6, RA7 are OSC. pins I/O - RA6, RA7 are I/O pins J14 OSC - RA4, RA5 are OSC. pins I/O - RA4, RA5 are I/O pins - I/O pin - 18F2331/2431 power supply )LJXUHMicrocontroller sockets PIC microcontrollers normally use a quartz crystal for the purpose of stabilizing clock frequency. The EasyPIC6 provides two sockets for quartz-crystal. Microcontrollers in DIP18A, DIP18B, DIP28 and DIP40 packages use socket X1 (OSC1) for quartz-crystal. If microcontrollers in DIP8, DIP14 and DIP20 packages are used, it is necessary to move quartz crystal from socket X1 to socket X2 (OSC2). Besides, it is also possible to replace the existing quartz-crystal with another one. The value of the quartz-crystal depends on the maximum clock frequency allowed. Microcontrollers being plugged into socket 10F use their own internal oscillator and are not connected to any of the aforementioned quartz-crystal sockets. 1 3 4 )LJXUHPlugging microcontroller into appropriate socket Prior to plugging the microcontroller into the appropriate socket, make sure that the power supply is turned off. Figure 2-2 shows how to correctly plug a microcontroller. Figure 1 shows an unoccupied 40-pin DIP socket. Place one end of the microcontroller into the socket as shown in Figure 2. Then put the microcontroller slowly down until all the pins thereof match the socket as shown in Figure 3. Check again that everything is placed correctly and press the microcontroller easily down until it is completely plugged into the socket as shown in Figure 4. 127( Only one microcontroller may be plugged into the development board at the same time. MikroElektronika page 8 EasyPIC6 Development System 2Q%RDUG86%3,&ÀDVK3URJUDPPHU The 3,&ÀDVK programmer is an obligatory tool when working with microcontrollers. The EasyPIC6 has an on-board 3,&ÀDVK programmer with mikroICD support which allows you to establish a connection between the microcontroller and your PC. Use the 3,&ÀDVK programmer to ORDGD+(;¿OHLQWRWKHPLFURFRQWUROOHU)LJXUHVKRZVWKHFRQQHFWLRQEHWZHHQDFRPSLOHU3,&ÀDVKprogrammer and microcontroller. Jumpers J10 used for connecting PGM line Jumpers J8 and J9 used for selecting socket with the microcontroller Jumper J7 used for selecting the MCLR pin’s function )LJXUH3,&ÀDVKZLWKPLNUR,&'programmer 1 Write a program in some of PIC FRPSLOHUVDQGJHQHUDWHD+(;¿OH Compiling program Executing code in binary and hexadecimal format 1 Write a code in some of PIC compilers, generate DKH[¿OHDQGWKHRQERDUGSURJUDPPHUZLOOWDNH care of loading data into the microcontroller. 2 2 Use the 3,&ÀDVK programmer to select an appropriate microcontroller DQGWRORDGWKH+(;¿OH 3 Click the :ULWH button to load the program into the microcontroller. 3 The 3,&ÀDVK programmer window contains several options for microcontroller settings. A number of buttons which will make the programming process easier are provided on the right side of the window. There is also an option at the bottom of the window which will enable you to monitor the programming progress. )LJXUHThe principle of programmer’s operation 127( For more information on the 3,&ÀDVK programmer refer to the relevant manual provided in the EasyPIC6 development system package. MikroElektronika There are two ways of programming PIC microcontrollers: Low Voltage and High Voltage programming modes. The 3,&ÀDVK programmer uses solely High Voltage programming mode during its operation. This mode requires voltage higher than the microcontroller’s power supply voltage (the range between 8V to 14V, depending on the type of the microcontroller in use) to be brought to the MCLR/Vpp pin in order so that the process of programming/debugging may be performed. page 9 EasyPIC6 Development System 7KH/RZ9ROWDJHSURJUDPPLQJPRGHFDQEHHQDEOHGGLVDEOHGXVLQJFRQ¿JXUDWLRQELWVRIWKHPLFURFRQWUROOHU,IWKH/RZ9ROWDJHSURJUDPPLQJ mode is enabled, the programming process is initiated by applying a logic one (1) to the PGM pin. Unlike this mode, the High Voltage programming mode is always enabled and the programming process starts by applying a high voltage to the MCLR/Vpp pin. All PIC microcontrollers have the Low Voltage programming mode enabled by default. In some rare cases, in order to enable the microcontroller to be programmed in the High Voltage programming mode, it is necessary to apply a logic zero (0) to the PGM pin, which prevents the microcontroller from entering the Low Voltage programming mode. Depending on the microcontroller in use, it is possible to select one of the following pins RB3, RB4 and RB5 to be used as the PGM pin. Jumper J10 is used as the PGM pin selector as shown in Figure 3-3. Jumper J10 default position when RB3, RB4 and RB5 pins are not connected to the PGM line. Jumper J10 position when the PGM line is connected to the RB5 pin. Jumper J10 position when the PGM line is connected to the RB4 pin. Jumper J10 position when the PGM line is connected to the RB3 pin. )LJXUHVarious positions of jumper J10 Build-in programmer with mikroICD Multiplexer MCU-PGD MCU-PGC MCLR Programming lines PGD PGC PROG VCC DD+ GND USB DATA MCLR User interface R R R During programming, a multiplexer disconnects the microcontroller pins used for programming from the rest of the board and connects them to the 3,&ÀDVK programmer. After the programming is complete, these pins are disconnected from the programmer and may be used as input/output pins. )LJXUHProgrammer schematic Microcontroler is plugged into one of the following sockets: DIP40, DIP28 DIP18A or DIP18B. (Default position) Microcontroller is plugged into one of the following sockets: DIP20, DIP14 or DIP8. Jumpers J8 and J9 are used for selecting the socket to receive the programming signal. Figure 3-5 shows the position of jumpers J8 and J9 depending on DIP sockets in use. )LJXUHThe position of jumpers J8 and J9 MCLR used as the MCLR/Vpp pin. )LJXUHThe position of jumper J7 MCLR used as an I/O pin. The function of the MCLR (Master Clear) pin depends on the position of jumper J7. When placed in the left-hand position, the MCLR pin has default function, i.e. is used as MCLR/Vpp. Otherwise, when the jumper is placed in the right-hand position, the MCLR pin is available as an I/O pin. MikroElektronika page 10 EasyPIC6 Development System 4.0. mikroICD (In-Circuit Debugger) The mikroICD (In-Circuit Debugger) is an integral part of the on-board programmer. It is used for the purpose of testing and debugging programs in real time. The process of testing and debugging is performed by monitoring the state of all registers within the microcontroller while operating in real environment. The mikroICD software is integrated in all compilers designed by mikroElektronika (mikroBASIC®, mikroC® and mikroPASCAL®$VVRRQDVWKHPLNUR,&'GHEXJJHUVWDUWVXSDZLQGRZDVVKRZQLQ¿JXUHEHORZDSSHDUV The mikroICD debugger communicates with the PC through the programming pins which cannot be used as I/O pins while the process of the program debugging is in progress. PLNUR,&'GHEXJJHURSWLRQV Icon commands Start Debugger Run/Pause Debugger Stop Debugger Step Into Step Over Step Out Toggle Breakpoint Show/Hide Breakpoints Clear Breakpoints A complete list of registers within the programmed microcontroller A list of selected registers to be monitored. The state of these registers changes during the program execution, which can be viewed in this window [F9] [F6] [Ctrl+F2] [F7] [F8] [Ctrl+F8] [F5] [Shift+F4] [Ctrl+Shift+F4] Each of these commands is activated via keyboard shortcuts or by clicking appropriate icon within the :DWFK9DOXHV window. Double click on the 9DOXH¿HOG enables you to change data format Figure 4-1: mikroICD Watch Values window The mikroICD debugger also offers functions such as running a program step by step (single stepping), pausing the program execution to examine the state of currently active registers using breakpoints, tracking the values of some variables etc. The following example illustrates a step-by-step program execution using the 6WHS2YHUcommand. 6WHS In this example the 41st program line is highlighted in blue, which means that it will be executed next. The current state of all registers within the microontroller can be viewed in the mikroICD :DWFK9DOXHV window. 6WHS After the 6WHS2YHUcommand is executed, the microcontroller will execute the 41st program line. The next line to be executed is highlighted in blue. The state of registers being changed by executing this instruction may be viewed in the :DWFK 9DOXHV window. 127( 1 During operation, the program line to be executed next is highlighted in blue, while the breakpoints are highlighted in red. The Run command executes the program in real time until it encounters a breakpoint. 2 For more information on the mikroICD debugger refer to the PLNUR,&''HEXJJHU manual. MikroElektronika 11 page EasyPIC6 Development System 5.0. Power Supply The EasyPIC6 development system may use one of two power supply sources: 1. +5V PC power supply through the USB programming cable; 2. External power supply connected to a DC connector provided on the development board. The MC34063A voltage regulator is used for enabling external power supply voltage to be either AC (in the range of 7V to 23V) or DC (in the range of 9V to 32V). Jumper J6 is used as power supply selector. When using USB power supply, jumper J6 should be placed in the USB position. When using external power supply, jumper J6 should be placed in the EXT position. The development system is turned OFF/ON by changing the setting on the OFF/ON switch respectively. DC connector (2) Power supply voltage regulator USB connector (1) Jumper J6 used for selecting power supply OFF/ON switch Figure 5-1: Power supply The programmer uses the MOSFET switch for suspending power supply on the development system during programming. When the process of programming is complete, the programmer enables the development system to be supplied with power. AC/DC connector USB connector power supply 330 35A 8N6 Side view SMD MOSFET IRFR9024N A OFF K 0.22 SWC SWE CT GND E1 330uF D12 D15 C8 VCC VCC-5V VCC-USB LD42 POWER J6 D7 R56 R55 1K 3K MBRS140T3 A K 106 10V Side view E2 E3 10uF 330uF 106 10V Side view MC 34063A Bottom view L2 220uH DRVC IPK Vin CMPR on-board programmer MOSFET switch Top view MC34063A 220pF Side view Side view U10 D14 AC/DC CN16 VCC-MCU 221 4x1N4007 D13 ON R57 Side view R14 2K2 + Side view Figure 5-2: Power supply source schematic MikroElektronika page 12 EasyPIC6 Development System 6.0. RS-232 Communication Interface RS-232 serial communication is performed through a 9-pin SUB-D connector and the microcontroller USART module. In order to enable such communication, it is necessary to establish a connection between RX and TX communication lines (KDQGVKDNLQJ lines CTS and RTS are optionally used) and microcontroller pins provided with USART module using a DIP switch. The microcontroller pins used in such communication are marked as follows: RX - UHFHLYHGDWD, TX - WUDQVPLWGDWD, CTS - FOHDUWRVHQG and RTS - UHTXHVWWRVHQG. Baud rate goes up to 115kbps. The USART (universal synchronous/asynchronous receiver/transmitter) is one of the most common ways of exchanging data between the PC and peripheral components. In order to enable the USART module of the microcontroller to receive input signals with different voltage levels, it is necessary to provide a voltage level converter such as MAX-202C. RS-232 connector Figure 6-1: RS-232 module The function of DIP switches SW7 and SW8 is to determine which of the microcontroller pins are to be used as RX and TX lines. The microcontroller pinout varies depending on the type of the microcontroller. Figure 6-2 shows the microcontroller in DIP40 package (PIC16F887). 6:5;&76 21 6:7;576 21 SUB-D 9p MAX202 Bottom view 1 5 9 6 !" R3 1K R54 1K PICxxxx MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1 RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 DIP40 Figure 6-2: RS-232 module schematic 127( Make sure that your microcontroller is provided with the USART module as it is not necessarily integrated in all microcontrollers. MikroElektronika 13 page EasyPIC6 Development System 7.0. PS/2 Communication Interface The PS/2 connector enables input units, such as keyboard and mouse, to be connected to the development system. In order to enable PS/2 communication, it is necessary to correctly place jumpers J20 and J21, thus connecting DATA and CLK lines to the microcontroller pins RC0 and RC1. Do not connect/disconnect input units to the PS/2 connector while the development system is turned on as it may permanently damage the microcontroller. PS/2 connector Figure 7-1: PS/2 connector (J20 and J21 are not connected) Figure 7-2: PS/2 connector (J20 and J21 are connected) VCC VCC-MCU R37 1K R38 1K J20 RC0 J21 RC1 PS/2 NC CLK VCC-MCU +5V NC X1 8MHz DATA Front view C6 4 2 1 3 22pF C7 22pF 6 5 Bottom view PICxxxx DATA NC GND VCC CLK NC MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1 RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 VCC-MCU DIP40 Figure 7-3: PS/2 connector connection schematic Figure 7-4: EasyPIC6 connected to keyboard 8.0. ICD Connector ICD (In-Circuit Debugger) connector enables the microcontroller to communicate with external ICD debugger (ICD2 or ICD3)* from MICROCHIP. Jumpers J8 and J9 are placed in the same way as when using the 3,&ÀDVK programmer with mikroICD designed by MikroEektronika. CN1 ICD connector CLK-PIC DATA-PIC GND VCC MCLR 1 2 3 4 5 6 RJ12 1 3 5 2 4 6 Front view Side view Bottom view Figure 8-1: ICD connector )LJXUH ICD connector pinout and pin labels *ICD2 and ICD3 are registered trademarks of MICROCHIP® MikroElektronika page 14 EasyPIC6 Development System 9.0. USB Communication The USB connector enables PIC microcontrollers with a built-in USB communication module to be connected to peripheral components. In order to enable USB communication, it is necessary to change the position of jumpers J12 from left-hand to right-hand, thus connecting the USB DATA lines (D+ i D-) to RC4 and RC5 microcontroller pins and the RC3/VUSB pin to capacitors C16 and C17. If USB communication is not used, jumpers J12 should be left in the left-hand position. The status of USB communication (OFF/ON) is indicated by LED. Figures 9-3 and 9-4 show schematics of the most commonly used microcontrollers with integrated USB module. USB connector Figure 9-1: USB communication Figure 9-2: USB communication disabled (default position) enabled Jumper J12 in the left-hand position C6 22pF C7 22pF RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 Jumper J12 in the left-hand position MCLR RA0 RA1 RA2 RA3 RA4 RA5 GND VCC-MCU OSC1 X1 8MHz Bottom view C6 22pF PIC18F2550 X1 8MHz PIC18F4550 VCC-MCU MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3/VUSB RD0 RD1 OSC2 C7 22pF RC0 RC1 RC2 RC3 RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RC7 RC6 RC5 RC4 VCC-MCU Bottom view D+ GND D- DIP28 VCC D+ GND D- CN4 VCC CN4 USB B USB B J12 VCC-BUS DD+ GND RC5 RC4 RC5 J12 RC4 RC3 RC3 LD44 USB ON LD44 USB ON C16 100nF C17 100nF R42 4K7 Figure 9-3: PIC18F4550 USB communication schematic MikroElektronika VCC-BUS DD+ GND DIP40 C16 C17 100nF 100nF R42 4K7 Figure 9-4: PIC18F2550 USB communication schematic 15 page EasyPIC6 Development System 10.0. DS1820 Temperature Sensor 1-wire® serial communication enables data to be transferred over one single communication line while the process itself is under the control of the master microcontroller. The advantage of such communication is that only one microcontroller pin is used. All VODYH devices have by default a unique ID code, which enables the master device to easily identify all devices sharing the same interface. DS1820 is a temperature sensor that uses 1-wire® standard for its operation. It is capable of measuring temperatures within the range of -55 to 125°C and provides ±0.5°C accuracy for temperatures within the range of -10 to 85°C. Power supply voltage of 3V to 5.5V is required for its operation. It takes maximum 750ms for the DS1820 to calculate temperature with 9-bit resolution. The EasyPIC6 development system provides a separate socket for the DS1820. It may use either RA5 or RE2 pin for communication with the microcontroller. Jumper J11’s purpose is selection of the pin to be used for 1-wire® communication. Figure 10-5 shows 1-wire® communication with microcontroller through the RA5 pin. NOTE: Make sure that halfcircle on the board matches the round side of the DS1820 Figure 10-1: DS1820 connector (1-wire communication is not used) Figure 10-2: J11 in the left-hand position (1-wire communication through the RA5 pin) Figure 10-3: J11 in the right-hand position (1-wire communication through the RE2 pin) Jumper J11 in the upper position VCC-MCU R1 1K DS1820 J11 DQ GND DQ VCC-MCU VCC-MCU DQ X1 8MHz Botoom view VCC-MCU GND C6 22pF C7 22pF MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1 PICxxxx Figure 10-4: DS1820 plugged into appropriate socket RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 VCC-MCU DIP40 Figure 10-5: 1-wire communication schematic MikroElektronika page 16 EasyPIC6 Development System 11.0. A/D Converter An A/D converter is used for the purpose of converting an analog signal into the appropriate digital value. A/D converter is linear, which means that the converted number is linearly dependent on the input voltage value. The A/D converter built into the microcontroller provided with the EasyPIC6 development system converts an analog voltage value into a 10-bit number. Voltages varying from 0V to 5V DC may be supplied through the A/D test inputs. Jumper J15 is used for selecting some of the IROORZLQJSLQV5$5$5$5$RU5$IRU$'FRQYHUVLRQ7KH5UHVLVWRUKDVDSURWHFWLYHIXQFWLRQDVLWLVXVHGIRUOLPLWLQJFXUUHQWÀRZ through the potentiometer or the microcontroller pin. The value of the input analog voltage can be changed linearly using potentiometer P1. RA0 is A/D input VCC-MCU J15 RA0 RB3 RA1 RB2 RA4 OSC1 MCLR OSC2 GND VCC RA2 RB7 RA3 RB6 RB0 RB5 RB1 RB4 R63 P1 10K 220R P1 10K Figure 11-2: The RA0 pin used as A/D conversion input Figure 11-1: ADC (default jumper positions) VCC-MCU X1 8MHz C6 22pF Top view C7 22pF DIP18A Figure 11-3: Microcontroller in DIP18A package and A/D converter test inputs connection RA0 is A/D input VCC-MCU RA0 is A/D input J15 R63 P1 10K 220R VCC-MCU Top view X1 8MHz C6 22pF C7 22pF PICxxxx P1 10K MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1 RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 VCC-MCU P1 10K J15 R63 220R P1 10K VCC-MCU VCC-MCU X1 8MHz Top view C6 22pF C7 22pF DIP40 Figure 11-4: Microcontroller in DIP40 package and A/D converter test inputs connectiion 127( Figure 11-5: Microcontroller in DIP28 package and A/D converter test inputs connection In order to enable the microcontroller to accurately perform A/D conversion, it is necessary to turn off LED diodes and pull-up/pull-down resistors on port pins used by the A/D converter. MikroElektronika 17 page EasyPIC6 Development System 12.0. LEDs /('GLRGH/LJKW(PLWWLQJ'LRGHLVDKLJKO\HI¿FLHQWHOHFWURQLFOLJKWVRXUFH:KHQFRQQHFWLQJ/('VLWLVQHFHVVDU\WRSODFHDFXUUHQW limiting resistor the value of which is calculated using formula R=U/I where R is referred to resistance expressed in ohms, U is referred to voltage on the LED and I stands for LED diode current. A common LED diode voltage is approximately 2.5V, while the current varies from 1mA to 20mA depending on the type of LED diode. The EasyPIC6 development system uses LEDs with current I=1mA. The EasyPIC6 has 36 LEDs which visually indicate the logic state of each microcontroller I/O pin. An active LED diode indicates that a logic one (1) is present on the pin. In order to enable LEDs, it is necessary to select appropriate port PORTA/E, PORTB, PORTC or PORTD using the DIP switch SW9. Notch indicating the SMD LED cathode I RB7 RB6 RB5 RB4 RB3 A R=U/I K SMD LED 472 R Microcontroller SMD resistor limiting current ÀRZWKURXJKDQ/(' Figure 12-1: LEDs 6:3257% 21 % # # # # # # $ $ $ !" !" % Figure 12-2: LED diode and PORTB connection schematic MikroElektronika page 18 EasyPIC6 Development System 13.0. Push Buttons The logic state of all microcontroller digital inputs may be changed using push buttons. Jumper J17 is used to determine the logic state to be applied to the desired microcontroller pin by pressing the appropriate push button. The purpose of the protective resistor is to limit maximum current thus preventing a short circuit from occurring. Advanced users may, if needed, disable such resistor using jumper J24. Just next to the push buttons, there is a RESET button which is not connected to the MCLR pin. The reset signal is generated by the programmer. VCC-MCU R17 10K RESET button RSTbut C14 100nF Jumper J24 used for enabling protective resistor Jumper J17 used for selecting logic state to be applied to the pin by pressing button Push buttons used for simulating digital inputs Figure 13-1: Push buttons By pressing any push button (R0-R7) when jumper J17 is in the VCC-MCU position, a logic one (5V) will be applied to the appropriate microcontroller pin as shown in Figure 13-2. Jumper J17 in the pull-up position ! """" ! Figure 13-2: PORTB push button connection schematic MikroElektronika 19 page EasyPIC6 Development System 14.0. Keypads There are two keypads provided on the EasyPIC6 development system. These are keypad 4x4 and keypad MENU. Keypad 4x4 is a standard alphanumeric keypad connected to the microcontroller PORTD. The performance of such a keypad is based on the ‘scan and sense’ principle ZKHUHWKH5'5'5'DQG5'SLQVDUHFRQ¿JXUHGDVLQSXWVFRQQHFWHGWRSXOOGRZQUHVLVWRUV7KH5'5'5'DQG5'SLQVDUH FRQ¿JXUHGDVKLJKOHYHOYROWDJHRXWSXWV3UHVVLQJDQ\EXWWRQZLOOFDXVHDORJLFRQHWREHDSSOLHGWRLQSXWSLQV3XVKEXWWRQGHWHFWLRQLV performed from within software. For example, pressing button ‘6’ will cause a logic one (1) to appear on the RD2 pin. In order to determine which of the push buttons is pressed, a logic one (1) is applied to each of the following output pins RD4, RD5, RD6 and RD7. Keypad MENU buttons are connected in a similar way to the PORTA buttons. The only difference is in the button arrangement. The keypad MENU buttons are arranged so as to provide easy navigation through menus. VCC-MCU RN4 8x10K J17 J4 SW4 BAT43 RD0 RD1 RD2 RD3 RD4 RD5 RD6 RD7 A R59 R60 R61 R62 T46 T54 T50 T38 T43 T47 T56 T51 T57 D9 T59 T58 T39 T44 T48 T52 T40 T45 T49 T53 D10 220R RD7 T42 T55 220R RD6 D8 220R RD5 T37 R58 220R D11 RA5 RD4 RA2 VCCMCU J24 Side view K RA0 22pF RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 RA3 22pF C7 )LJXUHKeypad MENU RA1 C6 RA4 X1 8MHz VCC-MCU MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1 PICxxxx VCC-MCU )LJXUHKeypad 4x4 performance )LJXUHKeypad 4x4 Jumper J17 is in the pull-up position. Pins 5'5' RD2 and RD3 are connected to pull-down resistors through DIP switch SW4 RD3 RD2 RD1 RD0 220R DIP40 Figure 14-4: Keypads (4x4 and MENU) and microcontroller connection schematic MikroElektronika page 20 EasyPIC6 Development System 15.0. 2x16 LCD Display The EasyPIC6 development system provides an on-board connector to plug alphanumeric 2x16 LCD display into. Such connector is connected to the microcontroller through the PORTB port. Potentiometer P4 is used for display contrast adjustment. The LCD switch on the DIP switch SW6 is used for turning on/off display backlight. Communication between an LCD display and the microcontroller is established using a 4-bit mode. Alphanumeric digits are displayed in two lines each containing up to 16 characters of 7x5 pixels. Connector for alphanumeric LCD display Contrast adjustment potentiometer Figure 15-1: Alphanumeric LCD connector Figure 15-2: 2x16 LCD display 6:/&'%&. 21 VCC-MCU C6 22pF C7 22pF DIP40 )LJXUH2x16 LCD display connection schematic MikroElektronika SW6 P4 10K Top view LCD-GLCD BACKLIGHT VCC-MCU GND VCC-MCU R43 10 VO RB4 GND RB5 GND GND GND GND RB0 RB1 RB2 RB3 RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 CN7 GND VCC VO RS R/W E D0 D1 D2 D3 D4 D5 D6 D7 LED+ LED- X1 8MHz PICxxxx VCC-MCU MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1 VCC 21 page EasyPIC6 Development System 16.0. On-Board 2x16 LCD Display On-board 2x16 display is connected to the microcontroller through a port expander. In order to use this display, it is necessary to set the DIP switch SW10 to the ON position, thus connecting the on-board LCD display to port expander’s port 1. The DIP switch SW6 enables the port expander to use serial communication. Potentiometer P5 is used for display contrast adjustment. Unlike common LCD display, the on-board LCD display has no backlights and receives data to be displayed through the port expander which employs SPI communication for the purpose of communicating with the microcontroller. Similar to standard 2x16 LCD display, the on-board 2x16 LCD display also displays digits in two lines each containing up to 16 characters of 7x5 pixels. DIP switch SW10 to turn the on-board 2x16 LCD display ON Contrast adjustment potentiometer Figure 16-1: On-board 2x16 LCD display 6:&65676&.0,62026, 21 6: 21 C6 22pF C7 22pF VCC-MCU SW6 RA2 RA3 RC3 RC4 RC5 PE-CS# PE-RST# SPI-SCK SPI-MISO SPI-MOSI VCC-MCU U5 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 VCCMCU CN17 COG-RS COG-E COG-D4 COG-D5 COG-D6 COG-D7 PE-INTA PE-INTB GND Vo VCC-MCU RS R/W E D0 D1 D2 D3 D4 D5 D6 D7 RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 PE-CS# SPI-SCK SPI-MOSI SPI-MISO P5 10K SW10 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RB0 RB1 X1 8MHz PICxxxx VCC-MCU MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1 R2 100K GPB0 GPB1 GPB2 GPB3 GPB4 GPB5 GPB6 GPB7 VCC GND CS SCK SI SO GPA7 GPA6 GPA5 GPA4 GPA3 GPA2 GPA1 GPA0 INTA INTB RESET A2 A1 A0 PE-INTA PE-INTB PE-RST# MCP23S17 VCC-MCU DIP40 Top view Figure 16-2: On-board 2x16 LCD display connection schematic MikroElektronika page 22 EasyPIC6 Development System 17.0. 128x64 Graphic LCD Display 128x64 graphic LCD display (128x64 GLCD) provides an advanced method for displaying graphic messages. It is connected to the microcontroller through PORTB and PORTD. GLCD display has the screen resolution of 128x64 pixels which allows you to display diagrams, tables and other graphical contents. Since the PORTB port is also used by 2x16 alphanumeric LCD display, you cannot use both displays simultaneously. Potentiometer P3 is used for the GLCD display contrast adjustment. Switch 8 on the DIP switch SW6 is used for turning on/off display backlight. . Contrast adjustment potentiometer GLCD connector Touch panel connector Figure 17-2: GLCD connector Figure 17-1: GLCD display 6:*/&'%&. 21 SW6 22pF DIP40 Figure 17-3: GLCD display connection schematic MikroElektronika LCD-GLCD BACKLIGHT Top view R28 10 RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 %$ " ' "& " PICxxxx MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1 VCC 23 page EasyPIC6 Development System 18.0. Touch Panel The touch panel is a thin, self-adhesive, transparent panel sensitive to touch. It is placed over a GLCD display. The main purpose of this SDQHOLVWRUHJLVWHUSUHVVXUHDWVRPHVSHFL¿FGLVSOD\SRLQWDQGWRIRUZDUGLWVFRRUGLQDWHVLQWKHIRUPRIDQDORJYROWDJHWRWKHPLFURFRQWUROOHU Switches 5,6,7 and 8 on the DIP switch SW9 are used for connecting touch panel to the microcontroller. 1 3 4 Figure 18-1: Touch panel )LJXUHVKRZVKRZWRSODFHDWRXFKSDQHORYHUD*/&'GLVSOD\0DNHVXUHWKDWWKHÀDWFDEOHLVWRWKHOHIWRIWKH*/&'GLVSOD\DV shown in Figure 4. VCC-MCU SW9 Q15 BC856 R49 10K RIGHT BOTTOM LEFT DRIVEA DRIVEB R44 1K R47 10K VCC-MCU CN13 VCC-MCU R48 1K Q13 BC846 Q14 BC856 R46 10K Q12 BC846 R52 100K VCC-MCU R45 10K VCC-MCU BOTTOM C26 100nF RIGHT TOP LEFT BOTTOM GLCD C25 100nF LEFT Q16 BC846 R53 100K X1 8MHz R50 1K R51 10K C6 22pF 6:%27720/()7'5,9($'5,9(% 21 TOUCHPANEL CONTROLLER C7 22pF RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 VCC GND RD7 RD6 RD5 RD4 RC7 RC6 RC5 RC4 RD3 RD2 PICxxxx TOP MCLR RA0 RA1 RA2 RA3 RA4 RA5 RE0 RE1 RE2 VCC GND OSC1 OSC2 RC0 RC1 RC2 RC3 RD0 RD1 VCC-MCU DIP40 Figure 18-2: Touch panel connection schematic 1 3 4 Figure 18-3: Placing touch panel )LJXUHVKRZVLQGHWDLOKRZWRFRQQHFWDWRXFKSDQHOWRWKHPLFURFRQWUROOHU%ULQJWKHHQGRIWKHÀDWFDEOHFORVHWRWKH&1FRQQHFWRUDV VKRZQLQ)LJXUH3OXJWKHFDEOHLQWRWKHFRQQHFWRUDVVKRZQLQ)LJXUHDQGSUHVVLWHDVLO\VRDVWR¿WWKHFRQQHFWRUDVVKRZQLQ)LJXUH Now you can plug a GLCD display into the appropriate connector as shown in Figure 4. 127( LEDs and pull-up/pull-down resistors on the RA0 and RA1 pins of the PORTA port must be turned off when using a touch panel. MikroElektronika page 24 EasyPIC6 Development System 19.0. Input/Output Ports Along the right side of the development system, there are seven 10-pin connectors which are connected to the microcontroller’s I/O ports. Some of the connector’s pins are directly connected to the microcontroller pins, whereas some of them are connected using jumpers. DIP switches SW1-SW5 enable each connector pin to be connected to one pull-up/pull-down resistor. Whether port pins are to be connected to a pull-up or pull-down resistor depends on the position of jumpers J1-J5. 2x5 PORTA male connector Jumper for pull-up/ pulldown resistor selection Figure 19-2: J2 in the pull-down position Additional module connected to PORTC DIP switch to turn on pull-up/pull-down resistors for each pin Figure 19-1: I/O ports )LJXUH J2 in the pull-up position 6: 21 Jumper J2 in the pull-down position -XPSHU-LQWKH9&&0&8SRVLWLRQ " #$ %& %& ! ! ! Figure 19-4: PORTB schematic connection MikroElektronika Pull-up/pull-down resistors enable voltage signal to be brought to the microcontroller pins. The logic level at pin idle state depends on the pull-up/pull-down jumper position. The RB0 pin along with the relevant DIP switch SW2, jumper J2 and RB2 push button with jumper J17 are used here for the purpose of explaining the performance of pull-up/pull-down resistors. The principle of their operation is identical for all the microcontroller pins. #### #$ ! " ! ! page 25 EasyPIC6 Development System In order to enable PORTB pins to be connected to pull-down resistors, it is necessary to set jumper J2 in the lower position, thus providing 8x10K resistor network with a logic zero (0V). To bring a signal to the RB0 pin, it is necessary to set switch 1 on the DIP switch SW2 to the ON position. This will cause the microcontroller RB0 pin to be ‘pulled down’ to the low logic level (0V) in its idle state. Jumper J17, used to determine the pin logic state provided by pressing push-buttons, should be set in the opposite position of jumper J2. Accordingly, every time you press the RB0 push button, a logic one (1) will appear on the RB0 pin. Figure 19-5: Jumper J2 in pull-down and J17 in pull-up positions #### #$ ! " ! ! In order to enable PORTB pins to be connected to pull-up resistors, it is necessary to set jumper J2 in the upper position (5V) and jumper J17 in the lower position (0V). This enables each PORTB pin to be ‘pulled up’ to the high logic level (5V) in its idle state. In order to do this, it is necessary to set appropriate switch on the DIP switch SW2 to the ON position. Accordingly, every time you press the RB0 push button, a logic zero (0) will appear on the RB0 pin. )LJXUH Jumper J2 in pull-up and J17 in pull-down positions In this case, jumpers J2 and J17 have the same logic state which means that pressing push button will not cause any pin to change its logic state. )LJXUH Jumpers J2 and J17 in the same position MikroElektronika page 26 EasyPIC6 Development System 20.0. Additional I/O Ports The SPI communication lines and MCP23S17 circuit provide the EasyPIC6 development system with a means of increasing the number of available I/O ports by two. If the port expander is connected over the DIP switch SW6, the following pins RA2, RA3, RC3, RC4 and RC5 will be used for SPI communication and thus cannot be used as I/O pins. Switches INTA and INTB on the DIP switch SW10 enable interrupt. 0&36HQDEOHVELWSDUDOOHOH[SDQVLRQDQGPD\EHFRQ¿JXUHGWRRSHUDWHLQHLWKHURUELWPRGH PORT0 Jumper for selecting pull-up/pull-down resistor PORT1 DIP switch connecting port expander to the microcontroller Figure 20-2: DIP switch SW6 when port expander is enabled Figure 20-1: Port expander 6:&65676&.0,62026, 21 6:,17$,17% 21 Jumpers J18 and J19 in the upper position !" # $% &' &' !" Figure 20-3: Port expander schematic MikroElektronika ) " !" !" ( ! ! !" !" ) ( ! ! DISCLAIMER All the products owned by MikroElektronika are protected by copyright law and international copyright treaty. Therefore, this manual is to be treated as any other copyright material. No part of this manual, including product and software described herein, may be reproduced, stored in a retrieval system, translated or transmitted in any form or by any means, without the prior written permission of MikroElektronika. The PDQXDO3')HGLWLRQFDQEHSULQWHGIRUSULYDWHRUORFDOXVHEXWQRWIRUGLVWULEXWLRQ$Q\PRGL¿FDWLRQRIWKLV manual is prohibited. 0LNUR(OHNWURQLND SURYLGHV WKLV PDQXDO µDV LV¶ ZLWKRXW ZDUUDQW\ RI DQ\ NLQG HLWKHU H[SUHVVHG RU LPSOLHG LQFOXGLQJEXWQRWOLPLWHGWRWKHLPSOLHGZDUUDQWLHVRUFRQGLWLRQVRIPHUFKDQWDELOLW\RU¿WQHVVIRUDSDUWLFXODU purpose. MikroElektronika shall assume no responsibility or liability for any errors, omissions and inaccuracies that may DSSHDULQWKLVPDQXDO,QQRHYHQWVKDOO0LNUR(OHNWURQLNDLWVGLUHFWRUVRI¿FHUVHPSOR\HHVRUGLVWULEXWRUVEH OLDEOHIRUDQ\LQGLUHFWVSHFL¿FLQFLGHQWDORUFRQVHTXHQWLDOGDPDJHVLQFOXGLQJGDPDJHVIRUORVVRIEXVLQHVV SUR¿WVDQGEXVLQHVVLQIRUPDWLRQEXVLQHVVLQWHUUXSWLRQRUDQ\RWKHUSHFXQLDU\ORVVDULVLQJRXWRIWKHXVH of this manual or product, even if MikroElektronika has been advised of the possibility of such damages. MikroElektronika reserves the right to change information contained in this manual at any time without prior notice, if necessary. All the product and corporate names appearing in this manual may or may not be registered trademarks RUFRS\ULJKWVRIWKHLUUHVSHFWLYHFRPSDQLHVDQGDUHRQO\XVHGIRULGHQWL¿FDWLRQRUH[SODQDWLRQDQGWRWKH RZQHUV¶EHQH¿WZLWKQRLQWHQWWRLQIULQJH HIGH RISK ACTIVITIES The products of MikroElektronika are not fault – tolerant nor designed, manufactured or intended for use or resale as on – line control equipment in hazardous environments requiring fail – safe performance, such as LQWKHRSHUDWLRQRIQXFOHDUIDFLOLWLHVDLUFUDIWQDYLJDWLRQRUFRPPXQLFDWLRQV\VWHPVDLUWUDI¿FFRQWUROGLUHFW life support machines or weapons systems in which the failure of Software could lead directly to death, SHUVRQDOLQMXU\RUVHYHUHSK\VLFDORUHQYLURQPHQWDOGDPDJHµ+LJK5LVN$FWLYLWLHV¶0LNUR(OHNWURQLNDDQGLWV VXSSOLHUVVSHFL¿FDOO\GLVFODLPDQ\H[SUHVVHGRULPSOLHGZDUUDQW\RI¿WQHVVIRU+LJK5LVN$FWLYLWLHV Copyright 2003 – 2009 by MikroElektronika. All rights reserved. ,I\RXKDYHDQ\TXHVWLRQVFRPPHQWVRUEXVLQHVVSURSRVDOVGRQRWKHVLWDWHWRFRQWDFWXVDWRI¿FH#PLNURHFRP If you are experiencing some problems with any of our products or just need additional information, please place your ticket at www.mikroe.com/en/support If you want to learn more about our products, please visit our website at www.mikroe.com