View previous topic :: View next topic |
Author |
Message |
khawer102
Joined: 14 Mar 2006 Posts: 9 Location: Pakistan
|
Problems with reading from a serial port |
Posted: Tue Mar 14, 2006 8:13 am |
|
|
I am using a PIC 18F452 microcontroller. i was interfacing the controller with a GSM modem. when i send the AT commands to the serial port i am unable to read the response from the modem.
Can somebody please help me in using GSM modems for sending SMS through a PIC 18F452 |
|
|
Donlaser
Joined: 17 Sep 2005 Posts: 12 Location: Trenque Lauquen, Argentina
|
|
Posted: Tue Mar 14, 2006 11:17 am |
|
|
Most modems use a hardware handshake protocol, you need to control or loop togheter the handshakes lines.
In the development a similar product i find very useful monitor the communication between pic18f252 and the motorola g20 modem using a 'T' plug and a PC to monitor comms as described in
http://www.airborn.com.au/rs232.html
In this page you find how to loop together the handshake lines. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
Re: Problems with reading from a serial port |
Posted: Tue Mar 14, 2006 6:43 pm |
|
|
khawer102 wrote: | I am using a PIC 18F452 microcontroller. i was interfacing the controller with a GSM modem. when i send the AT commands to the serial port i am unable to read the response from the modem.
Can somebody please help me in using GSM modems for sending SMS through a PIC 18F452 | Try searching this forum for similar projects. If that doesn't help you can post your code and we will have a look. |
|
|
michellelicious
Joined: 15 Apr 2007 Posts: 3
|
Hello, need help here :) |
Posted: Tue Apr 17, 2007 1:31 am |
|
|
Hi , im michelle, i was wondering if ever someone can send me a schematic on what would the circuit would be to interface PIC16F877a with a PC via RS232. Which will likely involve using a MAX232 chip... Iam also doing a similar project wherein your goal is to use a PIC MCU and a GSM module to send SMS. Im using CCS C Compiler btw. Please if anyone has a schematic send it to my EMAIL ADDRESS WHICH IS [email protected]
XoX
Michelle
|
|
|
K.Suresh Guest
|
PIC16F877A to PC connection using MAX232 |
Posted: Tue Apr 17, 2007 9:43 pm |
|
|
hi michelle,
from PIC 16F877 A to PC through MAX232, here are the connection details
At MAX 232
0.1 or 1uF or 10uF between pins 1 and 3( + of capacitor to pin 1)
0.1 or 1uF or 10uF between pins 4 and 5( + of capacitor to pin 4)
0.1 or 1uF or 10uF between pins 6 and ground ( + of capacitor to ground)
0.1 or 1uF or 10uF between pins 2 and 16 ( + of capacitor to pin 2)
pin 16 to +5V i.e VCC
0.1uF MLC capacitor between Pin 16 to Pin15
pin15 to ground
pin 9 to pin 26 of PIC16F877A
pin 10 to pin 25 of PIC16F877A
At PC end
use a DB9 connector with
pin 2 connected to pin 7 of MAX 232
pin 3 connected to pin 8 of MAX 232
pin 5 connected to pin 15 of MAX 232
To test the MAX232 working or not, remove the PIC16F877A, short 7 and 8 of MAX232. Now connect your DB9 connector to COM( 1 or 2) port of your PC.
Use any serial I/O test program like SIOW.exe available with CCS C compiler or Hyperterminal program available in your PC.
Now whatever character you key in should echo back.. if you get that, you have established good MAX232 ckt..
Rest to put PIC16F877A into work..
With PIC, don't forget to put correct delay statement (clock), #use RS232 statement in case if you use CCS C compiler..
Hope the above helps... |
|
|
NadSura Guest
|
Re: PIC16F877A to PC connection using MAX232 |
Posted: Tue Aug 07, 2007 6:04 am |
|
|
Instead of short circuiting pin 7 and pin 8. Short Circuit pin 9 and pin 10.
You can not test if the circuit is working correctly by short circuiting pin 7 and pin 8 because when you do so it will short circuit 2 & 3 of DB9 connector.
Pin 2 & pin 3 of DB9 is the receiver and transmitter. so whether you connect the circuit or not what you type echoes back. To check whether the serial communication is done well, you can initially short circuit pin2 & pin 3 of the DB connector!
Hope this correction will help! |
|
|
Guest
|
|
Posted: Mon Aug 10, 2009 9:04 am |
|
|
Like I said there is a problem with my program on pic 18f452 using the gsm but I am not able to get the sms on my phone. What's the problem, because it successfully healed but failed on the chip. Pls help me.
Code: |
#include <18f452.h>
#include <stdio.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
const int cr=0x0D; // PIC press ENTER
const int cz=0x1A; // PIC press Control-Z
BYTE blink = 1;
#int_ext
void interrupt_isr() {
delay_ms (20); //debounce
if( !input(PIN_B0) && !blink )
blink = 1;
else
if( !input(PIN_B0) && blink )
blink = 0;
}
void main() {
setup_adc_ports(NO_ANALOGS);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
INPUT_b();
enable_interrupts(global);
enable_interrupts(int_ext); ext_int_edge( H_TO_L );
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, stream=GSM1,errors)
delay_us(1);
output_a(0x00);
do {
if(blink)
{
output_high( PIN_A0 );
fprintf (GSM1, "AT");
fputc (cr, GSM1); // send ENTER (carriage return) signal
delay_ms (2000); // wait half second
fprintf (GSM1, "AT+CMGF=1");
fputc (cr, GSM1);
delay_ms (2000);
fprintf (GSM1, "AT+CMGS=\"0786417982\"");
fputc (cr, GSM1);
delay_ms (2000);
fprintf(GSM1,"Stranger");
fputc (cz,GSM1);
delay_ms (2000);
//fputc (cr,GSM1);
output_low( PIN_A0 );
}
} while( TRUE );
}
|
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Aug 10, 2009 4:34 pm |
|
|
Hello unknown guest user. I have no idea what you are talking about, but I do know you posted this in the wrong thread. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Aug 10, 2009 8:45 pm |
|
|
hi, I'm doing the exact same project
but with a 16F877A
I can tell you which problems I've ran into:
1) You are getting more characters than you expect from the gsm module.
2) You haven't used the right control lines.
3) My pic sends data but doesn't receive...I have alot of static problems and noise... when they start affecting my circuit.. the first thing that stops working is the receiving part of my program/circuit, even though the program seems like its running since it flashes every single debug LED I've got on it...
suggestions:
Write a small program, start really basic..
just getting an "OK" from your modem by sending "AT"
just to test the communication between modem and PIC.
Be careful how you receive your data on your pic/program
if you don't have a fast #INT_RDA ISR you might miss some characters...
Which might make your program not respond appropriately...thus appearing like its not getting any data...
and once more, make sure your control lines are in fact controlling something.
Also... like a previous user mentioned...
This not a gsm forum.... but if what you need is help with your code..
welcome....I try to keep my questions as programing related as I can...
telling people what your working does help us (mostly them, since I'm having alot of problems of my own) guide you in the right direction.
These guys here know alot... and are pretty good at helping...
I only help... because I'm the same boat as you are...
hope I helped
gabriel _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Aug 10, 2009 8:51 pm |
|
|
also
delay_ms(2000); is not half a second... that would be 2 whole seconds.
In your code I never saw you check your communication with the gsm module.
You just send commands...
You have no way of telling if your gsm module is actually getting what you send.
... follow my previous advice... it might get you going....
It worked for me.
gabriel _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
fandall Guest
|
questions |
Posted: Sat Feb 06, 2010 10:12 pm |
|
|
hi, i see you code for programing uC to use sms with AT command,
can you read sms with uC?
what is the code for this?
thanks from colombia
fabiavargas___g__m__a___i__l |
|
|
|