0% found this document useful (0 votes)
26 views10 pages

Lab 1

The document provides an overview of PIC microcontrollers, specifically the PIC16LF15376, and details the use of MPLAB X IDE for programming and configuring embedded designs. It explains the importance of pull-up and pull-down resistors in ensuring stable input pin states and introduces the functionality of LCD displays in embedded systems. Additionally, it outlines experiments involving LED control and text display on an LCD, along with the necessary wiring and code integration steps.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views10 pages

Lab 1

The document provides an overview of PIC microcontrollers, specifically the PIC16LF15376, and details the use of MPLAB X IDE for programming and configuring embedded designs. It explains the importance of pull-up and pull-down resistors in ensuring stable input pin states and introduces the functionality of LCD displays in embedded systems. Additionally, it outlines experiments involving LED control and text display on an LCD, along with the necessary wiring and code integration steps.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

ME2005 – MICRO-CONTROLLER

THE FALCUTY OF MECHANICAL ENGINEERING


MECHATRONICS DEPARTMENT Lab 1: Input-Output-LCD

1. Introduction ]1]
PIC is a Peripheral Interface Microcontroller which was developed in the year 1993 by the General
Instruments Microcontrollers. It is controlled by software and programmed in such a way that it
performs different tasks and controls a generation line. PIC microcontrollers are used in different
new applications such as smart phones, audio accessories and advanced medical devices.

Fig. 1 PIC16F15376 PIN


Board UMB1P.0-15375 V1.0 using 8-bit microcontroller PIC16LF15376

Fig. 2 UMB1P.0-15375 V1.0 board schematic1

Faculty of Mechanical Engineering @HCMUT 1


ME2005 – MICRO-CONTROLLER

Fig. 3 UMB1P.0-15375 V1.0 board schematic2


2. MPLAB X Integrated Development Environment [2]
 MPLAB X Integrated Development Environment (IDE) is an expandable,
highly configurable software program that incorporates powerful tools to
help you discover, configure, develop, debug and qualify embedded designs
for most of our microcontrollers and digital signal controllers. MPLAB X
IDE works seamlessly with the MPLAB development ecosystem of software
and tools, many of which are completely free.
 MPLAB® Code Configurator (MCC) is a free graphical programming
environment that generates seamless, easy-to-understand C code to insert
into your project. Using an intuitive interface, it enables and configures a
rich set of peripherals and functions specific to your application. MCC
consists of three content types: MCC Melody, MCC Classic and MPLAB
Harmony. It offers application libraries and system and peripheral drivers
for the development of embedded software. The MCC Content Manager
Tool (CMT) within MCC allows you to select the type of content and gives

Faculty of Mechanical Engineering @HCMUT 2


ME2005 – MICRO-CONTROLLER

you better flexibility by supporting content management and versioning at


an individual component level.
 Configure example in MCC:
o push button BT1 as Input and LED1 as Output
o Press and hold the BT1 button to make LED1 light, when you release your hand,
LED1 turns off

Fig. 4 Example schematic configuration


+ Open MCC in the Tool->Embedded menu of MPLAB X IDE. Create 1 MPLAB X
project for PIC16LF15376 . microcontroller

Fig. 5 Start MCC


+ Select the device for your project.

Fig. 6 Modules used in example


+ Open Pin Manager: Grid View. Select the RA5 padlock in the input row of the Pin
Module to set pin RA5 as input, select lock RE0, drive output to place pin RE0 is output

Faculty of Mechanical Engineering @HCMUT 3


ME2005 – MICRO-CONTROLLER

Fig. 7 Configure Pin Manager Grid View GPIO


+ Close the Pin Manager: Grid View window. Then, click on Pin Module at in the Project
Resources area
o The center section will show RE0 and RA5 listed on the I/O graph.
o RE5 will be the input that will read the switch.
o RA5 will be an output and drive the LED. Click the Output box to generate
o pin output and tick the Analog box to make analog output.
o Change the name of the pins to LED1 for RA5 and SW1 for RE0

Fig. 8 GPIO Module Pin Configuration


+ In this section, oscillator settings and configuration settings are selected.
o Oscillator
o Select HFINTOSC from the Oscillator Select drop-down menu.
o Select the 8MHz option from the HF Internal Clock drop-down menu.
o Set the Clock Driver value to 4.
o This will trigger the 2 MHz internal oscillator to work as the system clock pulse

Faculty of Mechanical Engineering @HCMUT 4


