Shop OBEX P1 Docs P2 Docs Learn Events
GPS/satellite modem help needed — Parallax Forums

GPS/satellite modem help needed

tvtv Posts: 5
edited 2007-01-21 23:33 in BASIC Stamp
I am new to the basic stamp world and need help on a quick learning curve. I have a BS2, Parallax GPS, DS1620 thermometer and a Iridium satellite modem. I need to get the GPRMC striing from the GPS, a temp reading and send it out via the satellite modem. I am trying to put together a program that will do the following:

Blink LED when powered up (done...yes this was easy)

Power up GPS - wait for GPRMC string, store in buffer, Power down GPS (sort of successful....but not quite there)

Get temp reading from DS1620, store in buffer

Power up modem, send AT command to accept data in buffer, load BS2 buffer data (GPS string and temp) into modem buffer, send AT command to modem to send message, power down modem

Sleep BS2 for 1 hour, then repeat starting at "Power GPS"

It all sounds pretty simple and I have accomplished bits and pieces of everything but my skills are still very basic. Anyone willing to help out? I can give more details when needed. Yes, I am in a time crunch on this.
Thanks,

Comments

  • Kevin WoodKevin Wood Posts: 1,266
    edited 2007-01-18 03:35
    Is this a homework project?
  • FranklinFranklin Posts: 4,747
    edited 2007-01-18 03:40
    You say you have bits and pieces.. Which parts do you have, and can we see them?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • tvtv Posts: 5
    edited 2007-01-18 06:00
    It is not a homework project, it is actually for work. We were anticipating that we could use an off the shelf solution that had the microcontroller and GPS in a single unit that was designed to talk with the satellite modem we are using. The product has been delayed and we find ourselves trying to create our own solution. It is a simple tracking device and we were hoping to have a few prototypes ready for a series of dog sled races here in Alaska. I have wanted to get a Basic Stamp developers kit for years but have not been able to commit the time for learning. Now, I finally have the chance to jump in with both feet but I quickly found myself over my head with no time to study and experiment. So, here is some of the bits and pieces of the code I have playing with. It is not much but it sort of gives the order of events that I see necessary. The code might not reflect much, but I have gotten what appears to be proper communication coming out of the bs2 and going to the modem. At least, when I ran it into Hyper Terminal, the baud rate and AT commands appeared correct. We had done simular work trying to control the modem with MatLab and we were successful with that. So far though, no success sending a satellite message via the bs2. I have also been able to see parts of the GPRMC string show up in the debug window. I cannot get the whole string to show up. I was also unsuccessful with the Parallax GPS, I got it to lock on twice at home near a window but here at work we have a metal building. So instead, I am using a Garmin GPS with a helix antenna and setting it up to output the NMEA strings. I figured the switch back to the Parallax GPS would be easy once the code is correct. One last thing before you check out the code, I don't know if I am having any issues with the serial pin assignments for communicaton. I noticed something in the manual about needing a resistor to drop the voltage down from 12 to 5? My guess, it would be best to start over with the code from scratch.

    thanks for any input. I will be happy to share modem command sets anytime.

    ' File.....TrekPak v1.0
    ' Purpose..Program development for TrekPak communication with Iridium modem.
    ' Date.....20070111
    '
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    '=====================================================================================


    DEBUG "setting up pin assignments",CR

    'pin 15 is used for LED
    'pin 14 is used for GPS
    TX1 CON 13 ' Q9612 "Tx" pin
    RX1 CON 12 ' Q9612 "Rx" pin
    TX2 CON 7 ' PC "Tx" pin
    Rx2 CON 6 ' PC "Rx" pin

    '====================================================================================
    'Blink power LED when power is applied
    '====================================================================================

    counter VAR BYTE
    FOR counter = 1 TO 10
    DEBUG ? counter
    HIGH 15
    PAUSE 200
    LOW 15
    PAUSE 200
    NEXT
    DEBUG "Light off", CR, CR


    '====================================================================================
    'Start of repeat LOOP FOR message timing
    '====================================================================================

    Again


    '====================================================================================
    'Power up GPS, get message string and store in buffer, power down GPS
    '====================================================================================

    'Power up GPS - not sure how to set this up on board yet
    serStr2 VAR BYTE (10) 'make 10 byte array
    SERIN 8, 16572, [noparse][[/noparse]WAIT ("GPRMC,"),STR serStr2\26]
    DEBUG CLS
    DEBUG STR serStr2
    'Power down GPS here

    '====================================================================================
    'Get temp reading and store in buffer
    '====================================================================================



    '====================================================================================
    'Wake up modem, tranfer buffer, send message and listen for modem message reply, power down modem
    '====================================================================================
    tx VAR BYTE
    FOR tx = 1 TO 25
    DEBUG ? tx
    'Power up modem
    PAUSE 3000 ' allow Q9612 modem to power up

    'DEBUG "clearing MO & MT Buffers",CR
    'SEROUT TX1, 16416,[noparse][[/noparse]"AT+SBDD2",CR] ' clear Q9612's MO and MT buffer
    'PAUSE 3000

    DEBUG "clearing Q9612 Buffers",CR
    SEROUT TX2, 16416,[noparse][[/noparse]"AT+SBDD2",CR] ' clear Q9612's MO and MT buffer
    PAUSE 3000

    'DEBUG "writing text message to PC",CR
    'SEROUT TX1, 16416,[noparse][[/noparse]"AT+SBDWT",CR] ' write a text message to Q9612 message buffer
    'PAUSE 3000
    'SERIN RX1, 16416,[noparse][[/noparse]WAIT ("READY")]
    'SEROUT TX1, 16416,[noparse][[/noparse]"Hello",CR]
    'PAUSE 3000

    DEBUG "writing text message to Q9612 message buffer",CR
    SEROUT TX2, 16416,[noparse][[/noparse]"AT+SBDWT=jan15basic1",CR] ' write a text message to Q9612 message buffer
    PAUSE 3000
    'SERIN RX2, 16416,[noparse][[/noparse]WAIT ("READY")]
    'SEROUT TX2, 16416,[noparse][[/noparse]"january15test2",CR]
    'PAUSE 3000

    DEBUG "initiating an SBD session",CR,CR,CR
    SEROUT TX2, 16416, [noparse][[/noparse]"AT+SBDI", CR] ' initiate an SBD session
    'SERIN RX1, 16416, 2500, Error, [noparse][[/noparse]WAIT ("OK")]
    SLEEP 900
    'Power down modem

    '====================================================================================
    'Power GPS and modem down and sleep Basic Stamp for 30 min then repeat from Wake GPS on
    '====================================================================================



    SLEEP 1800 'Message interval is set here - 30 minutes
    GOTO Again
  • LarryLarry Posts: 212
    edited 2007-01-18 07:53
    a quick peek at your code shows you are trying to do too much with the Stamp.

    First off, the BS2 has 26 bytes of variable space----period. You'll never be able to read a string longer than 26 bytes long.
    Early on in your code, you used 1 of them for "counter" that leaves 25

    then, you set your input array to 10 bytes and tried to read 26 bytes into it, not possible. That's why you only got back a partial reading with DEBUG


    You'll have better luck first deciding which information you need from a string and extracting just those pieces using formating modifiers.

    very good examples can be found in Jon Williams' Nuts and Volts articles.

    just google "jon Williams gps" and they'll all pop up - A couple bonus one from other authors, too.


    If you really want to massage gps stuff or input long strings, get a BS2p or other stamp that allows direct input to scratch pad ram.
    You'll be able to read in the whole string at once and massage it at your leisure. otherwise you'll need to extract different parts of the string over two or three reading.

    here's a line of code that shows how to extract data from a GPS sentence:

    SERIN gps_in, 16572,2000,nodata_GPRMC, [noparse][[/noparse]WAIT("GPRMC,"),WAIT(","),STR C_status\1,WAIT(","),WAIT(","),WAIT(","),WAIT(","), WAIT(","),DEC New_heading,WAIT(","),DEC deviation]


    it extracts only the message status (whether the signal was valid- 1 byte), the travel heading- (degrees Decimal 1 word), and the compass deviation (degrees Decimal 1 word).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • tvtv Posts: 5
    edited 2007-01-18 16:26
    Thanks Larry, I will try the extraction code and re-read Jon Williams articles. They are starting to make more sense now and I understand the WAIT sequence you laid out. If I can't do it with the BS2, I will order a BS2p.

    Tim
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-18 16:59
    It sounds like your application needs to conserve battery power. If so a BS2pe would be a better choice. This is assuming you need to send the entire NMEA/GPRMC string. The Parallax GPS Module makes things easier by allowing you to get the individual pieces of information without needing to buffer and parse the large GPRMC string. If you were just sending that data you could use the BS2. If you need the RAW string then the BS2pe is the lower power alternative which has the SPRAM to store the entire string and get the necessary information from it. By the way, as for turning the GPS Module on/off, you could use a 2N2222 to switch the GPS on/off. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • tvtv Posts: 5
    edited 2007-01-19 17:45
    Thanks for the suggestions. I really don't need to send the whole string as I can re-create data and even a close time stamp with the back office software on the other side. I will play with it a bit more. It is a bit difficult working with the Parallax GPS module since it doesn't work inside or near a window and it is a bit cold outside these days but I have tried the code in the GPS demo and it worked while I briefly had a good satellite fix. You answered my next problem of switching the GPS and modem on/off. I will try a switching transistor.

    Tim
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-01-19 17:49
    I'm assuming you also need a couple of MAX232 chips to provide the RS232 level shifting for the Iridium and the GPS, right?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-19 17:59
    Tim,

    Be sure the transistor you use can handle the current draw of the GPS Module. The 2N3904 will not, as an example. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • tvtv Posts: 5
    edited 2007-01-21 23:33
    Thanks Chris. I have aquired the help of an expert and should have this taken care of shortly. I appreciate all the help and now that I have had my appetite whetted, I am sure I will be enjoying learning and playing with microcontrollers without the pressure of a deadline.

    Tim
Sign In or Register to comment.