Programming PIC Microcontrollers in PicBasic Pro LCD Lesson 3 Cornerstone Electronics Technology and Robotics II

Similar documents
' The PicBasic Pro Compiler Manual is on line at: '

o What happens if S1 and S2 or S3 and S4 are closed simultaneously? o Perform Motor Control, H-Bridges LAB 2 H-Bridges with SPST Switches

Devantech SRF04 Ultra-Sonic Ranger Finder Cornerstone Electronics Technology and Robotics II

Laboratory 11. Pulse-Width-Modulation Motor Speed Control with a PIC

Direct Current Waveforms

Electronics Review 1 Cornerstone Electronics Technology and Robotics II Week 1

Hashemite University Faculty of Engineering Mechatronics Engineering Department. Microprocessors and Microcontrollers Laboratory

Figure 1: Basic Relationships for a Comparator. For example: Figure 2: Example of Basic Relationships for a Comparator

Figure 1: One Possible Advanced Control System

Pulse-Width-Modulation Motor Speed Control with a PIC (modified from lab text by Alciatore)

t w = Continue to the next page, where you will draw a diagram of your design.

infraled Zeppelin Nick Wagner, Austin Jurgensmeyer, and Christopher Record 12/16/08

GF of 9 THE GADGET FREAK FILES CASE #165. Analog Clock Measures Time in Meters

Lab 3 Final report: Embedded Systems Digital Potentiometer Subsystem TEAM: RAR

Potentiometer Tutorial Cornerstone Electronics Technology and Robotics I Week 8

ECE Senior Design Final Report For. Scalable Regulated Three Phase Power Rectifier. May 10, 2004 Rev. 1.0

Operational Amplifiers 2 Active Filters ReadMeFirst

o Semiconductor Diode Symbol: The cathode contains the N-type material and the anode contains the P-type material.

Introduction to Using the PIC16F877 Justin Rice IMDL Spring 2002

Digital-to-Analog Converter. Lab 3 Final Report

Automated flight through inertial navigation and digital fly-by-wire systems

Microprocessors A Lab 4 Fall Analog to Digital Conversion Using the PIC16F684 Microcontroller

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

PART 1: DESCRIPTION OF THE DIGITAL CONTROL SYSTEM

Cornerstone Electronics Technology and Robotics I Week 19 Electrical Relays

Circuit LED 1 LED 2 A on or off on or off B on or off on or off C on or off on or off

Exercise 1: The Rheostat

EXERCISE 4: A Simple Hi-Fi

Follow this and additional works at: Part of the Engineering Commons

Laboration: AD-conversion and the Thevenin theorem.

Microprocessors B Lab 4 Spring Motor Control Using Pulse Width Modulation (PWM)

EE283 Laboratory Exercise 1-Page 1

GRAPHICAL LCD BASED DIGITAL OSCILLOSCOPE

Screening Audiometer

DEPARTMENT OF ELECTRICAL ENGINEERING LAB WORK EE301 ELECTRONIC CIRCUITS

The Skiidometer. Hardware Description By: Adam Lee ; Etec474; Prof. Morton; WWU

Interfacing to Analog World Sensor Interfacing

PIC Station3. Multi-processor starter kit for PIC microcontroller. Kit content : PIC Station-3 experiment board

Part (A) Using the Potentiometer and the ADC* Part (B) LEDs and Stepper Motors with Interrupts* Part (D) Breadboard PIC Running a Stepper Motor

Lighting Tutorial Cornerstone Electronics Technology and Robotics I Week 7

Analog Circuits Laboratory EXPERIMENT 3: BJT CURRENT SOURCES

Operational Amplifiers

ECE3042 Lab Report and Homework Guidelines. Homework. Lab Report

DEPARTMENT OF ELECTRICAL ENGINEERING LAB WORK EE301 ELECTRONIC CIRCUITS

AC : THE UBIQUITOUS MICROCONTROLLER IN MECHANICAL ENGINEERING: MEASUREMENT SYSTEMS

A servo is an electric motor that takes in a pulse width modulated signal that controls direction and speed. A servo has three leads:

BMC052. Chordizer Last updated

More Fun with A/D Converters

PreLab 7: LED Blinker (Due Oct 30)

K1EL Granite State Crystal Matcher GS XTAL

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Embedded Systems. Oscillator and I/O Hardware. Eng. Anis Nazer First Semester

