MC68HC11A8-Indicator Head-Up Display (HUD)
The project Indicator Head-Up Display (HUD) is based on Motorola HC11 controller. This system is built to display the status of the direction indicator lamps of vehicles. When a direction indicator switch is operated for either left- or right-turn signaling the direction will be displayed on the LCD. To simulate this circuit, initially activate Mixed Mode simulator from the Schematic Editor window. Simulation can be performed by selecting Transient analysis from Simulation menu.
This project includes M68HC11A8 microcontroller, LCD unit (controller and display) and
potentiometer.
The HC11 controller has an eight channel, successive approximation ADC module as a peripheral. An arrangement of variable resistor (potentiometer) and a voltage source is used instead of direction indicator switch. This arrangement gives analog voltage in the range of 0 to 5V. The analog voltage value from the potentiometer is given to the ADC module through PORT E, pin 0. The ADC is configured for single channel continuous conversion. After conversion, the result is stored in ADC result register 1 (ADR1). The value stored is compared with a range of values and the corresponding direction is indicated in the LCD. HD44780U is an LCD controller, which converts ASCII codes to corresponding segment display information.
The source code written in C language and can be viewed from the
code editor window. It can be compiled after making any modifications (editing) and also debugged during simulation.
The program is as shown:
#include "Test_PORTS.h"
char config[] __attribute__((section(".config")))=
{
NOSEC | NOCOP | ROMON | EEON
};
#define DELAY 10 // DELAY = 10
#define CONT_S 0x20 // CONTINUOUS CONVERSION WITH SINGLE CHANNEL
#define E 0x80 // USE EXTERNAL E CLOCK
#define CH0 0x00 // SELECT CHANNEL 0
void initADC(uint8 m, uint8 clk, uint8 ch)
{
OPTION |= clk;
ADCTL = m|ch;
}
void Delay(uint8);
void Command(uint8);
void Display(uint8);
int Busy(void);
int main()
{
lock();
DDRC = 0XFF;
Command (0x30); // FUNCTION SET: 8-BIT, 1 LINE, 5x7 DOTSle(1)
Command (0x0f); // DISPLAY ON CURSOR BLINKING
while(1)
{
initADC (CONT_S, E, CH0);
if(ADR1>134)
{
Command (0x01);
Display ('L');
Display ('E');
Display ('F');
Display ('T');
}
else if(ADR1<120)
{
Command (0x01);
Display ('R');
Display ('I');
Display ('G');
Display ('H');
Display ('T');
}
else
{
Command (0x01);
Display ('O');
Display ('F');
Display ('F');
}
}
unlock();
return(0);
}
//Delay
void Delay(uint8 Time)
{
while (Time--);
}
void Command(uint8 Instrn)
{
uint8 busy;
L1:
busy = Busy();
if(busy == 0)
{
PORTC = Instrn;
PORTA = 0X20;
Delay (DELAY);
PORTA = 0X00;
}
else
goto L1;
}
void Display (uint8 Data)
{
uint8 busy;
L2:
busy = Busy();
if(busy == 0)
{
PORTC = Data;
PORTA = 0X30;
Delay (DELAY);
PORTA = 0X10;
}
else
goto L2;
}
//Checking Busy Flag
int Busy (void)
{
uint8 iTemp;
PORTC = 0X80;
PORTA = 0X28;
Delay (DELAY);
PORTA = 0X08;
DDRC = 0X00;
iTemp = PORTC;
iTemp = iTemp & 0x80;
DDRC = 0XFF;
return (iTemp);
}
The source code in the
code editor window
has to be
compiled
after making any modifications
(editing).
Also the code can be
debugged
during
simulation.