Saturday, 19 December 2015

WEEK 14 - Thursday



ANALYSIS AND DISCUSSION

            Based on the mini project development it can be analysed the problem that occurs during the project progress. The main problem on this project is the hardware doesn’t working and fuction as well as in simulation. During the hardware development, the microcontroller seems not operating and the LCD light on but only display the blank screen with no word on the screen. So, to prevent this problem occur again in the future the troubleshooting based on the coding is checked. There is no error was found. The circuit is constructed with very basic component to make sure all components are test and worked. The circuit is including four push button as input, IC8051 with basic component, and LCD which based in proteus simulation. So the connection on the hardware is checked to make sure the circuit is connected. The result of the trouble shooting is there is no problem on the connection circuit. Then LCD is checked because of the sensitivity of it. However the LCD only light on with no word on it again. So to short the time taken on the circuit, the IC 8951 is change to silicon lab toolstick850 in the hope the changing of the microcontroller can function the circuit. As for the silicon lab toolstick850 the other problem occur is adjustment of port used due to the port for IC 8051 in proteus is not the same with silicon lab toolstick850. The same problem occur again when silicon lab toolstick850 is connect to the circuit, the LCD didn’t display well. All the project progress, video, picture and final result was publish on our blog addressed at, http://digitalspeedometer.blogspot.com.



CONCLUSION


To be conclude, the objective of the mini project has not been achieved with the failure on the hardware development. However, this project provide a meaning lesson and experience on the programming project. This mini project encouraged students to do a lot of research about the C language on how to program a simple project. Moreover, student also can developed the skill to make hardware as an application of microcontroller system. So, students must be well prepared in terms of programming knowledge and hands on for the hardware. The project must be simulated first before hardware is work on. This is important because to troubleshoot in simulation is quite easy as being compared with trouble shooting on the hardware. Only when the simulation is completed and done, then the hardware can be continued progress to develop. This project give students lot of knowledge not just on how to coding a program but are also exposed with the electronics devices and components such as LCD, resistors, capacitors, microcontroller and etc. As the microcontroller silicon lab toolstick850 is quite more challenging than IC 8951. Lastly, this project really helpful for the students and can be applied for the future career.

Friday, 18 December 2015

WEEK 14 - Thursday


Well after the trouble shooting on the circuit, LCD didn't display the word. connection on the circuit is seem to be correct but there is still error on the LCD display even though we change the LCD.


Circuit with IC 8951:





Circuit with microcontroller toolstick 850:






WEEK 13 - Friday


Circuit for Toolstick 850

There is a change of port when the toolstick 850 is used. Toolstick 850 only consists a port P0, P1 and P2. Because of the pin is limited there a few changes on coding and circuit as well. for the toolstick 850 circuit we used 4 bit rather than 8 bit cause by the limitation on the pin port of the toolstick. We also change from 4 switch button to 2 switch button that already have in toolstick 850.


Circuit:


Coding:

//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <reg51.h>
#include <stdio.h>

#define lcd_clear 0x01
#define return_home 0x02
#define dec_cursor 0x04
#define inc_cursor 0x06
#define display_shift_left 0x05
#define display_shift_right 0x07
#define disp_off_cursor_off 0xE0
#define disp_on_cursor_off 0x0C
#define disp_on_cursor_blink 0x0F
#define shift_left_cursor 0x10
#define shift_right_cursor 0x1C
#define first_line 0x80
#define second_line 0xC0
#define lcd_2line 0x38
#define lcd_4bit 0x28
#define lcd_goto1 lcd_command(first_line)
#define lcd_goto2 lcd_command(second_line)
#define lcd_clr lcd_command(lcd_clear)
#define LCD_port P0

sbit RS = P0^1;
sbit EN = P0^2;
sbit SW1 = P1^7;
sbit SW2 = P2^1;

//const unsigned char set_lcd_4bit[7]={0x20, 0x20, 0x80, 0x00, 0xe0, 0x00, 0x60};

// ------ Private variable definitions ------------------------
signed char buf[20];


void delay_display(unsigned int gap)
{
unsigned int i, j;
for(i=0; i<gap; i++)
 for(j=0; j<200; j++);
}

//**********delay function**********//

