I cannot get the Analog to Digital conversion to work correctly, for 5vDC I expected 1023 but got 890. This is my Sketch,
// MOTORCYCLE THROTTLE POSITION DISPLAY Bob Dunford 27/01/2014.
// The Moto Guzzi V11 motorcycle fuel control uses the position of the throttle twistgrip via a
// throttle position sensor(TPS)to determine the correct fuel delivery (amongst other parameters).
// The TPS is a simple potentiometer connected to the throttle body spindle, it is supplied with +5vDC
// and ground (0v) by the electronic fuel control computer(ECU).
// The potentiometer wiper supplies the TPS output to the ECU as a value from 0-5vDC.
// The ECU converts the 0-5v analog input to 10 bit digital (0-1023),
// the fueling map lookup table splits this TPS range into 15 columns (0-14) against the motor RPM to determine the fuel
// required. (Injection duration)
// This Sketch intends to Use an Arduino Nano V3 to display the raw TPS output as a 10 bit conversion of the 0 to 5v TPS output
// (0-1023), also to display the fueling map column position 0-14 on a two digit seven segment LED.
//MY PROBLEM, The 10 bit output never rises above 890 when it should be 1023 at full throttle, a multimeter indicates 4.98vDC
//so why does the A to D conversion not work correctly, as a consequence the LED never displays higher than 13 when it should //be 15.
#include <SevenSeg.h>
SevenSeg disp(4 ,5 ,6 ,7 ,8 ,9 ,10); // LED digit bars a to g connections to Arduino digital pins D4 etc.
const int numOfDigits =2; // two digit seven segment LED.
int digitPins [ numOfDigits ]={11, 12}; // LED digits 1 & 2 connections to Arduino digital pins D11 and D12.
int analogPin = A0; // Arduino pin connected to potentiometer wiper, other two terminals connected to Arduino pins 30 (vin) and 29 (gnd).
void setup () {
Serial.begin(9600);
disp . setDigitPins ( numOfDigits , digitPins );
}
void loop() {
analogReference(DEFAULT);
int tpsRaw = analogRead(analogPin);
int tps = tpsRaw / (64);
Serial.println(tpsRaw);
disp . write(tps) ;
}