Shop OBEX P1 Docs P2 Docs Learn Events
Propeller with Parallax GPS Receiver Module — Parallax Forums

Propeller with Parallax GPS Receiver Module

Michael RankinMichael Rankin Posts: 2
edited 2006-10-10 18:37 in Propeller 1
I'm new to the spin language and was seeking some·help with this setup/code.
·
I have the propeller·demo board·and the Parallax GPS Receiver Module. The 4 pins on the GPS module are GND, VCC, SIO, and RAW. Currently, I have the GND pin going to VSS on the propeller demo board, VCC going to 5V on the demo board, and SIO going to I/O pin number 0 on the board.
·
What I am having trouble with is sending this header value "!GPS" plus a hex value (0x00) to the SIO pin (i/o pin 0)·and then receiving the·2 bytes back on i/o pin 0.
·
I am using the FullDuplexSerial v1.1 for the serial communication. Here is the code I have so far.
·
Any help is appreciated. Thanks.
·
Michael

CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
OBJ
  text : "vga_text"
  serial : "FullDuplexSerial1_1"
  
VAR
  Byte  RX_value[noparse][[/noparse]2]
  Byte  Index
  
PUB start
  text.start(16)
  
  dira[noparse][[/noparse]01]~~
  serial.start(1,1,0,4800)
  serial.tx($21)
  serial.tx($47)
  serial.tx($50)
  serial.tx($53)
  serial.tx($00)
  
  dira[noparse][[/noparse]01]~ 
  Index := 0
  repeat 3
    RX_value[noparse][[/noparse]Index++] := serial.rx
  
  Index := 0
  repeat 3
    text.hex(RX_value[noparse][[/noparse]Index++],8)
    text.out($0D)

Comments

  • El PaisaEl Paisa Posts: 375
    edited 2006-10-10 02:51
    Hi,

    This may help you.

    · serial.str(@msg1)·····
    · serial.tx($00)
    · waitcnt(900_000+cnt)

    DAT
    · msg1··· byte··· "!GPS",0

    I use this format to communicate with a uMMC card writer/reader.

    Hope this help.
  • El PaisaEl Paisa Posts: 375
    edited 2006-10-10 02:57
    Hi again,

    The program I use to communicate with a uMMC card writer/reader is :

    ''*****************************
    '' uMMC_1.spin
    ''*****************************

    CON

    · _clkmode····· = xtal1 + pll16x
    · _xinfreq····· = 5_000_000
    · RX_PIN······· = 2
    · TX_PIN······· = 3
    · MODE········· = %0000································ ' see FullDuplexSerial.spin for description
    · BAUD········· = 9600
    ·····
    VAR

    ······· long··· k

    OBJ

    ······· term··· : "tv_terminal"
    ······· serial· : "fullduplexserial"

    PUB start | i

    · serial.start(RX_PIN, TX_PIN, MODE, BAUD)·········· ' initialize serial object
    · waitcnt(4_000_000+cnt)


    ··· term.start(12)
    ··· term.str(@title)·
    ··· waitcnt(40_000_000+cnt)

    '
    [noparse][[/noparse]Main starts here]

    · term.str(@msg1)
    · term.out($09)····
    · serial.str(@msg1)·····
    · serial.tx(13)
    · waitcnt(900_000+cnt)
    · repeat until k==">"·········
    ··· k:=serial.rx
    ··· term.out(k)



    DAT
    · title·· byte··· "First uMMC Read/Write",13,13,0
    · msg1··· byte··· "V",0
  • Michael RankinMichael Rankin Posts: 2
    edited 2006-10-10 02:57
    I modified my code to implement your change and I get the same output:

    0x21 which is !
    0x47 which is G
    It looks like I am just getting back the command I am sending. I don't know if the GPS module is returning that or the code is reading it from memory

    Post Edited (Michael Rankin) : 10/10/2006 1:47:18 PM GMT
  • ALIBEALIBE Posts: 299
    edited 2006-10-10 18:37
    Michael,
    try this following code. Note, I have removed the use of fullduplex and am using 2 code snippets courtesy of Mike Green. It works like a charm for me in my AC4790 work I am doing w my ALIBE project.
    hope this works for you
    Const
      #1, Pin_GPS
    Var 
      byte buffer[noparse][[/noparse]256] 
    
    Pub Main |s  
      DirA[noparse][[/noparse]Pin_GPS]~~ 
      repeat 
        buffer[noparse][[/noparse]0] := "!"
        buffer[noparse][[/noparse]1] := "G"    
        buffer[noparse][[/noparse]2] := "P"    
        buffer[noparse][[/noparse]3] := "S"
        buffer[noparse][[/noparse]4] := $0
        txData 
        rxData 
        
    PUB rxData | c, x 
      x := 0 
      repeat until (c := SerialIn(Pin_GPS, 4800,1,8) ) == 0 
        buffer[noparse][[/noparse]x++] := c 
      buffer[noparse][[/noparse]x] := 0 
    
    PUB txData|x 
      x := 0 
      repeat until (buffer[noparse][[/noparse]x] == 0) 
       SerialOut(Pin_GPS, buffer[noparse][[/noparse]x++], 4800, 1, 8) 
    
     
    '//
    '// Code courtesy of Mike Green
    '//
    PUB serialIn(pin, Baud, mode, bits) | bitTime, time 
      {{ Accepts asynchronous byte value on defined pin, at Baud, in mode for #bits 
         Mode: 0 = Inverted - Normally low Constant: Inv 
         1 = Non-Inverted - Normally high Constant: NInv }} 
       
       dira[noparse][[/noparse]pin]~ ' Set up input pin as an input 
       bitTime := clkfreq / Baud ' Calculate bit time for Baud 
       waitpeq(mode << pin, |< pin, 0) ' Wait for idle (should be idle) 
       waitpne(mode << pin, |< pin, 0) ' Now wait for start of start bit 
       time := cnt ' Wait until middle of start bit 
       waitcnt(time += bitTime >> 1) 
       repeat bits ' Sample input at the middle of 
         waitcnt(time += bitTime) ' each data bit time for #bits 
         result := ((ina[noparse][[/noparse]pin] ^ (1 - mode)) << bits | result) >> 1 
    
    
    '//
    '// Code courtesy of Mike Green
    '//
    PUB serialOut(pin, char, Baud, mode, bits ) | bitTime, time 
      {{ Send asynchronous character (byte) on defined pin, at Baud, in Mode for #bits 
         Mode: 0 = Inverted - Normally low Constant: Inv 
         1 = Non-Inverted - Normally high Constant: NInv }} 
      outa[noparse][[/noparse]pin] := mode ' Set up output pin with the proper 
      dira[noparse][[/noparse]pin]~~ ' idle state and as an output 
      bitTime := clkfreq / Baud ' Calculate bit time for Baud 
      char := ((1 << bits | char) << 1) ^ (mode == 0) ' Add start/stop bits & invert if needed 
      time := cnt 
      repeat bits + 2 ' Send each bit based on baud rate 
       outa[noparse][[/noparse]Pin] := char 
       char >>= 1 
       waitcnt(time += bitTime) 
      waitcnt(time += bitTime * (bits + 2)) ' Allow a character time for pacing 
    
    

     
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot

    http://ALIBE.crosscity.com/
    http://fstop.crosscity.com/
    http://icar.crosscity.com/
    ·
Sign In or Register to comment.