Connect with us

PIC16F877A With GSM Modem SIM900A

Discussion in 'Microcontrollers, Programming and IoT' started by majdi, Oct 27, 2014.

Scroll to continue with content
  1. majdi

    majdi

    33
    0
    Jul 10, 2010
    Hello, and good day all.

    I have issue to communicate PIC16f877a with gsm/gprs modum sim900a. Test the communication with usb rs232 i can sending and received sms with tera term. From laptop sending command to modem ok.

    From pic16f877a send serial data to laptop and received in tera term. But Pic16f877a to gsm modem sim900a fail. Like the modem not detect the data from pic

    From pic i used max232 and working with usb rs232.. but to modem nothing feedback from modem when sending AT command, it should replay OK to lcd. Anyone have experience using sim900a.?
     
  2. Gryd3

    Gryd3

    4,098
    875
    Jun 25, 2014
    I don't have experience with this particular module, but have you confirmed the data being sent from the PIC to be correct?
     
  3. majdi

    majdi

    33
    0
    Jul 10, 2010
    I confirm sending serial from pic to computer using tera term. From pic sending "AT" then received in tera term "AT."

    My connection:
    [​IMG]

    First i test one by one, PIC send data to pc and recieved same what PIC send, then i try modem direct to pc, also can control the function with AT command. But when i PIC to Modem then nothing happend.
     
  4. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    Your circuit looks right. You may have made a wiring error. There are various checks you can make. Try these, in this order.

    Power up your PIC circuit, with the USB RS-232 device disconnected. Measure the voltage on pins 3 and 2 at the modem connector with the modem powered OFF, and again with the modem powered ON.
    • Modem powered OFF: pin 3 should measure -3V or more negative; pin 2 should be ~0V.
    • Modem powered ON: pin 3 and pin 2 should both measure -3V or more negative.
    Temporarily program your PIC to transmit 0x00 bytes continuously end-to-end forever. Measure those voltages again.
    • Modem powered OFF: pin 3 should measure +3V or more positive; pin 2 should be ~0V.
    • Modem powered ON: pin 3 should measure +3V or more positive; pin 2 should measure -3V or more negative (unless the modem is set to echo received characters; in that case, use Teraterm to turn that feature OFF).
    The modem will no DO anything in reponse to "AT"<CR>. It will just respond with "OK"<CR><LF>. This response will appear on pin 2 of the modem. Try connecting this pin to pin 2 on the USB RS-232 device and monitoring it with Teraterm. Get the PIC to send "AT"<CR> to the modem and see whether you get the "OK"<CR><LF> response on Teraterm.

    Upload at least one photo of your setup and a schematic of your circuit board.
     
  5. majdi

    majdi

    33
    0
    Jul 10, 2010
    Here my connection with modem:
    [​IMG]

    And here my messy setup:
    [​IMG]

    Test: PIC connected to Modem with PIC ON Modem OFF
    Pin 2: 0V
    Pin 3: -6.81V

    Test: PIC connected to Modem with PIC ON Modem ON
    Pin2: -5.54V
    Pin3: -6.81V


    Next i try to program the PIC with 0x00
     
  6. majdi

    majdi

    33
    0
    Jul 10, 2010
    [​IMG]
    This is my circuit for now.
     
  7. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    Good work! Thanks for those responses.

    I can't check your stripboard circuit because the connections aren't visible, but you certainly seem to know what you're doing, and your schematic looks OK, so I'm going to assume you've probably built it up correctly.

    I think it would be a good idea to clarify the signal names in the connection from the PIC to the MAX-232 board. That MAX232 board is obviously manufactured by some company, and perhaps they have chosen confusing names for the signals. Here is how the signals should be connected and named; perhaps you could modify your schematic to clarify this.

    The old RS-232 naming convention is based around connections between a "terminal" and a modem. This is because it was originally used with "data terminals" - a simplified computer that was just a keyboard and a display, with the actual processing being performed by a big computer in a lab somewhere - and modems, which allowed these terminals to connect to these computers.

    In the RS-232 naming standard, a "data terminal" is called a "DTE" - "data terminal equipment", and a modem is called a "DCE" - "data communication equipment". In your case, you have a "terminal" and a modem, so these names are still relevant. The PIC and its RS-232 interface is the DTE, and the modem is the DCE.

    Signals in the RS-232 naming convention relate to the DTE. So TXD means data that is transmitted by the DTE, i.e. transmitted by the PIC. This data is converted from 0V/5V levels to RS-232 levels by the MAX232, and fed to the modem, where a similar device inside the modem converts it back to logic levels so the modem's microprocessor can deal with it.

    At all stages in the process, this signal is called TXD. Because it is data transmitted by the DTE. Even at the input to the modem, on pin 3 of the 9-pin D-sub, this signal is called TXD, although the modem actually RECEIVES data on this pin.

    So that defines how the signals should be named. You may want to check these signals all the way from the PIC through to the modem connector.

    I'm sure you understand all the details I'm giving here. I'm just spelling it out thoroughly for completeness.

    1. Data from PIC to modem:
    This signal is called TXD all the way through the path.
    PIC transmits on RC6/TX/CK on pin 25. I checked this on the data sheet. This signal should be labelled TXD.
    This signal goes into the input of a transmitter on the MAX232 board; specifically, pin 11 of the MAX232, which is called "T1IN" because it's an input to an RS-232 transmitter. The signal at pin 11 should also be called TXD.
    The transmitter in the MAX232 converts this signal to RS-232 levels and its output is on pin 14, called T1OUT. This pin is also called TXD.
    MAX232 pin 14 must be connected to pin 3 of the 9-pin D-sub connector. This pin is also called TXD.
    The 9-pin connector connects to the modem through a pin-to-pin cable, so it arrives at the modem on pin 3 as well. This pin is also called TXD; even though the modem actually receives the data on that pin, that is the data that will be transmitted through the cellular network, so it's still called TXD.
    This is also the signal that will carry the AT commands from the PIC to the modem.

    2. Data from modem to PIC:
    This signal is called RXD all the way through the path.
    The modem receives data from the cellular network (and also generates its own responses, such as "OK"<CR><LF>, which come through the same channel. This data comes out on pin 2 of the 9-pin D-sub and is called RXD.
    This comes through to pin 2 of the 9-pin connector on the MAX232 board, and into pin 13 of the MAX232, called R1IN, the input to an RS-232 receiver, whose output is on pin 12, which goes to RC7/RX/DT on pin 26 of the PIC (40-pin DIP version). At all points, this signal should be called RXD.
     
  8. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    I just realised the most likely problem - flow control signals. The modem is probably expecting active flow control signals on the other pins of the connector.

    There may be an AT command that you can send from the PC to the modem to disable hardware flow control. Alternatively, you can force the flow control signals active by modifying the RS-232 board, to feed the positive voltage from pin 2 of the MAX232 to pins 4 and 7 (DTR and RTS) on the 9-pin D-sub.

    If you can give the manufacturer and part number for that board, I can give you more detailed advice.
     
  9. majdi

    majdi

    33
    0
    Jul 10, 2010
    Here is sim900a module circuit diagram, it same pin with the one i used, only different layout design.

    http://roman.stec.sweb.cz/ATK-SIM900A-V1.2_SCH.pdf

    Some picture:

    [​IMG]
    [​IMG]


    -------------------------------------------------------------------------------------------------------------------------------------------------------

    And here my max232 board picture:

    [​IMG]
    [​IMG]


    Last time i used TC35, there no problem, the sim900 also no problem with trap serial circuit with max232, so i can monitor what PIC send and control the modem via tera term.

    But in sim900a, when i connect in trap mode, only tera term can display feedback from modem and control it, any data from PIC not working.
     
  10. majdi

    majdi

    33
    0
    Jul 10, 2010
    I also attach source code using mplab hi-tech compiler 9.2v. Fully working with sim900 simcomm modem.
     

    Attached Files:

  11. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    You could try linking the end pin, marked RTS, on JP2, to the 0V/GND rail. That will assert the RTS signal on pin 7 of the 9-pin D-sub connector. But the modem may also expect active flow control on DTR, on pin 4 of the 9-pin D-sub connector.

    I found a schematic for that board (attached to this post). The pin numbering for the 9-pin D-sub connector is wrong. But ignoring that, it shows that DTR, pin 4, is supposed to be linked to DSR, pin 6, which comes from the modem. I don't see the track in the photos you posted, but maybe it's on the top side under the connector.

    There are two pads marked CTS and RTS on the underside of the MAX232 board, near pin 9 of the MAX232. I'm not sure what they do, and the schematic doesn't show them.

    First, try linking RTS on JP2 to GND on JP2. I hope that will fix the problems.

    Edit: Attached schematic (PDF)
     

    Attached Files:

  12. BobK

    BobK

    7,682
    1,686
    Jan 5, 2010
    If I read the datasheet correctly, that module wants TTL levels, not RS232. You should remove the MAX232 from the circuit.

    Bob
     
  13. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,270
    Nov 28, 2011
    LOL! Well done Bob.

    I thought he said he could communicate with the modem from his PC using a USB RS-232 device. But he actually said that he could communicate from the PC to the PIC.
     
  14. majdi

    majdi

    33
    0
    Jul 10, 2010
    Ok, i download the sim900a hardware design. It show on my gsm module using sp3238 ttl level converter to make it work with pc usb rs232.

    There have jumper to Sim900a Tx Rx, Pc-Tx Pc-Rx. If want to used laptop giving AT command to gsm modem, i need to short this two jumper. Sim900a have ttl 3.3v and pic16f877a have 4.5v-5v.

    If i want to connect pic to Tx Rx sim900a, do i need to used level converter first or just direct connect pic pin RC6 RC7 to sim900a Tx Rx?
     
  15. majdi

    majdi

    33
    0
    Jul 10, 2010
    One more, when i connect pc to pic, i only can recived value from pic to tera term, but cannot press anykey to send data from tera term to pic.
     
  16. majdi

    majdi

    33
    0
    Jul 10, 2010
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-