void delay_cycle(unsigned int interval)
{
        unsigned int i, j;
        for(i=0; i<interval; i++)
        {
                for(j=0; j<20; j++);
        }
}

//**********LCD Program**********//

void send_nibble(unsigned char value)
{
LCD_port=(LCD_port&0x0F)|(value&0x0F0);
EN=1;
delay_cycle(7);
EN=0;
LCD_port=(LCD_port&0x0F)|((value<<4)&0x0F0);
EN=1;
delay_cycle(7);
EN=0;
}

void lcd_command(unsigned char value)
{
RS=0;
delay_cycle(1);
send_nibble(value);
return;
}

void lcd_data(unsigned char value)
{
RS=1;
delay_cycle(1);
send_nibble(value);
return;
}

void lcd_init(void)
{
LCD_port =0x0F0;
lcd_command(0x33);
lcd_command(0x32);
lcd_command(lcd_4bit); // 4 bit mode
lcd_command(shift_left_cursor); // shift cursor left
lcd_command(inc_cursor); // increment cursor
lcd_command(disp_on_cursor_off); // display on cursor off
lcd_command(lcd_clear); // clear LCD
delay_cycle(20);
}

void lcd_putc(unsigned char c)
{
if(c=='\f')
        lcd_command(0x01);
else if(c=='\n')
        lcd_command(0xC0);
else
        lcd_data(c);
}

void lcd_puts(unsigned char *txt)
{
unsigned char limit=0;
while(*txt)
lcd_putc(*txt++);
}

void lcd_goto(unsigned char line, unsigned char column)
{
if(line==1){lcd_command(first_line+column);}
if(line==2){lcd_command(second_line+column);}
}

//-----------------------------------------------------------------------------
// main() Routine
// ----------------------------------------------------------------------------
void main(void)
{
        unsigned int x=0,n=0, y=0;


        lcd_init();

        lcd_goto1;
        lcd_puts("  HAFIZ  ");

        delay_display(250);

        lcd_goto2;
        lcd_puts("  SYAFIQ   ");


        delay_display(500);
        lcd_command(0x01);

        lcd_goto1;
        lcd_puts("    DIGITAL   ");

        delay_display(250);

        lcd_goto2;
        lcd_puts("   SPEEDOMETER");

        delay_display(300);
        lcd_command(0x01);


        while(1)
        {
                lcd_goto1;
                lcd_puts("  KM/H = ");
                sprintf(buf,"%d",y);
                lcd_puts(buf);


                if (SW1==0)
                {
                        n++;
                        delay_display(100);

                        if(n<=1)                        
                        {y=20;}        

                        else if(n<=2)                        
                        {y=40;}
                        
                        else if(n<=3)
                        {y=60;}

                        else if(n<=4)
                        {y=80;}

                        else if(n<=5)
                        {y=100;}

                        else if(n<=6)
                        {y=120;}

                        else if(n<=7)
                        {y=140;}
}
    
if (SW2==0)
                {
                        n++;
                        delay_display(100);

                        if(n<=8)
                        {y=140;}
         
                        else if(n<=9)                  
                        {y=120;}
      
                        else if(n<=10)
                        {y=100;}

                        if(n<=11)
                        {y=80;}

                        else if(n<=12)
                        {y=60;}

                        else if(n<=13)
                        {y=40;}

                        else if(n<=14)
                        {y=20;}

                        else if(n<=15)
                        {y=0;}
                }
        }


}



Thursday, 17 December 2015

WEEK 13 - Wednesday



For this mini project, we used 2 different microcontroller which are IC 8951 and TOOLSTICK 850-B-SK. All the coding for these two types of microcontroller are the same. After all the objective for using two microcontroller is as back up if anything happen at the IC during the project is conducted. Also these IC's have different way to burn the coding as the IC 8951 need a burner to copy the program coding while TOOLSTICK 850-B-SK have already USB port on it.



  • Circuit with IC 8951


  • Circuit with TOOLSTICK 850-B-SK



Wednesday, 16 December 2015

WEEK 12 - Wedneeday


This week, we are trying to solder the circuit to breadboard. The type of breadboard that we use is donut breadboard.







this is the link for the soldering video:

https://youtu.be/y91K7H9sI1k
https://youtu.be/KFYlOWm8HXg

Tuesday, 15 December 2015

WEEK 12 - Monday


