Close

PS3 controller: Hunting down the I2C issue

A project log for Building the Thor robot

Building a 6-axis robot based on the Thor robot. When size DOES matter!

olaf-baeyensOlaf Baeyens 04/17/2017 at 14:340 Comments

Things that don't work, I love them! It challenges you to dig in deeper and make them work.

But first is to identify the issue, make it visible and learn how to repeat the test setup.

So I ordered a DSO138 self build telescope and a cheap logic analyzer. I never heard about Saleae before so I thought I bought a official product. I will definitely buy an official one soon.

The oscilloscope (up right) shows the I2C communication. That oscilloscope does not match up to a real one but it shows something. It shows noise levels and voltage levels. They are all withing normal range.

This is the trace (last 7 bytes to read) when I start up the Arduino motherboard (2 different motherboards I tested on) but did not pair the PS3 controller yet.

These values should be "0" not "@ = 64). It is erratic as far as I can see above

Once I pair the PS3 controller then the erratic behavior stops but once in a while I values that should be 0 or 1 but in reality their value reflect the first 7 bytes instead.

These values are not random as they can be induced by noise, they are exactly the same as the first 7 bytes.

When I look at the complete signal then I can see the 35 bytes transmitted into 28 first bytes and then the last 7 bytes 29-35. (Gap 7-8 is interesting it it always is there)

The freeze seems also very interesting. The I2C communication just stops. Just let the controller run and it will freeze at random times. Sometimes it can take several minutes, sometimes it is instantly

void loop()
{
  unsigned char i;

  currentTime = millis();
    
  if(currentTime >= (ps3ReadTime + 50)){  
    // Get data from PS3 Controller every 50ms
    get_ps3(); 
    if (ps3.btn_triangle) {
      digitalWrite(LED_BUILTIN, HIGH);   
    } else { 
      digitalWrite(LED_BUILTIN, LOW);   
    }
    ps3ReadTime = currentTime;  // Updates ps3ReadTime
  }
  
  if(currentTime >= (ps3PrintTime + 200))
  { 
    // Print out our data to serial port every 200ms
    // print_ps3();
    ps3PrintTime = currentTime;  // Updates ps3PrintTime
  }

}
The code used for this setup.

ps3.btn_trialnge is located in the last 7 bytes retrieved. When you press it then the on board LED activates. It is a very easy way see if the PS3 data is still receiving without a logic analyzer os oscilloscopic.


My conclusion it is a firmware bug, probably something very tiny and easily fixed.

Discussions