DMC-8 (SKU#ROB )

Special Sensor Report

PROTOBot: Amoeba! A complete interactive robot By Camp Peavy and Randy Hootman. Complete Parts List: Prices may vary

Ocean Controls KT-5221 Modbus IO Module

B BasicATOM Lab Board Data Sheet

Experiment No. 4 The LM 741 Operational Amplifier

Understanding the Arduino to LabVIEW Interface

Experiment 5.B. Multifunction Wireless Control. ECEN 2270 Electronics Design Laboratory 1

BasicATOM Lab Board Data Sheet

Simulation Of Radar With Ultrasonic Sensors

Lab 2: Blinkie Lab. Objectives. Materials. Theory

νµθωερτψυιοπασδφγηϕκλζξχϖβνµθωερτ ψυιοπασδφγηϕκλζξχϖβνµθωερτψυιοπα σδφγηϕκλζξχϖβνµθωερτψυιοπασδφγηϕκ χϖβνµθωερτψυιοπασδφγηϕκλζξχϖβνµθ

Brief Manual of HERA Application Board. with MiDAS Family. V2.0 March 2006

EET140/3 ELECTRIC CIRCUIT I

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

Designing with a Microcontroller (v6)

ENGR-4300 Fall 2006 Project 3 Project 3 Build a 555-Timer

Design and Fabrication of High Frequency Linear Function Generator with Digital Frequency Counter using MAX038 and a PIC microcontroller

Board Of Education, Revision C (28150)

Week 9: Series RC Circuit. Experiment 14

MICROPROCESSORS A (17.383) Fall Lecture Outline

Follow this and additional works at: Part of the Engineering Commons

GetTutorialized Workshops Brochure-2017

Prelab: Introduction and Greenhouse Construction

Lab assignment: Strain gauge

Multipurpose Iron Man Glove & Moveable Platform

Experiment EB2: IC Multivibrator Circuits

Engineering 3821 Fall Pspice TUTORIAL 1. Prepared by: J. Tobin (Class of 2005) B. Jeyasurya E. Gill

ITT Technical Institute. ET275 Electronic Communications Systems I Onsite Course SYLLABUS

ET275P Electronic Communications Systems I [Onsite]

Community College of Allegheny County Unit 4 Page #1. Timers and PWM Motor Control

Lab 3: Embedded Systems

Development of a MATLAB Data Acquisition and Control Toolbox for BASIC Stamp Microcontrollers

USER MANUAL FOR THE LM2901 QUAD VOLTAGE COMPARATOR FUNCTIONAL MODULE

A Super trainer with advanced hardware and software features only found in very expensive equipment.

Solar Mailbox project. Pictures of the Solar Mailbox

Guitar Hero Game Controller

EXPERIMENT NUMBER 10 TRANSIENT ANALYSIS USING PSPICE

LEDs and Sensors Part 2: Analog to Digital

Data Conversion and Lab Lab 4 Fall Digital to Analog Conversions

PLXDigi (v1.00) Instruction manual Configuration software manual

AN ARDUINO CONTROLLED CHAOTIC PENDULUM FOR A REMOTE PHYSICS LABORATORY

EXPERIMENT 5 CURRENT AND VOLTAGE CHARACTERISTICS OF BJT

555 Astable Kit MitchElectronics 2018

Exercise 3: Power in a Series/Parallel Circuit

Arduino STEAM Academy Arduino STEM Academy Art without Engineering is dreaming. Engineering without Art is calculating. - Steven K.

Project 3 Build a 555-Timer

Transcription:

Programming PIC Microcontrollers in PicBasic Pro LCD Lesson 3 Cornerstone Electronics Technology and Robotics II Administration: o Prayer PicBasic Pro Programs Used in This Lesson: o General PicBasic Pro Program Listing: http://www.cornerstonerobotics.org/picbasic.php o Lab 1 lcd3 as.pdf file: http://www.cornerstonerobotics.org/code/lcd3.pdf o Lab 4 lcd1 as.pdf file: http://www.cornerstonerobotics.org/code/lcd1.pdf LCD PicBasic Programming: o New PICBasic Command: POT: Format POT Pin,Scale,Var Reads a resistive component (5K to 50K) such as a potentiometer on Pin. Pin may be called in the usual format, PORTB.0, or as a constant, 0 15, 0 is PORTB.0 and 15 is PORTA.7 (See section 4.11 Pins in the green PBP Compiler manual). To set Scale, see the POT command in the green microengineering Labs PicBasic Pro Compiler manual or the explanation and table below. Explanation of Scale: o Scale must be set empirically (with observation and experiments) such that the LCD readout value is 0 with the potentiometer set to one end and 255 when set to the other end. See the illustrations below. Scale Set Too High Scale Set Too Low Scale Set Properly Figure 1, POT Scale Settings Approximate Scale Values for Resistor R3 Resistor R3 in Schematic Below Approximate Scale Value 5K 165 10K 91 25K 45 50K 38 1

Example: POT 0,178,x POT reading on Pin RBO assigned to variable, x. Scale = 178 to give a full range of values over the potentiometer (0 to 255) for the variable, x. LCD Command Table Command $FE, 1 $FE, 2 $FE, $0C $FE, $0E $FE, $0F $FE, $10 $FE, $14 $FE, $18 $FE, $1C $FE, $80 $FE, $C0 $FE, $94 $FE, $D4 Operation Clear display Return home Cursor off Underline cursor on Blinking cursor on Move cursor left one position Move cursor right one position Display shift left Display shift right Move cursor to beginning of first line Move cursor to beginning of second line Move cursor to beginning of third line Move cursor to beginning of fourth line o Perform LCD3 LAB 1 lcd3.pbp o Perform LCD3 LAB 2 5 10K Series Resistors o Perform LCD3 LAB 3 LED Status on LCD Defining LCD Pins: o PicBasic Pro permits changing of LCD pin connections by using DEFINE statements. The LCD default pin connections are shown in Figure 2: Figure 2, LCD Default Connections 2

o To move the data connections, use the following DEFINE statements: DEFINE LCD_DREG sets the LCD data port. o DEFINE LCD_DREG PORTA Sets PORTA as LCD data port o DEFINE LCD_DREG PORTB Sets PORTB as LCD data port If an 8-bit data bus is used, all 8 bits must be in one port If a 4-bit data bus is used, the top 4 LCD data bits (DB4-DB7) must be either wired to the bottom 4 or top 4 bits of the port selected. For example, if DEFINE LCD_DREG PORTB is declared, then the top LCD bits DB4-DB7 must be connected to either RB0-RB3 or RB4- RB7 (see DEFINE LCD_DBIT immediately below). PicBasic Pro assumes the data lines DB4-DB7 are connected to PORTA.0-PORTA.3 (RA0-RA3). DEFINE LCD_DBIT sets starting data bit for 4-bit bus. o DEFINE LCD_DBIT 0 Set starting data bit to 0 o DEFINE LCD_DBIT 4 Set starting data bit to 4 PicBasic Pro default starting bit is bit 0 of PORTA or PORTA.0 Example: Move the data port AN0-AN3 to PORTB and the starting data bit to bit 4. Let Register Select and Enable connections remain unchanged. DEFINE Statements: o DEFINE LCD_DREG PORTB Sets PORTB as LCD data port o DEFINE LCD_DBIT 4 Set starting data bit to 4 The schematic in Figure 3 shows relocated the data port connections: Figure 3, Revised Data Port Connections 3

o To move the Register Select and Enable connections, use the following DEFINE statements: DEFINE LCD_RSREG sets the Register Select (RS) port. o DEFINE LCD_RSREG PORTB Sets PORTB as the RS port o DEFINE LCD_RSREG PORTE Sets PORTE as the RS port Register Select may be connected to any port pin. PicBasic Pro default setting for Register Select is PORTA. DEFINE LCD_RSBIT sets the Register Select (RS) bit. o DEFINE LCD_RSBIT 2 Sets bit 2 as RS bit o DEFINE LCD_RSBIT 6 Sets bit 6 as RS bit Register Select may be connected to any port pin. PicBasic Pro default setting for Register Select is bit 4 of PORTA or PORTA.4. DEFINE LCD_EREG sets the Enable (E) port. o DEFINE LCD_EREG PORTB Sets PORTB as Enable port o DEFINE LCD_EREG PORTD Sets PORTD as Enable port Enable may be connected to any port pin. PicBasic Pro default setting for Enable is PORTB. DEFINE LCD_EBIT sets the Enable (E) bit. o DEFINE LCD_EBIT 3 Sets bit 3 as the Enable bit o DEFINE LCD_EBIT 7 Sets bit 7 as the Enable bit Enable may be connected to any port pin. PicBasic Pro default setting for Enable is bit 3 of PORTB or PORTB.3. Example: Move the Register Select from AN4 to RB0 and the Enable from RB3 to RB1. Leave the data port connections in their default configuration. DEFINE Register Select Statements: o DEFINE LCD_RSREG PORTB Sets PORTB as the RS port o DEFINE LCD_RSBIT 0 Sets bit 0 as RS bit DEFINE Enable Statements: o DEFINE LCD_EREG PORTB Sets PORTB as Enable port o DEFINE LCD_EBIT 1 Sets bit 1 as the Enable bit The schematic in Figure 4 on the next page shows the relocated Register Select and Enable connections: 4

Figure 4, Revised Register Select and Enable Connections DEFINE LCD_BITS sets the bus size (4-bits or 8-bits). o DEFINE LCD_BITS 4 Sets 4-bit bus o DEFINE LCD_BITS 8 Sets 8-bit bus PicBasic Pro default setting for bus size is a 4-bit bus. DEFINE LCD_LINES sets the number of lines on the LCD. o DEFINE LCD_LINES 4 Sets LCD to display 4 lines o DEFINE LCD_LINES 2 Sets LCD to display 2 lines PicBasic Pro default setting is for the number of lines on the LCD is a 2 line LCD display. o In summary, LCD connections to PICs can be changed from their PIC default settings by using the DEFINE statements listed above. o We will need use these features in our lesson on analog-to-digital conversion. o Perform LCD3 LAB 4 Changing LCD Pins on a PIC 5

Cornerstone Electronics Technology and Robotics II LCD Lesson 3 LAB 1 lcd3.pbp Purpose: The purpose of this lab is to acquaint the student the PicBasic Pro command POT and the use of an LCD to monitor variable input values. Apparatus and Materials: 1 Analog/Digital Trainer PIC 16F88 Microcontroller Hantronix HDM16216H-5-300S 16x2 LCD, Jameco #618003 20 K Potentiometer 10K Potentiometer (R3) 4.7 K Resistor 0.1 uf Capacitor Procedure: o Wire the in-circuit serial programming connections before proceeding. See Lesson 15A, In-Circuit Serial Programming for details. o Now add the following circuitry. Use a 10K trimpot for R3: o Open lcd3.pbp and download into the PIC16F88. Adjust the 10K potentiometer R3 to see if the full range of the potentiometer is engaged. If the full range is not active, adjust the Scale value in the POT command to make the full range active. Do this by empirically (through observation and experimentation) setting the Scale value to its lowest number while the LCD displays 255. 6

Cornerstone Electronics Technology and Robotics II LCD Lesson 3 LAB 2 Five 10K Series Resistors Purpose: The purpose of this lab is to acquaint the student the fact that the PicBasic Pro command POT in non-linear in nature. Apparatus and Materials: 1 Analog/Digital Trainer PIC 16F88 Microcontroller Hantronix HDM16216H-5-300S 16x2 LCD, Jameco #618003 20 K Potentiometer 5-10K Resistors 4.7 K Resistor 0.1 uf Capacitor Procedure: o Wire the circuit LCD4 below and program the chip with lcd3.pbp. o Connect pin RB1 to Point A as shown in the schematic below. Set the POT command Scale value such that the 255 is the full range for the 5 10K resistors. Start by setting the Scale low so the LCD reads a number below 255, and then raise the Scale until you reach a full range reading of 255. o Now connect RB1 to Points B through F and plot the results on the accompanying graph. Observe the non-linear nature of the plot. 7

8

Cornerstone Electronics Technology and Robotics II LCD Lesson 3 LAB 3 LED Status on LCD Purpose: The purpose of this lab is to acquaint the student with using an LCD to display the state of an output. Apparatus and Materials: Analog/Digital Trainer or Breadboard w/ 5VDC Supply PIC 16F88 Microcontroller Hantronix HDM16216H-5-300S 16x2 LCD, Jameco #618003 1 4.7K Resistor 2 150 Ohm Resistors 20 K Potentiometer 2 LEDs Procedure: o Wire the following circuit lcd1. o Open blink1.pbp from your folder and run the program. Challenges: o Connect one LED (LED1) with a 150 ohm resistor to PORTB.1 and program it to blink on and off every second. Display LED1 and its state (0 or 1) as a variable on the LCD. Save the program as lcd16.pbp. Don t forget to set the proper bits in the TRISB register to outputs as needed. o Connect a second LED (LED2) to PORTB.2 and program it to blink opposite LED1. Display LED1 on the first line and LED2 on the second line with their respective states as variables. Save the program as lcd17.pbp. 9

Cornerstone Electronics Technology and Robotics II LCD Lesson 3 LAB 4 Changing LCD Pins on a PIC Purpose: The purpose of this lab is to acquaint the student with changing the default connections of an LCD to a PIC chip. Apparatus and Materials: Analog/Digital Trainer or Breadboard w/ 5VDC Supply PIC 16F88 Microcontroller Hantronix HDM16216H-5-300S 16x2 LCD, Jameco #618003 1 4.7K Resistor 1 20 K Potentiometer Procedure: o Wire the following circuit lcd1. o Download lcd1.pbp into the PIC16F88 o Change the LCD pin connections from their default settings to: Data port: PORTB Starting data bit: 0 Register Select port: PORTB Register Select bit: 4 Enable port: PORTB Enable bit: 5 4 or 8-bit bus: 4-bit bus, the PBP default setting Lines on LCD: 2, the PBP default setting o Save the revised lcd1.pbp as lcd18.pbp o Rewire the circuit to reflect the change in LCD pin connections. 10