The simulation for the digital simulation has been successful. The LCD display all the coding of the 5 different push button. For push button 1 it will display our name, push button 2 will display 'ENGINE START 0 KM/H', push button 3 will display 'SLOW SPEED 40 KM/H', push button 4 will display 'NORMAL SPEED 80 KM/H' and lastly push button 5 will display 'HIGHWAY TOP SPEED 110 KM/H'.

Simulation of Digital Speedometer

WEEK 11 - Sunday


For the coding it take a lot of time and even us have to change the circuit from using the sensor to push buttons. By using the push buttons we manage to construct the coding successfully. We set the coding of 4 push buttons differently as the output display from LCD will show with low speed to high speed.


Coding:

// DIGITAL SPEEDOMETER
// MR HAFIZZULLAH AND MR SYAFIQ
// MICRO C MINI PROJECT

#include <reg51.h>

sfr LCD_port = 0xA0; //port 2
sbit RS = P3^0;
sbit RW = P3^1;
sbit EN = P3^2;
sbit SW1 = P1^0; //push button 1
sbit SW2 = P1^1; //push button 2
sbit SW3 = P1^2; //push button 3
sbit SW4 = P1^3; //push button 4
sbit SW5 = P1^4; //push button 5

void delay_ms (int ms)
{
int i, j;
for (i=0; i<ms; i++)
for (j=0; j<100; j++);
}

void lcd_command(unsigned char value)
{
LCD_port = value;
RS = 0;
RW = 0;
EN = 1;
delay_ms(1);
EN = 0;
}

void lcd_init(void)
{
LCD_port = 0;

delay_ms(15);
lcd_command(0x30);
delay_ms(5);
lcd_command(0x30);
delay_ms(1);
lcd_command(0x30);
delay_ms(1);
lcd_command(0x30); //set to 8-bit mode operation
delay_ms(15);
lcd_command(0x30);
delay_ms(5);
lcd_command(0x30);
delay_ms(1);
lcd_command(0x30);
delay_ms(1);
lcd_command(0x30);

lcd_command(0x38); //function set: 8-bit mode, 2 lines, 5x7 font
lcd_command(0x10); //shift cursor position to left
lcd_command(0x06); //increment cursor (shift to right)
lcd_command(0x0C); //display ON, cursor OFF

lcd_command(0x01); //clear display
delay_ms(5);
}

void lcd_data(unsigned char value)
{
LCD_port = value;
RS = 1;
RW = 0;
EN = 1;
delay_ms(1);
EN = 0;
}

void lcd_position(unsigned char line, unsigned char column)
{
unsigned char position;

if (line == 1)
{
position = 0x80 + column;
lcd_command(position);
}
if (line == 2)
{
position = 0xC0 + column;
lcd_command(position);
}
}

void lcd_putchar(unsigned char c)
{
if (c == '\f')
lcd_command(0x01);
else if (c == '\n')
lcd_command(0xC0);
else
lcd_data(c);
}

void lcd_puts(unsigned char *txt)
{
while(*txt)
lcd_putchar(*txt++);
}

void main(void)
{

if (SW1 == 0 )
{
char text1[] = "HAFIZZULLAH";
char text2[] = "SYAFIQ";

lcd_init();

lcd_puts(text1);
lcd_position(2,5);
lcd_puts(text2);
}

if (SW2 == 0)
// while(1)
 {
char text3[] = "ENGINE START";
char text4[] = "0 KM/H";


lcd_init();

lcd_puts(text3);
lcd_position(2,3);
lcd_puts(text4);
}

else
if (SW3 == 0)
//while(1)
 {
char text5[] = "SLOW SPEED";
char text6[] = "40 KM/H";


lcd_init();

lcd_puts(text5);
lcd_position(2,3);
lcd_puts(text6);
}

else
if (SW4 == 0)
// while(1)
 {
char text7[] = "NORMAL SPEED";
char text8[] = "80 KM/H";


lcd_init();

lcd_puts(text7);
lcd_position(2,3);
lcd_puts(text8);
}
else
if (SW5 == 0)
// while(1)
 {
char text9[] = "HIHWAY TOP SPEED";
char text10[] = "110 KM/H";


lcd_init();

lcd_puts(text9);
lcd_position(2,3);
lcd_puts(text10);
}
}