Click here to Skip to main content
15,945,119 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am totally new to these commands and am going to start a project which is as follows:

I am going to work on a project that will turn on or off the electrical equipments in your home by sending "sms" from your personal cellphone to the home cellphone.

For this I require two modems .
One that will send the sms(My Cellphone) and one that will receive the SMS(Cellphone at home).

I have got two modems and a SIMCOM 300 Chip On which I want to write the AT Commands to retrive the SMS From my home modem and according to the command(Let Us Say "FAN OFF/ON")it will turn ON or OFF my Electrical Equipments in my home.

I have also got a GM28 Chip.

Please Suggest me any Idea Or any Sites To reffer to for initially starting and completing my project.Again I am totally blank about the AT programming Thing.

After a lot of search I have found a programming code to do the stuff but it is of no use untill I fully Understand it.

I have pasted the code here for any reference.
The file is in .asm format.
Please help :doh:


CSS
;
;
;   REMOTE CONTROL WITH SMS, FOR ERICSSON T10 GSM MOBILE PHONES
;
;   This circuit can handle 8 devices by sending SMS message with a mobile phone.
;   30-oct-2002 v1.0
;   04.10.2003  v1.01 --- I have change some routines to be more workable
;   writed with AVR studio 4.2
;
;
;   by Serasidis Vasilis
;
;   Home: http://www.serasidis.gr
;   email: info@serasidis.gr
;
;
;   Target: AT90S2313 with 8 MHz crystal
;   PD0= RxD
;   PD1= TxD
;   PB0-PB7= 8 bit output. You can drive with this port, 8 relays, 1 to eatch pin.
;   Send SMS message to T10, like this format: 11100101
;   That its mean, arm the relays No 1,3,6,7,8 and disarm the relays 2,4 and 5.
;
;
;

.nolist             ;Suppress listing of include file
.include "2313def.inc"      ;Define chip particulars
.list
.equ    BAUD    =51         ;9600 bps at 8.00 MHz.
.def    temp    =R16        ;temporary storage register
.def    EEard   =R17        ;EEPROM address to read from
.def    Txbyte  =R18        ;Data to be transmitted
.def    Rxbyte  =R19        ;Received data
.def    temp2   =R20
.def    temp3   =R21
.def    temp4   =R25
.def    temp5   =R29
.def    temp6   =R30
.def    ramtemp =r24        ;temporary storage register
.def    ramsize =r22        ;size of block to be copied
.def    EEard   =R23        ;EEPROM address to read from
.def    RamAdr  =R26
.def    delay1  =R27
.def    delay2  =R28
.def    delay3  =R31
.cseg
.org    0
;========================================================================
reset:
;   Setup buffers and pointers

    ldi     temp,RAMEND
    out     SPL,temp    ;Init Stack Pointer

    ldi     temp,0b11111111
    out     DDRB,temp
    ldi     temp,BAUD
    out     UBRR,temp   ;Set baud rate generator

;===========   Set UART, as Transmiter   =====================
    ldi     temp,0b00011000
    out     UCR,temp    ;Enable UART Tx w/o interrupts
;==============================================================
    rcall   long_delay
    ldi     EEard,0x17
load:
    rcall   eeread
    tst     Txbyte      ;see if at end of message
    breq    br1         ;if zero found, start over
    rcall   b_transmit  ;sent out char
    rjmp    load

br1:ldi     ramadr,96   ;Its the first byte of RAM
    ldi     temp2,16    ;16 bytes ram
uart2ram:
    rcall   receive     ;call getchar
    mov     YL,ramadr   ;init Z-pointer
    st      Y+,rxbyte   ;store data to RAM
    inc     ramadr      ;
    dec     temp2
    brne    uart2ram    ;if not done, loop more
    ldi     ramadr,96   ;
;--------------------------------------------------------
    ldi     ramadr,102  ;Memory potition for letter 'G' in ram
    mov     YL,ramadr   ;Send the ram address
    ld      txbyte,Y+   ;load the contain of selected potition
    cpi     txbyte,'G'  ;Look if its 'G' letter
    breq    aa          ;If yes, go to read all message from the phone
