Sari la conținut
ELFORUM - Forumul electronistilor

Sim900 + Pic 16f877a sms controller


Postări Recomandate

Buna seara , am un proiect facut cu un modem gsm sim 900 si pic 16f877a . Am 3 gsm shield-uri din care doar unul functioneaza corespunzator , comunica cu placa si raspunde la toate comenzile, problema e cu celelate doua module care desi testate , nu functioneaza impreuna cu pic-ul

Modulele le-am testat in hyperterminal si raspunde la toate comenzile AT date ( de pc)

Poate ma lamureste cineva care ar putea fii problema cu cele 2 modemuri 

Folosesc 2 max-uri max232ecpe si pic16f877a si modemul din imaginea din link-ul de mai jos 

http://www.geeetech.com/wiki/index.php/Arduino_GPRS_Shield

http://i63.tinypic.com/5yvudt.jpg 

 

Link spre comentariu
  • Răspunsuri 13
  • Creat
  • Ultimul Răspuns

Top autori în acest subiect

Initial foloseam un telefon sony ericsson t290 si am trecut pe modemul gsm , asa a ramas montajul 

Nelamurirea mea e de ce un modem merge si 2 nu , am sa testez si varianta fara max-uri ....conectat direct la pinii rx / tx al pic-ului

Folosesc pinii D7 si D8 al modemului , software serial 

Editat de flo_tiesto
Link spre comentariu

softserial#serial si apar probleme inexplicabile de comunicare si daca adaugi o linie de cod care nu face nimic.

am patit asta si folosesc numai serialul hardware, fac debug pe un display de nokia conectat temporar, pana pun totul la punct.

 

nivelele pe rx,tx netranslatate corect.

Link spre comentariu
  • 2 luni mai târziu...
