PDA

View Full Version : Propeller with Parallax GPS Receiver Module



Michael Rankin
10-10-2006, 10:33 AM
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[2]
Byte Index

PUB start
text.start(16)

dira[01]~~
serial.start(1,1,0,4800)
serial.tx($21)
serial.tx($47)
serial.tx($50)
serial.tx($53)
serial.tx($00)

dira[01]~
Index := 0
repeat 3
RX_value[Index++] := serial.rx

Index := 0
repeat 3
text.hex(RX_value[Index++],8)
text.out($0D)

El Paisa
10-10-2006, 10:51 AM
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 Paisa
10-10-2006, 10:57 AM
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)

'----------[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 Rankin
10-10-2006, 10:57 AM
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

ALIBE
10-11-2006, 02:37 AM
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[256]

Pub Main |s
DirA[Pin_GPS]~~
repeat
buffer[0] := "!"
buffer[1] := "G"
buffer[2] := "P"
buffer[3] := "S"
buffer[4] := $0
txData
rxData

PUB rxData | c, x
x := 0
repeat until (c := SerialIn(Pin_GPS, 4800,1,8) ) == 0
buffer[x++] := c
buffer[x] := 0

PUB txData|x
x := 0
repeat until (buffer[x] == 0)
SerialOut(Pin_GPS, buffer[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[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[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[pin] := mode ' Set up output pin with the proper
dira[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[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://ALIBE.crosscity.com/)
http://fstop.crosscity.com/
http://icar.crosscity.com/
·