pls help me w/ my program....


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2011
    Posts
    4

    Default pls help me w/ my program....

    Im just a beginer in programing and in making circuits... im currently doing my project... i used PIC16F877A and a GSM benqM23... the problem is the replying of my device... my project are compost of different sensors and when it detect it will send message to the given number and also you can send message to the device and it will reply to you... the sending part is ok but the reply part is not working... when i seperate the program for the reply it works well but when i combined it with the program of my sensor and sending it doesnt work... i dont know the problem if it is my program or my device... some one pls help me... here is my program...

    my current program----> the reply part is not working
    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 2/28/2011 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    DEFINE OSC 4
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1
    DEFINE HSER_SPBRG 12
    adcon1=7
    cmcon=7

    trisa=1
    trisb=1
    trisc=1
    trisd=0
    trise=1

    y1 var byte[2]
    y2 var byte[8]

    pass1 var bit
    pass2 var bit
    pass3 var bit

    a0 var porta.0
    a1 var porta.3
    a2 var porta.5
    a3 var porte.2

    b0 var portb.0
    b1 var portb.1
    b2 var portb.3
    b3 var portb.4
    b4 var portb.5
    b5 var portb.6
    b6 var portb.7

    c0 var portc.0
    c1 var portc.1
    c2 var portc.2

    d0 var portd.0
    d1 var portd.1
    d2 var portd.2
    d3 var portd.3
    d4 var portd.4
    d5 var portd.5
    d6 var portd.6
    d7 var portd.7

    e0 var porte.0
    e1 var porte.1

    y1[0]="0"
    y1[1]="0"

    pass1=0
    pass2=0
    pass3=0

    a0=1
    a1=1
    a2=1
    a3=1

    b0=1
    b1=1
    b2=1
    b3=1
    b4=1
    b5=1
    b6=1

    c0=1
    c1=1
    c2=1

    e0=1
    e1=1


    portd=%11111111
    pause 250
    HSerout ["AT+CMGF=1",13]
    Pause 500
    HSEROUT ["AT+CMGDA=",34,"DEL ALL",34,13]
    pause 500
    portd=%00000000

    main:
    while 1

    HSerin 5000, main2, [WAIT("SM")]
    gosub reply
    goto main

    main2:

    if a0=0 then
    y1[0]="1"
    y1[1]="6"
    y2[0]="C"
    y2[1]="R"
    y2[2]="I"
    y2[3]="T"
    y2[4]="I"
    y2[5]="C"
    y2[6]="A"
    y2[7]="L"
    portd=%00000001
    pause 500
    portd=%00000000
    pause 500
    if pass1=0 then
    gosub send1
    pass1=1
    pass2=0
    pass3=0
    endif
    goto main
    endif

    if a1=0 then
    y1[0]="1"
    y1[1]="5"
    y2[0]="A"
    y2[1]="L"
    y2[2]="R"
    y2[3]="M"
    y2[4]=32
    y2[5]=32
    y2[6]=32
    y2[7]=32
    portd=%00000011
    pause 500
    portd=%00000000
    pause 500
    if pass2=0 then
    gosub send1
    pass2=1
    pass1=0
    pass3=0
    endif
    goto main
    endif

    if a2=0 then
    y1[0]="1"
    y1[1]="4"
    y2[0]="A"
    y2[1]="L"
    y2[2]="E"
    y2[3]="R"
    y2[4]="T"
    y2[5]=32
    y2[6]=32
    y2[7]=32
    portd=%00000111
    pause 500
    portd=%00000000
    pause 500
    if pass3=0 then
    gosub send1
    pass3=1
    pass1=0
    pass2=0
    endif
    goto main
    endif

    IF a3=0 then
    y1[0]="1"
    y1[1]="3"
    goto main
    endif

    IF b0=0 then
    y1[0]="1"
    y1[1]="2"
    goto main
    endif

    IF b1=0 then
    y1[0]="1"
    y1[1]="1"
    goto main
    endif

    IF b2=0 then
    y1[0]="1"
    y1[1]="0"
    goto main
    endif

    IF b3=0 then
    y1[0]="9"
    y1[1]=32
    goto main
    endif

    IF b4=0 then
    y1[0]="8"
    y1[1]=32
    goto main
    endif

    IF b5=0 then
    y1[0]="7"
    y1[1]=32
    goto main
    endif

    IF b6=0 then
    y1[0]="6"
    y1[1]=32
    goto main
    endif

    IF c0=0 then
    y1[0]="5"
    y1[1]=32
    goto main
    endif

    IF c1=0 then
    y1[0]="4"
    y1[1]=32
    goto main
    endif

    IF c2=0 then
    y1[0]="3"
    y1[1]=32
    goto main
    endif

    IF e0=0 then
    y1[0]="2"
    y1[1]=32
    goto main
    endif

    IF e1=0 then
    y1[0]="1"
    y1[1]=32
    goto main
    endif

    wend

    send1:
    portd=%11111111
    pause 500
    portd=%00000000
    pause 500
    HSEROUT ["AT+CMGS=",34,"09166494457",34,13]
    pause 1000
    HSerout [y2[0],y2[1],y2[2],y2[3],y2[4],y2[5],y2[6],y2[7]," Water Level: ",y1[0],y1[1],26]
    PAUSE 2000
    portd=%01010101
    pause 500
    portd=%00000000
    pause 500
    return

    reply:
    portd=%00001111
    pause 500
    portd=%00000000
    pause 500
    HSEROUT ["AT+CMGS=",34,"09166494457",34,13]
    portd.6=1
    pause 1000
    HSerout ["Water Level: ",y1[0],y1[1],26]
    portd.5=1
    pause 2000
    return
    my program for replying only----> it works well
    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 11/19/2010 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    DEFINE OSC 4
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1
    DEFINE HSER_SPBRG 12
    adcon1=7
    cmcon=7
    'GSMBUFFER VAR BYTE[16]
    'Caller VAR BYTE[13]
    'GSMTime VAR BYTE[17]
    trisa=%11111111
    trisd=%00000000
    text var byte[4]
    text[0]="1"
    text[1]="2"
    text[2]="3"
    text[3]="4"
    portd=%111111111
    pause 2000
    HSerout ["AT+CMGF=1",13]
    Pause 500
    HSEROUT ["AT+CMGDA=",34,"DEL ALL",34,13]
    PAUSE 3000
    main:

    WHILE 1
    portd=%00000000
    portd.0=1
    PAUSE 500
    portd=%00000011
    pause 500
    HSERIN 5000, main, [WAIT("SM")]
    portd.7=1
    pause 1000
    HSEROUT ["AT+CMGS=",34,"09166494457",34,13]
    portd.6=1
    pause 1000
    HSerout ["WATER LEVEL: ",text[0],text[1],"m",26]
    portd.5=1
    pause 2000
    HSERIN 2000, main, [WAIT("OK")]
    portd=%11111111
    PAUSE 2000
    HSEROUT ["AT+CMGD=1",13]
    HSERIN [WAIT("OK")]
    portd=%10101010
    PAUSE 400
    portd=%00000000
    PAUSE 400
    WEND

  2. #2

    Default Re: pls help me w/ my program....

    Hi...may i ask first what's the purpose of the a0...a3 variables?

    am I understanding correctly that your program waits for "SM" from the modem for 5 seconds if not goes to main2? then if the modem does reply with "SM" yo go directly to reply...

  3. #3
    Join Date
    Mar 2011
    Posts
    4

    Default Re: pls help me w/ my program....

    hellow master_olan... the purpose of the a0...a3 is just to declared it as port.a0...port.a5 and etc... because my input for my sensor is port a,b,c,e...

    yes you are right about the purpose of the program it is to waits for "SM" from the modem for 5 seconds if not it goes to main2... then if the modem does reply with "SM" it go directly to reply.

    The replying program only is working well... but when i put it in the program of sensors and send it doesnt work... i dont know the problem why is not working... may be the declaration of

    DEFINE OSC 4
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1
    DEFINE HSER_SPBRG 12
    adcon1=7
    cmcon=7
    i dont know if i declared it right....

  4. #4

    Default Re: pls help me w/ my program....

    Well I programmed a PIC16f877a to a GSM modem for a friend some months ago... I also had problems with receiving data from Modem to PIC and added a buffer (74LS125)... It worked after that... also try changing this:
    DEFINE HSER_TXSTA 20h
    to this:
    DEFINE HSER_TXSTA 24h
    the manual says 24h works with high speed baud rates.. It's what I did with mine...
    Last edited by master_olan; - 4th March 2011 at 03:44.

  5. #5
    Join Date
    Mar 2011
    Posts
    4

    Default Re: pls help me w/ my program....

    Hellow master_olan thanks again for your help and reply... sorry for my noob question but where i should put the buffer... sorry im just a beginer in making circuits... it would be a great help if you can post a schematic diagram of your MUC with buffer... and thanks a lot

  6. #6

    Default Re: pls help me w/ my program....

    Well... just connect GSM Mod. TX to input of buffer then output of buffer to RX of PIC... Just like this...

    If that doesn't work i suggest you spy in your system by using the PCs hyperterminal.. That way you will know if the Module or the PIC does respond to the commands...

    I hope any of these will help you...

  7. #7
    Join Date
    Mar 2011
    Posts
    4

    Default Re: pls help me w/ my program....

    hi master_olan
    I Did all the things you said but it did not work... i also check it in pc but still the reply did not work... any suggestion or solution? thank you for your help and effort

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts