Docsity

Microcontroller LCD Display and Keyboard Functions, Study Guides, Projects, Research of Electrical and Electronics Engineering

Partial preview of the text

Download Microcontroller LCD Display and Keyboard Functions and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

Final Design Report

The Elixir Mixer

Team: Mixalot

EEL 4914 Senior Design

Spring 2007

Andrew Ehsaei [email protected] 704.737.

Mike Guidi [email protected] 727.501.

Table of Contents:

  • Abstract …………………………………………………………………………
  • Introduction …………………………………………………………………....
  • Objectives …………………………………...…………………………………
  • Features ………………..………………..………………… ……………...….
  • Machine Setup ….……...…………………………………………….…….....
  • Process Overview and Flowchart……..…………………………….…….....
  • Technology………………………………………………………………………
  • Design Schedule …………………………..……………………………….….
  • Responsibilities…………………………………………………………….…...
  • Costs ….………………………………………………………………….......
  • Issues …..……………………………………………..……………………....
  • Protel Schematics .....………………………………..……………………....
  • Code …………….. .....………………………………..……………………....

Objectives:

Programmed Options:

The Elixir Mixer utilizes a keyboard and LCD to interface with the user. It takes

the user input and processes the information using the MSP430 microcontroller.

The microcontroller then turns on the pumps for each type of liquid depending on

the user selection. The bottles are stored upside down in the machine, allowing

for smaller, lower power pumps to move the liquid. The liquids dispense through

tubes and empty into a funnel located above the user’s cup.

Custom Creation:

This feature requires the user to input the proportions of each liquid, in ounces,

using the keyboard. The options and selections are displayed on the LCD and

then stored into flash memory located on the MSP430. After a drink is created,

the user has the option of choosing the custom creation from the main menu in

addition to the preprogrammed options.

Customer Objectives:

The main customer objective is to produce a product that can be easily

assimilated into the household. The product needs to be as small as possible to

fit on a kitchen counter or home bar. Additionally, the interface is user-friendly to

allow for easy access and learning. Lastly, the product is designed to be as

inexpensive as possible. The product is meant to be affordable for the average

consumer so costs were watched closely.

Features:

Interface

 Keyboard to select options from the drink menu and allow the user to

specify a name for custom drinks.

 LCD to display the options in the drink menu.

Containers

 5 different containers that can be switched in and out based on customer

preference.

 The pre-programmed options deal with a default setup

Pumps

 5 small pumps, one for each liquid container.

 The pumps move the liquid from the containers into the user’s cup.

Options

 Custom drink creation options which can be saved for later use.

 Preprogrammed options for default drinks

Home Design

 Compact design to allow for home usage.

 Minimal power consumption and cost.

Machine Setup:

 The liquids are stored upside down on the back of the box construction.

 The pumps are positioned along the back wall of the box and tubing is

used to connect to the containers and mixing funnel.

 The pumps are based on timing, pumping selections in numbers of

ounces. The maximum number of ounces is 8 ounces per drink.

 The pumps are controlled using a MOSFET switch circuit. The

microcontroller sends control signals to open a close the switches, which

activates the pumps.

 The pumps will dispense the liquids into one funnel located above the

user’s cup.

Process Overview:

Microcontroller:

We used a TI msp430F1611 microcontroller because it is low power and easy to

use. The microcontroller was programmed in C, making it easier to accomplish

the tasks. The chip was used to control the following components:

 Liquid Pumps via Power MOSFETs

 LCD Interface

 Keyboard

 Memory Read/Write

 LED Display

LCD:

An important part of the project is the LCD, since that is the primary means of

interfacing with the user. As such, we decided to go with a graphical LCD to

allow for a larger screen and the ability to display things other than simple text.

The LCD we chose is a 128x64 GDM12864HLCM from Xamien Ocular Optics

since it fit our needs, was cheap and was readily available.

Keyboard:

We used a standard PS-2 connection to interact with the keyboard. This is the

most common current technology and was fairly easy to implement. Any home-

user will be familiar with a standard keyboard similar to those used with personal

computers. The keyboard sends two signals to the microprocessor, clock and