// PIC16F877a Sms cONtroller// Hi-Tech C //#define VAR_M_TEST//#define VAR_M_DS18#define VAR_M_1Wire#include <htc.h>#include <stdio.h>#include <string.h>#include <ctype.h>#include "stdlib.h"#include "myutils.h"#include "uart.h"#include "comenzi_at.h"#ifdef VAR_M_1Wire#include "GenericTypeDefs.h"#include "HardwareProfile.h"#include "1-Wire.h"#include "1-Wire_DS18B20.h"#endif#ifdef VAR_M_DS18#include "ds18x20lib.h"#endif__CONFIG(HS & WDTDIS & PWRTEN & BORDIS & LVPDIS & DUNPROT & WRTEN & DEBUGEN & UNPROTECT);#ifndef _XTAL_FREQ#define _XTAL_FREQ 10000000UL#endif//#define mobile_no_01    "0746973442"//0746105904bank1  char ReadBuffer[95]; ;volatile unsigned char wptr;volatile static unsigned char timeout = 0;volatile static unsigned char conditie = 0;volatile unsigned int i=0;unsigned int pozitie = 0;volatile static unsigned char flag3 = 0;volatile static unsigned char flag4 = 0;volatile static unsigned char flag5 = 0;volatile static unsigned char flag6 = 0;volatile static unsigned char flag7 = 0;volatile static unsigned char flag8 = 0;/* Global Variables */volatile unsigned int alarm_timer1;volatile unsigned int alarm_timer2;unsigned int alarm_timer3;unsigned int alarm_timer4;volatile unsigned char alarm_flag1;unsigned char alarm_flag2;unsigned char alarm_flag3;unsigned char alarm_flag4;/* FunctiONs */void interrupt isr(){	if (RCIF)	{		Write_RXBuff();	}   	if (TMR0IF)	{		alarm_flag4++;		TMR1_INC();				if(conditie == 1)		{			timeout++;		}		else		{			timeout = 0;		}	}}void Setup_Interrupts(void){    INTCON = 0;    GIE    = 1 ;    PEIE   = 1 ;    RCIE   = 1;    TMR0IE = 1;  //enable timer1 interrupt	//TMR0IE = 1;  //enable timer1 interrupt}void Setup_16F877AHW(void){   	TRISA|=(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<5);   	TRISE|=(1<<0)|(1<<1)|(1<<2);	TRISB=0x00;	TRISB = (TRISB&(0x00));	TRISD=0;	PORTD=0x00;	PORTB=0;   	TRISC = 0xf0;	RC0 = 0;	RC1 = 0;}void Setup_ADC(void){	ADCS1 = 1;				//select Fosc/8	ADCS0 = 1;	ADCON1=0b10001110; 		// A/D port cONfiguratiON 0	ADFM = 1;				//right justified result	ADON=1;					// turn ON the AD cONversiON module	 }void Setup_Timer0()  // interrupt every 50ms{      		OPTION = 0b00000111;	//INTCON = 0b11100000; //setarile se fac deja in fct de setare intreruperi	TMR0 = 12; //intrerupere la 25ms}void TMR1_INC(void){          TMR0IF = 0;              TMR0 = 12;	alarm_timer1++;	alarm_timer2++;	alarm_timer3++;	alarm_timer4++;       	if (alarm_timer1 >= 10)	{		alarm_flag1 = 0;		alarm_timer1 = 0;	}}void Reset_RXBuff(void){        wptr = 0;        memset(ReadBuffer, 0, 95);}void Write_RXBuff(void){        if ((RCSTA & 0b00000110) == 0)        {        ReadBuffer[wptr] = toupper(RCREG);                //putch(RXBuff[wptr]);                wptr++;                if (wptr > (95))                        wptr = 0;        }        else  /* There is an error! */        {                CREN = 0;                CREN = 1;        }         }/* return a 10-bit result */unsigned int read_adc(unsigned char channel){			ADON=1;	channel&=0x07;						// truncate channel to 3 bits	ADCON0&=0xC5;						// clear current channel select	ADCON0|=(channel<<3);				// apply the new channel select	Wait(5);	ADGO=1;		__delay_ms(10);						// initiate cONversiON ON the selected channel	while(ADGO)continue;	ADON=0;	return(((ADRESH&0x03)<<8)+ADRESL);	// return the 10-bit result}int temp_lm35_1(void){	int temp_an, temp, i;	temp_an=0;	for(i=0; i<10; i++)	{		temp_an =temp_an+read_adc(0);		__delay_ms(10);	}	temp_an=(temp_an/10);	temp = (int)(temp_an*0.49);	return(temp);}int temp_lm35_2(void){	int temp_an, temp, i;	temp_an=0;	for(i=0; i<10; i++)	{		temp_an =temp_an+read_adc(1);		__delay_ms(10);	}	temp_an=(temp_an/10);	temp = (int)(temp_an*0.49);	return(temp);}///////////////////////////////////////////////////////////////void echo_OFF(void)  // Sends echo command OFF{#ifdef VAR_M_WAIT_RES	while (1)	{#endif		Reset_RXBuff();		TransmitUSARTC("ATE=0");  //Text mode		USARTWriteChar('r');		Wait(10);#ifdef VAR_M_WAIT_RES				if (strstr(ReadBuffer, "OKrn0") != 0)			break;	}#endif	}void SMS_ATCMGF(void){#ifdef VAR_M_WAIT_RES	while (1)	{#endif            Reset_RXBuff();            TransmitUSARTC("AT+CMGF=1");			USARTWriteChar('r');            Wait(10);#ifdef VAR_M_WAIT_RES				if (strstr(ReadBuffer, "OKrn0") != 0)			break;	}#endif  }void SMS_ATCMGD(void){#ifdef VAR_M_WAIT_RES	while (1)	{#endif		Reset_RXBuff();//		SMS_ATCPMS();		TransmitUSARTC("AT+CMGD=1,4");		USARTWriteChar('r');		Wait(10);		TransmitUSARTC("AT+CMGD=2,4");		USARTWriteChar('r');		Wait(5);		TransmitUSARTC("AT+CMGD=3,4");		USARTWriteChar('r');		Wait(5);		TransmitUSARTC("AT+CMGD=4,4");		USARTWriteChar('r');		Wait(5);		TransmitUSARTC("AT+CMGD=5,4");		USARTWriteChar('r');		Wait(5);#ifdef VAR_M_WAIT_RES				if (strstr(ReadBuffer, "OKrn0") != 0)			break;	}#endif }void SMS_ATCPMS(void){#ifdef VAR_M_WAIT_RES	while (1)	{#endif		Reset_RXBuff();		TransmitUSARTC("AT+CPMS=");  //select phONe memory		USARTWriteChar('"');		TransmitUSARTC("ME");		USARTWriteChar('"');/*		//*****************************		USARTWriteChar(',');		USARTWriteChar('"');		TransmitUSARTC("SM");		USARTWriteChar('"');		USARTWriteChar(',');		USARTWriteChar('"');		TransmitUSARTC("MT");		USARTWriteChar('"');		//******************************/		USARTWriteChar('r');		Wait(10);#ifdef VAR_M_WAIT_RES				if (strstr(ReadBuffer, "OKrn0") != 0)			break;	}#endif }void SMS_ATCNMI(void){#ifdef VAR_M_WAIT_RES	while (1)	{#endif     		Reset_RXBuff();		TransmitUSARTC("AT+CNMI=2,2,2,2,0");		USARTWriteChar('r');		Wait(5);  //wait for ">" character#ifdef VAR_M_WAIT_RES				if (strstr(ReadBuffer, "OKrn0") != 0)			break;	}#endif}///////////////////////////////////////////////////////////////////////////////*void interrupt isr(void){		if(RCIF)	{		ReadBuffer[i++] = RCREG;		if(i>78) i = 0;		}	RCIF = 0; }*///^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/*void writeEEprom(const char* c,char adresa){	int i =0;	while(c[i]!=0x0 && c[i]!=0xd)	{		eeprom_write(adresa+i,c[i]);		i++;	}	 }/////////////////////////////////////////////////////unsigned char *readEEprom(unsigned char *valori,cONst char adresa,int nr_carac){		unsigned  char *dest;	dest = valori;	int i =0;	for(i=0;i<nr_carac;i++)	{		dest[i]=eeprom_read(adresa+i);		dest[nr_carac] = '0';	}	return (dest);} unsigned lONg Eeprom_Read_Float(unsigned int addr){      unsigned long result;      unsigned  char *ptr= (unsigned  char *)&result;      unsigned  char i;      for (i=0;i<10;i++)          *(ptr++)=eeprom_read(addr++);      return result;}	*/	//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^void main(void){		int val1,val2,val3;	char b [90];		#ifdef VAR_M_DS18	unsigned char temp_po_str[8],temp_pm_str[8];	int temp_po,temp_po_ok,temp_pm;	#endif    Setup_16F877AHW();    Setup_Interrupts();	Setup_Timer0();	Setup_ADC();	InitUSART();	Wait(10);	Reset_RXBuff();		#ifdef VAR_M_TEST	#ifdef VAR_M_DS18	ds1820_init(DS1820_pin_po);              //Initialize DS1820 Buffer oben//	ds1820_init(DS1820_pin_pm);              //Initialize DS1820 Buffer mitte	#endif	#endif		#ifdef VAR_M_1Wire	TRISA1=1;	#endif	#ifdef VAR_M_TEST	/********Test zone*/	while(1)	{				#ifdef VAR_M_DS18	    	temp_po = ds1820_read_temp(DS1820_pin_po);//Get temperature from DS1820 puffer oben					temp_po_ok = temp_po;			sprintf(temp_po_str,"%d C",temp_po); //Convert temp. puffer oben to string					sprintf (b, "temperatura pe zona 2 este %d",temp_po);	#endif		#ifdef VAR_M_1Wire	Read_Temperature();//	sprintf (b, "temperatura pe zona 2 este %d.%d C --n%x",(Temp.Val>>1),(Temp.bits.b3 * 5),Temp.Val);		if((Temp.Val < 0xff))	{		sprintf (b, "temperatura pe zona 2 este %d.%d C",(Temp.Val>>1),(Temp.bits.b3 * 5));	}	else	{		sprintf (b, "temperatura pe zona 2 este -%d.%d C",(((~Temp.Val)&0xFF)+1)>>1,(Temp.bits.b3 * 5));	}		#endif		TransmitUSARTC(b);		USARTWriteChar('r');		Wait(1);	}#else	echo_OFF();	SMS_ATCMGF();	SMS_ATCMGD();	SMS_ATCPMS();	SMS_ATCMGD();//	SMS_ATCNMI();	while(1)	{		TransmitUSARTC("AT+CMGL=");  //Reads All Unread Messages		USARTWriteChar('"');	//	TransmitUSARTC("REC UNREAD");		TransmitUSARTC("ALL");		USARTWriteChar('"');		USARTWriteChar('r');	/*		for(int k=0;k<=77;k++)		{			if(ReadBuffer[k]=='@')			{				pozitie = k+1;				Wait(20);				strncpy(nr_tel,ReadBuffer+pozitie,10);				nr_tel[10] = '0';					writeEEprom(nr_tel,0x10);				TransmitUSARTC(nr_tel);				USARTWriteChar('r');				Reset_RXBuff();				memset(nr_tel3, 0, 10);			}					}		//==========================================================						nr_tel2=Eeprom_Read_Float(0x10);			sprintf (nr_tel3, "%ld",nr_tel2);			TransmitUSARTC(nr_tel3);		//================================================================	//	mobile_no_01 = */				//Iesiri		 if(strstr (ReadBuffer,"RELEU1ON")!=0)		{				conditie = 1;			while(1)			{				RD0 = 1;				if( (RD0 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU1OFF")!=0)		{				conditie = 1;			while(1)			{				RD0 = 0;				if( (RD0 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU2ON")!=0)		{				conditie = 1;			while(1)			{				RD1 = 1;				if( (RD1 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU2OFF")!=0)		{				conditie = 1;			while(1)			{				RD1 = 0;				if( (RD1 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		//##############################################################################		else		if(strstr (ReadBuffer,"RELEU3ON")!=0)		{				conditie = 1;			while(1)			{				RD2 = 1;				if( (RD2 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}	  	else		if(strstr (ReadBuffer,"RELEU3OFF")!=0)		{				conditie = 1;			while(1)			{				RD2 = 0;				if( (RD2 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}								Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU4ON")!=0)		{				conditie = 1;			while(1)			{				RD3 = 1;				if( (RD3 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU4OFF")!=0)		{			conditie = 1;			while(1)			{				RD3 = 0;				if( (RD3 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU5ON")!=0)		{			conditie = 1;			while(1)			{				RD4 = 1;				if( (RD4 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU5OFF")!=0)		{			conditie = 1;			while(1)			{				RD4 = 0;				if( (RD4 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}      			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU6ON")!=0)		{			conditie = 1;			while(1)			{				RD5 = 1;				if( (RD5 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU6OFF")!=0)		{			conditie = 1;			while(1)			{				RD5 = 0;				if( (RD5 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}						Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU7ON")!=0)		{			conditie = 1;			while(1)			{				RD6 = 1;				if( (RD6 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU7OFF")!=0)		{			conditie = 1;			while(1)			{				RD6 = 0;				if( (RD6 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}								Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU8ON")!=0)		{			conditie = 1;			while(1)			{				RD7 = 1;				if( (RD7 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU8OFF")!=0)		{			conditie = 1;			while(1)			{				RD7 = 0;				if( (RD7 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU9ON")!=0)		{			conditie = 1;			while(1)			{				RB0 = 1;				if( (RB0 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU9OFF")!=0)		{			conditie = 1;			while(1)			{				RB0 = 0;				if( (RB0 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}     			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU10ON")!=0)		{			conditie = 1;			while(1)			{				RB1 = 1;				if( (RB1 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU10OFF")!=0)		{			conditie = 1;			while(1)			{				RB1 = 0;				if( (RB1 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}							Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU11ON")!=0)		{				conditie = 1;					while(1)			{				RB2 = 1;				if( (RB2 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        	//led0ON			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU11OFF")!=0)		{				conditie = 1;					while(1)			{				RB2 = 0;				if( (RB2 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			};			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU12ON")!=0)		{			conditie = 1;			while(1)			{				RB3 = 1;				if( (RB3 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU12OFF")!=0)		{			conditie = 1;			while(1)			{				RB3 = 0;				if( (RB3 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU13ON")!=0)		{			conditie = 1;			while(1)			{				RB4 = 1;				if( (RB4 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU13OFF")!=0)		{			conditie = 1;			while(1)			{				RB4 = 0;				if( (RB4 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}      			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU14ON")!=0)		{			conditie = 1;			while(1)			{				RB5 = 1;				if( (RB5 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU14OFF")!=0)		{			conditie = 1;			while(1)			{				RB5 = 0;				if( (RB5 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}							Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU15ON")!=0)		{			conditie = 1;			while(1)			{				RC1 = 1;				if( (RC1 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}		        				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU15OFF")!=0)		{			conditie = 1;			while(1)			{				RC1 = 0;				if( (RC1 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}								Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU16ON")!=0)		{			conditie = 1;			while(1)			{				RC0 = 1;				if( (RC0 == 1) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}			   				Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(strstr (ReadBuffer,"RELEU16OFF")!=0)		{			conditie = 1;			while(1)			{				RC0 = 0;				if( (RC0 == 0) || ( timeout > 200 ))				{					conditie = 0;					timeout = 0;					break;				}			}							Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		//^^^^^^^^^^^^^^^^^^^^^^^^^^Intrari^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^		else		if( strstr(ReadBuffer,"SENZOR1") != 0)		{			val1 = temp_lm35_1();			sprintf (b, "temperatura pe zona 1 este %dC",val1);			Wait(10);			trimit_sms_custom(b);			Wait(60);			SMS_ATCMGD();			Reset_RXBuff();			memset(b, 0, 90);		}		else		if(strstr(ReadBuffer,"SENZOR2")!=0)		{			#ifdef VAR_M_1Wire			Read_Temperature();		//	sprintf (b, "temperatura pe zona 2 este %d.%d C --n%x",(Temp.Val>>1),(Temp.bits.b3 * 5),Temp.Val);						if((!(Temp.Val & 0x8000)))			{				sprintf (b, "temperatura pe zona 2 este %dC",(Temp.Val>>4));			}			else			{				Temp.Val = ~Temp.Val + 1;				val2 = ((Temp.Val)>>4)*(-1);				sprintf (b, "temperatura pe zona 2 este %d C",val2);			}						#endif						Wait(10);			trimit_sms_custom(b);			Wait(60);			SMS_ATCMGD();			Reset_RXBuff();			memset(b, 0, 90);		}		else		if(((PORTA & 0b00000100) == 0)  && (flag3 == 0) )		{			flag3 = 1;			trimit_sms_custom("intrarea 1 activata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(((PORTA & 0b0000100) != 0) && (flag3 == 1) )		{			flag3 = 0;			trimit_sms_custom("intrarea 1 dezactivata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(((PORTA & 0b00001000) == 0)  && (flag4 == 0) )		{			flag4 = 1;			trimit_sms_custom("intrarea 2 activata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(((PORTA & 0b0001000) != 0) && (flag4 == 1))		{			flag4 = 0;			trimit_sms_custom("intrarea 2 dezactivata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(((PORTA & 0b00100000) == 0)  && (flag5 == 0) )		{			flag5 = 1;			trimit_sms_custom("intrarea 3 activata");			Wait(10);			SMS_ATCMGD();			Reset_RXBuff();		}		else		 if(((PORTA & 0b00100000) != 0) && (flag5 == 1) )		{			flag5 = 0;			trimit_sms_custom("intrarea 3 dezactivata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(((PORTE & 0b00000001) == 0) && ( flag6 == 0 ) )		{				flag6 = 1;			trimit_sms_custom("intrarea 4 activata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}			else		if(((PORTE & 0b00000001) != 0) && (flag6 == 1) )		{			flag6 = 0;			trimit_sms_custom("intrarea 4 dezactivata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}		else			if(((PORTE & 0b00000010) == 0) && (flag7 == 0)  )		{			flag7 = 1;			trimit_sms_custom("intrarea 5 activata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(((PORTE & 0b00000010) != 0) && (flag7 == 1) )		{			flag7=0;			trimit_sms_custom("intrarea 5 dezactivata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(((PORTE & 0b00000100) == 0) && (flag8 == 0 ) )		{			flag8 = 1;			trimit_sms_custom("intrarea 6 activata");			Wait(40);			TransmitUSARTC("AT+CMGD=1,4");			SMS_ATCMGD();			Reset_RXBuff();		}		else		if(((PORTE & 0b00000100) != 0) && (flag8 == 1) )		{			flag8 = 0;			trimit_sms_custom("intrarea 6 dezactivata");			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();		}		if(strstr(ReadBuffer,"STARE-IESIRI") != 0 )		{			sprintf(b,"R1=%d R2=%d R3=%d R4=%d R5=%d R6=%d R7=%d R8=%d R9=%d R10=%d R11=%d R12=%d R13=%d R14=%d R15=%d R16=%d ",RD0,RD1,RD2,RD3,RD4,RD5,RD6,RD7,RB0,RB1,RB2,RB3,RB4,RB5,RC1,RC0);			trimit_sms_custom(b);			Wait(40);			SMS_ATCMGD();			Reset_RXBuff();			memset(b, 0, 90);				}		else		if(strstr(ReadBuffer,"STARE-INTRARI") != 0 )		{			val1 = temp_lm35_1();			Wait(10);						Wait(10);						#ifdef VAR_M_1Wire			Read_Temperature();						if(!(Temp.Val & 0x8000))			{				val2 = (Temp.Val>>4);			}			else			{				Temp.Val = ~Temp.Val + 1;				val2 = ((Temp.Val)>>4)*(-1);			}						#endif						Wait(10);			sprintf(b,"T1=%d grade T2=%d grade IN1=%d IN2=%d IN3=%d IN4=%d IN5=%d IN6=%d",val1,val2,RA2,RA3,RA5,RE0,RE1,RE2);			trimit_sms_custom(b);			Wait(60);			SMS_ATCMGD();			Reset_RXBuff();			memset(b, 0, 90);;			}		Wait(10);		Wait(10);	}	#endif}

Cu intarziere dar am avut alte probleme de rezolvat si proiectul sa amanat.

Editat de flo_tiesto
Link spre comentariu

In codul postat de tine nu se vede cat este baud rate pentru USART atunci cand faci initializarea.Functia de initializare arata asa: void Usart_Init(const unsigned long baud_rate);Probabil la SIM900 baud rate default este 19200 bps, probabil ca stii si cat este la fiecare modul testat.Eu stiu ca baud in PIC si in SIM900 trebuie sa fie la fel.

Link spre comentariu

Creează un cont sau autentifică-te pentru a adăuga comentariu

Trebuie să fi un membru pentru a putea lăsa un comentariu.

Creează un cont

Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!

Înregistrează un nou cont

Autentificare

Ai deja un cont? Autentifică-te aici.

Autentifică-te acum



×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.Termeni de Utilizare si Ghidări