Controlling industrial hazards using GSM intimation and feedback

yanivx

yanivx

@yanivx-gvxfxa Oct 15, 2024
Hey Godfather I am currently working on a project controlling industrial hazards using GSM intimation and feedback..... has someone worked on a smilar project...... thanks in advance bro.... i have brought in all the hardware the GSM modem is working fine the only problem i am facings is with the code..... i have the code but i don't think the problem is in my ATMEGA16 development board i am using VMlab as my simulator
here is the c code i am using to this code.... to test my board and GSM modem

#include <avr/io.h>
#include <avr/interrupt.h>
#include <string.h>
#include <util/delay.h>
int counter=0;
char rx[25];

unsigned int i=0;
unsigned char once=1;
char dummy[]={13, 0};
char d2[]={26,0};

void main (void)
{

// set PORTC for output
DDRC = 0xFF;
// PORTC=0xFF;
TCCR0=0x05;
TIMSK=0x01;
SREG=0x80;

DDRB=0x0C;
PORTB=0x10;

// PORTC =0xFF;
UCSRA=0x60;
//UCSRB=0x18; //only transmitter & receiver is enabled
UCSRB=0x98; //rx tx enabled, interrupt enabled
UCSRC=0x86; //Asynchronuous, no parity, one stop bit, 8 bit character size


UCSRC &=0x7F; //using URSEL bit
//It generates 9600 baudrate at 7.3728MHz
UBRRH=0x0;
UBRRL=0x2F;
// for 115200 baudrate at 7.3728MHz
// UBRRH=0x0;
// UBRRL=0x03; //BE SURE TO CHANGE THIS FOR SIMULATION///////////////////////////////
/////////////////////////////


asm ("SEI");

while(1){


if((PINB & 0x10) == 0x10)
PORTC |= 0x80;
else
PORTC &= 0x0;


}
}
void send(char* str)
{
unsigned char len;
len=strlen(str);
for(int i=0;i<len;i++)
{
_delay_ms(100);
while((UCSRA & 0x20) == 0x0);
UDR=str;
}

}

ISR(USART_RXC_vect)
{

rx=UDR;
i++;
if(rx[i-2]==13 && rx[i-1]==10)
{
rx[i-1]='\0';
rx[i-2]='\0';
i=0;
if(strcmp(rx,"Call Ready")==0){
PORTC |= 0x40;
_delay_ms(5000);
send("AT");
send(dummy);
}

else if(strcmp(rx,"OK")==0){
if(once==1){
PORTC |= 0x20;
send("AT+CMGS=\"+923334491947\"");

send(dummy);
once++;
}
else if(once==2){
PORTC |= 0x08;
once++;
}
}
for(int j=0;j<25;j++)
rx[j]=0;
}
else if(strcmp(rx,"> ")==0)
{
PORTC |= 0x10;
send("ATMEGA16L says Hello");
send(d2);
}


}

ISR(TIMER0_OVF_vect)
{
counter++;

if(counter==60)
{
PORTB |=0x08;
// counter=0;
TIMSK=0x0;//Disable timer interrupt to free-up controller

}

}

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • yanivx

    yanivx

    @yanivx-gvxfxa Mar 22, 2011

    Re: CEan - Godfather's Ultimate Electronics / Communications Project Ideas - 2011

    Solar tracking device.... can u explain something i don't think so this is practically possible..... i may be wrong though.... it could be solar powered Tracking device.......something like that.... 😉 but in 2nd year u taught something so huge u deserve applause... njoy
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Mar 22, 2011

    Posts moved to new thread in Other Engineering Trades section 😀
  • yanivx

    yanivx

    @yanivx-gvxfxa Apr 21, 2011

    This project is completed and its working perfect.... now i will post all tyhe details very soon.... finally i am done with my final year project 😁
  • Harshad Italiya

    Harshad Italiya

    @harshad-ukH5ww Apr 21, 2011

    yanivx
    This project is completed and its working perfect.... now i will post all tyhe details very soon.... finally i am done with my final year project 😁
    Oh this Post is specially for me. 😁 Thanks Mate.

    Great i am very happy that your project is completed. Now if you want to share it here with the Ceans then i can help you we can make its full detail report and share here for the further discussion this will help you to get the more knowledge of the project too.
    what you say yanivx?
  • narayana murthy

    narayana murthy

    @narayana-z4W16q Apr 22, 2011

    nice post here i missed it
    here i learned 1 thing in practice we never use masm or tasm programming we use only C
  • Harshad Italiya

    Harshad Italiya

    @harshad-ukH5ww Apr 22, 2011

    narayana murthy
    nice post here i missed it
    here i learned 1 thing in practice we never use masm or tasm programming we use only C

    You get the point NM. so try to make your C powerful. 😀