PDA

View Full Version : PLIZ CHECK MY SCHEMATIC,pic16f84->max232->gsm phone



dumato52
- 13th March 2010, 12:32
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

Ioannis
- 13th March 2010, 13:25
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

keithdoxey
- 13th March 2010, 14:17
You may want to connect Pin 5 of J1 to ground ;)

dumato52
- 15th March 2010, 12:06
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

Ioannis
- 15th March 2010, 12:39
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

dumato52
- 15th March 2010, 18:59
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

keithdoxey
- 15th March 2010, 19:48
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.

Ioannis
- 16th March 2010, 10:52
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

dumato52
- 16th March 2010, 14:10
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

Ioannis
- 16th March 2010, 14:55
How about obtain a legal copy of the PBP compiler?

Ioannis

keithdoxey
- 16th March 2010, 17:06
pliz help me with the link for the manual and i try to follow it up. I dont have hard copy,

Help terminated !!!!

dumato52
- 18th March 2010, 09:46
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

Ioannis
- 18th March 2010, 11:20
Something like this?



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

dumato52
- 18th March 2010, 19:30
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

Ioannis
- 18th March 2010, 20:28
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

aratti
- 18th March 2010, 22:10
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.

Ioannis
- 18th March 2010, 22:52
Hi Al.

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

Ioannis

aratti
- 18th March 2010, 23:29
.... Are you aware of it?

Yes! I will upload it in the new forum as soon as I understand how does it work.

Al.

dumato52
- 19th March 2010, 17:08
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?

Ioannis
- 19th March 2010, 17:32
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

dumato52
- 20th March 2010, 10:25
I have found that i can use DLR3 cable, trying to look for and test
regards
dumato

dumato52
- 23rd March 2010, 08:55
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

Ioannis
- 23rd March 2010, 10:02
A million reasons!

Maybe the baud rate?

Ioannis

dumato52
- 23rd March 2010, 11:15
Thankyou Ioannis; i have tried to change the baud rates but still no response.
regards
dumato

Ioannis
- 23rd March 2010, 11:44
Usually the baud is at 9600 by default.

Also USB to Serial converters may pose an issue sometimes.

Ioannis

dumato52
- 25th March 2010, 11:54
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

Ioannis
- 25th March 2010, 21:33
No!

Ioannis

dumato52
- 26th March 2010, 08:07
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

Ioannis
- 26th March 2010, 09:13
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

dumato52
- 26th March 2010, 11:01
Thankyou Ioannis, am going to do that
regards
dumato

dumato52
- 6th April 2010, 16:13
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

Ioannis
- 6th April 2010, 20:47
Well, my car is not moving... what might be the problem???

Ioannis

dumato52
- 8th April 2010, 10:36
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

Ioannis
- 8th April 2010, 13:29
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

f_lez
- 8th April 2010, 13:47
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.....

dumato52
- 9th April 2010, 11:52
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

Ioannis
- 9th April 2010, 12:06
look here:

http://www.picbasic.co.uk/forum/showpost.php?p=87154&postcount=29

Ioannis

dumato52
- 24th April 2010, 12:46
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

Ioannis
- 24th April 2010, 13:59
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