ECE383: Microcomputers Lab 6 Basic and Finite State Machine LED and Switch I/O Programming

Similar documents
ECE383: Microcomputers Lab 2 PIC24 System Schematic Creation in PCB Artist

ECE383: Microprocessors Lab 9 Analog-to-Digital and Digital-to-Analog Conversion with I 2 C Serial EEPROM Data Storage

ECE383: Microcomputers Lab 4 MPLAB Introduction and PIC24 Assembly Language

Microcomputers. C and Embedded Systems

Microprocessors B Lab 1 Spring The PIC24HJ32GP202

PIC Dev 14 Surface Mount PCB Assembly and Test Lab 1

PIC Dev 14 Through hole PCB Assembly and Test Lab 1

Contents. The USB Logic Tool... 2 Programming... 2 Using the USB Logic Tool... 6 USB Logic Tool Features... 7 Device Hardware...

Microprocessors B Lab 3 Spring PIC24/24LC515 EEPROM Interface Using I 2 C

MICROPROCESSORS A (17.383) Fall Lecture Outline

Finite State Machine Lab

ECE 362 Experiment 3: General Purpose I/O

University of Hawaii EE 361L MPLab Quick Tutorial and Project 2.1 Last updated September 1, 2011

ECE 270 Lab Verification / Evaluation Form. Experiment 1

PICado Alpha Development Board V1.0

Laboratory 10. Programming a PIC Microcontroller - Part II

Experiment 9: Binary Arithmetic Circuits. In-Lab Procedure and Report (30 points)

Getting acquainted with the development tools June 27, 2006 ELE492 Embedded System Design Exercise 1

Standard Logic Chips and National Instruments ELVIS Breadboarding for Combinational Logic Circuits

Laboratory Exercise 7 - Extended I/O & Parallel Processing

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Product Overview -A 16 bit Micro Experimenter for Solderless Breadboards

KPIC-0818P (V050919) Devices Included in this Data sheet: KPIC-0818P

CPE 200L LABORATORY 4: INTRODUCTION TO DE2 BOARD UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND:

AVR Board Setup General Purpose Digital Output

Sidewinder Development Board rev 1.0

ECE2049 Embedded Computing in Engineering Design. Lab #0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

RFID: Read and Display V2010. Version 1.1. Sept Cytron Technologies Sdn. Bhd.

ECE 362 Experiment 4: Interrupts

Cygnos360 V2 Installation Manual

Lab Overview. Lab Details. ECEN 4613/5613 Embedded System Design Week #7 Spring 2005 Lab #4 2/23/2005

ENEE245 Digital Circuits and Systems Lab Manual

FPGA Introductory Tutorial: Part 1

Images Scientific OWI Robotic Arm Interface Kit (PC serial) Article

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 1.

Getting Started in C Programming with Keil MDK-ARM Version 5

BC-USB-Kit Manual. First Edition. February, BeatCraft, Inc.

Lab 2 EECE473 Computer Organization & Architecture University of Maine

University of Florida EEL 3701 Dr. Eric M. Schwartz Department of Electrical & Computer Engineering Revision 0 12-Jun-16

Tutorial 1: Software Setup

TDSDB Features. Description

Embedded Systems. 2. Software Development. Lothar Thiele. Computer Engineering and Networks Laboratory

Embedded Systems - FS 2018

Embedded Systems - FS 2018

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

ECE 362 Lab Verification / Evaluation Form Experiment 5

Lab #3: Keypad Scanning in C Week of 11 February 2019

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

PIC32MX150F128 Breakout Board

AGH University of Science and Technology Cracow Department of Electronics

NIOS CPU Based Embedded Computer System on Programmable Chip

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

ECE Homework #3

Outline for Today. Lab Equipment & Procedures. Teaching Assistants. Announcements

- create new schematic to the new project, PCB design begins with a schematic diagram, which present how components are connected

MICROPROCESSORS A (17.383) Fall Lecture Outline

ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives:

University of California, Davis Department of Electrical and Computer Engineering. Lab 1: Implementing Combinational Logic in the MAX10 FPGA

Getting Started in C Programming with Keil MDK-ARM Version 5

ECE 491 Laboratory 1 Introducing FPGA Design with Verilog September 6, 2004

32 bit Micro Experimenter Board Description and Assembly manual

Install Visual Studio Community Version 2017

NIOS CPU Based Embedded Computer System on Programmable Chip

Cygnos360 V2 Installation Manual

Display Real Time Clock (RTC) On LCD. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

Getting Started in C Programming with Keil MDK-ARM Version 5

Atmel AVR datasheet. Matrix Multimedia Atmel AVR Board EB Contents

PIC KIT 2 BASIC-USERS GUIDE FEMTO ELECTRONICS

Lab 2 - Powering the Fubarino. Fubarino,, Intro to Serial, Functions and Variables

