PICDEM™ Mechatronics Demonstration Board User’s Guide © 2006 Microchip Technology Inc.
Note the following details of the code protection feature on Microchip devices: • Microchip products meet the specification contained in their particular Microchip Data Sheet. • Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions. • There are dishonest and possibly illegal methods used to breach the code protection feature.
PICDEMTM MECHATRONICS DEMO BOARD USER’S GUIDE Table of Contents Preface ........................................................................................................................... 1 Chapter 1. PICDEM™ Mechatronics 1.1 Introduction ..................................................................................................... 7 1.2 Highlights ........................................................................................................ 7 1.3 Quick Start Guide .................
PICDEMTM Mechatronics Demo Board User’s Guide 3.2.3 FAULT LED Stays On Or Continues To Trip When SW5 Is Pressed ........47 3.2.4 Microcontroller Does Not Run After Programming By The MPLAB ICD 2 ......................................................................................................48 3.2.5 Back EMF At J16 Is Floating ......................................................................48 3.2.6 Board Is Non-Functional When Microcontrollers Are Installed In Both U1 And U2 .....................
PICDEMTM MECHATRONICS DEMO BOARD USER’S GUIDE Preface NOTICE TO CUSTOMERS All documentation becomes dated, and this manual is no exception. Microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. Please refer to our web site (www.microchip.com) to obtain the latest documentation available. Documents are identified with a “DS” number.
PICDEMTM Mechatronics Demo Board User’s Guide DOCUMENT LAYOUT This document describes how to use the PICDEM™ Mechatronics Demonstration Board. The manual layout is as follows: • Chapter 1: PICDEM Mechatronics – An overview of the PICDEM Mechatronics Demo Board. PCB layout, parts and how to connect the provided jumper wires to the board. • Chapter 2: Example Projects – Projects that describe how to read the sensors on the board, drive the LCD and control several motors.
Preface CONVENTIONS USED IN THIS GUIDE This manual uses the following documentation conventions: DOCUMENTATION CONVENTIONS Description Represents Examples Code (Courier font): Plain characters Sample code Filenames and paths #define START c:\autoexec.bat Angle brackets: < > Variables
PICDEMTM Mechatronics Demo Board User’s Guide WARRANTY REGISTRATION Please complete the enclosed Warranty Registration Card and mail it promptly. Sending in your Warranty Registration Card entitles you to receive new product updates. Interim software releases are available at the Microchip web site. RECOMMENDED READING It is recommended that you become familiar with the documents listed below, prior to using the PICDEM Mechatronics Demo Board.
Preface THE MICROCHIP WEB SITE Microchip provides online support via our web site at www.microchip.com. This web site is used as a means to make files and information easily available to customers.
PICDEMTM Mechatronics Demo Board User’s Guide CUSTOMER SUPPORT Users of Microchip products can receive assistance through several channels: • • • • • Distributor or Representative Local Sales Office Field Application Engineer (FAE) Technical Support Development Systems Information Line Customers should contact their distributor, representative or field application engineer (FAE) for support. Local sales offices are also available to help customers.
PICDEMTM MECHATRONICS DEMO BOARD USER’S GUIDE Chapter 1. PICDEM™ Mechatronics 1.1 INTRODUCTION The PICDEM™ Mechatronics is intended to be a learning tool for individuals interested in Mechatronic design. Mechatronics refers to integrating electronic controls into mechanical systems or replacing mechanical components with an electronic solution. PICmicro® microcontrollers are ideal for use in Mechatronic systems due to their small size, high efficiency, speed and abundance of peripheral configurations.
PICDEMTM Mechatronics Demo Board User’s Guide 1.3 QUICK START GUIDE The PICDEM Mechatronics Demo Board is programmed at the factory with a demonstration program. The board must be configured as described in this chapter in order to use the demonstration program. Once the board is configured and powered up, the speed of the Brushed DC (BDC) motor on the board may be varied using the potentiometer (POT1). The 8-bit hexadecimal interpretation of the position of POT1 is displayed on the LCD.
PICDEM™ Mechatronics QUICK BOARD SETUP TM FIGURE 1-1: © 2006 Microchip Technology Inc.
PICDEMTM Mechatronics Demo Board User’s Guide 1.4 PICDEM™ MECHATRONICS DEVELOPMENT KIT CONTENTS The PICDEM™ Mechatronics Development Kit contains the following items: 1. 2. 3. 4. 5.
© 2006 Microchip Technology Inc. 11 10 9 12 1 2 16 13 4 17 14 3 15 22 18 21 19 20 19. 20. 21. 22. 18. 16. 17. 15. 14. 7. 8. 9. 10. 11. 12. 13. 6. 4. 5. 1. 2. 3. 40-pin socket 20-pin socket On-board voltage regulator and power connections 8 LEDs 39 segment LCD connected to 14 pins on the 40-pin socket RS-232 socket and associated hardware Temperature sensor Light sensor 2 potentiometers 32.
PICDEMTM Mechatronics Demo Board User’s Guide The reasons for requiring you to use the provided jumpers to connect components to the microcontroller are three-fold. 1. You will gain knowledge and experience by physically connecting components to the microcontroller. 2. There are more peripherals than pins on the microcontrollers so that you can do more with the board. 3. Should you choose to use the board to experiment on your own, the board allows you the flexibility to do so.
PICDEM™ Mechatronics CONNECTING THE MPLAB ICD 2 TO THE PICDEM MECHATRONICS DEMO BOARD PI CD EM ™ Me c ha tro nic s FIGURE 1-3: D ge ug eb r InCir cu it PO W E ER R RO R BU SY MIC MPL ROCHI P AB ® ICD 2 CONNECTING THE PICkit™ 2 TO THE PICDEM MECHATRONICS DEMO BOARD PI C DE M ™ M ec ha tro nic s FIGURE 1-4: © 2006 Microchip Technology Inc.
PICDEMTM Mechatronics Demo Board User’s Guide 1.8 GENERAL PICDEM™ MECHATRONICS DEMONSTRATION BOARD INFORMATION Power Supply Maximum Ratings Supply voltage: 12 VDC Output current (drive stage): 1.2A (total) 1.8.1 Experimentation The PICDEM Mechatronics Demo Board was designed for your experimentation. After completing the projects in Chapter 2. “Example Projects”, please experiment freely on your own. Voltage power supplies and motors, other than those provided in the kit, may be used.
PICDEM™ Mechatronics FIGURE 1-5: 1.8.3 CONNECTING PORTC PINS TO LEDS FOR DEBUGGING OVER-CURRENT PROTECTION CIRCUIT The over-current protection circuit included on the board shuts down the drive portion of the circuit if the board drives 1.2 amps continually for 100 ms or longer. Upon powering up the board, the “FAULT” LED will be on.
PICDEMTM Mechatronics Demo Board User’s Guide 1.8.6 SNAP-OFF SENSORS The temperature sensor and light sensor can be snapped off to give greater flexibility in using these sensors. For example, the temperature sensor may be snapped off and moved into a more hostile environment, while keeping the board within sight. Once, snapped off, solder wires of the same length between the adjoining holes (i.e., JP3 and JP4 for the temperature sensor) on the PICDEM Mechatronics Demo Board and the sensor board. 1.8.
PICDEM™ Mechatronics 1.8.9 HEADER/JUMPER FUNCTIONS TABLE 1-1: HEADER/JUMPER FUNCTIONS Header/ Jumper # Description J1* Output MOSFET drive pins. J2 Full-bridge drive circuit (Drives 1 and 2): Place three shunts vertically on these pins to create a full-bridge drive circuit incorporating Drives 1 and 2. J3 Full-bridge drive circuit (Drives 3 and 4): Place three shunts vertically on these pins to create a full-bridge drive circuit incorporating Drives 3 and 4.
PICDEMTM Mechatronics Demo Board User’s Guide NOTES: DS51557C-page 18 © 2006 Microchip Technology Inc.
PICDEMTM MECHATRONICS DEMO BOARD USER’S GUIDE Chapter 2. Example Projects 2.1 INTRODUCTION The following projects cover basic mechatronic principles such as reading a sensor, interfacing to a LCD and driving a motor. These projects also provide examples of how to use the various PICmicro® microcontroller peripherals. The projects are presented sequentially so that you will build knowledge as you progress from one project to the next.
PICDEMTM Mechatronics Demo Board User’s Guide 2.2 LOADING PROJECTS IN MPLAB® IDE The firmware for the projects is arranged in corresponding project folders in the install directory for the PICDEM Mechatronics CD. If you installed the CD in the default directory, the firmware for Project 1 is located in: C:\PICDEM Mechatronics\firmware\Project1 Opening a Project 1. 2. 3. 4. Start MPLAB IDE. In the menu bar choose File -> Open Workspace. Find the project folder. Open the *.mcw file.
Example Projects 2.3.1 Project 1: Hello World (Light a LED) When learning to use a new computer language, the first practical lesson traditionally instructs the user how to print “Hello World” on the screen. Staying with tradition, this project will make your PICDEM Mechatronics Demo Board say “Hello World” in the most practical way a microcontroller can – lighting a LED. Objectives 1. Use the PIC16F917 to read a tactile switch input. 2. Implement switch debouncing. 3.
PICDEMTM Mechatronics Demo Board User’s Guide Instructions Pressing SW2 toggles LED (D0) on and off. Discussion Switch debouncing is done to ensure that mechanical contact chatter in the switch is not mistaken for more than one button push. Debouncing also ensures that for every one press of the button, only one function is executed. In this project that function is toggling a LED. Note: DS51557C-page 22 See Section 2.
Example Projects 2.3.2 Project 2: Dusk Indicator Using the Voltage Comparator If you have yard lights or a porch light at home that automatically turns on at dusk then you are familiar with the application we will create in this project. The comparator on the PIC16F917 will be used to compare the voltage level from the potentiometer to the voltage level out from the light sensor. When the intensity of the light to the sensor is reduced below the trip point set by the potentiometer, the LED will turn on.
PICDEMTM Mechatronics Demo Board User’s Guide FIGURE 2-5: PROJECT 2: SCHEMATIC VDD PIC16F917 VDD 11/32 Light Sensor C24 0.1 μF 6 VDD 4 VBAT 7 R31 VDD 2 C1- 1 kΩ GND RD7 30 TSL251RD 5 C1+ VDD POT1 10 kΩ VSS 12/31 R36 270 Ω D0 R10 1 kΩ Instructions Provide a light source for the light sensor and set Potentiometer 1 to the desired trip point. Block the light source and LED1 should turn on. Experiment with the set point and the amount to which you block the light from the sensor.
Example Projects 2.3.3 Project 3: Thermometer Using the Analog-to-Digital Converter This project shows how to read an analog temperature sensor and display the temperature on a LCD. The Analog-to-Digital Converter module is used to read the analog voltage output from the temperature sensor. Then, the resulting value is converted into degrees Celsius and displayed. Objectives 1. Use the Analog-to-Digital Converter module on the PIC16F917 to read the analog voltage output of the TC1047A temperature sensor.
PICDEMTM Mechatronics Demo Board User’s Guide Instructions The LCD displays a temperature reading in degrees Celsius. Breathe on the temperature sensor or introduce another heat source. The displayed temperature should rise. Move the jumper wire from the temperature sensor to the potentiometer (POT1 on J4). Move the potentiometer to view the full range of temperature conversion. Discussion The project introduces you to use of the Analog-to-Digital Converter module.
Example Projects 2.3.4 Project 4: Digital Clock Using Timer1 Most appliances that have a LCD show a clock readout when the appliance is not in use. In this project, Timer1 is used to create a real-time clock readout on the LCD. Objectives 1. Configure the PIC16F917 to use the 32.768 kHz crystal to clock Timer1. 2. Convert Timer1 into seconds, minutes and hours.
PICDEMTM Mechatronics Demo Board User’s Guide FIGURE 2-9: PROJECT 4: SCHEMATIC VDD 11/32 LCD1 PIC16F917 13 C35 22 pF Y1 32.768 kHz 14 SEGX Segment pins T1OSO VIM-332-DP VDD R4 10 kΩ R8 10 kΩ R5 2 RA0 1 kΩ VDD RA3 5 SW4 R9 1 kΩ 3 SW3 Common pins C34 22 pF VDD SW2 COMX T1OSI RA1 VSS 12/31 R6 10 kΩ R7 1 kΩ Instructions Use Switch 2 to set the hours and Switch 3 to set the minutes. Pressing and holding either of these switches will make the hours or minutes increment at a fast rate.
Example Projects 2.3.5 Project 5: Brushed DC Motor Speed Control with Optical Encoder Feedback Motor control is required in many mechatronic applications ranging from power windows to washing machine cycle control. This project will demonstrate speed control of a Brushed DC motor. Brushed DC motor control is simple as the commutation, or sequencing of power to the various windings, is automatically performed by the motor’s brushes.
PICDEMTM Mechatronics Demo Board User’s Guide 32.768 kHz CRYSTAL TM BRUSHED DC MOTOR OPTICAL INTERRUPTER PROJECT 5: JUMPER DIAGRAM Brushed DC Lead FIGURE 2-10: DS51557C-page 30 © 2006 Microchip Technology Inc.
Example Projects FIGURE 2-11: PROJECT 5: SCHEMATIC VDD LCD1 PIC16F917 11/32 VDD COMX Common pins SEGX Segment pins VDD R10 POT1 10 kΩ 1 kΩ 2 AN0 C26 1000 pF VIM-332-DP VDD VDD VDD U11:B R11 20 kΩ R20 470 Ω Q6 RD7 R22 30 24 RC5 470 Ω 10 kΩ D12 Motor U10:A 12/31 VSS CCP2 21 10 kΩ Simplified circuit shows equivalent functionality Instructions Use POT1 to adjust the speed of the motor.
PICDEMTM Mechatronics Demo Board User’s Guide 2.3.6 Project 6: Brushed DC Speed Control with Back EMF Feedback Project 5 uses an optical encoder to provide motor speed feedback. In this project, another form of speed measurement will be explored, Back Electromotive Force (Back EMF). You may be aware that a Brushed DC motor, when turned by hand, will produce voltage at its leads, becoming a generator.
Example Projects PROJECT 6: JUMPER DIAGRAM TM Brushed DC Lead FIGURE 2-12: © 2006 Microchip Technology Inc.
PICDEMTM Mechatronics Demo Board User’s Guide FIGURE 2-13: PROJECT 6: SCHEMATIC VDD LCD1 PIC16F917 11/32 VDD COMX Common pins SEGX Segment pins VDD R10 POT1 10 kΩ 1 kΩ 2 AN0 C26 1000 pF VIM-332-DP VDD U11:B R32 Back EMF 1 kΩ 7 AN4 RD7 30 C36 1000 pF 10 kΩ Back EMF Motor U10:A 12/31 CCP2 21 VSS 10 kΩ Simplified circuit shows equivalent functionality Instructions POT1 adjusts the speed of the motor. Set POT1 at 100% to run the motor at full speed.
Example Projects 2.3.7 Project 7: Stepper Motor Control: Single Stepping, Half Stepping and Microstepping This project demonstrates the various ways to drive a bipolar stepper motor. There are several ways to step a stepper motor, the most basic of which is single stepping, or moving the motor in one-step increments. If a motor is specified as a 7.5 degrees-per-step motor, then single stepping the motor will result in moving the shaft of the motor 7.5 degrees per step.
PICDEMTM Mechatronics Demo Board User’s Guide DS51557C-page 36 Yellow Red Orange PROJECT 7: JUMPER DIAGRAM Brown FIGURE 2-14: © 2006 Microchip Technology Inc.
© 2006 Microchip Technology Inc. VDD POT1 10 kΩ SW2 12/31 C26 1000 pF VSS 7 AN0 3 RA1 VDD CCP2 24 * RD4 27 * RD5 28 CCP1 21 * RD6 29 5 kΩ * 5 kΩ 5 kΩ VDD 5 kΩ * 5 kΩ VDD 5 kΩ * * * * = These are simplified circuits that show the equivalent functionality.
PICDEMTM Mechatronics Demo Board User’s Guide Instructions Adjusting POT1 varies the speed of the motor. Toggle between single stepping, half stepping, and microstepping modes by pressing SW2. At low speeds, the motor should noticeably step in single stepping and half stepping modes. The movement will be quite jerky in both modes, though to a lesser extent in the half stepping mode. In microstepping mode, the jerky motion should be virtually eliminated.
Example Projects 2.3.8 Project 8: PC Interface Using the USART Communicating with the serial port on a PC is a very useful tool. Applications include a piece of test equipment that needs to interface to a PC or a design that uses the serial port during development to configure the device. In this project, the PIC16F917 will use the USART to receive commands from a PC application. Another notable feature to this project is that the firmware implements an auto-baud routine to sync up with the application.
PICDEMTM Mechatronics Demo Board User’s Guide FIGURE 2-17: PROJECT 8: SCHEMATIC VDD U18 C17 0.1 μF 16 VCC C17 0.1 μF 2 J19 1 6 2 7 3 8 4 9 5 DE9S-FRS C17 V+ 1 3 4 C21 0.1 μF PIC16F917 11/32 VDD 5 C20 0.1 μF R60 11 25 14 TX 10 300 Ω 7 12 13 8 9 0.1 μF 6 V- GND 15 R61 26 RX MAX3232CUE 300 Ω 12/31 RD7 30 R36 270 Ω D0 VSS Instructions Locate the PIC® MCU Communicator GUI in the PIC MCU Communicator folder in Project 8 on the CD-ROM. Choose the Comm Port and baud rate.
Example Projects Discussion The firmware for this project implements RS-232 communication between the PC and PIC16F917. The USART is used to perform this communication. If a crystal oscillator were used as the clock source for the PIC16F917, auto-baud would not be necessary. However, because the PIC16F917 is using the internal RC oscillator, it is necessary to perform auto-baud.
PICDEMTM Mechatronics Demo Board User’s Guide 2.3.9 Project 9: Brushed DC Motor Control Using the ECCP This project is very similar to Project 5, only in this project, we are using the Enhanced Capture Compare PWM (ECCP) module in the PIC16F690 (see note). In PWM mode, the ECCP module has four outputs for directly driving an H-bridge circuit. This makes implementing bidirectional speed control of a Brushed DC motor a simple task. Note: To change microcontrollers, disconnect power from the board.
Example Projects PROJECT 9: JUMPER DIAGRAM Brushed DC Lead FIGURE 2-19: © 2006 Microchip Technology Inc.
DS51557C-page 44 VDD POT1 10 kΩ SW2 1 kΩ R10 VDD 17 AN2 2 RA5 7 VSS 20 P1D 14 P1C P1B 6 10 kΩ 10 kΩ 10 kΩ * * = These are simplified circuits that show the equivalent functionality. C26 1000 pF 1 kΩ R5 1 10 kΩ * Motor +5V * * FIGURE 2-20: R4 10 kΩ VDD +5V P1A 5 PIC16F690 +5V PICDEMTM Mechatronics Demo Board User’s Guide PROJECT 9: SCHEMATIC © 2006 Microchip Technology Inc.
Example Projects Instructions Use POT1 to adjust the speed of the motor. SW2 toggles between the following four modes of operation: • • • • Motor Off Forward Motor Off Reverse Discussion The ECCP module is ideal for driving a full-bridge circuit. Dead-band Delay Control and Automatic Shutdown are some of the other features of the ECCP module when configured in PWM mode.
PICDEMTM Mechatronics Demo Board User’s Guide NOTES: DS51557C-page 46 © 2006 Microchip Technology Inc.
PICDEMTM MECHATRONICS DEMO BOARD USER’S GUIDE Chapter 3. Troubleshooting 3.1 INTRODUCTION This chapter describes common problems associated with using the PICDEM™ Mechatronics and steps on how to resolve them. 3.2 COMMON PROBLEMS 3.2.
PICDEMTM Mechatronics Demo Board User’s Guide 3.2.4 Microcontroller Does Not Run After Programming By The MPLAB ICD 2 When using the MPLAB ICD 2 as a programmer, the microcontroller will not run unless you disconnect the MPLAB ICD 2 or release the MPLAB ICD 2 from Reset. Figure 3-1 shows the “Release From Reset” button. FIGURE 3-1: 3.2.5 RELEASE FROM RESET BUTTON Back EMF At J16 Is Floating Check that a Fault has not occurred by checking that the FAULT LED is off.
PICDEMTM MECHATRONICS DEMO BOARD USER’S GUIDE Appendix A. Hardware Schematics A.1 INTRODUCTION This appendix contains the PICDEM™ Mechatronics Board Schematic Diagram. SCHEMATIC DIAGRAM (PAGE 1 OF 7) M FIGURE A-1: © 2006 Microchip Technology Inc.
PICDEMTM Mechatronics Demo Board User’s Guide SCHEMATIC DIAGRAM (PAGE 2 OF 7) M FIGURE A-2: DS51557C-page 50 © 2006 Microchip Technology Inc.
Hardware Schematics SCHEMATIC DIAGRAM (PAGE 3 OF 7) M FIGURE A-3: © 2006 Microchip Technology Inc.
PICDEMTM Mechatronics Demo Board User’s Guide SCHEMATIC DIAGRAM (PAGE 4 OF 7) DS51557C-page 52 12 9 13 8 GND 15 10 7 6 V- 11 14 16 VCC 2 V+ C1+ C1C2+ C2- 1 3 4 5 M FIGURE A-4: © 2006 Microchip Technology Inc.
Hardware Schematics SCHEMATIC DIAGRAM (PAGE 5 OF 7) M FIGURE A-5: 3 1 7, 8 2 6 4 6 5 4 3 2 1 3 2 5 3 5, 6 4 2 5, 6 4 7, 8 1 1 © 2006 Microchip Technology Inc.
PICDEMTM Mechatronics Demo Board User’s Guide SCHEMATIC DIAGRAM (PAGE 6 OF 7) M FIGURE A-6: 2 11 13 12 11 13 12 9 10 8 2 7, 8 3 5, 6 4 4 1 8 3 5, 6 9 7, 8 10 1 DS51557C-page 54 © 2006 Microchip Technology Inc.
Hardware Schematics SCHEMATIC DIAGRAM (PAGE 7 OF 7) M FIGURE A-7: © 2006 Microchip Technology Inc.
PICDEMTM Mechatronics Demo Board User’s Guide NOTES: DS51557C-page 56 © 2006 Microchip Technology Inc.
PICDEMTM MECHATRONICS DEMO BOARD USER’S GUIDE Appendix B. LCD Segment Mapping Worksheet B.1 INTRODUCTION This appendix contains the LCD Segment Mapping Worksheet. © 2006 Microchip Technology Inc.
© 2006 Microchip Technology Inc.
LCD Segment Mapping Worksheet NOTES: © 2006 Microchip Technology Inc.
WORLDWIDE SALES AND SERVICE AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: http://support.microchip.com Web Address: www.microchip.