Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Moved] Vehicle Monitoring System with GPS and GSM - PIC18F46k22

Status
Not open for further replies.

blackpearl87

Newbie level 5
Newbie level 5
Joined
Jun 8, 2014
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
91
I'm doing a project using Picdem 2 Plus 2010 demo board to simulate a vehicle theft and accident alerting system. GPS receiver and GSM modem are being used to locate the vehicle and send a SMS to pre-determined mobile number. I'm using PIC18F46K22 micro-controller for this project.

the LCD on board is a 4-bit mode. DB4-DB7 pins of the LCD are connected to D0-D3 pins of pic controller. RS, RW, EN and PWR pins are respectively connected to D4-D7. I developed the below code, but I still can't get anything displayed on LCD.

Could anyone please highlight me what's wrong with this code?

Code:
#include <p18f46k22.h>
#include <delays.h>
 
#define LCD_DATA PORTD
#define LCD_RS PORTDbits.RD4
#define LCD_RW PORTDbits.RD5
#define LCD_EN PORTDbits.RD6
#define LCD_PWR PORTDbits.RD7
 
 
void Init_LCD(void);
void disCmd(unsigned char);
void disData(unsigned char);
void lcdCmd(unsigned char);
void lcdData(unsigned char);
void LCD_STROBE(void);
void string(char);
 
void main()
{
    ADCON1 = 0x0f;
    OSCCON = 0x36;
    TRISD = 0;
 
    Init_LCD();
 
    disCmd(0x80);
    string("HELLO WORLD");
    disCmd(0xc0);
    string("IT IS WORKING:-)");
 
}
 
 
//****************************************************************************************************
/* LCD display initialization */
void Init_LCD()                     
{
    disCmd(0x02);
    disCmd(0x82);
    disCmd(0x60);
    disCmd(0xc0);
    disCmd(0x80);
    disCmd(0x30);
    disCmd(0x10);
}
 
 
void LCD_STROBE(void)
{
    LCD_EN = 1;
    Delay1KTCYx(0.001);
    LCD_EN = 0;
}
 
 
void string(char q)
{
    while(q)
        disData(q++);
}
 
void disCmd(unsigned char cmdValue)
{
    unsigned char cmdValue1;
    cmdValue1 = PORTD;
    cmdValue1 &= 0xf0;
    cmdValue1 = cmdValue1 | (cmdValue & 0x0f);
    lcdCmd(cmdValue1);
}
 
 
void disData(unsigned char dataValue)
{
    unsigned char dataValue1;
    dataValue1 = PORTD;
    dataValue1 &= 0xf0;
    dataValue1 = dataValue1 | (dataValue & 0x0f);
    lcdData(dataValue1);
} 
 
 
void lcdCmd(unsigned char cmdOut)
{
    LCD_RS = 1;
    LCD_RW = 0;
    LCD_DATA = (cmdOut >> 4);
    LCD_STROBE();
    LCD_DATA = cmdOut;
    LCD_STROBE();
}
 
 
void lcdData(unsigned char dataOut)
{
    LCD_RS = 1;
    LCD_RW = 0;
    LCD_DATA = (dataOut >> 4);
    LCD_STROBE();
    LCD_DATA = dataOut;
    LCD_STROBE();
}
 

Re: Vehicle Monitoring System with GPS and GSM - PIC18F46k22

Hello,
please show me how the connections are on lcd.
I think you should ground the RW pin.
You mounted your circuit in a simulator (Proteus-ISIS)? If yes, show me a printscreen.
 

Re: Vehicle Monitoring System with GPS and GSM - PIC18F46k22

lcd_pin.jpg

Hi, I'm using Picdem 2 Plus 2010 board, and the above is the pin connections.
 

Re: Vehicle Monitoring System with GPS and GSM - PIC18F46k22

i think you have a problem in this function


Code C - [expand]
1
2
3
4
5
void string(char q)
{
    while(q)
        disData(q++);
}



try to use "Pointer" instedof a char...let it like this


Code C - [expand]
1
2
3
4
5
6
void string(char *q)
{
    while(*q != 0)                        // While the String didn't reach the NULL Keep Doing
        disData(*q++);                  // Display the Data that the pointer points to it's address then
                                                   increment the pointer
}




also it's written on the Datasheet of the Hitachi driver(Most conman driver for the LCDs) that the LCD in the 4bit Mode sends the High Nipple(4 most bits) 1st then the Lowest Nipple...then i think that's not what you wrote in this function which sends the reversed order nipples


Code C - [expand]
1
2
3
4
5
6
7
8
9
void lcdCmd(unsigned char cmdOut)
{
    LCD_RS = 1;
    LCD_RW = 0;
    LCD_DATA = (cmdOut >> 4);      // what you send here is cmdOut = 0000xxxx which i believe                   
    LCD_STROBE();                        // is Zeros
    LCD_DATA = cmdOut;
    LCD_STROBE();
}

 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top