Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

need help in programming for my project

Status
Not open for further replies.

jakshay

New Member
hello..
I am working a car parking monitor system...plz find the attachment with complete details....
i have made few changes..i am not using TSOP RECEIVER in my circuit..i am using simple ir led receiver..

i am making six slots interfacing to micro controller 89s52.
the input pins are 2.0 to 2.6 and output pins are port connected to LCD (jhd 162a 16*2)

i want a program logic for the following

case1:when all parking slots are empty
LCD should display " vacant slots:b1,b2,b3,b4,b5,b6

case2: now a car gets parked in slot b1 (for example)
LCD output should be
empty slots :b2,b3,b4, b5,b6 (exclude b1)

case 3: say the parking slot b1 gets vacant again
b1 should again come in the list..

output on LCD , of empty slots=b1,b2,b3,b4,b5,b6

thanks in advance
 

Attachments

  • Car Parking Monitoring System.doc
    49 KB · Views: 210

jakshay

New Member
car parking monitoring system

hi...rushikesh
the schematic is on the same lines as shown in the attachment.

however the microcontroller for interfacing the lcd is as follows

#include <reg52.h>
#include <lcd.h>
#include<math.h>
#include<stdio.h>
sbit rs=0xa0; /*P2.0 LCD RS pin #21*/
sbit rw=0xa1; /*P2.1 LCD R/W pin #22*/
sbit en=0xa4; /*P2.4 LCD E pin #25*/
sfr lcdbus=0x80; /*p0 LCD data bus D0=P0.0*/
unsigned int sys10mscounter;
unsigned char syslimitcounter;

// Self define font
char path1[8]={0x00,0x1f,0x00,0x1f,0x00,0x1f,0x00,0x1f}; // Horizontal 1
char path2[8]={0x1f,0x00,0x1f,0x00,0x1f,0x00,0x1f,0x00}; // Horizontal 2
char pats1[8]={0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15}; // Vertical 1
char pats2[8]={0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a}; // Vertical 2

void soft_nop(){}

void soft_10ms() // 12MHZ 10MS software delay
{ register int i;
for(i=0;i<711;i++);
}

void soft_20ms() // 12MHZ 20MS software delay
{ soft_10ms();
soft_10ms();
}

void hard_10ms(unsigned int delaytime) // delaytime*10MS hardware delay
{ sys10mscounter=delaytime;
while(sys10mscounter);
}

unsigned char data lcdcounter;
bit lcdusing1,lcdusing2;

bit lcd_checkbusy() // is LCD busy?
{register lcdstate;
rs=0; // dc=1 -> data, =0 -> command
rw=1; // rw=1 -> read, =0 -> write
en=1; // cs=1 -> selected
soft_nop();
lcdstate=lcdbus;
en=0;
return((bit)(lcdstate&0x80));
}

void lcd_wrcmd(unsigned char lcdcmd) // write a character to LCD
{ lcdusing1=1;
while(lcd_checkbusy());
lcdbus=lcdcmd;
rs=0; // dc=1 -> data, =0 -> command
rw=0; // rw=1 -> read, =0 -> write
en=1; // cs=1 -> selected
soft_nop();
en=0;
lcdbus=0xff;
lcdusing1=0;
}

void lcd_moveto(char position) // move cursor to position 0-79
{register cmd=0x80;
lcdcounter=position;
if (position > 59)
position += 0x18;
else
{ if (position > 39) position -= 0x14;
else
{ if (position > 19) position += 0x2c;
}
}
cmd = cmd | position;
lcd_wrcmd(cmd);
}

void lcd_wrdata(char lcddata) // at surrent cursor write a character
{unsigned char i;
lcdusing2=1;
while(lcd_checkbusy());
if (lcdcounter==20){
lcd_moveto(20);
while(lcd_checkbusy());
}
if (lcdcounter==40){
lcd_moveto(40);
while(lcd_checkbusy());
}
if (lcdcounter==60){
lcd_moveto(60);
while(lcd_checkbusy());
}
if (lcdcounter==80){
lcd_moveto(0);
while(lcd_checkbusy());
lcdcounter=0;
}
lcdcounter++;
lcdbus=lcddata;
rs=1; // dc=1 -> data, =0 -> command
rw=0; // rw=1 -> read, =0 -> write
en=1; // cs=1 -> selected
soft_nop();
en=0;
lcdbus=0xff;
lcdusing2=0;
}