data. While waiting for the user to input a key, the clock input is continuously

sampled until it reaches the falling edge indicating the beginning of transmission.

The data format is start bit, 8 data bits, parity, and stop bit. We used the clock on

the keyboard to sample the data input on each falling edge. The 8 data bits were

then translated into the appropriate character using a lookup table.

Liquid Pumps:

The liquid pumps are small, motor driven pumps intended for use in toy water

guns. The pumps function using a small motor and a gear reduction system to

drive a piston and create suction. The pumps are low power and use a standard

5V, allowing the microcontroller to control them through a voltage level shifter.

Power MOSFETs were used in a switch circuit because the pumps draw more

current than we were able to achieve using transistor gain.

Design Schedule:

Issues:

Solenoid Controlled Valves

The first attempt at controlling the liquid flow was to use a shot dispenser valve

controlled by a solenoid. The shot dispenser valve measures and releases one

shot (1.5 fluid ounces) and is shown below:

The liquid container sits on the top of the valve and gravity pulls the liquid down

into the measuring glass. An upward force is needed to open the valve, which

closes the opening to the liquid container and the measured amount is released.

There is large spring located within the valve and when the force is no longer

applied, the valve returns to the previous state.

Originally, we planned on using a push-type solenoid to apply the needed force

in opening the valves and tried many configurations of solenoid placement. The

solenoids were not strong enough to overcome the force of the resisting spring.

Also, the placement of the electronic solenoid could not be close to the exiting

liquid for safety concerns.

Next, the spring was taken out of the valve and a push-pull type solenoid was

used in conjunction with a horizontal plate, to keep the liquids and solenoids

separated. This also produced inconsistent results, primarily stemming from the

poor quality of the valves and attachment method.

Motor Controlled Valves

The next attempt was made using gear reduction motors and PVC valves. The

plan was to use a rotating PVC valve and attach it to the end of a gear reduction

motor to open and close the valves. There were many problems associated with

this design as well. The main problem was attaching the motor to the PVC valve.

The valve was made out of plastic and PVC material and the motor end was

metal. Numerous adhesives and bindings were tried but we discovered that the

plastic did not bond well to the metal.

The other problem was the accuracy of the rotations. The valve was setup so

that the motor could turn in one direction and open/close the valve with each

turn. The accuracy of the motor starting and stopping exactly when the valve was

open/closed was very difficult. Also, the transistor switch circuit did not turn the

pumps off exactly when the control signal stopped.

Micro Pumps

The solution to the valve issues was to look for inexpensive pumps to pump the

liquid from the containers rather than open valves. We found the micro pumps

online, originally intended for use in toy water guns. The pumps consist of a small

motor and a gear reduction system attached to a piston. They were small and

only required 5 volts to operate, making it easy to incorporate into our project.

The problem with the pumps is that they are not very powerful and not intended

for this purpose. To get around the power problem, we decided to use the shot

dispenser valves to hold the liquid containers upside down and pump from the

bottom of the container, utilizing gravity and minimizing the pumping distance.

LCD

Character Generation

One difficulty with the LCD is that the KS0108 drivers to not have a built in text

capability. Due to this, each character must be mapped to a specific pixel

representation. We decided to use characters that were 6x7 for general purpose

display. Each character was mapped to a starting address in memory. That

memory address and the following five addresses contain the pixel information

for the character. Other design images were ‘drawn’ using individual pixel

configurations.

Contrary to what might be expected, the pixels for a given location are written

from top to bottom. So if we wanted to draw single dot at the bottom two pixels

of a line, the representative byte would be 0xC0 instead of 0x03.

Two-Side Writing

The LCD is divided into two halves, each controlled with a KS0108 LCD driver

IC. The Chip Select (CS) pins on the LCD select which side is to be written to.

CS1 controls the right side of the LCD and CS2 controls the left side. If a chip

select is active, the data written to the LCD will appear on that half of the screen.

If both are active, both sides get written to. The chip select also controls the

on/off display of each side. A typical LCD write to both sides would appear as

this:

--CS1 = L, CS2 = H

--Write left side LCD data

