Close

Ps3 controller: Compensating for errors

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/09/2017 at 21:060 Comments

For Thor I want to use a USB host controller that connects to PS3 but I ended up having a issue that may become dangerous when operated on machinery: ps3-controller-i2c-concerns

I contacted Hobbytronics telling them that their firmware may have an issue.


I can wait for them to fix a firmware, OR I can find a workaround.

I prefer to find a workaround because this device is going to control a hardware that can hurt people when it suddenly gets an erratic command to start moving.

Even if it is not a firmware bug, it could be because of faulty wiring or some other I2C device adding data noise.

Trace example.

When you look at the trace then the first 6 numbers can be between 0 and 255., however the next 29 are only true or false.

So I can disregards the 35 byte command received when the numbers above position 6 is something else than 0 or 1. I wait for the next received data stream.

But I could also have the frozen bytes issue that I have on the Arduino Due. I still receive correct 35 bytes but the bytes are repeated from the last transmitted ones. However byte 5 and 6 comes from an accelerometer and I assume that the operator will hold it into his hand. So these 1 values will change slightly. The variation these 2 bytes indicate a human operator. I actually wonder if I can use these 2 values telling the robot that a user has taken up the controller. So it may turn on a red warning light.

Finally if the robot gets in values that seems to be frozen or when the accelerometer don't move too much like it is sitting on a table. I am thinking to make the robot come to a standstill if it is in manual mode.


Example below represents thee received data from the USB host controller v2.4 (code comes from Hobbytronics)

typedef struct ps3_data {
	unsigned char joy_left_x;
	unsigned char joy_left_y;
	unsigned char joy_right_x;
	unsigned char joy_right_y;
	unsigned char accel_x;
	unsigned char accel_y;
	unsigned char press_up;
	unsigned char press_right;
	unsigned char press_down;
	unsigned char press_left;
	unsigned char press_lb;
	unsigned char press_rb;
	unsigned char press_lt;
	unsigned char press_rt;
	unsigned char press_triangle;
	unsigned char press_circle;
	unsigned char press_x;
	unsigned char press_square;
	unsigned char btn_left;
	unsigned char btn_down;
	unsigned char btn_right;
	unsigned char btn_up;
	unsigned char btn_start;
	unsigned char btn_joy_right;
	unsigned char btn_joy_left;
	unsigned char btn_select;
	unsigned char btn_square;
	unsigned char btn_x;
	unsigned char btn_circle;
	unsigned char btn_triangle;
	unsigned char btn_rt;
	unsigned char btn_lt;
	unsigned char btn_rb;
	unsigned char btn_lb;
	unsigned char btn_ps3;
};

Discussions