I saw a couple of articles on hacking reverse parking sensors using micro’s other than an Arduino and decided to have a go myself. A lot of information I got from the following two sources http://www.mp3car.com/hardware-development/121995-custom-usb-parking-sensor-interface-formally-pdc-usb.html and http://ishankarve.blogspot.co.uk/2011/06/decoding-ultrasonic-parking-sensor.html There a lots of different versions available on eBay but I decided to go with the wireless version from the first link. The manufacturer was listed as CISBO. First action was to remove the  screws to get access to the circuit board

IMG_1144 IMG_1142 IMG_1143

 

As can be seen here

IMG_1146

IMG_1147

I solder wires to ground and data in then hooked up to my saleae logic Analyser

IMG_1152

I obtained the following trace

trace

The trace is made up of three bytes, 1st byte identifies which  Sensor A, B, C or D. The next two bytes provide the distance measurement in cm’s.

Next it was time to hook up to an Arduino

IMG_1159IMG_1164

And write some code

int pin = 7;
int ledPin = 13;
unsigned long pulse_length;
byte sensorValue[24];
byte pulse_value;
byte temp = 0;
byte distance = 0;

// const sensor address's
const byte senA = B11110000;
const byte senB = B11010010;
const byte senC = B11100001;
const byte senD = B11000011;

void setup()
{
pinMode(pin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
}

void loop()
{
int i;
//look for starter pulse
pulse_length = pulseIn(pin, LOW);
while (pulse_length < 18000) {
pulse_length = pulseIn(pin, LOW);
}
for (i = 0; i < 25; i = i + 1) {
pulse_length = pulseIn(pin, HIGH);
if (pulse_length > 290 && pulse_length < 310) {
pulse_value = B0;
digitalWrite(ledPin, LOW);
}
else {
pulse_value = B1;
digitalWrite(ledPin, HIGH);
}
sensorValue[i] = pulse_value;
}

Serial.println(" ");

for (i = 0; i < 25; i = i + 1) {
Serial.print(sensorValue[i], BIN);
}
Serial.println(" ");

for (i = 0; i < 25; i = i + 1) {
pulse_value = sensorValue[i];

// write pulse_value to bit 0
bitWrite(temp,0,pulse_value);
switch (temp) {
case senA:
Serial.print("Sensor A: ");
Serial.print (temp, BIN);
Serial.print(" ");
pulse_distance(i+1);
i = i + 16;
break;
case senB:
Serial.print("Sensor B: ");
Serial.print (temp, BIN);
Serial.print(" ");
pulse_distance(i+1);
i = i + 16;
break;
case senC:
Serial.print("Sensor C: ");
Serial.print (temp, BIN);
Serial.print(" ");
pulse_distance(i+1);
i = i + 16;
break;
case senD:
Serial.print("Sensor D: ");
Serial.print (temp, BIN);
Serial.print(" ");
pulse_distance(i+1);
i = i + 16;
break;
}

// shift left
temp = temp << 1;
}

}
void pulse_distance(int i) {
//read next 8 bits
int j;
distance = 0;
for (j=0; j < 8; j = j + 1) {
pulse_value=sensorValue[i];
// shift left
distance = distance << 1;
// write pulse_value to bit 0
bitWrite(distance,0,pulse_value);
i = i + 1;
}
distance = ~distance;

Serial.println(distance, BIN);

}

Which produced the following output

IMG_1163

I then wrote a processing sketch to display the data more elegently

import processing.serial.*; /* Needed for Serial Communication */

/* Global variables */
Serial comPort;
String [] comPortList;
String comPortString;

sliderV sV1, sV2, sV3, sV4;

color cor;

/*--------------------------------------------------*/

void setup(){
size(500,500);            /* Set the size of the window  */
//background(0);            /* Set the background to black */

/* Get the available com ports. If there is at least one
com port available, then start communicating on it.
If there are more than one com ports available, we will
only open the first one (i.e. comPortList[0])
The bufferUntil('\n'); statement will generate a serial Event
when it reads a carriage return */

comPortList = Serial.list();
if(comPortList.length>0){
comPort = new Serial(this, comPortList[0], 115200);
comPort.bufferUntil('\n');
}

// create 3 instances of the sliderV class
sV1 = new sliderV(100, 100, 90, 255, #FF0000);
sV2 = new sliderV(200, 100, 90, 255, #03FF00);
sV3 = new sliderV(300, 100, 90, 255, #009BFF);
sV4 = new sliderV(400, 100, 90, 255, #FF9BFF);
}

/*--------------------------------------------------*/

void draw(){
/* The serialEvent function will update the display */
}

/*--------------------------------------------------*/

void serialEvent(Serial cPort){
comPortString = cPort.readStringUntil('\n');
if(comPortString != null) {
comPortString=trim(comPortString);
String items[] = split(comPortString, ':');

// if there was more than one string after the split
if (items.length > 1) {
// remove any whitespace from the label
String label = trim(items[0]);
// remove the ',' off the end
String val = trim(items[1]);
// check what the label was and update the appropriate variable
if (label.equals("A")) {
sV1.p = int(val);
}
if (label.equals("B")) {
sV2.p = int(val);
}
if (label.equals("C")) {
sV3.p = int(val);
}
if (label.equals("D")) {
sV4.p = int(val);
}
}

/* Print to the Debug screen in Processing IDE */
println(comPortString);
}

background(0);
sV1.render();
sV2.render();
sV3.render();
sV4.render();
}

/*
Slider Class - www.guilhermemartins.net
based on www.anthonymattox.com slider class
*/
class sliderV {
int x, y, w, h, p;
color cor;
boolean slide;

sliderV (int _x, int _y, int _w, int _h, color _cor) {
x = _x;
y = _y;
w = _w;
h = _h;
p = 90;
cor = _cor;
slide = true;
}

void render() {
fill(cor);
rect(x-1, y-4, w, h+10);
noStroke();
fill(0);
rect(x, h-p+y-5, w-2, 13);
fill(255);
text(p, x+2, h-p+y+6);

if (slide==true && mousePressed==true && mouseX<x+w && mouseX>x){
if ((mouseY<=y+h+150) && (mouseY>=y-150)) {
p = h-(mouseY-y);
if (p<0) {
p=0;
}
else if (p>h) {
p=h;
}
}
}
}
}

which gave the following output

IMG_1167

 

 

 

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required