Lab Overview. Lab Details. ECEN 4613/5613 Embedded System Design Week #1 Fall 2008 Lab #1 8/27/2008

IME-100 ECE. Lab 3. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE,

CSC 258 lab notes, Fall 2003

NIOS CPU Based Embedded Computer System on Programmable Chip

UF-3701 Power Board Construction Guide

QRPGuys Digital Dial/Frequency Counter

IME-100 ECE. Lab 4. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE,

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

AKKON USB CONTROLLER BOARD

Capacitive Touch Remote Control Reference Design User s Guide

Hibernation Module. Introduction. Agenda

LED Knight Rider. Yanbu College of Applied Technology. Project Description

ECE 3610 Microprocessing Systems Lab #1 Verilog Design of the TOC Using Quartus II

Micro-Controllers. Module 2: Outputs Control and Inputs Monitoring. IAT Curriculum Unit PREPARED BY. August 2008

Experiment 0: Introduction to MPLAB and QL200 development kit

Assembly Instructions for 128x64 Graphics Display Unit

EMT1250 LABORATORY EXPERIMENT. EXPERIMENT # 7: VHDL and DE2 Board. Name: Date:

DMX512-4 Channel PWM Driver Board #805

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Complete Tutorial (Includes Schematic & Layout)

Problem Score 1 / 27 2 / 19 3 / 16 4 / 14 code check off 5 / 22 /2 Total /100

ENEE245 Digital Circuits and Systems Lab Manual

Design a three-input, two-output sequential digital circuit which functions as a digital locking mechanism. LOCK ALARM

TUTORIAL SESSION Technical Group Hoda Najafi & Sunita Bhide

PCB Design utilizing Cadence Software. Application Note

LAB 7 Writing Assembly Code

Microchip 18F4550 Interface, Signal conditioning, USB, USB- RS-232, 16x2 LCD Interface

Creating a PCB Design with OrCAD PCB Editor

Experiment 2 Fall 2012

PicProtoBoard 32MX Adapter User Manual

Transcription:

ECE383: Microcomputers Lab 6 Basic and Finite State Machine LED and Switch I/O Programming Goals: The goals of this lab are to continue to instruct students in a PIC24-based hardware system using PIO ports for switch input and LED output using basic and finite state machine (FSM) processing. 1. Introduction This lab introduces basic PIO port configuration and utilization for switch-based input and LED output. A C-based software finite state machine is used for an LED/switch I/O problem. The tasks in this lab include: Modifying and expanding the PIC24HJ128GP502 reference system schematic and printed circuit board to include additional pushbutton and LED components. Programming the Microstick II to implement a basic LED problem. Programming the Microstick II to implement a software finite state machine for an LED/switch I/O problem using additional pushbutton and LED components on the breadboard. 2. Prelab For this lab assignment, Tasks 1, 2, and 3 should be completed as a pre-lab assignment prior to your assigned lab time. You are also strongly encouraged to have the majority of the software written for Task 4 and 5 complete before your assigned lab time. TA check: As soon as you enter lab, provide the TA with a pre-lab report that includes the complete schematic, PCB layout, and C programs. Lab time will be devoted to debugging the program execution and correcting any errors within MPLAB noted by the lab instructor. Make sure your group member names and date are on the pre-lab report. 3. TASK 1: Expanding the PIC24 Reference System Schematic Using PCB Artist, expand and modify the basic PIC24 system previously created as shown in Figure 1 below. If your previous PIC24 system schematic was designed and constructed neatly and correctly you may use your schematic from the previous lab as a starting point for this design. Otherwise you should construct a new system. Note that the pushbuttons use a different component from previous labs. The pushbutton component to use for this design, named PUSHBUTTON, is located in the ECE383 PCB Artist library located on the class website. TA check: Upon entering the lab, show the TA the schematic design. Use a screen capture tool to capture the schematic window and include it in your lab report. 1 P a g e

Figure 1. Expanded PIC24 System Schematic 4. TASK 2: Expanded PIC24 System Printed Circuit Board Layout For this task we will create a printed circuit board layout from the PIC24 schematic created as a part of task 1. The board size should be 80mm x 80mm. The board part number should be ECE383-LAB6 and the Revision Number should be 001. These parameters can be set through the PCB wizard. Use the Settings->Grids function to set the Working Grid and the Screen Grid to 1mm x 1mm. Use the Settings->Coordinates function to set the Coordinate System Origin to the lower left corner of the board. Left click on the bottom edge of the board, press the = key and note the Y coordinate value. Left click on the left edge of the board, press the = key and note the X coordinate value. Enter the X and Y values for the Coordinate System Origin using the Settings->Coordinates function. This should set the origin to the lower left corner of the board as indicated by a symbol. Another method for setting the system origin is to highlight an item (i.e. the bottom edge of the board), right click and select Origins->Set System Origin At Item. We will create four mounting holes for this PCB using the Add->Board->Circle function. The diameter for each mounting hole should be 3mm and they should be placed in the four corners of the board with each hole being exactly 2mm from each edge of the board. Use the Tools->Measure function to assist you in this layout. 2 P a g e