ME2005 – MICRO-CONTROLLER

Fig. 9 Configure System Module GPIO


+ Also, make sure that Low-voltage Programming Enable is enabled at the bottom of the
Module System screen.
+ Click the Generate button to have MCC generate a software library for this project

Fig. 10 Projects GPIO interface


+ Add the following code at the end of the main.c file:

Faculty of Mechanical Engineering @HCMUT 5


ME2005 – MICRO-CONTROLLER

3. Pull up and Pulll down resistor [5], [6]


If there is nothing connected to the pin and your program reads the state of the pin, will it be high
(pulled to VCC) or low (pulled to ground)? It is difficult to tell. This phenomena is referred to as
floating. To prevent this unknown state, a pull-up or pull-down resistor will ensure that the pin is
in either a high or low state, while also using a low amount of current.
o Pull up
With a pull-up resistor, the input pin will read a high state when the button is not pressed. In other
words, a small amount of current is flowing between VCC and the input pin (not to ground), thus
the input pin reads close to VCC. When the button is pressed, it connects the input pin directly to
ground. The current flows through the resistor to ground, thus the input pin reads a low state. Keep
in mind, if the resistor wasn’t there, your button would connect VCC to ground, which is very bad
and is also known as a short

Fig. 11 Pull up resistor [6]

o Pull down

Faculty of Mechanical Engineering @HCMUT 6


ME2005 – MICRO-CONTROLLER

Pull-down resistors work in the same manner as pull-up resistors, except that they pull the pin
to a logical low value. They are connected between ground and the appropriate pin on a device

Fig. 12 Pull down resistor [6]

4. LCD [7]

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of
applications. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. These modules are preferred over seven segments and other multi
segment LEDs. The reasons being: LCDs are economical; easily programmable; have no
limitation of displaying special & even custom characters (unlike in seven
segments), animations and so on.
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD
each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command
and Data.
The command register stores the command instructions given to the LCD. A command is an
instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the
cursor position, controlling display etc. The data register stores the data to be displayed on the
LCD. The data is the ASCII value of the character to be displayed on the LCD. Click to learn more
about internal structure of a LCD.

Fig. 13 module LCD

Faculty of Mechanical Engineering @HCMUT 7


ME2005 – MICRO-CONTROLLER

Wiring connection using LCD420.C in driver folder

Fig. 14 Example wiring connection to PIC

Fig. 15 LCD Pin Manager Grid View Configuration

Fig. 16 LCD Module Pin Configuration

Faculty of Mechanical Engineering @HCMUT 8


ME2005 – MICRO-CONTROLLER

+ Add library files “LCD.h” and “LCD.c” to the project

Experiment Result
Experiment 1:
If Press button BT1, LED will turn on sequentially: LED1, LED2, LED3.
If Press button BT2, LED will turn on sequentially: LED3, LED2, LED1.
If Press button BT2, LED will turn on sequentially: LED2, LED1, LED3.

Run □ Does not Run □ Run incorrectly □

Fig. 17 Schematic for Experiment 1


Comments

Experiment 2: Display text: Mechatronics (line 1) and Nhom x (line 2 with x: group’s number
Run □ Does not Run □ Run incorrectly □

Experiment 3: Display number on LCD while clicking BT1


Run □ Does not Run □ Run incorrectly □
Comments

Student name and code


No Code Name

Faculty of Mechanical Engineering @HCMUT 9


ME2005 – MICRO-CONTROLLER

Reference
[1] INTRODUCTION TO MICRO-CONTROLLERS, https://electrosome.com/getting-
started-pic-ccs-c/
[2] MPLAB® X Integrated Development Environment (IDE)
https://www.microchip.com/en-us/tools-resources/develop/mplab-x-ide

[3] Programming PIC 16F877A microcontroller By PICKit2,


https://nationalcircuits.wordpress.com/2016/09/24/programming-pic-16f877a-
microcontroller-by-pickit2/
[4] Getting Started with PIC Microcontroller – CCS C Compiler,
https://electrosome.com/getting-started-pic-ccs-c/

[5] Pull-up Resistors, https://learn.sparkfun.com/tutorials/pull-up-resistors


[6] Pull up resistor / Pull down resistor, http://www.resistorguide.com/pull-up-
resistor_pull-down-resistor/
[7] LCD, https://www.engineersgarage.com/electronic-components/16x2-lcd-module-
datasheet

Faculty of Mechanical Engineering @HCMUT


1
0

You might also like