Gauge Pod 2.0 Development

Been busy coding away on the Gauge Pod software. It’s coming along nicely. I’ve taken a slightly different approach from the first version and the code is turning out to be a lot simpler. Still using layered architecture to separate Sensors, Gauges, Communication and UI but I changed how the layers interact with each other. The update performance has gone up dramatically. Using the Gauge Pod Sender in USB mode has also greatly reduced overhead and feeds data incredibly fast.

I’m currently in the testing phase of the software but looking good so far. The gauges are VERY stable compared to the last version. Will start testing the software on the car in the next few weeks as time permits. Can’t wait to try this in the car.

Gauge Pod 2.0 – Sender (pt 2)

I’ve spent about 2 days on dealing with the ADC (Analog to Digital Converter) of the Arduino platform. Turns out there’s more problems to overcome when dealing with taking analog signal from a sensor and converting it to meaningful digital reading.

The issue is that even with a constant input voltage the ADC reading sampling error rate is larger than I’d like (~1.2%) with some random spikes in excess of 3%.

I built a test rig to troubleshoot the issue. Using constant input voltage and a potentiometer to simulate the analog input from a sensor.


– At least 4 sample updates per second. (Smooth gauge updates)
– Stable voltage regardless of outside interference.

Things I found:
– Arduino Atmel chip uses a single ADC and multiplexes the input pins.
– Switching read pin on the ADC causes noise in the system. Solution to read the first value and totally discard it. Then wait at least 10ms before sampling actual data.
– Sample accuracy is inversely proportional to the delay between samples. Shorter delay between reads, less drift. But over a static period of time, the error rate is the same.
– ADC is quite sensitive to electronic noise. Adjacent pins seem to affect reading.

Things I tried:

– Average voltage over multiple samples (currently 11 samples per read)
– Add delay between readings (1 to 12 ms) (currently 2ms)
– Discard top and bottom values and average the rest (currently discard 25%)
– Add a delta value, discard new value if difference is less than delta (currently 0.011V)
– vary delay on multiplex debounce (currently 10ms)

Current sampling rate: 3.7 samples / second.

Final Arduino Code:

const int LED_RED = 9;
const int LED_GREEN = 8;
const int LED_BLUE = 7;
const int LED_ACT = 11;
const int INPUT_REF = 22;
const int INPUT_RATE = 20;

int refPins[4] = {19, 17, 18, 16};
int sensePins[4] = {15, 13, 14, 12};
double lastRefVolts[4] = { 0, 0, 0, 0 };
double lastSenseVolts[4] = { 0, 0, 0, 0 };

const float LOW_VOLTAGE = 4.5; //alert voltage for 5V bus

const int MAX_SAMPLES = 50; //max sample on trim pot
const float DISCARD_PCT = 0.25; //percent of samples to discard (top and bottom)
const float MAX_DELTA = 0.011; //ignore changes less than this
const int SAMPLE_DELAY = 2; //delay MS between sample reads
const int INITIAL_DELAY = 10; //delay MS on pin change

void setup()
  //set pin IO modes
  pinMode(LED_RED, OUTPUT);
  pinMode(LED_BLUE, OUTPUT);
  pinMode(LED_ACT, OUTPUT);
  for (int pin = 0; pin < 4; pin++) 
    pinMode(refPins[pin], INPUT);
    pinMode(sensePins[pin], INPUT);
  pinMode(INPUT_REF, INPUT);
  pinMode(INPUT_RATE, INPUT); 
  //cycle leds
  digitalWrite(LED_RED, HIGH);
  digitalWrite(LED_BLUE, HIGH);
  digitalWrite(LED_GREEN, HIGH);

  setLED(LOW, LOW, LOW);

  //emulated serial, speed ignored  

