Have your longed to add a GPS speedometer to your GSX-R powered golf cart? Well, probably not. If you do, we have your fix!
Why GPS speed? The golf cart uses a CVT transmission. Therefore, the stock speedometer pickup no longer directly relates to wheel speed. A different approach was needed for speed measurement. An electronic GPS/pulse converter was proposed that would completely eliminate the variable transmission gearing issues. Commercial gps/pulse units like this are available from autometer but that's no fun! We present our own IOT solution to this issue.
The photon receives the serial GPS stream and converts this to a usable PWM speedometer signal that emulates the calibration of the OEM Suzuki GSX-R digital speedometer pickup.
The Photon also uses a separate PWM channel to blink D7 as a satellite lock indicator. D7 blinks in Hz according to the # of satellites used. D7 does not natively have pwm on the photon, so D7 is configured as an input and D2 is jumpered to D7 to hijack the built in blue LED. D0 and D2 are used as they utilize different hardware timers inside the particle photon.
Wifi is disabled by default, but by cleverly hijacking the setup button a quick press can join a wifi network. Once connected Configuration over the cloud from a mobile device becomes easy.
The circuit is rather simple. The photon is directly connected to the serial output of the GPS module. The PWM 0-3.3V signal is directly tied to the speedometer input of the cart. The stock sensor was a 0-5V hall effect unit but the 3.3v signal from the photon gets the job done.
The GLONASS compatible GPS module is a ublox M8N engine with a separate Honeywell i2C magnetometer. This module is a small form factor, includes an internal rechargeable backup battery and cost less than US$30. It is capable of up to 18hz, but we have it programmed for 5hz. We are using a somewhat unconventional speed of 230400 baud. Several rates were tested. Notably it did work at 460800 baud with no issues. With the RTOS in the photon, it may be beneficial to have a fast baud rate and limit the time the processor is handling receive interrupts.
The UBLOX gps is GLONASS compatible and outputs messages that do not start with the GPSS prefix, it defaults to GNSS. To make the stream compatible with the Tiny GPS++ library a different message configuration was needed. This causes the GLONASS/GPS aggregated solution to be broadcast as GPSS. To do this set GPS as the "main talker id".
Once the baud rate and message configuration is changed you must write the settings for the GPS module to memory for them to persist through power cycles.
It was discovered that the photon would stop parsing gps packets if it had a wifi connection and was taken out of range. The poor wifi connection caused issues. The gps would not recover until back in wifi range. The work-around was to use the semi automatic connection mode and then use the onboard "setup" button as a wifi switch. By default, the wifi does not connect with this code. You must press the setup button for 1/2 second for it to attempt a connection. A subsequent press will also cause a disconnect. For our purposes the wifi was only being used for configuration so this was acceptable.
Particle function "setmode" determines the frequency output mode.
A setmode = 0 is the default, gps based frequency output. The adapter always boots in this mode.
freqout = setcal*gpsspeedmph
setmode = 1; setfreq will override the output frequency for testing and calibration.
freqout = setfreq
setmode =2; setfreq will override the gps speed.
freqout = setfreq*calibration
"setcal" allows sending a new calibration factor to the onboard eeprom.
freqout = setcal*gpsspeedmph
"setcal" writes this value to the emulated eeprom. As the particle boots, it reads and loads this value each time.
To configure, use mobicle.io to call the following functions
setmode = 1
setfreq = 100
watch the digital speedo and record the speed indicated.
use observed value to create the calibration factor.
100/observedspeed = calibrationfactor
use the setcal function to program the calibration factor
setcal = calibrationfactor
you can use setmode = 2 to test a speed, or setmode = 0 or reboot to restart in normal GPS speed mode.
This project was created as an example for my UNC Charlotte MEGR3171 instrumentation class.