Arduino to Power Commander 5

Hey guys, I’m interested in starting my first Arduino project.

I want to be able to read Throttle Body Position or RPM (either way, though preferably the former) on my R1.

I have a Power Commander 5 and software that displays RPM/Gear Position and all sorts of other stats via the software they provide.

I was able to find some documentation on the various inputs, but I’m not sure how to go about hooking it up to the Arduino.

Here’s what I’ve found so far that may be useful.

Power Commander 5 documentation: (some of it)

A program someone wrote to automatically switch fuel maps by reading TPS values (Attached).

What’s not clear to me is how to connect the physical hardware.

Should I use the Analog socket (from documentation?)

Any help would be greatly appreciated

/*---( NOTES )---*/
 - Rev1.1
 - Date 12.06.16
 - By L.K.
 - Automated fuel map switch for cruising
 - Reads throttle position sensor (TPS) voltage on Analog Pin A0
 - When cruise conditions are detected, sends 5 volt signal on Pin 13 to switch fuel maps on PCV

 - MRTI - Minimum run time inhibit
 - TPSR - TPS rate of change
 - TPSS - TPS smoothness factor

 - Pin A0 Input voltage from TPS
 - Pin 13 Output voltage to PCV / Relay


/*---( Import needed libraries )---*/

/*---( Declare Constants )---*/
 #define TPSin  A0                          // Pin for TPS input voltage
 #define PCVout = 13;                       // Pin for map switch output voltage
 #define displayInterval = 500              // Value for time between displaying values on screen (m/s)
 const int MRTI = 120000;                   // Value for minimum run time inhibit (sec)
 const int TPSR = 2.5;                      // Value for TPS rate of change (V/s) - THIS VALUE IS A GUESS
 const int TPSS = 5;                        // Value for TPS smoothness (V^2/s) - THIS VALUE IS A GUESS
 const int sampleDuration = 30000;          // TPS sampling duration for smoothness averaging (ms)
 unsigned long dt = 100;                    // TPS sampling rate (ms)

/*---( Declare objects )---*/

/*---( Declare Variables )---*/
 int numReadings;                           // Number of samples for averaging
 int readings[numReadings];                 // the readings from the analog input
 int readIndex = 0;                         // the index of the current reading
 int total = 0;                             // the running total
 int TPSaverage = 0;                        // the average
 int TPSinteger;                            // Reading from the TPS signal as 10 bit value
 float TPSvoltage;                          // TPS value converted to 0-5 volts 
 float LastVoltage = 0;                     // TPS starting voltage
 elapsedMillis timer;                       // timer for counting between screen prints

/*---( Setup runs once )---*/
void setup()
 Serial.begin(9600);                        //Start sending to "Serial Monitor"
 Serial.println("PCV AUTO MAP SWITCH");     //Display message on screen 

/*-( Initialize all the readings to 0 )-*/
 for (int thisReading = 0; thisReading < numReadings; thisReading++) 
  readings[thisReading] = 0;                // initialize all the readings to 0

/*---( Loop runs continuously )---*/  
void loop()

/*---( Minimum Run Time Inhibit )---*/    
 if (millis() < MRTI)   
  digitalWrite(PCVout, LOW);                // no voltage to PCV map switch

  Serial.println("Minimum run time inhibit. Please wait."); // Display message on screen

/*---( TPS rate of change )---*/  
  TPSinteger = analogRead(TPSin);           // Read TPS value
  TPSvoltage = TPSinteger * (5.0 / 1024.0); // Convert TPS value to Volts 
  TPSchange = (TPSvoltage-LastVoltage);     // Find the change of TPS compared to last reading
  LastVoltage = TPSvoltage                  // Store TPS value for comparison with next reading
  TPSrate = (TPSchange/dt);                 // Find the rate of change of TPS

/*---( TPS smoothness )---*/ 

  numReadings = (sampleDuration/dt);        // Number of samples for smoothing TPS
  total = total - readings[readIndex];      // Subtract the last reading
  readings[readIndex] = TPSchange^2         // Square the TPS rate of change and store in an array
  total = total + readings[readIndex];      // add the reading to the total:
  readIndex = readIndex + 1;                // advance to the next position in the array

  if (readIndex >= numReadings)             // if we're at the end of the array
   readIndex = 0;                           // wrap around to the beginning:

  TPSsmoothness = total / numReadings;      // Smoothness of TPS - SEE COMMENT BELOW

  timeArray = MRTI + sampleDuration;        // Time duration to allow the array to fill up with data

/*---( Check if TPSR and TPSS are ok to switch fuel maps )---*/ 
  if (millis() > timeArray && TPSrate < TPSR && TPSsmoothness < TPSS )
   digitalWrite(PCVout, HIGH);              // Switch on voltage to PCV map switch

/*---( Print values on screen )---*/ 
  if (timer > interval) 
   timer -= interval; //reset the timer      // Setup timer to print on screen at set intervals

   Serial.println("TPS voltage = ");         // Display message on screen
   Serial.print(TPSvoltage, 3);              // Print value 
   Serial.print(" V");                       // Print value 

   Serial.println("TPS rate of change = ");  // Display message on screen
   Serial.print(TPSrate, 3);                 // Print value 
   Serial.print(" V/s");                     // Print value 

   Serial.println("TPS smoothness = ");      // Display message on screen
   Serial.print(TPSsmoothness, 3);           // Print value 
   Serial.print(" V^2/s");                   // Print value 

  delay(dt);                                 // Wait until next sample

/*---( End loop )---*/

PCV Auto Map Switch Rev1.1.txt (5.27 KB)


I'd really like to get some info about this - can anyone help me out?

This post is now #1 search on google for this.

Should I use the Analog socket (from documentation?)

Hi there.
Yes, according to the code you uploaded:

Connect pin A0 to TPS sensor output
GRD to TPS ground

then power to the Arduino via a step up/down power module like a Pololu to give the arduino 5v or 3.3v (depending on what you are using).

Lastly the output to the PCV:
Pin 13 and GRD on the arduino to a relay that will close when activated by this code and act like a switch to change the map.

You will also have to go through the code and change the vairables (TPSR and TPSS) to match your bike. If you connect a screen to the arduino and cruise the serial out will show you the
values and you should be able to go from there.

Let me know how you get on or if you already worked this out.