Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/02/06 08:38
Read: times


 
#111035 - Detail about my aim.
Responding to: ???'s previous message
Dear all,

What I want to make is, a non-linear capacitive type humidity sensor is to be calibrated using the MC. I have a capacitive to voltage converter cct. (analog cct.). If we vary the capacitance in the input of the cct. it will give a o/p analog voltage according to the i/p variation. As the variation of the sensor with respect to humidity is highly non-linear (exponential type) so look table method , I thought , would be best. I have measured and made a chart of relative humidity Vs cap. to voltage converter cct. o/p voltage. I want to pass this analog voltage through ADC and then fed to P1of the MC. For testing purpose I want to show a 10%RH change in the LCD. For that started from the 28 HEX , because from my table,keeping the sensor at 0% RH the voltage I am getting from the C to Voltage converter cct. corresponds to 28 in HEX in 0-5 volt span. Likewise I have to follow the algo like- if P1 is in between 29 and 37 HEX –display 10.0 , if P1 is in between 38 and 48 HEX –display 20.0 and so on….

So , hope u can understand my aim. As this is my first project related to this field may be I am making the program clumsy . Your guidance is required.

With Thanks
Kaushik.





#include<stdio.h> 
#include<string.h> 
#include<regx52.h> 
#include<stdlib.h> 

static unsigned long overflowcount=0; 

void delay(void); 
void lcdcommand(unsigned char); 
void lcdinit(void); 
void lcdout(char * ); 
void timecount(void); 			//Function for counting time
void timer(void); 			// Function for setting timer mode


/***************************
Timer1 interrupt service routine
***************************/ 
void timer1_ISR() interrupt 3 
{ 

overflowcount++; 

} 

void timer() 
{ 
TMOD=(TMOD&0x0f)|0x20; 
TH1=0; 
TL1=TH1; 
ET1=1; 
TR1=1; 
EA=1; 

} 

void timecount() 
{ 

lv: 
if(overflowcount!=1800)   // nop for 0.5 sec
goto lv; 

} 