Each of the components should be placed in specific locations on the PCB. Highlight a component and press the = key. This will allow you to type in exact locations for the origins of each of the components. Table 1 gives the X and Y values for the location of each component in your design. Component X location Y location PIC24 (U1) 10 60 LM2937-3.3 (U2) 70 65 SW1 57 72 SW2 47 72 SW3 37 72 LED1 70 44 LED2 20 10 LED3 30 10 LED4 40 10 LED5 50 10 R1 24 30 R2 9 68 R3 30 30 R4 36 30 R5 42 30 R6 48 30 C1 64 67 C2 6 33 C3 22 33 C4 71 56 C5 22 54 Table 1. Expanded PIC24 System Component Locations. Use your experience from previous labs to create a PCB similar to the diagram shown in Figure 2 below. After the PCB has been completed, use Tools->Design Rule Check to verify the design passes all the basic electrical design rules checks built into PCB Artist. Checking the Spacing, Nets and Manufacturing checkboxes should ensure all design rule checks are performed. The design rule check file created should indicate No errors found under the Results section if all design rule checks successfully pass. Generate a bill of materials CSV by running the Output->Reports->User Reports->bill of materials CSV report. This report should list all components in the design. Include the report output in an appendix of your lab report. Generate a component positions report by running the Output->Reports->User Reports- >component positions cvs report. This report should list the exact positions of all components in the design. Include the report output in an appendix of your lab report. Note that the positions reported may differ slightly from the location values from Table 1. They will only be identical if the center of the component is also the origin for that component. 3 P a g e

Figure 2. Expanded PIC24 System Printed Circuit Board TA check: Upon entering the lab, show the TA the printed circuit board you completed. Include a printout of your PCB in your lab report. 5. TASK 3: A Basic LED Problem This task will require you to write a C program to implement a basic LED problem. Perform the following steps: Start the MPLAB IDE. Use Project->Project Wizard for the creation of an MPLAB project. o Step One: Select the device PIC24H128GP502 for the MicroStick II. o Step Two: Select the Active Toolsuite as Microchip C30 Toolsuite. o Step Three: Create a New Project File in a unique directory on the local hard disk (C:\temp\task3a.mcp as an example). o Step Four: Skip the addition of existing files to the project. After the project is open, use Project->Build Options to add the C:\microchip\lib\include directory to the Include Search Path directory. 4 P a g e

o Step Five: Configure the clock source for the processor. Select Configure->Configuration Bits Uncheck the Configuration Bits Set in code checkbox. Change to FNOSC filed by clicking on the Setting area showing Internal Fast RC (FRC) with divide by N. Change the setting to Internal Fast RC (FRC) w/ PLL. Recheck the Configuration Bits Set in code checkbox. Enter the C program below and save it with the name task3a.c as a part of the project. #include "pic24_all.h" #if PIC24HJ128GP502 #define LED1 _LATA0 // MicroStick II definitions #define CONFIG_LED1() CONFIG_RA0_AS_DIG_OUTPUT() #endif int main(void) { CONFIG_LED1(); LED1=0; while (1) { LED1 =!LED1; } return 0; DELAY_MS(100); // Infinite while loop // Toggle LED1 // Delay 100ms } Use Project->Add Files to Project to add the following files to your project: o C:\microchip\lib\common\pic24_clockfreq.c o C:\microchip\lib\common\pic24_serial.c o C:\microchip\lib\common\pic24_uart.c o C:\microchip\lib\common\pic24_util.c Compile the project by selecting Project->Build All. Enable the MPLAB IDE debugger by selecting Debugger->Select Tool->Starter Kit on Board for the MicroStick II. Download your code into a device on the board by selecting Debugger->Program. (Note: This is an important step to follow. Do not just click Run because it will run the previous program in the PIC24 memory. Every time, you edit the code. Build first, and then click Program). Run the application by selecting Debugger->Run. This should toggle an LED on the PIC24 board. TA check: Show the TA the operation of the flashing LED program. Using the procedure described above, create a new project (task3b.mcp), containing a C program (task3b.c). This program should alternate the rate at which the LED should toggle. The program should toggle the LED at a rate of 10 times per second for 5 seconds then change to 5 times per second for another 5 seconds. The process should then repeat. Use a variable that keeps track of elapsed time by counting the number of times the DELAY_MS() function is executed. TA check: Show the TA the operation of the modified flashing LED program. 5 P a g e

