Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

[ARM] Adc-gsm interface using LPC2148 ARM7

Status
Not open for further replies.

ddnair

Junior Member level 1
Junior Member level 1
Joined
Aug 25, 2014
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
128
Hai friends,
Iam a beginner in LPC2148 ARM7. I want to do a simple project as follows.
I have done with ADC and GSM programs.. But I dont know hoe to use it together. I want to send the ADC output through GSM to a mobile number, and each time i change the adc value the next message should be sent. Please provide me the code for that.

Thank you.
 

Read ADc values
store in variable

use that variable in send message functions you created..

just printf() or serial output string is enough..

if you share your adc and gsm program i can tell where to change or add
 
  • Like
Reactions: ddnair

    ddnair

    Points: 2
    Helpful Answer Positive Rating
this is my program....


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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <lpc21xx.h>                    /* LPC2200 definitions             */
#include <stdio.h>  
#include <string.h>
#include "uart.h"                    /* standard I/O .h-file               */
 
 
#define CR     0x0D
#define VREF  3
 
int adc_process();
void delay1(int n);
void delay2(int n);
int tem_conv(void);
 
unsigned int val,temp1=0,temp2;
float deg_temp,temperature;          //temp1=previous value,temp2=current value
char t[2],degree[5];
int j;
 
 
void
delay(void)
{
    int temp;
 
    for(temp = 0; temp < 400000; temp++) {
    }
}
 
int main(void)
{
  
    IODIR1 = 0x00FF0000;                        
    
    VPBDIV = 0x02;                         /*Set the Pclk to 30 Mhz              */
    uart();
 
    while(1)
    {                               
        printf("AT\n\r%c",13);
        delay2(10000);
        printf("AT+CMGF=1\n\r%c",13);               
        delay2(10000);                                          //Text Mode  | hex value of 13 is 0x0D (CR )
        printf("AT+CMGS=\"9986552281\"\n\r%c",13);  
        delay2(10000);
        
       temp2=adc_process();
    
         
         while((temp2-temp1)<=50);
         
        temp1=temp2;
        sprintf(t,"%d",temp1);
        printf ("Digital Value=" );
        for(j=0;t[j]!='\0';j++)
         {
          put(t[j]);
         } 
         
         delay2(1000);
         printf("\n");  
         deg_temp=tem_conv();
         sprintf(degree,"%f",deg_temp);
         printf("Temperature(C)=");
         for(j=0;degree[j]!='\0';j++)
         put(degree[j]);
                                                
        delay2(10000);                                  
        //   printf("ATD9986552281;\r");                        //calling function
        printf("%c",0x1A);                                      //line feed command
        delay2(10000);  
             
       }
 
    }       
 
 
int adc_process()                              /* Setup the A/D converter */
{
PINSEL1 = 0x04000000;                    /* P1.16..23 defined as Outputs       */
ADCR   = 0x00210604;                   /* Setup A/D: 10-bit AIN0 @ 3MHz      */
while(1) 
    {
      
    ADCR  |= 0x01000000;                  // Start A/D Conversion              
    while ((ADDR & 0x80000000) == 0);    // Wait for the conversion to complete 
    val = ((ADDR >> 6) & 0x03FF);         // Extract the A/D result              
 
  
    IOSET1=val; 
     return(val);
    }
}
 
 
//Delay Routine start here
void delay1(int n)
{
    int i;
    for(i=0;i<n;i++);
}
 
void delay2(int n)
{
    int i;
    for(i=0;i<n;i++)
        delay1(1000);
}
 
int tem_conv(void)
{
temperature=(((float)adc_process()/1023)*3.3*100);
return(temperature);
}

 
Last edited by a moderator:

I got partial output. When I debug the program Im getting the adc value and temperature value, corresponding to the voltage given. But when I do in Hardware I need to reset each time for getting the next output..The corresponding adc or temperature value is not coming in serially as soon as i change the value...
 