void lcd_string(char *strpoint) // at current cursor write a string
{register i=0;
while(strpoint!=0){
lcd_wrdata(strpoint);
i++;}
}

void lcd_init() //initialize LCD
{
lcd_wrcmd(0x38); //8 bit data bus
lcd_wrcmd(0x0c); //block cursor,non blink
lcd_wrcmd(0x06); //don't move after display
lcd_wrcmd(0x01); //Clear display
lcdcounter=0;
}

void lcd_cls() // clear LCD
{
lcd_wrcmd(0x01);
lcdcounter=0;
}

void timer0(void) interrupt 1 // T0 interrupt service routine
{
TH0=0xd8; /*12M,10ms*/
TL0=0xf6;
TR0=1;
if(sys10mscounter !=0)sys10mscounter--; // 10ms timer
if(syslimitcounter!=0)syslimitcounter--; // 10ms timer
}

main()
{unsigned char j;

IE=0;P0=0xff;P1=0xff;P2=0xff;P3=0xff; // Initialize
lcd_init(); soft_20ms();
TMOD=0x51;
TH0=0xd8; /*12M,10ms*/
TL0=0xf6;
TR0=1;ET0=1;EA=1;
while(1)
{
// Display :
// All black; horizontal 1; horizontal 2; vertical 1; vertical 2
// UUUUUU...., QQQQQQQ.... ABCD...
lcd_init(); // all black
for(j=0;j<80;j++){lcd_wrdata(0xff);}
hard_10ms(50);

lcd_init(); // Horizontal 1 -> check font definition
lcd_wrcmd(0x40);
for(j=0;j<8;j++)lcd_wrdata(path1[j]);
for(j=0;j<100;j++)lcd_wrdata(0);
hard_10ms(50);

lcd_init(); // Horizontal 2
lcd_wrcmd(0x40);
for(j=0;j<8;j++)lcd_wrdata(path2[j]);
for(j=0;j<100;j++)lcd_wrdata(0);
hard_10ms(50);

lcd_init(); // Vertical 1
lcd_wrcmd(0x40);
for(j=0;j<8;j++)lcd_wrdata(pats1[j]);
for(j=0;j<100;j++)lcd_wrdata(0);
hard_10ms(50);

lcd_init(); // Vertical 2
lcd_wrcmd(0x40);
for(j=0;j<8;j++)lcd_wrdata(pats2[j]);
for(j=0;j<100;j++)lcd_wrdata(0);
hard_10ms(50);

lcd_init();
lcd_string("WELCOME WELCOME WELCOME
WEL

COMEWELCOMEWELCOMEWELCOMEWELCOME ");
hard_10ms(50);

lcd_init();
lcd_string("QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ");
hard_10ms(50);

lcd_init();
lcd_string("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789+-!#$%&?");
hard_10ms(50);
}
}
 

jakshay

New Member
car parking monitoring system

this is the code for interfacing the slots with the controller

#include<reg51.h>
#include<stdio.h>

#define LCD P0
sbit EN=P0^3;
sbit RW=P0^2;
sbit RS=P0^1;

void lcdcmd(unsigned char);
void displaycharlcd(unsigned char);
void delay(void);
void dispstr(char*);

void main()
{
lcdcmd(0x28);
lcdcmd(0x01);
lcdcmd(0x0e);
lcdcmd(0x06);
lcdcmd(0x80);
if((P1^0 || P1^1 || P1^2 || P1^3 || P1^4 || P1^5) ==1) //chose these port bits which r free in ur controller
dispstr("RECIEVER ON");
else
{
}
while(1);
}

void lcdcmd(unsigned char cmd)
{
LCD=(cmd & 0xf0);
RS=0;
EN=1;
delay();
EN=0;
LCD=(cmd<<4);
RS=0;
EN=1;
delay();
EN=0;
delay();
}

void displaycharlcd(unsigned char var)
{
LCD=(var & 0xf0);
RS=1;
EN=1;
delay();
EN=0;
LCD=(var<<4);
RS=1;
EN=1;
delay();
EN=0;
delay();
}

void dispstr(char *p)
{
while(*p)
displaycharlcd(*p);
}

void delay(void)
{
unsigned int i;
for(i=0;i<100;i++)
{
}
}
 
Status
Not open for further replies.

Latest threads

Top