Balloon Collaboration
December 10, 2019, 09:42:21 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: barntek.com is now part of the BarnTek information network...Currently redirected to barntek.net
 
   Home   Help Search gallery Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Next Step...  (Read 1403 times)
Larry
Administrator
Hero Member
*****
Posts: 1167



View Profile
« on: May 25, 2015, 02:49:46 AM »

Ok, I managed to get the next program written and working very well.  gpsParse.py is designed to pull the important data from the GPS sentences and write them to a data file, Current.dat, where it can be accessed by any program to obtain current data.  The data contained in the data file is as follows: Time, Date, Latitude, Longitude, Altitude, Speed, and Course...  although, not in that order.
Quote
#!/usr/bin/python

### General Info #######################################################
### gpsParse.py
### GPS Sentence Parser
### ...by Larry Barnes
###
### Ports Used: 31757

### Socket Setup ########################################################
import socket
host = ""
port = 31757
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))

### Main Program ########################################################
print 'Running...'

while 1:

  try:
    data,address = s.recvfrom(4096)
    datum=data.split(",")
    if datum[0]=="$GPRMC":
      GPS_DATE=datum[9]
      GPS_TIME=datum[1].split(".")[0]
      GPS_LAT=datum[3]
      GPS_LON=datum[5]
      GPS_SPEED=datum[7]
      GPS_COURSE=datum[8]
      while 1:
        data2,address = s.recvfrom(4096)
        datum2=data2.split(",")
        if datum2[0]=="$GPGGA":
          GPS_TIME=datum2[1].split(".")[0]
          GPS_LAT=datum2[2]
          GPS_LON=datum2[4]
          GPS_ALT=int(float(datum2[9]))
          break
    GPS_DATA="%s,%s,%s,%s,%s,%s,%s" % (GPS_DATE,GPS_SPEED,GPS_COURSE,GPS_TIME,GPS_LAT,GPS_LON,GPS_ALT)
    with open('/home/pi/Data/Current.dat','w') as d:
      d.write(GPS_DATA)


  except KeyboardInterrupt:
    exit()

  except:
    continue
Logged
Dan
Administrator
Full Member
*****
Posts: 175



View Profile
« Reply #1 on: May 25, 2015, 01:02:22 PM »

Will the GPS connect directly to the Pi pins or will you have to convert the 5v output to 3.3v?
Logged
Larry
Administrator
Hero Member
*****
Posts: 1167



View Profile
« Reply #2 on: May 26, 2015, 02:04:37 AM »

I am going thru a MAX233a RS-232C converter chip. It is being powered from the 5vdc from the Pi.  The data sheet says it handle TTL (5vdc) and CMOS (3.3vdc).  I have used this for both microcontrollers and the Pi without an issue on either one.  The chip takes care of all the level conversions and polarity issues.  This particular chip is super simple as it only requires 1 cap.  The MAX232 does the same thing, but requires about 6 or 7 external caps.

I just re-read your question, and maybe this will help, too.  The Pi handles UART, which is a TTL level communication standard and the GPS is RS-232C which is a different standard, with 10vdc levels.  This chip converts between 2 for you.

Datasheet




I have just 4 wires between the pi and the chip: Gnd => Pin 6,9; +5v => Pin 7; Xmit => Pin 1; Recv => Pin 3.  I then run 5v from the Pi to the 9-pin subD as well as Gnd, Pin 18 and Pin4.  The GPS plugs into the 9-pin subD.


« Last Edit: May 26, 2015, 02:59:59 AM by Larry » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!