Maker Pro
Maker Pro

pic programming help - controlling GSM to send message from PIC16F873A

ya. the whole code is getting executed but no SMS is received. I think there's a problem with the code. the logic is correct, but don't know if the code is exactly correct.
 
ya it's working.
the code is fully getting executed but the sms is not received. the logic is correct, but the code might not be exactly correct. correct me if u can.
 
ya it's working.
the code is fully getting executed but the sms is not received. the logic is correct, but the code might not be exactly correct. correct me if u can.

What is working, and how do you know it?

If you use the PIC, how is the connection between the PIC and the GSM unit?
Are you running it through a RS232 interface?
If not, do you use inverters for the TXD and RXD?

The logic signal from the PIC is inverted in the RS232 interface, and the GSM unit is running RS232 if you communicate via a COM port on the PC.
 

KrisBlueNZ

Sadly passed away in 2015
OK, as gorgon says, if the GSM modem connects directly to a COM port, you need an RS-232 transceiver IC between the PIC and the GSM modem to convert between logic levels and RS-232 levels. The transceiver also inverts the signals - transmitters convert logic low to positive voltage, and logic high to negative voltage, and receivers do the opposite.

Look into the MAX232 (or equivalents from other manufacturers).

What is the clock source for the PIC? Do you have an external crystal? If so, what is its frequency? How did you calculate the baud rate divisor to get 9600 baud?
 
I have the MAX 232 IC inbuilt in the GSM modem. I do use a external crystal oscillator 4MHz. I used to generate 9600 baud rate from reference to the Datasheet of the PIC (by specifying spbrg value). the PIC and GSm are interfaced using RS232 connector.
gorgon please refer to my previous post to see the interface between GSM and PIC.
 

KrisBlueNZ

Sadly passed away in 2015
The GSM modem probably does have a MAX232 inside it, to convert its internal logic-level signals to RS-232 levels. You need ANOTHER MAX232, on your board, to convert the RS-232-level signals back to logic levels that you can connect to your PIC.
 
so it should be like this, is it!


--------------- MAX232 for PIC-------------RS232-------------------MAX232 for GSM (inbuilt)
PIC------> (Tin )MAX232(Tout) -----------------------> (Rin)MAX232(Rout) ------> GSM
 
Last edited:

davenn

Moderator
so it should be like this, is it!


--------------- MAX232 for PIC-------------RS232-------------------MAX232 for GSM (inbuilt)
PIC------> (Tin )MAX232(Tout) -----------------------> (Rin)MAX232(Rout) ------> GSM

no, the other way around
the GSM is transmitting data, the PIC is receiving data


DAve
 

KrisBlueNZ

Sadly passed away in 2015
PIC TXD -----> (T.IN) MAX232 transmitter (T.OUT) -----> GSM "TXD" connection
PIC RXD <----- (R.OUT) MAX232 receiver (R.IN) <----- GSM "RXD" connection

The GSM modem, being a DCE (data communications equipment) component in the RS-232 conventions, should actually receive its data on the connection marked TXD; this connection is called TXD because it's the data transmitted by the PIC, which is a DTE (data terminal equipment, another RS-232 term), and it's also the data transmitted to the GSM network by the GSM modem.

Conversely, the data received from the GSM network by the modem should be sent out from the GSM modem on the connection marked RXD, and received by the serial port on your PIC board.

It's possible that the designers of the modem did not follow this RS-232 convention, which is very old. In that case, they may have swapped the names of the TXD and RXD signals at the GSM modem.

You can tell which way the modem is connected by just powering it up, and measuring the voltages on the two connections relative to the GND connection. One connection should have around 0V on it; this is the data input to the modem. The other connection should have a negative voltage of at least 3V on it; this is the data output from the modem.

If the negative voltage is present on the connection marked RXD, then the diagram at the top of this post is correct.

If the negative voltage is present on the connection marked TXD, then use this diagram instead:

PIC TXD -----> (T.IN) MAX232 transmitter (T.OUT) -----> GSM "RXD" connection
PIC RXD <----- (R.OUT) MAX232 receiver (R.IN) <----- GSM "TXD" connection

The only difference is that TXD and RXD at the GSM modem are swapped.
 
I would suggest that you connect your pic to a terminal, then you can make sure that the voltage is inverted correctly, the baud rate is correct and that the command is correct, also as you've already connected the modem to the terminal you then know for sure what the wiring should be
 
so, do I need to insert a MAX232 IC inbetween PIC and GSM (inbuilt MAX232) or not. I tried by inserting, but its not working
 
Here what you asked Kris!.
Richard, I cannot catch up what you said. could you be more detailed.
 

Attachments

  • block diagram2.png
    block diagram2.png
    17.7 KB · Views: 162

KrisBlueNZ

Sadly passed away in 2015
That's right, but it's not a complete diagram. Most of the detail is missing. Pin numbers, for example.

Also you haven't connected the data in the other direction. Even if it isn't needed (yet), you should connect it.
 

KrisBlueNZ

Sadly passed away in 2015
That looks right. I agree with Richard's suggestion: feed the RS-232 transmitted data into the received data connection of a serial port on a PC and run some terminal software on the PC. Set it to 9600 baud and see whether it receives the transmission from the PIC.

You can also use an oscilloscope or a logic probe to see whether there is data at the TXD output of the PIC and the RS-232 transmit output.
 
connect pin 14 on your max232 to pin 2 on the pc "d"type
connect 0v from your pic to pin 5 on the pc "d"type


download realterm

http://realterm.sourceforge.net/

set the terminal software to the correct baud rate and connect to the correct comport.

start your pic and see what is displayed
 
Top