Shop OBEX P1 Docs P2 Docs Learn Events
sending of txt msg & h/w flow control in bs2p?? ensuring bs2p "talk" to modem?? — Parallax Forums

sending of txt msg & h/w flow control in bs2p?? ensuring bs2p "talk" to modem??

nuradilanuradila Posts: 18
edited 2005-12-19 08:37 in BASIC Stamp
hi..
how to make sure that the modem REALLY communicate with the BS2p? is it through SERIN/SEROUT?confused.gif
i've tried mike cook's suggestion, that i shld tie the DTR to 5v, set modem's flow control to off and to save that settings in the modem, but it doesnt·seem to·work.below's the revised codes.

another qn: how to write·just a·simple program in BS2P such that it can send a text message/SMS to a mobile phone?
the BS2p is linked to a·wavecom gsm modem. i've tried this·alot of times (the program's below), and yet the program doesnt work. shakehead.gif why it doesn't work and is flow control needed in this case?

just wanna ask if we can actually set hardware·flow control in bs2p. how to go abt doing that?
can explain more abt flow control?·· ·cry.gif

·DEBUG "ATE1"
· DEBUG CR
· PAUSE 5000
· SERIN RX\CTS, Baud, 50, RX_Error, [noparse][[/noparse]WAIT ("OK")]···· ' to test flow control
·
'flow ctrl
· DEBUG "AT+IFC"
· DEBUG 61
· DEBUG "0,0"· '0,0 for flow ctrl off
· DEBUG CR
· PAUSE 5000
· SERIN RX\CTS, Baud, 50, RX_Error, [noparse][[/noparse]WAIT ("OK")]
·
'AT+CSCA="98540020"[noparse][[/noparse]ENTER] -for smsc
· DEBUG "AT+CSCA"
· DEBUG 61
· DEBUG 34················ 'ASCII Equivalent for "
· DEBUG "98540020"············· 'smsc no defined - starhub
· DEBUG 34
· DEBUG CR
· PAUSE 5000
· SERIN RX\CTS, Baud, 50, RX_Error, [noparse][[/noparse]WAIT ("OK")]
·
'Making sure that the GSM module is in text mode.
· DEBUG "AT+CMGF=1"
· DEBUG CR···················· ' Carraige Return ot 'Enter'
· PAUSE 5000
· SERIN RX\CTS, Baud, 50, RX_Error, [noparse][[/noparse]WAIT ("OK")]
·
'AT+CGMS=91918287[noparse][[/noparse]ENTER]
· DEBUG "AT+CMGS"
· DEBUG 61······················ 'ASCII Equivalent for =
· DEBUG "91918287"··········· 'dest mobile no
· DEBUG CR
· PAUSE 5000
· SERIN RX\CTS, Baud, 50, RX_Error, [noparse][[/noparse]WAIT ("OK")]
·
'>MSG^Z
· DEBUG "Testin frm bs2p"· 'msg
· DEBUG 26
· PAUSE 5000
· SERIN RX\CTS, Baud, 50, RX_Error, [noparse][[/noparse]WAIT ("OK")]
END

RX_Error:
· DEBUG "Modem Error",CR,LF
· STOP

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


..:: aDiLa nUr ::..