Code:
#include <lpc21xx.h>                    /* LPC2200 definitions             */
#include <stdio.h>  
#include <string.h>
#include "uart.h"                    /* standard I/O .h-file               */
 
 
#define CR     0x0D
#define VREF  3
 
int adc_process();
void delay1(int n);
void delay2(int n);
int tem_conv(void);
 
unsigned int val,temp1=0,temp2;
float deg_temp,temperature;          //temp1=previous value,temp2=current value
char t[2],degree[5];
int j;
 
 
void
delay(void)
{
    int temp;
 
    for(temp = 0; temp < 400000; temp++) {
    }
}
 
int main(void)
{
  
    IODIR1 = 0x00FF0000;                        
    
    VPBDIV = 0x02;                         /*Set the Pclk to 30 Mhz              */
    uart();
 
    while(1)
    {                               
        printf("AT\n\r%c",13);
        delay2(10000);
        printf("AT+CMGF=1\n\r%c",13);               
        delay2(10000);                                          //Text Mode  | hex value of 13 is 0x0D (CR )
        printf("AT+CMGS=\"9986552281\"\n\r%c",13);  
        delay2(10000);
        
       temp2=adc_process();
    
         
         while((temp2-temp1)<=50);
         
        temp1=temp2;
        sprintf(t,"%d",temp1);
        printf ("Digital Value=" );
        for(j=0;t[j]!='\0';j++)
         {
          put(t[j]);
         } 
         
         delay2(1000);
         printf("\n");  
         deg_temp=tem_conv();
         sprintf(degree,"%f",deg_temp);
         printf("Temperature(C)=");
         for(j=0;degree[j]!='\0';j++)
         put(degree[j]);
                                                
        delay2(10000);                                  
        //   printf("ATD9986552281;\r");                        //calling function
        printf("%c",0x1A);                                      //line feed command
        delay2(10000);  
             
       }
 
    }       
 
 
int adc_process()                              /* Setup the A/D converter */
{
PINSEL1 = 0x04000000;                    /* P1.16..23 defined as Outputs       */
ADCR   = 0x00210604;                   /* Setup A/D: 10-bit AIN0 @ 3MHz      */

    {
      
    ADCR  |= 0x01000000;                  // Start A/D Conversion              
    while ((ADDR & 0x80000000) == 0);    // Wait for the conversion to complete 
    val = ((ADDR >> 6) & 0x03FF);         // Extract the A/D result              
 
  
    IOSET1=val; 
     return(val);
    }
}
 
 
//Delay Routine start here
void delay1(int n)
{
    int i;
    for(i=0;i<n;i++);
}
 
void delay2(int n)
{
    int i;
    for(i=0;i<n;i++)
        delay1(1000);
}
 
int tem_conv(void)
{
temperature=(((float)adc_process()/1023)*3.3*100);
return(temperature);
}

Try this code..
 

    V

    Points: 2
    Helpful Answer Positive Rating
Hai friend...what changes have you made in that code? I can't see any changes.
 

it is just as before ...When I debug the program Im getting the adc value and temperature value, corresponding to the voltage given. But when I do in Hardware I need to reset each time for getting the next output..The corresponding adc or temperature value is not coming in serially as soon as i change the value...
 

Perhaps you should think about this pretty pointless code snippet:
Code:
temp2=adc_process();
while((temp2-temp1)<=50);
temp1=temp2;

You don't need a debugger to see why it loops forever in the second program pass.

As another comment, this is really a kind of poor man's GSM handling. I would expect some interaction, waiting for command responses, e.g. OK or ERROR, ">" to send the actual SMS text etc.
 
  • Like
Reactions: ddnair

    ddnair

    Points: 2
    Helpful Answer Positive Rating
Hi friends...is there any method to find the current location using GSM only..(without using GPS). Currently I am working on a Vehicle Tracking System project...Please share with me if there...

Thanks in Advance
 

So can u please go through that program, and give a correct code to get the output...Please. I am a beginner, please help me.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top