This project will show how to interface a GPS module with a serial interface on the Ci20 development board. A U-blox NEO6MV is used. This module has a male header that exposes the VDD, RX, TX and GND pins.
On the Ci20 this will be connected to connector J4P. This is the 4-pin white Molex connector near the HDMi port.
As seen from the above schematic, pin 1 is VDD. This is the pin adjacent to the white triangle indicator sign. Remember to criss-cross the TX and RX pins from the GPS to the connector.
Enabling the Serial PortThe serial port brought out on the Molex connector is /dev/ttyS4. This port is used by the getty program. In order for the user to leverage the port capabilities in his/her programs , the user has to disable the serial port.
Issue:
sudo nano /etc/inittab
Now comment the line that references the /dev/ttyS4 port.
#Spawn a getty on the Ci20 serial line
#T0:23:respawn:/sbin/getty -L ttyS4 115200 vt100
The serial port should be usable from userspace right now without intervention from the getty program.
Serial TerminalThe easiest way to observe the GPS output is to install a serial terminal.
The following commands install minicom , give appropriate permissions to the serial port and open the terminal with a baud rate of 9600 which is the same as the GPS baud rate.
sudo apt-get install minicom
sudo chmod a+rw /dev/ttyS4
sudo chmod g+s /usr/bin/minicom
sudo minicom -b 9600 -o -D /dev/ttyS4
To configure the serial port after opening minicom, press CTRL-A and then Z to get a list of options. Press Z then once the menu opens press O.
Set UART port ttys4 so that it does not have hardware flow control since only the TX and RX pins are exposed.
Select serial port setup from the Menu. Enter the letter of the option you want to change.
Normally this is either the baud rate in which case you should select option E.
Or the hardware flow control which is option F. The serial port is selected via option A.
The python code below can be used to parse the GPS data. The code depends on the pyserial library. Open a console terminal and issue:
sudo apt-get install python-pip
sudo pip install pyserial
Then use the python code attached below to interpret the data from the GPS.
Graphical DisplayThere is also a GPS client on Linux. Install this by issuing:
sudo apt-get install gpsd gpsd-clients
If you want to see a graphical representation of the GPS data issue xgps.
Alternatively issue cgps by passing it the correct port number to see the data on the console.
EpilogueThis tutorial showed how to quickly interface a GPS module with the serial port on the Ci20 MIPS development board. Hopefully, your robot can now pinpoint its location anywhere in the globe.
Comments