--CS1 = H, CS2 = L

microprocessor. Since using current gain failed, we decided to use single

MOSFET switches. The gate voltage is supplied by the microprocessor which

forms the conducting channel. At 3.3V on the gate, the MOSFETs couldn’t

conduct the required current to operate the pumps. We shifted the voltage up to

5V, and this provided a large enough field to allow the pumps to run.

Protel

In our first board design, all the components for our system were located on the

same board. The pump control circuits were a little crowded and incorporated

typical BJT transistors. After testing the control circuits on the pumps, we

determined the pumps were drawing too much current for the transistors to

handle. In a new board design, the components were split up so that there would

be more room for the motor connections, and the BJT transistors were replaced

with power MOSFETs, having the ability to withstand very large currents.

Another issue with the Protel schematics was the voltage level shifter chips. In

our design we use the level shifter chips because the microcontroller runs on 3.

volt signals and the other components run on 5 volt signals. The voltages were

shifted when exiting and entering the microprocessor on a great deal of signals.

The voltage shifter chips added a complexity to the routing on the Protel boards.

Many of the wires became crossed because of the layout and as a result, a two-

layer board was required for our main board.

Code:

#include <msp430x16x.h>

#include <string.h>

//LCD Data Pins Connected to Port 1 Pins 1..7 + Port2 Pin

//LCD Control Pins Connected to I/O Port

//Port2 Pin 1 is R/W

//Port2 Pin 2 is RS

//Port2 Pin 3 is E

//Port2 Pin 4 is CS2 = Left Side Contol

//Port2 Pin 5 is CS1 = Right Side Control

//Port2 Pin 6 is /Res

//Keyboard Data connected to port3 pin

//Keyboard Clock connected to port3 pin

//Pumps are connected to Port4 pins 1-

#define LCD_Data P1OUT

#define SetData7 (P2OUT |= 0x01)

#define ClearData7 (P2OUT &= 0xFE)

#define LCD_Control P2OUT

#define LCD_Data_Dir P1DIR

#define LCD_Control_Dir P2DIR

#define Keyboard_Dir P3DIR

#define Keyboard_Data P3IN

#define Pump_Dir P4DIR

#define Pump_Out P4OUT

//Special Keyboard Keys

#define ENTER 0xFF

#define ESC 0xFE

#define TAB 0xFD

#define BS 0xFC

#define BADKEY 0xFB

#define BREAK 0xF

//Pump Definitions

#define PUMP0 0x

#define PUMP1 0x

#define PUMP2 0x

#define PUMP3 0x

#define PUMP4 0x

//Stings for Drinks

#define Premade0 "PURPLE"

#define Premade1 "ORANGE"

#define Premade2 "GREEN"

#define Premade3 "REDGREEN"

//Function Declarations

void QuickDelay();

void LongDelay(int Time);

void MedDelay();

void PumpDelay(int Time);

//LCD Functions

void Init_LCD();

int String_To_LCD(char str[], int CurrentPage);

void Char_To_LCD(char Character);

void LCD_En();

0x3E, 0x41, 0x41, 0x51, 0x32, 0x00,// G

0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00,// H

0x00, 0x41, 0x7F, 0x41, 0x00, 0x00,// I

0x20, 0x40, 0x41, 0x3F, 0x01, 0x00,// J

0x7F, 0x08, 0x14, 0x22, 0x41, 0x00,// K

0x7F, 0x40, 0x40, 0x40, 0x40, 0x00,// L

0x7F, 0x02, 0x04, 0x02, 0x7F, 0x00,// M

0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00,// N

0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00,// O

0x7F, 0x09, 0x09, 0x09, 0x06, 0x00,// P

0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00,// Q

0x7F, 0x09, 0x19, 0x29, 0x46, 0x00,// R

0x46, 0x49, 0x49, 0x49, 0x31, 0x00,// S

0x01, 0x01, 0x7F, 0x01, 0x01, 0x00,// T

0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00,// U

0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00,// V

0x7F, 0x20, 0x18, 0x20, 0x7F, 0x00,// W

0x63, 0x14, 0x08, 0x14, 0x63, 0x00,// X

