Speed Control of a DC Motor using Digital Control

Similar documents
/*Algorithm: This code display a centrifuge with five variable speed RPM by increaseing */

Timer0..Timer3. Interrupt Description Input Conditions Enable Flag

ECE Homework #10

LCD. Configuration and Programming

Timer1 Capture Mode:

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

Team 8: Robert Blake Craig Goliber Alanna Ocampo

BME 4900 Page 1 of 2. Meeting 2: Personal Progress Report 12/2/09 Team 12 with Drew Seils. Semester One Week Two

More Fun with Timer Interrupts

Chapter 13. PIC Family Microcontroller

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

unsigned char ReadADC() { /************* start A/D, read from an A/D channel *****************/ unsigned char ADC_VALUE;

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation

Contents. PIC Mini Data Sheets

unsigned char ReadADC() { /************* start A/D, read from an A/D channel *****************/ unsigned char ADC_VALUE;

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

Final Design Report 19 April Project Title: Pneumatic Exercise Machine

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

Embedded Systems Module. 6EJ505. C Tutorial 3: using the ICD3 rev tjw

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

Interrupts on PIC18F252 Part 2. Interrupts Programming in C Language

Capture Mode of Pic18F252

Flow Charts and Assembler Programs

Mid-Range Family Peripheral Configuration with C Programming

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING MSC SYSTEMS ENGINEERING AND ENGINEERING MANAGEMENT SEMESTER 2 EXAMINATION 2016/2017

Hong Kong Institute of Vocational Education Digital Electronics & Microcontroller. 8. Microcontroller

C and Embedded Systems. So Why Learn Assembly Language? C Compilation. PICC Lite C Compiler. PICC Lite C Optimization Results (Lab #13)

Analog Output with a Digital to Analog Converter

Inverted Pendulum Microprocessor and FPGA Manual Sheldon Logan July 3, 2006

PIC16F870/ /40-Pin, 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram. Microcontroller Core Features:

Human Response Timer

Microcontroller Overview

Interactive Modules for the Intelligent Teddy Bear

Interrupts on PIC18F252 Part 2

Accurate Time and Interrupts

Using Timers of Microchip PIC18F Microcontrollers

SRF08 Ultra sonic range finder

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

// sets the position of cursor in row and column

Simon. Final Project Report December 11, 2009 E155. Julia Karl and Kirsten McAfee

Embedded System Design

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca.

BME 361 Biomeasurement Laboratory Demonstration Biomedical Engineering Program University of Rhode Island June 10, 2015

PIC16F87XA Data Sheet

C:\Users\cunningh\StaysOnPC\ME430 Downloads & Projects\exam2_problem1\problem1Cunningham.c

Table of Contents COMPANY PROFILE 1-1 SECTION 1. INTRODUCTION 1-1

PIC16F /40-Pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

EEE394 Microprocessor and Microcontroller Laboratory Lab #6

Lecture (09) PIC16F84A LCD interface LCD. Dr. Ahmed M. ElShafee

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics:

Section 14. Timer1 HIGHLIGHTS. Timer1. This section of the manual contains the following major topics:

PIC16F818/819 Data Sheet

Interrupts. Embedded Systems Interfacing. 08 September 2011

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING. BEng(Hons) Electrical and Electronics Engineering SEMESTER 1 EXAMINATION 2016/2017

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

Embedded Systems Programming and Architectures

EXPERIMENT 5. Oven Temperature Control Using Open loop and Closed Loop Methods

The University of Texas at Arlington Lecture 21_Review

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

Laboratory: Introduction to Mechatronics

EE 361L Digital Systems and Computer Design Laboratory

Tel: Fax:

Chapter 11: Interrupt On Change

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

NOTICE: 1, the timing for Start, Stop, ACK, NACK, write and read is same as I2C

PIC16F7X Data Sheet. 28/40-pin, 8-bit CMOS FLASH Microcontrollers Microchip Technology Inc. DS30325B


UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING B.ENG (HONS) ELECTRICAL AND ELECTRONIC ENGINEERING EXAMINATION SEMESTER /2016

Sales: Technical: Fax:

ELCT 912: Advanced Embedded Systems

Topic 10 10/24/2010. C with Embedded Extension

The MCU s Pulse. Internal clock or oscillator to synchronize operation. One clock cycle = 1 TOSC = 1/fOSC. t TOSC

Binary Outputs and Timing

Remote Controlled KitchenAid Mixer for the Clients at ADEC. Appendices. Arnaud Bacye Karina Dubé Justin Erman Matthew Martin

Laboratory Exercise 5 - Analog to Digital Conversion

EET203 MICROCONTROLLER SYSTEMS DESIGN Serial Port Interfacing

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

Example of Asyncronous Serial Comms on a PIC16F877

Relay. bit4 bit5 bit6 bit7

PIC16F872 Data Sheet. 28-Pin, 8-Bit CMOS Flash Microcontroller with 10-Bit A/D Microchip Technology Inc. DS30221C

Programmable Pet Feeder

CREATING FIRST PROJECT in mikropascal PRO for PIC32

Simple cpik Tutorial

Chapter 9. Input/Output (I/O) Ports and Interfacing. Updated: 3/13/12

DRPIC166X IP Core. High Performance 8-bit RISC Microcontroller v. 2.17

PIC Microcontroller Introduction

These 3 registers contain enable, priority,

Microprocessors B (17.384) Spring Lecture Outline

CENG-336 Introduction to Embedded Systems Development. Timers

LCDs. Embedded Systems Interfacing. 20 September 2011

Appendix A: Rack Specification Sheet

PIC16C745/ Bit CMOS Microcontrollers with USB. Pin Diagrams. Devices included in this data sheet: Microcontroller Core Features:

Lecture (03) PIC16F84 (2)

PIC18FXX2 Registers. Hyperlinked Index

Input/Output Ports and Interfacing

PIC16F630/676 Data Sheet

movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt

Interrupts, timers and counters

PIC16F630/676 Data Sheet

Transcription:

Speed Control of a DC Motor using Digital Control The scope of this project is threefold. The first part of the project is to control an LCD display and use it as part of a digital tachometer. Secondly, we need to develop a PI controller for controlling the speed of a DC motor. Thirdly, we need to deliver our control signal to an H-bridge to control speed and direction of the DC motor. LCD Display Driver LCD displays come in a variety of configurations, multiline, graphical, and color displays. A lot of these displays are controlled by the Hitachi HD44780 or compatible controller. For our purposes we selected the MDLS-81809 display which is a single line, eight character display. This was selected because we need to display 10000rpm and this would be adequate. Digital Tachometer with Voltage Output 0-73kHz approx. input

LCD display reads 0-10000 rpm approx. 8-bits out on PORTC to give D/A input this code is written with Hi-Tech C Lite for a 16f877 with 10MHz oscillator compile with config bits osc = xt, wdt & put & cp & bod & lvp & derp & fpw all off include standard pic header file #include <pic.h> define lcd signals to port bits #definelcd_rs #definelcd_rw #define lcd_en #define busy_bit #define direction RE2 RD7 RC0 RE1 RE0 #define lcd_data PORTD define global variables int count; int temp,temp1,temp2,temp3,temp4; int tempcount,advalue; initialization routine void init(void) TRISD = 0; TRISB = 0; TRISC = 0; port d is output port b is output port c is output

TRISA = 0xff; port a is input PORTD = 0; port d value = 0 PORTB = 0; port b value = 0 PORTC = 0; port c value = 0 INTCON = 0xc0; PIE1 = 0x01; ADCON1 = 0x04; ADCON0 = 0x89; T1CON = 0x31; global and peripheral interrupts enabled timer1 interrupt enabled port a and e are digital inputs prescale = 8, Fosc/4 input, timer on OPTION = 0x24; ra4 input to timer0 prescale = 32 TMR1H = 0x94; TMR1L = 0x58; timer interval to give full scale output Interrupt Service Routine static void interrupt isr(void) if (TMR1IF) T1CON &= 0xfe; count = TMR0; TMR0 = 0; test for timer1 interrupt timer1 off read timer0 value reset timer0 TMR1H = 0x94; TMR1L = 0x58; TMR1IF = 0; T1CON = 0x01; restore timer1 value clear interrupt flag timer1 on Routine that gives 1ms delay with 10MHz oscillator

void delayms(void) int i; for (i=1;i<180;i++); void initpwm(void) PR2 = 0x3f; CCPR1L = 0; period register CCP1X = 0; least sig. bits of duty cycle CCP1Y = 0; T2CKPS1 = 0; prescale timer 1 TMR2ON = 1; turn timer on CCP1M3 = 1; for PWM mode CCP1M2 = 1; for PWM mode void speedup(void) int i,j; tempcount = advalue; for (i=0;i<tempcount;i=i+10) CCPR1L = i; for (j=0;j<5;j++) 5ms delay void slowdown(void) int i,j; tempcount = advalue;

for (i=tempcount;i>0;i=i-10) CCPR1L = i; for (j=0;j<5;j++) 5ms delay void getad(void) GODONE = 1; while (GODONE) advalue = ADRESH; start A/D conversion wait for completion read upper 8 bits adn save in advalue test for lcd busy flag this routine is not used void lcdbusy(void) unsigned int busydata; TRISD = 0xff; lcd_rs = 1; lcd_rw = 1; lcd_en = 1; portd input data mode read operation enable lcd while (busy_bit!= 0); wait for busy bit to go low lcd_rs = 0; control lines back to 0 lcd_rw = 0; lcd_en = 0; TRISD = 0; portd output

sends a command to the lcd display void lcdputcmd(int cmd) int i; lcd_data = cmd; lcd_rw = 0; lcd_rs = 0; lcd_en = 1; lcd_en = 0; for (i=0;i<5;i++) put command on portd write operation command mode enable lcd 5ms delay void lcdclr(void) lcdputcmd(0x01); clear lcd display Sends data to be displayed on lcd void lcdputdata(int dat) lcd_data = dat; put data on portd lcd_rw = 0; write operation lcd_rs = 1; data mode lcd_en = 1; enable lcd lcd_en = 0; control lines back to 0 lcd_rs = 0; initialize lcd display

void lcdinit(void) lcdputcmd(0x30); lcdputcmd(0x0e); lcdputcmd(0x06); function set 8x1 display entry mode display mode main() int i,j; init(); initialize pic initpwm(); getad(); speedup(); for (j=0;j<4;j++) for(i=0;i<1900;i++); delay for lcd to power up lcdinit(); initialize lcd display while(1) getad(); tempcount = count + count + count + count; convert and display count if (count < advalue) direction = 0; CCPR1L = advalue + (advalue - count)/4; else direction = 0; CCPR1L = advalue - (count - advalue)/4; resolution of 40rpm temp = tempcount/1000; lcdputdata(0x30+temp);

temp1 = (tempcount - temp * 1000)/100; lcdputdata(0x30+temp1); temp2 = (tempcount - temp * 1000-temp1*100)/10; lcdputdata(0x30+temp2); temp3 = (tempcount - temp * 1000-temp1*100-temp2*10)/1; lcdputdata(0x30+temp3); lcdputdata('0'); lcdputdata('r'); lcdputdata('p'); lcdputdata('m'); for(j=0;j<100;j++) lcdclr();