GPS Guided Truck PBasic Programs

Once I learned PBasic I came up with this very very simple program written for the Parallax Basic Stamp 2.

It is important to note that I used a Scott Edwards Serial Servo Controller 2. All of the Serout commands are going to that controller to change my steering and speed. Without that controller the pulses to the servos would stop every time the stamp would start reading in data from the GPS. That doesn't sound like a big deal but at 4800bps the data coming in isn't blazingly fast and would make the truck movement jerky.

This program has much room to expand. With this program running the truck only makes a steering correction every TWO seconds, this is due to the fact the GPS is only outputting data at 4800bps. A GPS unit that will output at 9600 will update every 1 second. Future improvements include: making steering the amount of my turn correction proportional to the difference between the course heading and waypoint heading. The greater the difference the sharper the turn. 

'Matthew Klarich GPS guidance program for R/C truck with Scott Edwards SSCII Serial Servo Controller
'GPS used is a garmin etrex set to NMEA 0183 at 4800bps

'GPS is on pin 8

'Serial Servo Controller on pin 7

'order of serial inputs of GPRMB and GPRMC may need reversed depending on GPS unit.


tr1 var word     'true heading variable
wp1 var word   'waypoint heading variable
sync con 255     'sync byte for servo controller
n24n con $418d     'this is the baudrate out to servo controller

loop1:
' next sentence takes information from $GPRMC sentence coming from GPS unit 
' set to NMEA data out. 
' It is set at the standard NMEA rate of 4800 baud

serin 8, 16572, [wait("GPRMC,"),wait(","),wait(","),wait(","),wait(","),wait(","), 
wait(","),wait(","),dec tr1] 'puts serin data in RAM, it is the current 
true heading

serin 8, 16572, [wait("GPRMB,"),wait(","),wait(","),wait(","),wait(","),wait(","),
wait(","),wait(","),wait(","),wait(","),wait(","), dec wp1] 'puts serin 
data in RAM, it is current waypoint heading

IF wp1 < tr1 THEN bearLeft 
serout 7,n24n,[sync,0,177]
serout 7,n24n,[sync,1,145]
goto loop1

bearLeft:
serout 7,n24n,[sync,0,77]
serout 7,n24n,[sync,1,145]
goto loop1

 

General Information Look here first !!

Pictures of Truck 

Programming

Wiring Information

For any further information please email: mklarich@stoneflyers.com