Shop OBEX P1 Docs P2 Docs Learn Events
SERIN hangs or crashes when connected to wavecom modem — Parallax Forums

SERIN hangs or crashes when connected to wavecom modem

Paul LeighPaul Leigh Posts: 4
edited 2005-01-13 01:16 in BASIC Stamp
Hi, I'm new to the stamp development scene. I've built a breadboard with a MAX232 chip on it. The aim being to be able to initiate a call via a Wavecom GSM modem.

With the code and setup as it is, I can send AT Commands and view them via HyperTerminal. The SEROUT and SERIN seems to work fine. ie: I can see the AT Command appear in the terminal window and if I type inthe terminal I can see the values via a debug statement.

The problem I have is if I take the same code and connect a wavecom modem (Maestro 20), then the process hangs at the SERIN line. The Stamp needs to be reset to continue.

I've checked the modem out with the same cable and HyperTerminal and all is well.

The code snippet I'm using is a follows. I'd be grateful for any assistance you guys could offer.

· MakeCall:
··· ModemResponse VAR Byte(2)
··· DEBUG "SEROUT - AT", CR
··· SEROUT TX\RTS, BAUD, [noparse][[/noparse]"AT",CR]
··· SERIN· RX\CTS, BAUD, [noparse][[/noparse]STR ModemResponse\2]
· RETURN