6. TASK 4: Software-Based Finite State Machine for LED/Switch I/O For this task you use the MicroStick II and the breadboard and interface the following components. Two pushbuttons will be connected to RB12 and RB14 similar to the schematic created in Task 1. You will use the pushbuttons purchased as a part of your lab components. Two LEDs will be connected to RB1 and RB15. Resistors (910 ohm) should be connected to the cathode of each LED. The other terminal of the resistor should be connected to a Vss (GND) pin of the PIC24, which is either pin 19 or 8. The constructed circuit should resemble the circuit shown in Figure 3. Note: All power will be provided to the PIC24 system via the USB cable. Implement the following LED/Switch I/O problem: 1. Turn on LED1 (RB15). On a press and release of pushbutton SW1, turn off the LED1 and go to step 2. 2. After a press and release of a pushbutton (SW1), blink LED1 two times and the freeze the LED1 on. 3. After a press and release of a pushbutton (SW1), if SW2 = 0, go to (1), else go to the next step. 4. When the pushbutton (SW1) is pressed and held down, blink LED2 five times per second. LED2 should be off if SW1 is not pressed. After the second release, go to (5). 5. Blink LED2 rapidly (twice as fast as step 4). On press and release of the pushbutton (SW2), go to (1). Your first task should be to determine the states required and construct an ASM chart for implementing your assigned LED/switch I/O problem. Create an MPLAB project task4.mcp and the corresponding C program task4.c to implement the finite state machine. Download your code to your PIC24 system and test the operation of your software design using the debugging capabilities of MPLAB and the Microstick II. TA check: Show the TA your ASM chart and that your LED/switch code functions as expected. Figure 3. Task 4 schematic 6 P a g e

7. TASK 5: Variable Rotating LED For this task, you will implement a rotating LED program using the RGB LED interfaced with the PIC24 system. RGB (Red-Green-Blue) LEDs are actually three LEDs in one. Most RGB LEDs have four pins: one for each color and a common cathode pin. In this task, you will use a common cathode RGB LED which is shown in Figure 4. The data sheet link: http://www.kingbrightusa.com/images/catalog/spec/wp154a4sureqbfzgc.pdf Figure 4. Common Cathode RBG LED In this task, you are required to control the RGB LED using both binary codes and gray codes. Since there are only 3 leds in one RGB LED, we only consider binary codes and gray codes with 3-bits. Table 2 shows each 3-bit binary code and its corresponding gray code. Binary 000 001 010 011 100 101 110 111 Gray 000 001 011 010 110 111 101 100 Table 2. Three-bit Binary Code and Gray Code You are required to write a function in C which converts a binary code to its corresponding gray code. The input parameter of this function is a char type data which represents a binary code while the output is the gray code also in data type char. There are numerous methods for this conversion process. One possible approach is by bit shifting and an XOR operation. One example is given below. Example: Suppose we want to convert binary code 010 to gray code 011. Step 1: 00000010 Step 2: 00000001 (shift the code to right by 1bit, system would add 0 to last digit) Step 3: 00000011 (XOR) Once the code convert function is written write a program that implements the functionality given in Table 3 7 P a g e

below. SW1 SW2 Y location Not pressed Not pressed Turn on all LEDs (R,G,B) Not pressed Pressed Repeatedly display binary code from 000 to 111 on RGB LED with each combination on for 0.5 sec Pressed Not pressed Repeatedly display gray code from 000 to 100 on RGB LED with each combination on for 0.5 sec Pressed Pressed Blink the RGB led (all three colors) at the rate of 10 times per second Table 3. Task Five Program Functionality Name the project task5.mcp and the corresponding C program task5.c. Download your code to your PIC24 system and test the operation of your software design. Note that all the gray codes must be converted from the binary code instead of coming from Table 2 directly. The constructed circuit should resemble the circuit in Figure 5. Figure 5. Task 5 schematic Provide answers to the following questions in your lab report. 1. What are the advantages of binary codes and gray codes respectively? 2. Can we convert a gray code value back to binary code? If the answer is yes, please describe one possible method. Otherwise please explain the reason. 8 P a g e

TA check: Show the TA that your program functions as expected. 8. Laboratory Report No later than a week from the day the lab is performed, provide the TA a printed copy of the lab report following the ECE383 Lab report Template given on the class website. Each lab group will submit one joint lab report to the TA. Your report should have the reporting requirements needed for Tasks 1-5. The TA will take off a significant number of points (15 points from total lab grade) if your C source does not have the required comments. 9. Grading Policy 1. Completion of Task 1 with results included in lab report (10%) 2. Completion of Task 2 with results included in lab report (10%) 3. Completion of Task 3 with results included in lab report (20%) 4. Completion of Task 4 with results included in lab report (20%) 5. Completion of Task 5 with results included in lab report (20%) 7. Completeness, quality, and correctness of the lab report (20%) 9 P a g e