Miscellaneous › Others › please anybody send the program for pic to send sms stored in array “sms” from gsm
- This topic has 0 replies, 1 voice, and was last updated 9 years, 5 months ago by Gagan.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
April 19, 2015 at 5:59 pm #3631GaganParticipant/* Main.c file generated by New Project wizard** Created: Wed Feb 11 2015* Processor: PIC18F458* Compiler: HI-TECH C for PIC18*/#include <htc.h>#include <stdio.h>#define ldata PORTD#define rs PORTBbits.RB0#define rw PORTBbits.RB1#define en PORTBbits.RB2void init_adc();long adc_result();long double convert_volts(double adc_result);void lcdcmd(unsigned char value);void initLCD();void lcddata(unsigned char value);//void lcdputfloat(float I);//void lcdputfloat1(float I);void lcdputfloat2(float I);void lcdputint(unsigned int x);//void MSDelay(unsigned int itime);void lcdstr(unsigned char *str);void delay();long double i_read();long double v_read();const char mycom[]={0x0E,0x01,0x06,0x80};unsigned char digit[6]={0};void delay1(unsigned int count);float Temper();float RAD();void main(void){TRISD=0;TRISB=0;en=0;int r,r1;float i=0,v,t,rad,op,ip,eff;unsigned char sms[20];TRISAbits.RA0 = 1;TRISAbits.RA1 = 1;lcdcmd(0x38);delay(1);initLCD();lcdstr(" WELCOME TO ");lcdcmd(0xc0);lcdstr("SPV DATA LOGGER");delay1(300);lcdcmd(0x01);while(1){i=i_read();lcdcmd(0x80);lcdstr("Current=");lcdputfloat2(i);lcddata('A');v=v_read();lcdcmd(0xc0);lcdstr("Voltage=");lcdputfloat2(v);lcddata('V');delay1(200);lcdcmd(0x01);lcdstr(" Temperature ");lcdcmd(0xc0);lcdstr(" =");t=Temper();lcdputfloat2(t);lcdstr("'C");delay1(200);lcdcmd(0x01);lcdcmd(0x80);lcdstr(" Radiation ");lcdcmd(0xc0);lcdstr(" =");rad=RAD();//lcdputfloat2(rad);r1=(rad*100)+1;//lcdputint(r1);if((r1<=336)){r=0;lcdputint(r);}if((r1>336) && (r1<=338)){r=80;lcdputint(r);}if((r1>338) && (r1<=340)){r=100;lcdputint(r);}if((r1>340) && (r1<=342)){r=110;lcdputint(r);}if((r1>342) && (r1<=346)){r=120;lcdputint(r);}if((r1>346) && (r1<=348)){r=125;lcdputint(r);}if((r1>350) && (r1<=352)){r=137;lcdputint(r);}if((r1>352) && (r1<=354)){r=140;lcdputint(r);}if((r1>356) && (r1<=358)){r=150;lcdputint(r);}if((r1>360) && (r1<=362)){r=160;lcdputint(r);}if((r1>362) && (r1<=364)){r=170;lcdputint(r);}if((r1>364) && (r1<=366)){r=175;lcdputint(r);}if((r1>366) && (r1<=368)){r=180;lcdputint(r);}if((r1>370) && (r1<=372)){r=197;lcdputint(r);}if((r1>372) && (r1<=374)){r=203;lcdputint(r);}if((r1>374) && (r1<=376)){r=210;lcdputint(r);}if((r1>376) && (r1<=378)){r=225;lcdputint(r);}if((r1>378) && (r1<=380)){r=230;lcdputint(r);}if((r1>380) && (r1<=382)){r=251;lcdputint(r);}if((r1>382) && (r1<=384)){r=261;lcdputint(r);}if((r1>384) && (r1<=386)){r=271;lcdputint(r);}if((r1>386) && (r1<=388)){r=291;lcdputint(r);}if((r1>=390) && (r1<=392)){r=300;lcdputint(r);}if((r1>392) && (r1<=394)){r=325;lcdputint(r);}if((r1>394) && (r1<=396)){r=348;lcdputint(r);}if((r1>396) && (r1<=398)){r=356;lcdputint(r);}if((r1>398) && (r1<=400)){r=374;lcdputint(r);}if((r1>400) && (r1<=402)){r=400;lcdputint(r);}if((r1>402) && (r1<=404)){r=408;lcdputint(r);}if((r1>404) && (r1<=406)){r=416;lcdputint(r);}if((r1>406) && (r1<=408)){r=464;lcdputint(r);}if((r1>408) && (r1<=410)){r=500;lcdputint(r);}if((r1>410) && (r1<=412)){r=533;lcdputint(r);}if((r1>412) && (r1<=414)){r=575;lcdputint(r);}if((r1>414) && (r1<=416)){r=593;lcdputint(r);}if((r1>416) && (r1<=418)){r=635;lcdputint(r);}if((r1>418) && (r1<=420)){r=650;lcdputint(r);}if((r1>420) && (r1<=422)){r=680;lcdputint(r);}if((r1>422) && (r1<=424)){r=700;lcdputint(r);}if((r1>424) && (r1<=426)){r=732;lcdputint(r);}if((r1>426) && (r1<=428)){r=763;lcdputint(r);}if((r1>428) && (r1<=430)){r=778;lcdputint(r);}if((r1>430) && (r1<=432)){r=850;lcdputint(r);}if((r1>432) && (r1<=434)){r=863;lcdputint(r);}if((r1>434) && (r1<=436)){r=900;lcdputint(r);}if((r1>436) && (r1<=438)){r=945;lcdputint(r);}if((r1>438) && (r1<=440)){r=960;lcdputint(r);}if((r1>440) && (r1<=460)){r=985;lcdputint(r);}if((r1>460) && (r1<=480)){r=1000;lcdputint(r);}lcdstr(" W/m^2");delay1(200);ip=(float)(r*0.05);op=(float)(v*i);eff=((float)(op/ip)*100);lcdcmd(0x01);lcdcmd(0x80);lcdstr(" Efficiency ");lcdcmd(0xc0);lcdstr(" = ");lcdputint(eff);lcdstr(" % ");delay1(200);sprintf (sms,"v=%.2f,i=%.2f,t=%.1f,r=%f",v,i,t,r); //may cause error if so use *smslcdcmd(0x01);lcdcmd(0x80);lcdstr(sms);delay1(400);}// while (1)// ;}//main endlong adc_result(){long i;ADCON0bits.GO = 1;while(ADCON0bits.DONE == 1);i =0;i|=ADRESH;i=i<<8;i |= ADRESL;return i;}long double convert_volts(long double adc_result){long double float_val;float_val = (adc_result * (5.00/1024.00));return float_val;}void lcdcmd(unsigned char value){ldata=value;rs=0;rw=0;en=1;delay();en=0;}void initLCD(){int z=0;for(;z<4;z++){lcdcmd(mycom[z]);delay(3);}}void lcddata(unsigned char value){ldata=value;rs=1;rw=0;en=1;delay(1);en=0;}/*void lcdputfloat2(long double I){long double x=0;x=I*10000;digit[5]=(unsigned char)(x/100000);digit[4]=(unsigned char)(x/10000)-digit[5]*10;digit[3]=(unsigned char)(x/1000)-digit[5]*100-digit[4]*10;digit[2]=(unsigned char)(x/100)-digit[5]*1000-digit[4]*100-digit[3]*10;digit[1]=(unsigned char)(x/10)-digit[5]*10000-digit[4]*1000-digit[3]*100-digit[2]*10;digit[0]=x-digit[5]*100000-digit[4]*10000-digit[3]*1000-digit[2]*100-digit[1]*10;lcddata(digit[5]+0x30);lcddata(digit[4]+0x30);lcddata('.');lcddata(digit[3]+0x30);lcddata(digit[2]+0x30);lcddata(digit[1]+0x30);lcddata(digit[0]+0x30);}*/void lcdputfloat2(float I){int x=0;x=I*100;//digit[4](x%10)+0x30);//x=x/10;digit[3](x%10)+0x30);x=x/10;digit[2](x%10)+0x30);x=x/10;digit[1](x%10)+0x30);x=x/10;digit[0](x%10)+0x30);x=x/10;lcddata(digit[0]);lcddata(digit[1]);lcddata('.');lcddata(digit[2]);lcddata(digit[3]);//lcddata(digit[4]);}void lcdputint(unsigned int x){//digit[4](x%10)+0x30);//x=x/10;digit[3](x%10)+0x30);x=x/10;digit[2](x%10)+0x30);x=x/10;digit[1](x%10)+0x30);x=x/10;digit[0](x%10)+0x30);x=x/10;lcddata(digit[0]);lcddata(digit[1]);lcddata(digit[2]);lcddata(digit[3]);//lcddata(digit[4]);}void lcdstr(unsigned char *str){while(*str){lcddata(*str++);//*str++;}}void delay(){T0CON=0x80;TMR0H=0xF6;TMR0L=0x3C;T0CONbits.TMR0ON=1;while(INTCONbits.TMR0IF==0);T0CONbits.TMR0ON=0;INTCONbits.TMR0IF=0;}long double i_read(){long double x=0,y;long double i,v_sense,I=0.00,n=0.00;ADCON0 = 0b01000001; //CHAN0(AN0) SelectADCON1 = 0b11000100;i = adc_result();v_sense = convert_volts(i);/*if(v_sense<=2.50){I=0.000000;return(I);}*/I=(v_sense-2.50)/0.1;x=v_sense*100;n=x-250;if(n<22.00){I=I+(n/100);}else if((n>=22.00) && (n<43.00)){n=n-21.00;I=I+(n/100);}else if((n>=43.00) && (n<64.00)){n=n-42.00;I=I+(n/100);}else if((n>=64.00) && (n<85.00)){n=n-63.00;I=I+(n/100);}else if((n>=85.00) && (n<106.00)){n=n-84.00;I=I+(n/100);}else if((n>=106.00) && (n<127.00)){n=n-105;I=I+(n/100);}return(I);}long double v_read(){long double j=0;long double vtg=0.00;ADCON0 = 0b01001001; //CHAN1(AN1) SelectADCON1 = 0b11000100;j=adc_result();vtg=convert_volts(j);vtg=vtg*11.03;return(vtg);}float RAD(){float temper, j;ADCON0 = 0b01011001; //CHAN1(AN1) SelectADCON1 = 0b11001001;j=adc_result();temper=convert_volts(j);//temper=temper*100;return(temper);}float Temper(){float temper, j;ADCON0 = 0b01010001; //CHAN1(AN1) SelectADCON1 = 0b11001001;j=adc_result();temper=convert_volts(j);temper=temper/0.01;return(temper);}void delay1(unsigned int count) // Function to provide time delay in msec.{int i,j;for(i=0;i<count;i++)for(j=0;j<1275;j++);}
-
AuthorPosts
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.