void loop()
   //read serial to clear buffer
  if (Serial.available() > 0)

  //get number of samples to read
  int readCount = getReadCount();

  //write +5V bus voltage

  //write all input sensors
  for (int pin = 0; pin < 4; pin++) {
    writeSerialVoltage(pin, readCount);

void writeSerialVoltage(int pin, int readCount) 

  digitalWrite(LED_BLUE, HIGH); //blue off - start sending
  digitalWrite(LED_ACT, LOW); //internal off
  //ref volt, seems more volatile
  float refVolt = getVoltage(refPins[pin], readCount);
  float newRefVolt = processRefVoltage(pin, refVolt);

  //get sensor voltage
  float senseVolt = getVoltage(sensePins[pin], readCount);
  float newSenseVolt = processSenseVoltage(pin, senseVolt);

  Serial.print("IN");  //write identifier
  Serial.print(newRefVolt, 4); 
  Serial.print(newSenseVolt, 4);
  digitalWrite(LED_ACT, HIGH); //internal on
  digitalWrite(LED_BLUE, LOW); //blue on - sending done


//do a delta comparison on Ref voltage
float processRefVoltage(int Pin, float refVolt) 
  float lastRefVolt = lastRefVolts[Pin];

   if (abs(refVolt - lastRefVolt) < MAX_DELTA)
     refVolt = lastRefVolts[Pin];
     lastRefVolts[Pin] = refVolt;  
    return refVolt;


//do delta comparison on sensor voltage
float processSenseVoltage(int Pin, float senseVolt) 
  float lastSenseVolt = lastSenseVolts[Pin];

   if (abs(senseVolt - lastSenseVolt) < MAX_DELTA)
      senseVolt = lastSenseVolts[Pin];
     lastSenseVolts[Pin] = senseVolt;
    return senseVolt;

//send bus voltage to host
void writeRefVoltage(int readCount) {
  float refVoltage = getVoltage(INPUT_REF, readCount);
  if (refVoltage < LOW_VOLTAGE) 
    digitalWrite(LED_RED, LOW);
    digitalWrite(LED_GREEN, HIGH);
    digitalWrite(LED_RED, HIGH);
    digitalWrite(LED_GREEN, LOW);
  Serial.print(refVoltage, 4);

//read value from ADC (0-1023) and convert to voltage (0-5)
float getVoltage(int PIN, int samples) {
  //allow ADC to stablize
  analogRead(PIN); //ignore value
  delay(INITIAL_DELAY); //wait for debounce
  float sampleList[samples]; 

  //read samples
  for (int i = 0; i < samples; i++) 
    float voltage = (float)analogRead(PIN) * (5.0 / 1024.0);
    //round to 2 decimals
    sampleList[i] = (ceil(voltage * 100.0)) / 100.0;
   //sort array (shitty bubble sort, cause i'm lazy)
    float swapper;
    for (int o = samples-1; o > 0; o--) {
        for (int i = 1; i <= o; i++) {
          if (sampleList[i-1] > sampleList[i]) {
          swapper = sampleList[i-1];
          sampleList [i-1] = sampleList[i];
          sampleList[i] = swapper;
      //discard % of top and bottom values, average the rest
      int avgStart = max(samples * DISCARD_PCT, 1); //array start
      int avgEnd = min(samples * (1.0 - DISCARD_PCT), samples); //array end
      int avgSamples = 0;
      float ret = 0;
      //average out the values
      for (int cntr = avgStart; cntr < avgEnd; cntr++) 
        ret += sampleList[cntr];
      return ret / (float)avgSamples;

//read trim pot, get average samples
int getReadCount() {
  int readCount = analogRead(INPUT_RATE);
  return map(readCount, 0, 1023, 4, MAX_SAMPLES);

//set RGB led values
void setLED(int RED, int GREEN, int BLUE) {
digitalWrite(LED_RED, RED);
digitalWrite(LED_GREEN, GREEN);
digitalWrite(LED_BLUE, BLUE);

Binary sketch size: 7,196 bytes (of a 32,256 byte maximum)
Estimated memory use: 103 bytes (of a 2,560 byte maximum)

This is probably as close as I can get to get an accurate reading that doesn't jump around too much. Filters most noise while giving a decent sample rate. Currently reading all 4 inputs. Technically could reduce to 3 inputs since 4th won't be used for a while. Will see how well Gauge Pod software deals with current feed rate.

Gauge Pod 2.0 – Sender

I’ve started working on Gauge Pod 2.0 for the Challenger. The original version had some issues as described here.

The original sender was located under the dash. Currently utilizes three sensors (AFR, Boost and Fuel Pressure). The box was built to support more sensors but in the end I ended up using only those three. I used 3 pin molex connectors which turned out to the a bad idea as the connections weren’t very secure. Additionally I had to make some last minute modifications to feed a 5V signal to the sensors. In the end the box was way too bulky and not terribly efficient.

Due to the fact that the Arduino Diecimila uses pin connections (as it’s more for prototyping), the connections weren’t very good. While I had no problem with the connections themselves, I didn’t feel that this was sufficient for long term use. The next sender will have everything properly soldered.

The enclosure I used was also too large even for the size of the board. The new Arduino board (Teensy) is tiny compared to the original board. Teensy is actually more powerful than the Diecimila board, as it offers double the RAM (whooping 2K), double the Flash (32K) and a lot of PWM outputs and Analog inputs. Additionally, the Teensy board can act as native USB device, no need for serial port emulation. It’s also quite cheaper than the official Arduino.

Sensor voltage is supplied via an RC BEC board from Castle Creations. The BEC can be programmed for any output voltage. Originally the board was programmed for 5.1V from factory. The BEC is most likely type of MOSFET voltage regulator instead of the more traditional linear regulator. This does introduce a bit of noise into the system as the PWM system typically operates in the Khz range. Though, with bench testing I didn’t see any significant problems with this.

I didn’t actually realize right away that I had a programmer for the BEC. I picked one up last year for my Mamba Pro ESC. With just a few clicks of a button I was able to program it for 5V.

One of my theories for the flactuating voltage is that one or more sensors was putting too much load on the BEC. During testing I noticed that with higher amperages the BEC supplied voltage would drop. At 0.7A the voltage dropped to almost 4V. This was quite unusual since the BEC is rated at 10A. To mitigate this problem I’m using some inline, low ohm resistors to current limit the supply. This should prevent excessive load on the BEC.

For the input voltage and sensors I’m using 2 and 4 pin barrel connectors.

Connector Pinouts:

Sensor Input Barrel Connector:
1 – Black – Ground
2 – Red – +5V
3 – Blue – +5V (Current Limited)
4 – Green – Sense In

Power In Barrel Connector
1 – Black – Ground
2 – Red – +12V (ACC)

Teensy Sensor Pins:

Input Sense Pin Ref Pin
Input 1 15 19
Input 2 13 17
Input 3 14 18
Input 4 12 16

I’m also using an RGB LED for status indicator. The LED uses a common anode, so the LED turns on when driving Teensy pin LOW.

LED Pins on Teensy:
Common Anode: 5V
Red: 9
Green: 8
Blue: 7
Internal: 11

The Blue indicator blinks when new voltage data is sent. The Green indicator is on when the sensor supply voltage is above 4.5V. The Green indicator changes to Red if the voltage drops below 4.5V

I’m using a small perf board to solder all the components on. There’s not much to it. A few 1/4W resisitors for current limiting sensors, few resistors for the RGB LED and a trim pot for adjusting data rate.

The box all done. There’s a small hole on the side for the mini-USB connector that will connect via USB cable to the carputer. This will in turn be read by the Gauge Pod software, parsed and displayed as an analog gauge on the screen.

Last step was to solder up some of the female connectors that will be spliced into the Challenger itself. Just three sensor connections for now. I might add oil pressure sensor later down the line.

Thanks to the use of the reference voltage on each input any fluctuations of supply voltage and ADC error will be smoothed out. The Arduino sketch is very simple. The sender simply sends tab delimited data to the USB device in the format:


e.g. IN1\t5.00\t2.00\r\n

This is repeated for each sensor input and finally sends the supply voltage: REF\t5.00\r\n

Final Features:
* USB HID Device. No more COM ports, no drivers needed.
* Reference Voltage on all inputs
* Reference supply voltage for each sensor
* Variable sending speed via trim pot
* Low Supply Voltage Indicator (less than 4.5V)
* Serial sending / Keep Alive Indicator
* Vibration proof screw-in type connectors
* Dual Current limited/non-limited sensor connectors

With the sender box complete, the next step is to re-write the Gauge Pod software to fix some of the issues and add some additional features.