;--------------------------------------------------------
    ldi     EEard,37
    rcall   delay
    rcall   delay
    rcall   delay
    rcall   delay
    rjmp    load
;===================================================================
aa: ldi     EEard,37
load2:
    rcall   eeread
    rcall   b_transmit  ;sent out char
    tst     Txbyte      ;see if at end of message
    brne    load2       ;if zero found, start over
    ldi     ramadr,96   ;Its the first byte of RAM
    ldi     temp2,87    ;87 bytes ram
uart2ram2:
    rcall   receive     ;call getchar
    mov     YL,ramadr   ;init Z-pointer
    st      Y+,rxbyte   ;store data to RAM
    inc     ramadr      ;
    dec     temp2
    brne    uart2ram2   ;if not done, loop more
;===================================================================
    rcall   nextline    ;\
    ldi     txbyte,'+'  ; \
    rcall   b_transmit  ;  \
    ldi     temp2,117   ;  / Print the service center number
    ldi     temp3,6     ; /
    rcall   read        ;/
    rcall   nextline    ;\
    ldi     txbyte,'+'  ; \
    rcall   b_transmit  ;  \
    ldi     temp2,135   ;  / Print the sender`s number
    ldi     temp3,6     ; /
    rcall   read        ;/
    rcall   nextline    ;\
    ldi     temp2,151   ; \
    ldi     temp3,1     ;  \
    rcall   read        ;   \
    ldi     txbyte,'-'  ;    \
    rcall   b_transmit  ;     \
    ldi     temp3,1     ;      \
    rcall   read        ;       |
    ldi     txbyte,'-'  ;       |
    rcall   b_transmit  ;       |
    ldi     temp3,1     ;       |
    rcall   read        ;       \
    ldi     txbyte,' '  ;       / Print the date and the time of the received message.
    rcall   b_transmit  ;       |
    ldi     temp3,1     ;       |
    rcall   read        ;       |
    ldi     txbyte,':'  ;       |
    rcall   b_transmit  ;      /
    ldi     temp3,1     ;     /
    rcall   read        ;    /
    ldi     txbyte,':'  ;   /
    rcall   b_transmit  ;  /
    ldi     temp3,1     ; /
    rcall   read        ;/
;=================================================================================
; Here its the routine for convert the ASCII to HEX and stored to RAM address 185
;=================================================================================

    ldi     temp2,185   ;
    ldi     temp3,8     ;8 bytes message
    ldi     ramadr,167  ;First byte of the message in the RAM (message like this 11001101)
septet:
    mov     YL,ramadr   ;
    ld      txbyte,Y+   ;
    subi    txbyte,0x30
    mov     eeard,txbyte
    rcall   eeread
    swap    txbyte
    mov     temp4,txbyte
    inc     ramadr
    mov     YL,ramadr   ;
    ld      txbyte,Y+   ;
    subi    txbyte,0x30
    mov     eeard,txbyte
    rcall   eeread
    add     temp4,txbyte
    mov     txbyte,temp4
    inc     ramadr
    mov     YL,temp2    ;init Z-pointer
    st      Y+,txbyte   ;store data to RAM
    inc     temp2
    dec     temp3
    brne    septet

;==============================================================
;       convert the HEX values to septets
;==============================================================
    clr     Rxbyte
    rcall   nextline    ;
    ldi     temp3,7     ; Number of septets (characters).
    ldi     ramadr,185  ;Load the 9 hex bytes from...
    ldi     temp5,7
    ldi     temp6,1
    mov     temp,temp6
    mov     delay1,temp5
    mov     YL,ramadr   ;\
    ld      txbyte,Y+   ; \ print the 1st septet
    cbr     txbyte,0x80 ; /
    rcall   b_transmit  ;/
    cpi     txbyte,0x31 ;Check if txbyte is 0x31
    brne    more        ;If not...
    sbr     Rxbyte,1    ;
more:
    lsl     Rxbyte
    mov     YL,ramadr   ;
    ld      temp2,Y+    ;
    inc     ramadr      ;
    mov     YL,ramadr   ;
    ld      txbyte,Y+   ;
dec6:
    lsl     txbyte      ;
    dec     temp
    brne    dec6
dect:
    lsr     temp2       ;rotate n times
    dec     delay1      ;
    brne    dect        ;
    add     txbyte,temp2    ;
    cbr     txbyte,0x80 ;
    cpi     txbyte,0x31 ;Check
    brne    aaa         ;If not go to
    sbr     Rxbyte,1

aaa:
    rcall   b_transmit
    inc     temp6
    mov     temp,temp6
    dec     temp5
    mov     delay1,temp5
    dec     temp3
    brne    more
    out     portB,Rxbyte    ;output the message from GSM to PortB
    rcall   long_delay
    ldi     EEard,49    ;Set the eeprom address to "Delete SMS" command
load3:
    rcall   eeread
    tst     Txbyte      ;see if at end of message
    breq    br2         ;if zero found, start over
    rcall   b_transmit  ;sent out char
    rjmp    load3
    ;rcall  nextline    ;
br2:ldi     EEard,37
    rjmp    load
;=====================================================
read:
    inc     temp2
    mov     ramadr,temp2
    mov     YL,ramadr
    ld      txbyte,Y+
    rcall   b_transmit
    dec     ramadr
    mov     YL,ramadr
    ld      txbyte,Y+
    rcall   b_transmit
    inc     temp2
    dec     temp3
    brne    read
    ret
;=============================================================
;=============================================================

EERead:
    sbic    EECR,EEWE   ;if EEWE not clear
    rjmp    EERead      ;    wait more
    out     EEAR,EEard  ;output address
;***** Issue EEPROM read strobe twice due to a bug in AVR!
    sbi     EECR,EERE   ;set EEPROM Read strobe 2nd time
                ;This instruction takes 4 clock cycles since
                ;it halts the CPU for two clock cycles
    in      Txbyte,EEDR ;get data
    rcall   delay
    inc     EEard       ;point to next EE address
    ret
    rjmp    EERead
    ret
;=============================================>

nextline:
    ldi     txbyte,0x0d
    rcall   b_transmit
    ldi     txbyte,0x0a
    rcall   b_transmit
    ret


;========================================================================

;***************************************************************************
; Transmiting routine (The data from the eeprom through the AVR are going to
; the PC computer)
;***************************************************************************
b_transmit:
    sbis    USR,UDRE    ;is UART transmitter ready?
    rjmp    b_transmit
    out     UDR,txbyte  ;sent out char
    ret
;*************************************************************************
; Receiving routine (The data from PC computer through to the AVR are going
; to the eeprom)
;*************************************************************************
receive:
    sbis    USR,RXC
    rjmp    receive
    in      Rxbyte,UDR
    ret
;*******************************************************************
;                   Stop and Delay routines
;*******************************************************************
long_delay:
    ldi     delay3,32
waitmore2:
    rcall   delay
    dec     delay3
    brne    waitmore2
    ret
delay:
    ldi     delay2,0xff
waitsome:
    ldi     delay1,0xff
waitmore:
    dec     delay1
    brne    waitmore
    dec     delay2
    brne    waitsome
    ret
.eseg
msg:    .db 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,"-------"
    .db 0x0A,0x0B,0x0C,0x0D,0x0E,0x0F
msg2:   .db "AT+CPMS=",'"',"ME",'"' ,0x0d,0x0a  ;Select the phone memory ("ME")
    .db "AT+CMGR=1" ,0x0d,0x0a, 0               ;read the received message(Memory possition 1)
    .db "AT+CMGD=1" ,0x0d,0x0a, 0               ;delete the received message (Memory possition 1)
Posted

1 solution

Well, I have no idea about the project you are working on, but I can help you with AT Commands and sending receiving SMS part.

Introduction to AT Commands[^]

Read the whole tutorial from the above site. It explains AT commands and it's use in sending and receiving SMS very well.

This should give you a good start. :thumbsup:
Get back in case you don't understand anything or need more help on this.
 
Share this answer
 
Comments
Be Yourself 29-Oct-10 4:18am    
thanks .. for Ur Help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900