Comments

  • achilles03achilles03 Posts: 247
    edited 2005-01-12 21:17
    My initial guess is that it doesn't appear to be on the stamp side. It sounds like a question for someone familiar with that brand of modem. Two things I would check are:

    1. Are you communicating at the right BAUD rate with the modem (what's the modem set for)?
    2. Do you anticipate the modem sending a full 2 bytes worth of data?

    Look at the "SERIN" command in the manual and read up on timeouts. That will atleast prevent you from having to reset, and will tell you it didn't receive anything.

    Dave
  • Paul LeighPaul Leigh Posts: 4
    edited 2005-01-12 21:43
    The modem is a very popular modem and I've used it in a number of VB and C# apps without any major hurdles. Its set for 9600-8-N-1, using hardware flow control.

    I've had a play around with Timeouts and adjusted the number of bytes received from 1 to 20. The only extra information I can offer right now is that when using BAUD 84 (its a BS2) and connected to a cable back to the PC (and reading in HyperTerminal), the following code works:

    ··· ModemResponse VAR Byte(2)
    ··· DEBUG "SEROUT - AT", CR
    ··· SEROUT TX\RTS, BAUD, [noparse][[/noparse]"AT",CR]
    ··· SERIN· RX\CTS, BAUD, 5000, ModemNotRespondingOK, [noparse][[/noparse]ModemResponse]
    ··· DEBUG "Modem replied 'OK'"

    I get the debug statement after manually typing in 2 characters. Conversely, if I try exactly the same code but with the modem plugged in, the SERIN statement still hangs. If I then change the BAUD to 16468 and try again, the Timeout of the SERIN does kick in and the program execution jumps to the ModemNotRespondingOK function. If I then swap the modem for the HyperTerminal setup again, it then hangs.

    Summary:

    BAUD 84 & HyperTerminal = Ok

    BAUD 84 & Modem = Hangs

    BAUD 16468 & Modem = OK (But no information returned)

    BAUD 16468 & HyperTerminal = Hangs

    The MAX232 chip is wired up as per the document nv89.pdf found via this forum.
  • steve_bsteve_b Posts: 1,563
    edited 2005-01-12 22:19
    Hi Paul,

    the MAX232 chip is expecting ttl levels in an rs232 pattern...so you need to use TRUE values of baud.· So, 84 IS the right baudvalue.

    Some RS232 ports can see ttl levels so you are sometimes able to talk to serial ports using a stamp pin connected through a 22kohm resistor (most important on the serin port!).· BUT, in this case you must use INVERTED baudvalues.·

    RS232 standards declare a 1 (mark) as a -12V value; whereas the 0 (space) is a +12V value.· So, you can see the difference from TTL binary where a 1 is +5 and a 0 is zero.· Anyhow, there's that little tidbit for ya!

    which max232 chip did you get?· THe Max232CPE has the built in charge pump so that you only need to supply +5v (and various capacitors for the pump) and away you go!· pins 10 and 11 are the TTL I/O's and 7 and 14 are the rs232 I/O's.

    pins 10 and 7 are mated and pins 11 and 14 are mated.· Be sure you haven't crossed somewhere!

    Is the modem using a 25pin cable?· How are you tapping in to the cable?· Or do you have your own connector made up?· You may need to short together a few pins! (can't quite remember which ones -- maybe RTS DSR DTR??)

    Can you yank out the flow control from your code and see if it'll hammer itself in?

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

    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."

  • Paul LeighPaul Leigh Posts: 4
    edited 2005-01-13 00:15
    The wiring I have is as follows:

    ·9PINF····· ·9PINM········ MAX232CPE········· STAMP
    ·Modem··· HyperTerm
    ·(2) RX· --- (2)·
    ( 7) T2Out·
    ·(3)·TX· --- (3)
    ( 8) R2In
    ·(7)·RTS --- (7)
    (13) R1In
    ·(8) CTS --- (8)
    (14) T1Out
    ·(5) GND --- (5) -- GND
    ····· ····· · ·· ·········(12) R1Out
    (3) CTS
    ············ · ·· ········(11) T1In··
    ·(2) RTS
    ············· · ··· ··· ··(10) T2In··
    (4) TX
    ·············· · ····· ···( 9)·R2Out
    (5) RX

    If I remove the flow control the same thing happens as before and the application hangs. This wiring works flawlessly with HyperTerminal set to exactly the same as the modem settings·of 9600-8-N-1. The moment the modem is plugged in, the app hangs on the SERIN line again.

    All·5, 1.0uF caps are present with the MAX232 (1-3,4-5,6-Gnd,2-5v,16-Gnd).

    I've changed the code slightly, to have the SERIN line wait for an "OK":

    ··· DEBUG "SEROUT - AT", CR
    ··· SEROUT TX, BAUD, [noparse][[/noparse]"AT",CR]
    ··· SERIN· RX, BAUD, 2000, ModemNotRespondingOK, [noparse][[/noparse]WAIT("OK")]
    ··· DEBUG "Modem replied 'OK'"

  • steve_bsteve_b Posts: 1,563
    edited 2005-01-13 00:56
    Paul, I was surprised to see the 9pin on the modem (I'm still stuck in the old days I guess!).
    Anyhow, I think you're Hyperterm pins for rx and tx are wrong (at least in your message!).
    The RX from the modem would go to the TX in hyperterm and;
    The TX from the modem would go to the RX in hyperterm.

    Anyhow, you should connect all your grounds together too.· So, pin5 from the modem to pin15 on the MAX232 to Vss on your board.
    I think your pins from your modem to and out of the max232 are right.·

    Do you need to set the DSR and DTR to get the modem to go?
    The Data Set Ready is from the modem and the Data Terminal Ready is from the PC (normally Hyperterm/etc..).
    Maybe tie these together?· or to RTS?
    I've 'faked' a modem once for a remote security panel and had to tie RTS, DSR and DTR together to get it to work.

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

    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."

  • Paul LeighPaul Leigh Posts: 4
    edited 2005-01-13 01:12
    Steve,

    Many thanks for all your help. The last couple of points were just the missing link I needed. I swapped the Modem pins (2/3) over as suggested and shorted 7/8 (CTS & RTS) at the 9 pin modem cable and it all works perfectly now.

    The modem 9 Pin is actually 15 pin to 9 pin cable as the modem is one of those factory fit car phone jobs. Then to add even further amusement, its connected by way of a usb to serial adapter.

    Much appreciated.
    Cheers,
    Paul.
  • steve_bsteve_b Posts: 1,563
    edited 2005-01-13 01:16
    Woo hoo....good job!

    I've worked with RS232 a lot and almost ALWAYS get the rx and tx crossed at some point.· Before I even both with test equipment I'll swap these to see if I did it again.·

    There's a Canadian show up here called 'The Red Green Show'....his trademark signoff is, "If the women don't find ya handsome, they should at least find you handy!"·



    OF course his other one is, " Keep your stick on the ice"!



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

    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."

Sign In or Register to comment.