void main(void) 
{ 
unsigned char port; 

char s0[]="0.0"; 
char s10[]="10.0"; 
char s20[]="20.0"; 
char s30[]="30.0"; 
char s40[]="40.0"; 
char s50[]="50.0"; 
char s60[]="60.0"; 
char s70[]="70.0"; 
char s80[]="80.0"; 
char s90[]="90.0"; 
char s100[]="100.0"; 

char sp[9]="Error!"; 

timer(); 		//start the timer
lcdinit(); 

port=P1; 		// taking the data of P1 port(coming from ADC)

switch(port)   		// to show the desired value comparing the voltage level ADC is getting 
{ 

case (0X28): 
            lcdout(s0); 
             break; 
case (0X29): 
case (0X2A): 
case (0X2B): 
case (0X2C): 
case (0X2D): 
case (0X2E): 
case (0X2F): 
case (0X30): 
case (0X31): 
case (0X32): 
case (0X33): 
case (0X34): 
case (0X35): 
case (0X36): 
case (0X37): 
            lcdout(s10); 
            break; 

case (0X38): 
case (0X39): 
case (0X3A): 
case (0X3B): 
case (0X3C): 
case (0X3D): 
case (0X3E): 
case (0X3F): 
case (0X40): 
case (0X41): 
case (0X42): 
case (0X43): 
case (0X44): 
case (0X45): 
case (0X46): 
case (0X47): 
case (0X48): 
            lcdout(s20); 
            break; 
case (0X49): 
case (0X4A): 
case (0X4B): 
case (0X4C): 
case (0X4D): 
case (0X4E): 
case (0X4F): 
case (0X50): 
case (0X51): 
case (0X52): 
case (0X53): 
case (0X54): 
case (0X55): 
case (0X56): 
case (0X57): 
           lcdout(s30); 
            break; 
case (0X58): 
case (0X59): 
case (0X5A): 
case (0X5B): 
case (0X5C): 
case (0X5D): 
case (0X5E): 
case (0X5F): 
case (0X60): 
case (0X61): 
case (0X62): 
case (0X63): 
case (0X64): 
case (0X65): 
case (0X66): 
           lcdout(s40); 
           break; 
case (0X67): 
case (0X68): 
case (0X69): 
case (0X6A): 
case (0X6B): 
case (0X6C): 
case (0X6D): 
case (0X6E): 
case (0X6F): 
case (0X70): 
case (0X71): 
case (0X72): 
case (0X73): 
case (0X74): 
case (0X75): 
           lcdout(s50); 
            break; 
case (0X76): 
case (0X77): 
case (0X78): 
case (0X79): 
case (0X7A): 
case (0X7B): 
case (0X7C): 
case (0X7D): 
case (0X7E): 
case (0X7F): 
case (0X80): 
case (0X81): 
case (0X82): 
case (0X83): 
case (0X84): 
           lcdout(s60); 
             break; 
case (0X85): 
case (0X86): 
case (0X87): 
case (0X88): 
case (0X89): 
case (0X8A): 
case (0X8B): 
case (0X8C): 
case (0X8D): 
case (0X8E): 
case (0X8F): 
case (0X90): 
case (0X91): 
case (0X92): 
case (0X93): 
           lcdout(s70); 
           break; 
case (0X94): 
case (0X95): 
case (0X96): 
case (0X97): 
case (0X98): 
case (0X99): 
case (0X9A): 
case (0X9B): 
case (0X9C): 
case (0X9D): 
case (0X9E): 
case (0X9F): 
case (0XA0): 
case (0XA1): 
case (0XA2): 
           lcdout(s80); 
           break; 
case (0XA3): 
case (0XA4): 
case (0XA5): 
case (0XA6): 
case (0XA7): 
case (0XA8): 
case (0XA9): 
case (0XAA): 
case (0XAB): 
case (0XAC): 
case (0XAD): 
case (0XAE): 
case (0XAF): 
case (0XB0): 
case (0XB1): 
           lcdout(s90); 
              break; 
case (0XB2): 
case (0XB3): 
case (0XB4): 
case (0XB5): 
case (0XB6): 
case (0XB7): 
case (0XB8): 
case (0XB9): 
case (0XBA): 
case (0XBB): 
case (0XBC): 
case (0XBD): 
case (0XBE): 
case (0XBF): 
case (0XC0): 
case (0XC1): 
case (0XC2): 
case (0XC3): 
            lcdout(s100); 
            break; 
default : 
          lcdout(sp); 
           break; 
} 





} 

void lcdinit() 
{ 

lcdcommand(0x38); 
lcdcommand(0x10); 
lcdcommand(0x01); 
lcdcommand(0x06); 
lcdcommand(0x0C); 
lcdcommand(0x03); 


} 

void lcdcommand(unsigned char cmd) 
{ 
P3=0x10; 
P2=cmd; 
P3=0x00; 
delay(); 


} 

void lcdout(char *s ) 
{ 
int i; 
for(i=0; i<strlen(s); i++) 
{ 
P3=0x14; 
P2=s[i]; 
P3=0x04; 
delay(); 

} 
timecount(); 	     // to stop to perform any operation so that LCD does not change the already shown value for 0.5 sec
overflowcount=0; 

} 

void delay() 
{ 
int i; 
for(i=0;i<100;i++) 
; 

} 





List of 15 messages in thread
TopicAuthorDate
Regarding the LCD display problem            01/01/70 00:00      
   Code i used            01/01/70 00:00      
       overflowcount++;            01/01/70 00:00      
         Detail about my aim.            01/01/70 00:00      
      Main            01/01/70 00:00      
         Rep: Ian            01/01/70 00:00      
   Reset ?            01/01/70 00:00      
      MC working after the reset            01/01/70 00:00      
         So where's the problem?            01/01/70 00:00      
            Reply to Russell            01/01/70 00:00      
               Reset system            01/01/70 00:00      
                  Could be bad LCD Reset.            01/01/70 00:00      
                     LCD resets            01/01/70 00:00      
                     Rep: Prahlad Purohit            01/01/70 00:00      
                        Yes you need a supervisor.            01/01/70 00:00      

Back to Subject List