Post Edited (nuradila) : 8/11/2004 2:57:04 PM GMT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-07-27 09:48
    Yes. In the SERIN and SEROUT statements you may specify a flow-control pin. The syntax is:

    · SERIN Spin\FCpin, baud, [noparse][[/noparse]InputData]

    The help file has complete details. If you want to "talk" to a PC using flow control, take a look at this article:

    · http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv89.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • nuradilanuradila Posts: 18
    edited 2004-07-28 08:23
    ok, thnx jon..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ..:: aDiLa nUr ::..
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-07-28 14:25
    I don't know anything about GSM phones or connecting to them, but I can tell you that there is no flow control with DEBUG and its baud is fixed at 9600.· You will have to use a regular IO pin (or two if you want flow-control) to make your connection.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Mike CookMike Cook Posts: 829
    edited 2004-07-28 19:50
    Depends on what your GSM modem is expecting (flowcontrol), see if your modem supports AT+IFC if so set AT+IFC=0,0 to disable flowcontrol on the modem, do this in your terminal application (hyperterm) first and save your modem settings (AT&W) then connect back to the Stamp.·Also some modems may require DTR to be set so it will send an SMS, check your modem's documentation and or tie DTR(pin 4 on the modem's RS-232) to +5vdc.

    Mike

    Post Edited (Mike Cook) : 7/28/2004 7:54:41 PM GMT
  • Mike CookMike Cook Posts: 829
    edited 2004-07-29 17:03
    Attached is a short program that will send SMS. You may need to make some changes for the WaveCom modem. Line number 154 contains the phone number to send the SMS to. In the attached program this is a "fake" phone number.

    Hope this helps,

    Mike
  • poguemomhoinpoguemomhoin Posts: 13
    edited 2004-07-31 15:57
    I've used Jon's article to try to send an SMS through a Nokia cell phone, using flow control through a Max232.
    I've attached the program file (GSMmodemtest.txt), but I can't get it to work correctly. The phone seems to be getting stuck in text mode, even though the escape character has been sent. The second file, output.txt, is what is actually going to the phone (I watched the output using Hyperterminal), looks ok to me, but I don't get any text!
    If anyone can see the problem I'd be grateful for suggestions.
  • nuradilanuradila Posts: 18
    edited 2004-07-31 16:09
    poguemomhoin, i've heard that not all cell phones support text mode. maybe u should try pdu mode and see the outcome. but it's only a suggestion. [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • poguemomhoinpoguemomhoin Posts: 13
    edited 2004-07-31 16:21
    nuradila,
    If I sent these commands to the phone using hyperterminal, it works fine, which is confuses me!
    Thanks anyhow.
  • nuradilanuradila Posts: 18
    edited 2004-07-31 16:23
    oh..ok..hehe..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • Mike CookMike Cook Posts: 829
    edited 2004-08-03 12:25
    Lets break this problem down to a few simple tests.

    try this:

    Connect your modem to your PC using a three wire cable, RX, TX, and GROUND only. Then from hyperterm try to communicate with the modem, if you can talk to the modem then try to send the SMS again from hyperterm. Remember when connecting your modem to your PC use the following table:

    Modem Pin Out:·DB9·············PC's·RS-232 DB9
    PIN 1 DCD (OUTPUT)
    PIN 2 TX (OUTPUT)·············· PIN 2 RX (INPUT)
    PIN 3 RX (INPUT)················· PIN 3 TX (OUTPUT)
    PIN 4 DTR (OUTPUT)
    PIN 5 GROUND···················· PIN 5 GROUND
    PIN 6 DSR (OUTPUT)
    PIN 7 RTS (INPUT)
    PIN 8 CTS (OUTPUT)
    PIN 9 RING (OUTPUT)

    What we're trying to determine here is the minimum number of connections needed between the PC and the modem to successfully send a SMS, once this is determined then we'll address connecting the GSM/GPRS modem to the stamp.

    Post Edited (Mike Cook) : 8/4/2004 2:52:16 AM GMT
  • nuradilanuradila Posts: 18
    edited 2004-08-04 03:13
    when i just connect the gsm modem's cable to the pc for testing on the hypertherm, and send sms as per normal, it works. so anyone knows abt the connection there?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • Mike CookMike Cook Posts: 829
    edited 2004-08-04 03:39
    I'm sorry I guess I don't understand your answer.

    Did you use a three wire cable between the modem and the PC or just a standard 9 wire cable to do this test?
  • nuradilanuradila Posts: 18
    edited 2004-08-04 03:40
    standard

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • Mike CookMike Cook Posts: 829
    edited 2004-08-04 03:44
    If you would, try using a three wire cable and repeat the SMS test between the PC and the GSM/GPRS modem. The results of this test will determine what handshaking lines are required for your modem to send a SMS.
  • nuradilanuradila Posts: 18
    edited 2004-08-04 12:55
    ok.. i've tried mike's suggestion n it works without problems on the hypertherm, but it doesnt work when i tested it on the BS2p.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • Mike CookMike Cook Posts: 829
    edited 2004-08-04 14:18
    Ok, now you know your modem will work with a three wire connection. Next few steps might get a little complicated:

    Don't use the Debug/Programming port of the stamp, this can be used to print debug statements to find out what's not working.

    Pick another pin on the stamp to do your serial out statements to the modem. If you have a computer with two serial ports this will make this step easier.

    Write a program for the stamp to output the modem commands, don't worry about the serial in for right now or the flow control stuff. After you download this to the stamp, connect the pin that you used on the stamp, for serial output to the modem, and connect it to PIN 2 of your other serial port on your PC. Open Hyperterm on that port and set the baud rate. When you reset the stamp you should see the commands that the stamp is outputting to Hyperterm. If your AT Commands show up in the hyperterm window then your ready for the next step. other wise you've got some debugging to do. As a standard I always use carriage return and Line feed with at Commands, something like this:

    SEROUT ModemTx, Baud, [noparse][[/noparse]"AT", CR, LF]

    If the Hyperterm test worked out ok then make sure your modem is set for the correct baud rate that the stamp is sending at, If the modem "auto bauds" don't rely on this, on most GSM/GPRS modems to set the baud rate you will use the AT+IPR command, once this is issued most modems will immediately change baud rate. You will need to reconfigure Hyperterm to the new baud rate, make sure you can talk to the modem and then save the new baud rate using AT&W. As a double check power cycle the modem and make sure that it comes up at the programmed baud rate.

    Now with hyperterm still open at the baud rate that the stamp and the modem are communicating at, connect the modems PIN 2 on it's RS-232 connector to PIN 2 of the serial port of the PC. you will need to connect PIN 5 of the modem to PIN 5 of the PC's serial port also. Now on the stamp make sure that you connect a ground to PIN 5 of the modem's serial port and connect the pin that you are using on the stamp for serial output to the modem's PIN 3 of its serial port. Now hit reset on the stamp.

    When the stamp resets it will send the AT Commands to the modem and the modems responses will show up on your PC's hyperterm window. Using this technique you can monitor what is actually happening and adjust the stamp's programming to output the correct commands for the modem to send an SMS. After you can successfully send a SMS message this way then you can use the Stamps serial in statement to check for the modem's responses and do some action on whether you get an "OK" or "ERROR".

    As a side note I would use some debug statements so you can determine where in the code the stamp is while it's running.
  • nuradilanuradila Posts: 18
    edited 2004-08-05 13:10
    mike,

    i understand that i shld use SEROUT instead of DEBUG to send out the AT commands. sorry but i dont understand the connection portion as follows:

    "connect the pin that you used on the stamp, for serial output to the modem, and connect it to PIN 2 of your other serial port on your PC. Open Hyperterm on that port and set the baud rate. When you reset the stamp you should see the commands that the stamp is outputting to Hyperterm."

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • Mike CookMike Cook Posts: 829
    edited 2004-08-05 14:26
    In this step you are checking to see what the stamp is actually sending.

    By feeding the stamp's serial output line into a hyperterm session, using PIN 2 of the PC's serial port, you will see the AT commands that the stamp is sending. This way you will be able to see if they are being sent correctly and at the baud rate that you are expecting.
  • dk_akjdk_akj Posts: 37
    edited 2004-08-06 11:00
    Mike >>

    Is this wirring correct ?

    PC1 = stamp editor PC
    PC2 = hyperterminal PC
    GSM = GSM modem


    PC1-RX
    BS2SX-SOUT
    PC1-TX
    BS2SX-SIN
    (using standard programming cable)


    PC2-RX
    BS2SX-PIN0
    |
    GSM-RX--

    PC2-TX
    BS2SX-PIN1
    |
    GSM-TX--

    Can the modem simply be connected directly to e.g. pin 0 and pin 1 ??


    Regards
    Anders
  • Mike CookMike Cook Posts: 829
    edited 2004-08-06 12:49

    There are 2 tests I was trying to get nuradila to perform:

    1. Determine if the Stamp was outputting the correct AT commands to a test device, in this case the test device would be Hyperterm configured for Serial Port 2.

    2. Use the Stamp to output AT Commands to the modem and watch the modem's responses in Hyperterm configured for serial port 2.



    Let me explain my setup:

    ONE PC that has two serial ports, I have two programs running, the Stamp IDE and Hyperterm.

    The Stamp IDE is configured to communicate on Serial Port 1, using a standard serial cable connected to the Stamp's dev board. This allows me to program the Stamp and then when the Stamp is running I can see the IDE's terminal window if I've used debug statements.

    Hyperterm is running on the same PC using Serial Port 2 set for 9600,8,N,1 no flow control. All I'm using Serial port 2 for is for receive, so on the PC side all I need is PIN 2 of the DB9 (Serial Input) and PIN 5 (ground) on the DB9 of the second serial port.

    Ok now to do test 1:

    Program the stamp to output AT Commands that would be required to send a SMS message if it was connected to a modem. The Stamp Pin that I use is PIN 14 for the SEROUT command.

    1. Now that I've got a program to do this it's time to test the Stamp's output, so I connect the STAMP PIN 14 (Serial Output) to the PC's Serial Port 2 PIN 2 (Serial Input).

    2. I also need a ground to complete the circuit so I connect a ground from the Stamps Dev Board to the PC's Serial Port 2 PIN 5 (Ground).

    3. In the Stamp's IDE program I click on RUN, this will download the program to the Stamp and Run the program.

    4. Now I click on the Hyperterm Window. Note: I usually put a PAUSE statement in the beginning of the program so I will have time to activate the Hyperterm Window.

    5. On my display I will have the Stamp IDE in the background and Hyperterm overlaid on top of the IDE.

    6. In the Hyperterm Window I should see what I have programmed the Stamp to output. I use this to see if the AT Commands are being sent at the expected baud rate, and if they "look" correct. If I can answer yes to both questions then I do Test 2, otherwise I have a programming problem, or a hardware problem (Bad Stamp PIN, Bad PC Serial Port, or what ever)



    Test 2:

    I use the same setup as test 1, Hyperterm is still running, however I disconnect the wire between the Stamp SEROUT pin, in my case PIN 14, that is connected to the PC's serial Port 2 PIN 2 on the RS-232 DB9 and connect it to the modem's Serial output PIN 2.

    My wiring is as follows:

    Modem DB9 PIN 2 goes to the PC's Serial Port 2 DB9 PIN 2

    PC'S DB9 PIN 5 goes to the Stamp Dev Board's Ground

    Modem's DB9 PIN 5 goes to the Stamp Dev Board's Ground

    Stamp's SEROUT to the modem's DB9 PIN 3

    Now go back to Test 1 and do steps three, four, five, and return to here

    In the Hyperterm window I should see the responses that the modem is outputting when the Stamp is sending AT Commands to the modem.

    This setup will allow you to debug what AT Command the modem is failing on. After you have determined what AT command is failing, then you can go back and make modifications to the Stamps program to send what ever else is needed.

    I've attached a screen shot of the terminal program that shows the modems responses to my Stamps output of the necessary at commands used to send a SMS message. Note: I use ProComm as my terminal program, Hyperterm works just as well.

    Also I attached the Stamp Program that I'm using.



    Post Edited (Mike Cook) : 8/6/2004 1:14:02 PM GMT
    773 x 580 - 18K
  • nuradilanuradila Posts: 18
    edited 2004-08-06 13:45
    mike, i was able to do d 1st test, the output shows, but the funny thing's dat the subsequent AT commands "overwrites" the previous commands, unlike the way it is on the screen shot u attached.

    thus when i tried the second test, the sms could not be sent. so the problem might be the program downloaded into the BS2p.

    thank u so much, mike. i really appreciate your help.. [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • Mike CookMike Cook Posts: 829
    edited 2004-08-06 14:24
    Make sure that the Stamp is sending <CR> and <LF> after each AT Command (some modems require both <CR> AND <LF> others are just fine with <CR>). Another useful program is PortMon, it can be found here:

    http://www.sysinternals.com/ntw2k/freeware/portmon.shtml

    You run PortMon first, set it up for the serial port to monitor, set it to display HEX or ASCII (I use HEX), then start Hyperterm. PortMon will show all the "unprintable" characters that Hyperterm won't display.

    In test 2 were you monitoring the modem responses? If so at what AT Command was the Modem failing?
  • nuradilanuradila Posts: 18
    edited 2004-08-11 15:00
    mike,
    thank u so much.. i've tried all that u've suggested, n it works..

    as for receiving sms, is SERIN needed? and is the procedure to program the bs2p to receive a sms same as sending sms? in terms of the hyperterminal settings and the transmitting of AT commands..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • nuradilanuradila Posts: 18
    edited 2004-09-05 13:15
    one qn: what if i use a nokia 7710 cell phone instead of the Wavecom GSM modem? when tested on hyperterm, it can send a SMS, but the baud needed is 19200-8-N-1. when i checked the basic stamp 2p manual, there's 1200, 2400 and 9600 baud and i couldn't find the constant for the baudmode needed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • nuradilanuradila Posts: 18
    edited 2004-10-01 08:37
    now i'm having the same problem as poguemomhoin's when i tried the same procedure mike cook suggested when i used wavecom modem. when i connected the bs2 to the pc serial and tested the output on the hyperterminal, the commands are shown correctly as follows:

    AT
    AT+CMGF=1
    AT+CMGS="93912749"
    test frm nokia 7110

    but after connecting a nokia 7110 mobile phone, just like how i connected the wavecom modem to the stamp and the pc serial, there is no output displayed on the terminal and no message is received. i've already set the baudmode as needed is 19200-8-N-1, and i've saved the flow control off settings inside the nokia 7110 phone. the irony is that when i tested the nokia phone in the hyperterminal, it can work. the SMS is sent and the destination phone can receive it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • steve_bsteve_b Posts: 1,563
    edited 2004-10-01 14:58
    Was going to suggest the <CR>'s but I saw you already got them.

    Why typing in hyperterm...in order for your command to be sent, you have to hit CR.· As far as the modem knows, the bytes it receives are for each character of the command and when a <CR> is received it knows to stop receiving and process that current command.

    The BS2P was just outputting text string after text string after text string....so the modem just cued up this large command while it was waiting for the <CR> to execute it.



    I was surprised that you didn't have to short back a couple of the handshake lines on the modem.· (CTS/RI/etc...tied together to fake it out).





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://members.rogers.com/steve.brady
    http://www.geocities.com/paulsopenstage

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."

  • nuradilanuradila Posts: 18
    edited 2004-10-11 03:55
    now i see why the sms could not be sent. when i tested to see if only pins 2,3,5 of the phone's rs232 are needed through hyperterminal, i could type the commands but when i pressed enter, there isn't any acknowledgement, ie OK response from hyperterminal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ..:: aDiLa nUr ::..
  • kintikinti Posts: 9
    edited 2005-01-24 23:35
    Hi nuradila,

    I also want to try to send sms like you did. Can i have de testprogram you use and de wiring between my modem en BS2p

    thnx

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ing. H.S. Hanoeman

    DSP-Solutions
  • ktekxktekx Posts: 71
    edited 2005-12-19 08:37
    I believe that there is a total of 4 pins used in the cable, the RX, TX, GND and a pin for power. I've been trying to do something simliar, but with a sony ericsson and that is what I've found. Since the phone works on a 3v TTL serial and interfacing it to a computer would require it to be RS232 voltage 12v, what it does is, the cable actually uses one of the control pins from the PC to power 12v's and using the switching circuits inside the cable itself for the cell phone to communicated.

    You could probably just add some current limiting resistors and directly interface the basic stamp's pins to the cell phone itself without actually having to use the switching circuits inside the cable.
Sign In or Register to comment.