Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sms control relays pic16f887

Status
Not open for further replies.

tofigg

Junior Member level 1
Joined
Jul 10, 2010
Messages
15
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Location
malaysia
Activity points
1,373
hello everybody
im doing project about controlling relays by sms and i wrote my code and couldnt get it work and i need help plz if anyone know anything about it help me
i should read the sms and then check if its a valid command from the user then operate the specific order for that command
external ocs :7.372M
buad rate: 9600
gsm modem: sim300
pic16f887

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
unsigned char uart_rd;
unsigned char text;
char K;
unsigned char a[4];
int i=0;
 
 
 
 void SMS(){
 for(i=0;i<3;i++)
 {
 a[i]=UART1_Read();
 }
 
if ((a[0] == 'A') & (a[1] == 'B') & (a[2] == 'C'))
   PORTD=1;
if ((a[0] == 'X') & (a[1] == 'Y') & (a[2] == 'Z'))
   PORTA=1;
  UART1_Write_Text("AT+CMGD=1");
                  UART1_Write(13);
                  UART1_Write(10);
                   Delay_ms(500);
}
 
 
void main() {
 
 
                 PORTA = 0xFF;
                 PORTB = 0xFF;
                 ANSEL  = 0;                        // Configure AN pins as digital I/O
                 ANSELH = 0;
                 TRISD  = 0x00;    // making port as output
                 PORTD  = 0x00;       // making port as output
 
           
             
             
              UART1_Init(9600);
               Delay_ms(1000);
               
             UART1_Write_Text("AT");
                UART1_Write(13);
                UART1_Write(10);
                 Delay_ms(2000);
 
               UART1_Write_Text("AT+CMGF=1");
                  UART1_Write(13);
                  UART1_Write(10);
                   Delay_ms(2000);
                   
                    UART1_Write_Text("AT+CMGD=1");
                  UART1_Write(13);
                  UART1_Write(10);
                    Delay_ms(500);
 
 
                  while (1) {
 
 
                    
                    UART1_Write_Text("AT+CMGR=1");
                     UART1_Write(13);
                     UART1_Write(10);
                     Delay_ms(500);
                     
                     
                     UART1_Read_Text(a, "*", 200); // reads text until '*' is found
 
                      {
                         SMS();
 
                         }
                           UART1_Write_Text("AT+CMGD=1");
                            UART1_Write(13);
                             UART1_Write(10);
                               Delay_ms(100);
 
                             }
                             
                             }

 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,149
Reputation
4,304
Reaction score
2,089
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
do a serach in the forum before posting the thread,,, it is already answered many times..... see the bottom of the page where it gives links related to your post and so a good search in the forum........
 

tofigg

Junior Member level 1
Joined
Jul 10, 2010
Messages
15
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Location
malaysia
Activity points
1,373
i have read everything in this forum about my problem and nobody gives answer if u know anything help
 
  • Like
Reactions: judfid

    judfid

    Points: 2
    Helpful Answer Positive Rating

tofigg

Junior Member level 1
Joined
Jul 10, 2010
Messages
15
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Location
malaysia
Activity points
1,373
ppl any help plz

Last warning for using against sms or short hand typing language....
this forum is not for lazy people..
all your post will be deleted if continued further.. read the rules of the forum ...
 

engshahrul

Banned
Joined
Apr 27, 2009
Messages
330
Helped
97
Reputation
194
Reaction score
94
Trophy points
1,308
Location
Malaysia
Activity points
0
UART1_Read_Text(a, "*", 200);
I don't know why you read uart until found *, because the AT command not replay this character.

The way you read sms also, I think wrong. The AT command not give direct sms output. It have some other data.
For reference code, you can see here using Hi-Tech.
 
  • Like
Reactions: tofigg

    tofigg

    Points: 2
    Helpful Answer Positive Rating

tofigg

Junior Member level 1
Joined
Jul 10, 2010
Messages
15
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Location
malaysia
Activity points
1,373
thank you for ur reply actually what m doing now is to find the delimiter which is in the end of the sms and then go to read it
btw i couldnt open ur link can u post it again plz
thank u so much
 

engshahrul

Banned
Joined
Apr 27, 2009
Messages
330
Helped
97
Reputation
194
Reaction score
94
Trophy points
1,308
Location
Malaysia
Activity points
0
The link can open now.
 

    V

    Points: 2
    Helpful Answer Positive Rating

tofigg

Junior Member level 1
Joined
Jul 10, 2010
Messages
15
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Location
malaysia
Activity points
1,373
if you know all the posts and knew where is the answer for my problem post it here of don't reply again ckshivaram
thank you
 

nandhu015

Advanced Member level 5
Joined
Feb 11, 2006
Messages
1,965
Helped
300
Reputation
600
Reaction score
224
Trophy points
1,353
Location
India
Activity points
9,837
if you know all the posts and knew where is the answer for my problem post it here of don't reply again ckshivaram
thank you

As ckshivaram said we dont spoon feed here. If you really need help follow the rules and obey the moderators. Else...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top