Mini Project
Mini Project
Mini Project
3.1 Preparation................................................................................................................5
Result................................................................................................................................14
Reference..........................................................................................................................16
Page 1 of 17
1. LCD Blinking
- For this project, we'll use an LCD 1602 and the DE10 kit to blink the phrase
"Hello World!!!" once every second.
This task's flow chart is as follows:
Figure 1. Flow chart of the Problem No.1
The LCD Module
HD44780 LCD modules almost always have a 14-pin
microcontroller/microprocessor interface. Some displays may include more pins for
backlighting or other functions, but the first 14 pins are still used as the interface.
Page 2 of 17
The power for the LCD module is provided by the first three pins. Pin 1 is GND,
and it's connected to the Launchpad's GND. Pin 2 is VCC, and it is connected to the
Launchpad's +5V VBUS. The LCD Display Bias is connected to pin 3. To control the
voltage, a 10k potentiometer is connected to this pin. The contrast of the display can be
modified by altering the voltage or duty cycle of pin 3. With a voltage between 5V and
10V, most character LCDs can produce high display contrast.
Firgure 2. LCD module QAPASS
Page 3 of 17
Depending on how the plus and minus are connected, a DC motor can spin
backward or forward.
Switch 1,4 closed Switch 2,3 closed
In actuality, a
transistor with
adequate biasing can
function as a switch,
allowing it to toggle
between the two states of
an on/off switch. This transistor design has been used in an H-bridge to drive a motor
clockwise and anticlockwise.
We can regulate the speed of the motor by changing the time that we deliver
electricity to the motor in one cycle, thanks to the H-bridge design employing transistors.
For example, consider the following signal to the motor:
Page 4 of 17
If we provide a motor with a voltage source that is not constant but consists of
PWM pulses, the motor will spin at the same speed as it would with a constant voltage
source Vm if the frequency of the pulses is high enough.
Tm
With Vm = . Vcc ( Tm = duty cycle) = D.Vcc (D<=1)
T
We can easily modify the speed of the motor using the equation above by adjusting
the time that we deliver voltage to the motor (duty cycle).
Page 5 of 17
3.2 Platform design VHDL
Page 6 of 17
3.3 Working on Project
VHDL code
Page 7 of 17
Page 8 of 17
Page 9 of 17
Eclipse code
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/alt_alarm.h>
#include <altera_avalon_pio_regs.h>
#include <system.h>
#include <stdio.h>
#include <unistd.h>
Page 10 of 17
char d[3];
//extern alt_u32 T; //Period (us)
//extern alt_u32 D; //duty cycle (%)
//extern unsigned short sw;
char status_Switch;
void lcd_init()
{
lcd_cmd(0x38); //Send function set
Page 11 of 17
usleep(39); //Wait 39 us
else
{lcd_cmd(0x01);}
return alt_ticks_per_second();
}
Page 12 of 17
alt_u32 L298CB(void* context)
{
//Duty cycle range is 18% - 98%
if(D > 98) D = 98;
else if(D < 18) D = 18;
//Run motor when switch 1 is on
if(status_Switch != 0x02 && status_Switch != 0x04 && status_Switch !=
0x08 && status_Switch != 0x10 && status_Switch != 0x20 && status_Switch !=
0x40 && status_Switch != 0x80 && status_Switch != 0x100) return
alt_ticks_per_second()*0.001;
int main()
{
static alt_alarm alarm_H_bridge, alarm_LCD;
alt_alarm_start(&alarm_H_bridge,
alt_ticks_per_second()*0.001,L298CB,NULL);
lcd_init();
alt_alarm_start(&alarm_LCD, alt_ticks_per_second(),LCDCB,NULL);
while(1)
{
status_Switch = READ(SWITCH_BASE);
if(status_Switch == 0x01)
{
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,1);
}
else if(status_Switch == 0x02)
{
D = 20;
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,2);
}
else if(status_Switch == 0x04)
{
D = 40;
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,4);
}
else if(status_Switch == 0x08)
{
D = 60;
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,8);
}
Page 13 of 17
else if(status_Switch == 0x10)
{
D = 80;
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,16);
}
else if(status_Switch == 0x20)
{
D = 90;
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,32);
}
else if(status_Switch == 0x40)
{
D = 100;
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,64);
}
else
IOWR_ALTERA_AVALON_PIO_DATA(LEDR_BASE,0x00);
}
return 0;
}
Result
Page 14 of 17
Reference
- Interfacing LCD display
- LCD datasheet
- L268 H bridge
Page 15 of 17
Page 16 of 17