Search Your Query

Custom Search

Saturday, 21 May 2011

GSM BASED INDUSTRIAL AUTOMATION


ABSTRACT:
In normal we used to control the industrial equipments by manual operation. Hence it is to be updated step by step manually. It is overcome by a new mode of communication which is used to control all those equipments through a single message from anywhere. GSM is the most popular mobile phone system in the world which could be used for this controlling operation from anywhere else.
GSM – Global System for Mobile Communication is used as a media which is used to control and monitor the industrial equipments from anywhere by sending a message. It has its own deterministic character. Thereby, here GSM is used to monitor and control the DC motor, Stepper motor, Temperature sensor and Solid State Relay by sending a message through GSM modem. Hence no need to waste time by manual operation and transportation.
Hence it is considered as highly efficient communication through the mobile which will be useful in industrial controls, automobiles, and appliances which would be controlled from anywhere else. It is also highly economic and less expensive; hence GSM is preferred most for this mode of controlling.
CIRCUIT DIAGRAM:
GSM BASED AUTOMATION CIRCUIT DIAGRAM
PROJECT CODINGS:

ADC CODING:
#include
#include
#include
#include
#define ACK 1
#define NO_ACK 0
#define HIGH 01;
#define LOW 00;
idata unsigned char dat;
int ACK1 = 1,i;
float dat1;
char result,dat2;
unsigned char b,p,q;
sbit SDA = P2^3; // connect to SDA pin (Data)
sbit SCL = P2^4; // connect to SCL pin (Clock)
xdata char *ptr_cmd = (xdata char *) 0×0FFF8;
xdata char *ptr_en = (xdata char *) 0×0FFF9;
void lcd_comm();
void init_lcd();
void display1(char *name);
void disp(int name1);
void lcd_delay();
void Delay_Time();
void delay()
{
unsigned int i =1000;
while ( i– );
}
void busy_check()
{
*ptr_cmd = 0×02;
while ( ( *ptr_en & 0×80 ) != 0×00 );
}
void I2C_STOP()
{
SCL=HIGH;
SDA=LOW;
Delay_Time();
Delay_Time();
SDA=HIGH;
}
void I2C_START()
{
SCL =LOW;
SDA =LOW;
Delay_Time();
Delay_Time();
SCL=HIGH;
Delay_Time();
Delay_Time();
SDA=HIGH;
Delay_Time();
Delay_Time();
SDA=LOW;
Delay_Time();
Delay_Time();
SCL=LOW;
}
void I2C_WRITE(unsigned char j)
{
dat=j;
printf(”%c”,j);
for(i=0;i<8;i++)
{
SDA = dat & 0×80;
dat=dat<<1;
SCL=HIGH;
Delay_Time();
Delay_Time();
SCL = LOW;
}
SDA=HIGH;
Delay_Time();
Delay_Time();
SCL = HIGH;
Delay_Time();
Delay_Time();
ACK1 = SDA;
Delay_Time();
Delay_Time();
SCL=LOW;
if(ACK1!=0)
{
}
else
{
}
}
unsigned char I2C_READ()
{
unsigned char i,j;
j = 0;
j = SDA;
for(i=0; i<8; i++) //for reading the data bit by bit
{
j <<= 1; //shifting the data line one at a time
SCL = HIGH;
j |= SDA;
Delay_Time();
SCL=LOW;
}
Delay_Time();
Delay_Time();
Delay_Time();
SDA = LOW;
Delay_Time();
Delay_Time();
Delay_Time();
SCL = HIGH;
Delay_Time();
Delay_Time();
Delay_Time();
SCL = LOW;
Delay_Time();
Delay_Time();
Delay_Time();
SDA = HIGH;
Delay_Time();
Delay_Time();
Delay_Time();
return(j);
}
void adc_data()
{
init_lcd();
display1(”TEMPERATURE: “);
I2C_START();
I2C_WRITE(0X90);
I2C_WRITE(0X00);
I2C_STOP();
I2C_START();
I2C_WRITE(0X91) ;
dat1 =I2C_READ();
I2C_STOP();
printf(” result: %2.1f degree celcius\n”,dat1);
P2 = 0×0ff;
dat1=dat1;
q=dat1;
lcd_comm();
*(ptr_en)=0xc9;
busy_check();
disp(((q%100)/10)+48);
disp(((q%10)/1)+48);
display1(”.”);
disp((q%10)+48);
display1(0×6f);
display1(” C”);
for(q=0;q<25;q++)
{
lcd_delay();
}
}
void lcd_delay()
{
int i=15000;
while(i–){}
}
void Delay_Time()
{
unsigned long int i;
for(i=0;i<100;i++);
}
void display1(char *name)
{
int i,k = 15;
int l = strlen(name);
if (l <= 15)
k = l;
for(i = 0;i < k;i++)
{
*(ptr_cmd) = 0×01;
*(ptr_en) = name[i];
busy_check();
}
for (i; i
{
*(ptr_cmd) = 0×01;
*(ptr_en) = name[i];
busy_check();
}
}
void disp(int name1) //LCD display routine (for digits display )
{
*(ptr_cmd) = 0×01;
*(ptr_en) = name1;
busy_check();
Delay_Time();
}
void init_lcd()
{
lcd_comm();
*( ptr_en ) = 0×38;
busy_check();
lcd_comm();
*(ptr_en) = 0×0e;
busy_check();
lcd_comm();
*(ptr_en) = 0×01;
busy_check();
lcd_comm();
*(ptr_en) = 0×06;
busy_check();
lcd_comm();
*(ptr_en) = 0×80;
busy_check();
}
void lcd_comm()
{
*( ptr_cmd ) = 0×00;
}
void main()
{
init_lcd();
while(1)
{
adc_data();
}
}
STEPPER MOTOR CODING:
#include
#include
int i,j,k,p=0;
static int x;
char cmgs[60];
at 0xB2 sbit (int0);
sbit MDM = P2^1;
code char AT_CMD1[9]={’a',’t',’+',’c',’m',’g',’f',’=',’1′};
code char AT_CMD2[23] = {’a',’t',’+',’c',’s’,'c’,'a’,'=’,'”‘,’+',’9′,’1′,’9′,’8′,’4′,’3′,’0′,’0′,’0′,’0′,’4′,’0′,’”‘};
code char AT_CMD3[17] = {’a',’t',’+',’c',’n',’m',’i',’=',’1′,’,',’2′,’,',’0′,’,',’0′,’,',’0′};
xdata char *ptr_cmd = (xdata char *)0×0FFF8; //LCD command mode control
xdata char *ptr_en = (xdata char *)0×0FFF9; //LCD Enable
char AT1[13];
char AT2[28];
char AT3[21];
unsigned char a[]={0×66,0xcc,0×99,0×33};
unsigned char b[]={0×00,0×00,0×00,0×00};
char mybyte;
char serial_rx ();
void busy_check ();
void display (char* );
void send_sms ();
void slow();
void medium();
void fast();
void off();
//**********************************************************************
// SERIAL INIT_TX_RX
//**********************************************************************
void baud_init ()
{
TMOD = 0×20;
TH1 = 0xF4;
SCON = 0×50;
TR1 = 1;
}
//**********************************************************************
// DELAY ROUTINES
//**********************************************************************
void delayms ()
{
int i, j;
for( i = 0 ; i <= 1000 ; i++ )
for( j = 0 ; j <= 1000 ; j++ );
}
void delay()
{
int i,j;
for (i=0;i<10;i++)
for(j=0;j<400;j++);
}
void delay1()
{
int i,j;
for(i=0;i<75;i++)
for(j=0;j<500;j++);
}
void delay2()
{
int i,j;
for(i=0;i<50;i++)
for(j=0;j<250;j++);
}
void delay3()
{
int i,j;
for(i=0;i<25;i++)
for(j=0;j<100;j++);
}
//**********************************************************************
// SEND FIRST AT COMMAND
//**********************************************************************
void send_cmd1()
{
int j;
for( j = 0 ; j <= 8 ; j++ )
{
SBUF = AT_CMD1[j];
while(TI == 0);
TI = 0;
AT1[j] = serial_rx ();
}
SBUF = 0×0D;
while(TI == 0);
TI = 0;
AT1[9] = serial_rx ();
AT1[10] = serial_rx ();
AT1[10] = serial_rx ();
AT1[11] = serial_rx ();
AT1[12] = serial_rx ();
AT1[13] = ‘\0′;
}
//**********************************************************************
// SEND SECOND AT COMMAND
//**********************************************************************
void send_cmd2()
{
int j;
for( j = 0 ; j <= 22 ; j++ )
{
SBUF = AT_CMD2[j];
while(TI == 0);
TI = 0;
AT2[j] = serial_rx ();
}
SBUF = 0×0D;
while(TI == 0);
TI = 0;
AT2[23] = serial_rx ();
AT2[24] = serial_rx ();
AT2[24] = serial_rx ();
AT2[26] = serial_rx ();
AT2[27] = serial_rx ();
AT2[28] = ‘\0′;
}
//**********************************************************************
// READ SMS COMMAND
//**********************************************************************
void read_sms()
{
int k;
for( k = 0 ; k <= 16 ; k++ )
{
SBUF = AT_CMD3[k];
while(TI == 0);
TI = 0;
AT3[k] = serial_rx ();
}
SBUF = 0×0D;
while(TI == 0);
TI = 0;
AT3[17] = serial_rx ();
AT3[18] = serial_rx ();
AT3[18] = serial_rx ();
AT3[19] = serial_rx ();
AT3[20] = serial_rx ();
AT3[21] = ‘\0′;
}
//**********************************************************************
// LCD ROUTINE
//**********************************************************************
char serial_rx()
{
while(RI == 0);
mybyte = SBUF;
RI = 0;
return (mybyte);
}
void busy_check()
{
*ptr_cmd = 0×02;
while((*ptr_en & 0×80) != 0×00){}
}
void lcd_comm()
{
*(ptr_cmd) = 0×00;
}
void init_lcd()
{
lcd_comm();
*(ptr_en) = 0×38;
busy_check();
lcd_comm();
*(ptr_en) = 0×0C;
busy_check();
lcd_comm();
*(ptr_en) = 0×80;
busy_check();
lcd_comm();
*(ptr_en) = 0×01;
busy_check();
}
//**********************************************************************
// DISPLAY ROUTINE
//**********************************************************************
void display (char *name)
{
int l = strlen(name);
int i;
for( i = 0; i <= 15 ; i++ )
{
*(ptr_cmd) = 0×01;
*(ptr_en) = name[i];
busy_check();
}
*(ptr_cmd) = 0×00;
*ptr_en = 0xC0;
busy_check ();
for( i ; i < l ; i++ )
{
*(ptr_cmd) = 0×01;
*(ptr_en) = name[i];
busy_check();
}
}
void display1(char *name)
{
int i;
int l;
l = strlen(name);
for( i = 51; i <= 57 ; i++ )
{
*(ptr_cmd) = 0×01;
*(ptr_en) = name[i];
busy_check();
}
*(ptr_cmd) = 0×00;
*ptr_en = 0xc0;
busy_check ();
}
//**********************************************************************
// SMS_MOTOR CONTROL ROUTINE
//**********************************************************************
void sms_cntrl_mtr ()
{
int i,x,z,j;
char mtrF[] = “STPMTR-F”;
char mtrS[] = “STPMTR-S”;
char mtrO[] = “STPMTR-O”;
unsigned char a[]={0×66,0xcc,0×99,0×33};
unsigned char b[]={0×00,0×00,0×00,0×00};
IE = 0×85; //0×81=interrupt 0, 0×84=interrupt 1
IT0=1;
IT1=1;
while(1)
{
medium();
if( MDM == 0 )
{
off();
}
else
{
MDM=1;
medium();
}
}
i = 51; j = 0;
while ( (cmgs[i] == mtrF[j]) && (j != 8 ))
{
i++;
j++;
}
if ( j == 8 )
{
fast();
display ( ” MATCH-FAST ” );
}
i=51; j = 0;
while ( ( cmgs[i] == mtrS[j] ) && ( j != 8 ) )
{
i++;
j++;
}
if (j == 8 )
{
slow();
display ( ” MATCH-SLOW ” );
}
i=51; j = 0;
while ( ( cmgs[i] == mtrO[j] ) && ( j != 8 ) )
{
i++;
j++;
}
if (j == 8 )
{
off();
display ( ” MATCH-OFF ” );
}
while(cmgs[i])
{
i++;
*ptr_cmd = 0×01;
*ptr_en = cmgs[i];
}
}
//**********************************************************************
// SMS_STEPPER MOTOR FUNCTIONS ROUTINE
//**********************************************************************
void slow()
{
int x,z;
for(z=0;z<100;z++)
{
for(x=0;x<4;x++)
{
P1=a[x];
delay3();
}
}
}
void off()
{
int x,z;
for(z=0;z<100;z++)
{
for(x=0;x<4;x++)
{
P1=b[x];
delay3();
}
}
}
void medium()
{
int x,z;
for(z=0;z<100;z++)
{
for(x=0;x<4;x++)
{
P1=a[x];
delay2();
}
}
}
void fast()
{
int x,z;
for(z=0;z<100;z++)
{
for(x=0;x<4;x++)
{
P1=a[x];
delay1();
}
}
}
void ext_int0() interrupt 0
{
fast();
}
at 0×0013
void ext_int1() interrupt 1
{
slow();
}
void main( void )
{
unsigned int e = 65533;
//**********************************************************************
// AT+CMGF=1 – OK
//**********************************************************************
init_lcd ();
baud_init ();
send_cmd1 ();
display (AT1);
delayms ();
//**********************************************************************
// AT+CSCA =”MESSAGE CENTRE NO” – OK
//**********************************************************************
init_lcd ();
baud_init ();
send_cmd2 ();
display (AT2);
delayms ();
//**********************************************************************
// READ – SMS = OK
//**********************************************************************
while(1)
{
init_lcd ();
baud_init ();
read_sms ();
display (AT3);
p = 0;
while (p <= 58)
{
cmgs[p] = serial_rx();
++p;
}
cmgs[p] = ‘\0′;
sms_cntrl_mtr ();
while (e–);
e = 65533;
}
while(1);
}
D.C MOTOR CONTROL:
void sms_cntrl_mtr ()
{
int i,j;
char mtrL[] = “mtr-l”;
char mtrR[] = “mtr-r”;
char mtrO[] = “mtr-o”;
i = 51; j = 0;
while ( (cmgs[i] == mtrL[j]) && (j != 5 ))
{
i++;
j++;
}
if ( j == 5 )
{
mtrr = 0;
mtrl = 1;
display ( ” MATCH-LEFT ” );
}
i=51; j = 0;
while ( ( cmgs[i] == mtrR[j] ) && ( j != 5 ) )
{
i++;
j++;
}
if (j == 5 )
{
mtrl = 0;
mtrr = 1;
display ( ” MATCH-RIGHT ” );
}
i=51; j = 0;
while ( ( cmgs[i] == mtrO[j] ) && ( j != 5 ) )
{
i++;
j++;
}
if (j == 5 )
{
mtrl = 0;
mtrr = 0;
display ( ” MATCH-OFF ” );
}
while(cmgs[i])
{
i++;
*ptr_cmd = 0×01;
*ptr_en = cmgs[i];
}
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...