PLIZ CHECK MY SCHEMATIC,pic16f84->max232->gsm phone


Closed Thread
Results 1 to 39 of 39
  1. #1
    Join Date
    Mar 2010
    Posts
    20

    Default PLIZ CHECK MY SCHEMATIC,pic16f84->max232->gsm phone

    Hullo friends
    Pliz check my schematic attached whether the connections are ok and guide me, the pic16f84 should instruct the phone to send SMS when push button is +5V, which phone do u suggest i use, help me with coding and any other advice,
    thankyou
    regards
    dumato
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    Post your code please.

    Hmm, wth no phone there is no help though.

    You have to select a phone with Serial port like the old 6210, 6310 of Nokia with the appropriate serial cable. But nowadays I think it is a little difficult to find such a device.

    May be you have to find a GSM module from an on-line shop (e-bay, sparkfun, digikey, etc)

    Once I used the Wavecom and have to same they are very good.

    About examples look at http://www.picbasic.co.uk/forum/showthread.php?t=3765

    There is code available but for specific model.

    Ioannis

  3. #3
    Join Date
    Feb 2003
    Posts
    432

    Default

    You may want to connect Pin 5 of J1 to ground
    Keith

    www.diyha.co.uk
    www.kat5.tv

  4. #4
    Join Date
    Mar 2010
    Posts
    20

    Default sample code

    Thankyou for ur contributions, about the code, am totally new in Picbasic programming but i got some code from the forum and tried to make it suit my project, it returns sucess when its pic616f877 what changes and additions should i make for it to suit pic16f84
    code:
    DEFINE OSC 4
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1

    'Setup the names that will be used throughout the program
    PushButton var PORTB.0 ' Setup the name PushButton to mean PortB input 0

    Main:

    IF PushButton = 0 THEN SMS 'If button is pressed then run the SMS routine below

    goto main ' however if the button is not pushed then just go back to the Main
    ' routine to wait for the button to be pressed

    SMS: ' this is the SMS commands routine in order to send an SMS

    HSEROUT ["AT" ,13,10] ' send AT to modem followed by a CR and line feed

    HSERIN 5000, SMS, [WAIT("OK")] ' now wait for 5secs until OK is received however
    ' if it is not then goto the SMS routine again

    HSEROUT ["AT+CMGF=1" ,13,10]

    HSERIN 5000, SMS, [WAIT("OK")]

    HSEROUT ["AT+CMGS=+256782277658"]

    HSEROUT [13,10]

    HSERIN 5000, SMS, [WAIT(">")]

    HSEROUT ["BUTTON HAS BEEN PRESSED!"]

    HSEROUT [26] ' this is ASCII for Ctrl+Z of which completes SMS sending

    HSERIN 15000, SMS, [WAIT("+CMG")] ' then PIC should receive +CMG from modem

    HSEROUT [10] 'ascii code for a line feed

    end

    Pliz help me
    regards
    dumato

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    1. Get rid off 16F84. It does not have Hardware Serial Port. It is old. It is too expensive too. From direct.microchip.com you can order whatever you want at very low cost.

    2. If you insist on using the F84 part, you have to change the commands from HSERIN/HSEROUT to SERIN/SEROUT or SERIN2/SEROUT2 as these are the software commands. Read the Manual for these. Almost the same as the hardware ones.

    But I really do recommend to use other chip.

    Ioannis

  6. #6
    Join Date
    Mar 2010
    Posts
    20

    Default pic16f84

    Thankyou Ioannis, currently its pic16f84 available for my project and in my country its hard to get access to microcontrollers so i have to just utilize it.
    I have replaced HSERIN/HSEROUT with SERIN/SEROUT but still generating errors,probably i have change something again;
    After changing this is the code:
    DEFINE OSC 4
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1

    'Setup the names that will be used throughout the program
    PushButton var PORTB.0 ' Setup the name PushButton to mean PortB input 0

    Main:

    IF PushButton = 0 THEN SMS 'If button is pressed then run the SMS routine below

    goto main ' however if the button is not pushed then just go back to the Main
    ' routine to wait for the button to be pressed

    SMS: ' this is the SMS commands routine in order to send an SMS

    SEROUT ["AT" ,13,10] ' send AT to modem followed by a CR and line feed

    SERIN 5000, SMS, [WAIT("OK")] ' now wait for 5secs until OK is received however
    ' if it is not then goto the SMS routine again

    SEROUT ["AT+CMGF=1" ,13,10]

    SERIN 5000, SMS, [WAIT("OK")]

    SEROUT ["AT+CMGS=+256782277658"]

    SEROUT [13,10]

    SERIN 5000, SMS, [WAIT(">")]

    SEROUT ["BUTTON HAS BEEN PRESSED!"]

    SEROUT [26] ' this is ASCII for Ctrl+Z of which completes SMS sending

    SERIN 15000, SMS, [WAIT("+CMG")] ' then PIC should receive +CMG from modem

    SEROUT [10] 'ascii code for a line feed

    end

    regards
    dumato

  7. #7
    Join Date
    Feb 2003
    Posts
    432

    Default

    The defines you have that start with "HSER" are for a harware serial port which the F84 doesnt have therefore the compiler will not be happy with you trying to define a non existant value.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    Please READ the manual about the Syntax of the Commands.

    You do not define the port pin, the baud rate. No wait for Serin (only for Serin2). No square brackets for the variables. Only in Serin2.

    Same for the Serout/Serout2.

    And as keithdoxey noted, no DEFINEs as these are for he Hserin/Hserout.

    I do not like the "read he manual" statement but I cannot teach you the Lanquage and how to write programs. It is something you have to do it yourself.

    Do you have a printed manual?

    Start by flashing a LED, as trivial may sound this.

    I even do this when I change PIC micro, just to be sure that I am in control of the new beast before I try anything more complicate.

    Ioannis

  9. #9
    Join Date
    Mar 2010
    Posts
    20

    Default

    Thankyou keith and Ioannis for ur contributions, pliz help me with the link for the manual and i try to follow it up. I dont have hard copy, mean while i wil make the changes u have told me
    regards

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    How about obtain a legal copy of the PBP compiler?

    Ioannis

  11. #11
    Join Date
    Feb 2003
    Posts
    432

    Default

    Quote Originally Posted by dumato52 View Post
    pliz help me with the link for the manual and i try to follow it up. I dont have hard copy,
    Help terminated !!!!
    Keith

    www.diyha.co.uk
    www.kat5.tv

  12. #12
    Join Date
    Mar 2010
    Posts
    20

    Default

    I read through the manual and made the changes, now the new code is succesful with 16f84 but i wanted the same message to be sent to two phone numbers, pliz help me and check the code below;

    code:

    PushButton var PORTB.0 ' Setup the name PushButton to mean PortB input 0

    Main:

    IF PushButton = 0 THEN SMS 'If button is pressed then run the SMS routine below

    goto main ' however if the button is not pushed then just go back to the Main
    ' routine to wait for the button to be pressed

    SMS: ' this is the SMS commands routine in order to send an SMS

    SEROUT PORTB.1,6,["AT" ,13,10] ' send AT to phone followed by a CR and line feed

    SERIN PORTB.2,6,["OK"] ' now wait until OK is received

    SEROUT PORTB.1,6,["AT+CMGF=1" ,13,10]

    SERIN PORTB.2,6,["OK"]

    SEROUT PORTB.1,6,["AT+CMGS=+256782277658"]

    SEROUT PORTB.1,6,[13,10]

    SERIN PORTB.2,6,[">"]

    SEROUT PORTB.1,6,["BUTTON HAS BEEN PRESSED!"]

    SEROUT PORTB.1,6,[26] ' this is ASCII for Ctrl+Z of which completes SMS sending

    SERIN PORTB.2,6,["+CMG"] ' then PIC should receive +CMG from modem

    SEROUT PORTB.1,6,[10] 'ascii code for a line feed

    end

    regards

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    Something like this?

    Code:
    PushButton var PORTB.0 ' Setup the name PushButton to mean PortB input 0
    
    Main:
    
    IF PushButton = 0 THEN SMS 'If button is pressed then run the SMS routine below
    
    goto main ' however if the button is not pushed then just go back to the Main
    ' routine to wait for the button to be pressed
    
    SMS: ' this is the SMS commands routine in order to send an SMS
    
    SEROUT PORTB.1,6,["AT" ,13,10] ' send AT to phone followed by a CR and line feed
    
    SERIN PORTB.2,6,["OK"] ' now wait until OK is received
    
    SEROUT PORTB.1,6,["AT+CMGF=1" ,13,10]
    
    SERIN PORTB.2,6,["OK"]
    
    SEROUT PORTB.1,6,["AT+CMGS=+256782277658"]
    
    SEROUT PORTB.1,6,[13,10]
    
    SERIN PORTB.2,6,[">"]
    
    SEROUT PORTB.1,6,["BUTTON HAS BEEN PRESSED!"]
    
    SEROUT PORTB.1,6,[26] ' this is ASCII for Ctrl+Z of which completes SMS sending
    
    SERIN PORTB.2,6,["+CMG"] ' then PIC should receive +CMG from modem
    
    SEROUT PORTB.1,6,[10] 'ascii code for a line feed
    
    '---------- second number------------
    
    SEROUT PORTB.1,6,["AT+CMGS=+000222333666444"]
    
    SEROUT PORTB.1,6,[13,10]
    
    SERIN PORTB.2,6,[">"]
    
    SEROUT PORTB.1,6,["BUTTON HAS BEEN PRESSED!"]
    
    SEROUT PORTB.1,6,[26] ' this is ASCII for Ctrl+Z of which completes SMS sending
    
    SERIN PORTB.2,6,["+CMG"] ' then PIC should receive +CMG from modem
    
    SEROUT PORTB.1,6,[10] 'ascii code for a line feed
    
    end
    Ioannis

  14. #14
    Join Date
    Mar 2010
    Posts
    20

    Default phone interface

    Thank you Ioannis, i highly appreciate ur help;
    Now i need to connect the phone to microcontroller, am looking for the models u told me nokia 6210, 6310 but i needed to know when i acquire the phone, how do i test whether it supports AT commands, any software i need to instal?
    regards
    dumato

  15. #15
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    I would recommend to find a GSM module or a device like the Wavecom, Siemens or other brand. All support AT commands.

    Mobile phones are not designed for this job, although they will work eventually.

    Ioannis

  16. #16
    Join Date
    May 2008
    Location
    Italy
    Posts
    825

    Default

    Ioannis, I would stress your above recommendation adding that some old phone will accept AT command, but they will work only in PDU mode, while the OP needs to work in Text mode.

    Al.
    All progress began with an idea

  17. #17
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    Hi Al.

    Your project related to GSM remote control has been down. Are you aware of it?

    Ioannis

  18. #18
    Join Date
    May 2008
    Location
    Italy
    Posts
    825

    Default

    .... Are you aware of it?
    Yes! I will upload it in the new forum as soon as I understand how does it work.

    Al.
    All progress began with an idea

  19. #19
    Join Date
    Mar 2010
    Posts
    20

    Default phone interface

    Thankyou for ur advice on GSM module but i think i can easily get 6210/6310 nokia in my country, how do i test whether it supports AT commands?, will it be affected by the baud rate i set at 9600?

  20. #20
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    It does support the full AT commands from Nokia. you have to find that AT command manual though.

    You will also need a specific cable from Nokia to RS-232.

    Ioannis

  21. #21
    Join Date
    Mar 2010
    Posts
    20

    Default phone interface

    I have found that i can use DLR3 cable, trying to look for and test
    regards
    dumato

  22. #22
    Join Date
    Mar 2010
    Posts
    20

    Default Hyperterminal

    When i connnect the phone to the PC and test the cable with hyperterminal, there is no response thats no ERROR or OK, what could be the problem,
    I used the following commands at the hyperterminal,

    AT
    I expected OK or ERROR but its blank
    AT+CPIN?
    I expected +CPIN? READY OR ERROR but blank also

    Could it be the cable?, PC or settings of PC, pliz guide me.
    regards
    dumato

  23. #23
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    A million reasons!

    Maybe the baud rate?

    Ioannis

  24. #24
    Join Date
    Mar 2010
    Posts
    20

    Default hyperteminal

    Thankyou Ioannis; i have tried to change the baud rates but still no response.
    regards
    dumato

  25. #25
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    Usually the baud is at 9600 by default.

    Also USB to Serial converters may pose an issue sometimes.

    Ioannis

  26. #26
    Join Date
    Mar 2010
    Posts
    20

    Default size of hex file

    When i compile my code i generate HEX file of 3KB which cant fit PIC16F84, since its limit is 1KB is there a way i can compress it and load it into pic16f84
    regards

  27. #27
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    No!

    Ioannis

  28. #28
    Join Date
    Mar 2010
    Posts
    20

    Default change of pic

    Thankyou Ioannis, Now the only choice is to change pic but i will have to just to simulate it bse i had only pic16f84, but wen i changed to pic16f877 and tried to simulate, nothing appeared on virtual terminal and proteus gave me this message ''can't perform real time simulation due CPU overlaod, what should i do?
    regards
    dumato

  29. #29
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    I never use simulators of any kind. And Never ever write the whole program at once. I am not Darrel or Melanie...

    What I do is:

    1. Whenever I change PIC, I start by a led and a button. Just 3 lines of code to read the button and light the LED.

    2. Then I add a serial port to see on a terminal what is happening to the PIC.

    3. Then an LCD and see if it works.

    4. Then...

    Ioannis
    Last edited by Ioannis; - 9th April 2010 at 12:05.

  30. #30
    Join Date
    Mar 2010
    Posts
    20

    Default simulation

    Thankyou Ioannis, am going to do that
    regards
    dumato

  31. #31
    Join Date
    Mar 2010
    Posts
    20

    Default simulation

    I have practiced simulation, now i was trying to simulate my project above but Virtual terminal is showing AT,AT, AT contineously after pressing ON the push button. What could be the problem?
    regards

  32. #32
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    Well, my car is not moving... what might be the problem???

    Ioannis

  33. #33
    Join Date
    Mar 2010
    Posts
    20

    Default

    Hullo Ioannis, probably u needed details,my code is below,am using pic16f877,
    code:
    DEFINE OSC 8
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1

    PushButton var PORTB.0

    Main:

    IF PushButton = 0 THEN SMS

    goto main

    SMS:

    HSEROUT ["AT" ,13,10]

    HSERIN 5000, SMS, [WAIT("OK")]

    HSEROUT ["AT+CMGF=1" ,13,10]

    HSERIN 5000, SMS, [WAIT("OK")]

    HSEROUT ["AT+CMGS=+256782277658"]

    HSEROUT [13,10]

    HSERIN 5000, SMS, [WAIT(">")]

    HSEROUT ["BUTTON HAS BEEN PRESSED!"]

    HSEROUT [26]

    HSERIN 15000, SMS, [WAIT("+CMG")]

    HSEROUT [10]

    end

  34. #34
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    Your AT you see, is every 5 seconds, right?

    The Hserin command times out on 5000 msec because it does not receive any response, like an OK.

    I will repeat my self again now telling that simulation is not a panacea...

    Ioannis

  35. #35

    Default

    cant help much with code but i am currently doing very much the same with a 2550, as i found the f84/f88 to be short of code space.

    the t68i will connect direct to a pic and is 5v tolerant, it works at 9600 and better at 4800, but 1200 gave best performance with 0 errors.

    the t68i only works in pdu mode, but you can make the pdu stings in pduspy, and then just cut/paste them into your code for sending.

    decoding is a little more tricky.... but you can cheat by reading your message in pdu and comparing it to what it should look like in pdu, you never need to use plain text, and should stop thinking of sms messages as messages and think of them as response strings, and as with all response strings, you compare them to what they should look like, its just as easy to compare 'ok' to 'ok' as it is to compare 32'65'66'67 to 32'65'66'67 as it is to ' ABC' - why waste time converting in chip, when you can convert before compile and just use the converted string.....

    good luck.

    and move to a bigger chip lol

    /comments on his SW status, he says he has no manual, not that he's a pirate, have you never lost a manual?

    and on my own point here, if he is a pirate, I'd sooner he was using PB and contributing to the group and not to some other group!


    flies/bees/honey/donkeys/carrots/sticks.....

  36. #36
    Join Date
    Mar 2010
    Posts
    20

    Default simulation

    Thankyou Ioannis and f Lez for your contributions, i got the point of no response from the virtual terminal, am wondering how can i make it respond, like when pic16f877 sends ''AT'' ,terminal is supposed to respond ''OK'',
    Do i need to use two virtual terminals? pliz guide me
    regards

  37. #37
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

  38. #38
    Join Date
    Mar 2010
    Posts
    20

    Default code

    Thankyou Ioannis, i have decided to remove the option for the response from the phone since i think that can only be achieved practically not through simulation, BUT, i have encountered one problem!, When the push button(interrupt) is detected the microcontroller sends a message contineously, how can i stop this?, I want it to send a message only once on detection of an interrupt, my code is below
    regards
    code:

    BEGIN:
    if PORTD.2 = 0 then SEND_SMS
    GOTO BEGIN

    SEND_SMS:
    sound PORTB.2,[100,10,50,10]
    HIGH PORTB.6
    HSEROUT ["at+cmgs=",34,"+256782277658",34,13]
    PAUSE 1000
    HSEROUT ["An interruption has occured",34,13]
    LOW PORTB.6
    pause 1000
    HIGH PORTB.6
    HSEROUT ["at+cmgs=",34,"+256772021358",34,13]
    PAUSE 1000
    HSEROUT ["An interruption has occured",34,13]
    goto BEGIN

  39. #39
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default

    Isn't it obvious? What are your code doing?

    1. Button pressed?

    2. Yes, goto send SMS

    3. Button pressed?

    4. Yes, goto send SMS

    5. .....

    You are in an endless loop.

    You may check if the button is released before sending another SMS.

    Or have a timer to send every say 10minutes if the button is still pressed.

    Or have a flag set in the sending SMS routine and cleared when the button is released

    Or...

    Ioannis

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