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.

pic18f4550 with KS0108 GLCD /MPX4115 SENSOR READING PROBLEM

Status
Not open for further replies.

alsamadi

Newbie level 1
Joined
May 27, 2016
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
0
Activity points
29
Dear all,
I am having tough time to interface the reading of pressure sensor mpx4115.
I am new to the software and i could not display Pressure= something kPA
i have tried to do some calculation and the interface of the program
but nothing appeared in the Glcd


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Glcd module connections // glcd pinout settings
char GLCD_DataPort at PORTD;
 
sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS  at RB2_bit;
sbit GLCD_RW  at RB3_bit;
sbit GLCD_EN  at RB4_bit;
sbit GLCD_RST at RB5_bit;
 
sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction  at TRISB2_bit;
sbit GLCD_RW_Direction  at TRISB3_bit;
sbit GLCD_EN_Direction  at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections
 
 
void main()
{
 
unsigned int adcvalue;
unsigned int voltage;
unsigned char p;
char buffer;
 //////
 TRISD = 0;
 TRISB = 0;
 
 
 while(1)
 {
           adcvalue=Adc_Read(0);
           voltage = 5000.0f/1024*adcvalue;
            p=0.1111111f*voltage/5+10.555f;
            ByteToStr(p,buffer);
            Glcd_Write_Text(buffer, 10, 2, 1);
            Delay_ms(500);
 
 
 }
}

 
Last edited by a moderator:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Glcd module connections // glcd pinout settings
char GLCD_DataPort at PORTD;
 
sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS  at RB2_bit;
sbit GLCD_RW  at RB3_bit;
sbit GLCD_EN  at RB4_bit;
sbit GLCD_RST at RB5_bit;
 
sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction  at TRISB2_bit;
sbit GLCD_RW_Direction  at TRISB3_bit;
sbit GLCD_EN_Direction  at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections
 
 
void main()
{
unsigned char Buffer[4];
float pressure;
float pressure1;
unsigned int ADCResult=0;
 //////
 
 TRISD = 0;
 TRISB = 0;
  TRISA.RA0 = 1;
  ADC_Init();
  Glcd_Init();
 Glcd_Fill(0x00);
 
 
 while(1)
 {
 
               ADCResult = Adc_read(0);
               pressure1 = ((5.0/1023.0)*ADCResult);
               pressure = ((pressure1/5.0)+0.095)/0.009-1;
                Glcd_Write_Text("Pressure = ", 1, 0, 1);
 
                sprintf(buffer,"%.3g",pressure);
                Glcd_Write_text(buffer, 78, 0, 1);
                Glcd_Write_Text("Kpa", 100, 0, 1);
                Delay_ms(500);
 }
}







its not working too
 
Last edited by a moderator:

What do you mean by "not working"? You need to tell us a lot more detail.
Also show us the config bits as they can be important (especially as you have no code to set up the oscillator which can be important when initialising peripherals).
Have you stepped through the code?
Have you taken out the ADC code and just tried to display a simple text string?
Have you checked the connections to the display on a scope and are they are expected?
Susan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top