0x03, 0x04, 0x78, 0x04, 0x03, 0x00,// Y

0x61, 0x51, 0x49, 0x45, 0x43, 0x00// Z

/* 0x00, 0x00, 0x7F, 0x41, 0x41,// [

0x02, 0x04, 0x08, 0x10, 0x20,// ""

0x41, 0x41, 0x7F, 0x00, 0x00,// ]

0x04, 0x02, 0x01, 0x02, 0x04,// ^

0x40, 0x40, 0x40, 0x40, 0x40,// _

0x00, 0x01, 0x02, 0x04, 0x00,// `

0x20, 0x54, 0x54, 0x54, 0x78,// a

0x7F, 0x48, 0x44, 0x44, 0x38,// b

0x38, 0x44, 0x44, 0x44, 0x20,// c

0x38, 0x44, 0x44, 0x48, 0x7F,// d

0x38, 0x54, 0x54, 0x54, 0x18,// e

0x08, 0x7E, 0x09, 0x01, 0x02,// f

0x08, 0x14, 0x54, 0x54, 0x3C,// g

0x7F, 0x08, 0x04, 0x04, 0x78,// h

0x00, 0x44, 0x7D, 0x40, 0x00,// i

0x20, 0x40, 0x44, 0x3D, 0x00,// j

0x00, 0x7F, 0x10, 0x28, 0x44,// k

0x00, 0x41, 0x7F, 0x40, 0x00,// l

0x7C, 0x04, 0x18, 0x04, 0x78,// m

0x7C, 0x08, 0x04, 0x04, 0x78,// n

0x38, 0x44, 0x44, 0x44, 0x38,// o

0x7C, 0x14, 0x14, 0x14, 0x08,// p

0x08, 0x14, 0x14, 0x18, 0x7C,// q

0x7C, 0x08, 0x04, 0x04, 0x08,// r

0x48, 0x54, 0x54, 0x54, 0x20,// s

0x04, 0x3F, 0x44, 0x40, 0x20,// t

0x3C, 0x40, 0x40, 0x20, 0x7C,// u

0x1C, 0x20, 0x40, 0x20, 0x1C,// v

0x3C, 0x40, 0x30, 0x40, 0x3C,// w

0x44, 0x28, 0x10, 0x28, 0x44,// x

0x0C, 0x50, 0x50, 0x50, 0x3C,// y

0x44, 0x64, 0x54, 0x4C, 0x44,// z

0x00, 0x08, 0x36, 0x41, 0x00,// {

0x00, 0x00, 0x7F, 0x00, 0x00,// |

0x00, 0x41, 0x36, 0x08, 0x00,// }

0x08, 0x08, 0x2A, 0x1C, 0x08,// ->

0x08, 0x1C, 0x2A, 0x08, 0x08 // <-*/

};

//Introduction "Drawing"

const char Intro[] = {

//Left Side

//Page 0

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0xFF, //Top T

0xFF, 0xFF, 0xFF, 0x0F, 0x0F, 0x0F,

0x0F,

0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,

0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0xFF, //Top H

0xFF, 0xFF, 0xFF,

0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,

0xFF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, //Top E

0xCF, 0xCF,

//Page 1

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, //Bottom T

0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,

0x00,

0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,

0xFF, 0x03, 0x03, 0x03, 0x03, 0xFF, //Bottom H

0xFF, 0xFF, 0xFF,

0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,

0xFF, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, //Bottom E

0xF3, 0xF3,

//Page 2 = Empty

//Page 3

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00,

0xFF, 0xFF, 0xFF, 0xFF, 0xCF, //Top E

0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF,

0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,

0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, //Top L

0x00, 0x00,

0x00, 0x00, 0x00, //Top I

0xFF, 0xFF, 0xFF, 0xFF,

//Page 4

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00,

0xFF, 0xFF, 0xFF, 0xFF, 0xF3, //Bottom E

0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,

0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,

0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, //Bottom L

0xF0, 0xF0,

0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, //Bottom I

0xFF,

//Page 5 = Empty

//Page 6 = Empty

//Page 7 = Empty