9 Attachment(s)
Custom USB Parking Sensor interface (formally PDC-USB)
According to the requests of some users, I've developed this new interface that allows to connect an ultrasonic parking sensor to the PC through the USB port, like I've alredy done for the TPMS kit (Hoops! I did it again :biggrin1:).
The whole project is based on a cheap parking sensor kit (see the picture below) which can be purchased from many online retailers as well as on eBay and a simple interface based on the PIC microcontroller 18F2550.
The Parking Sensor used is wireless, this means that it doesn't need a wired connection between the main unit and the LED display and that it uses a serial protocol for the communication, so, once identified the transmitter located inside the main unit, it has been relatively easy to analyze the data structure.
Basically the whole data packet is composed by 24 periods where the logical "0" has a time duration of about 600 µS and the logical "1" is about 1200 µS, so when the Parking Sensor is powered, typically through the reversing lights, it starts to transmit a series of 3 bytes (24 bits) many times per second.
The 3 bytes sequence contains the address and the data (distance from the obstacle) detected from each ultrasonic sensor, so, since the ultrasonic sensors are 4, we will have 4 sequences of 3 bytes repeated over time, one for each ultrasonic sensor.
The first byte is composed by 2 nibble (4 bits), the first nibble identifies the ultrasonic sensor (0 = A, 1 = B, 2 = C and 3 = D) and the second nibble is complementary to the first, in order to verify the integrity of the data received.
The second byte, as for the second nibble of the first byte, is complementary to the third byte.
The third byte contains the distance detected expressed in centimeters.
So, if the ultrasonic sensor B detects an obstacle at 83 cm, the sequence is: 30 - 172 - 83 (0001 1110 - 10101100 - 01010011).
In order to allow the use of other types of Parking Sensors kits, I also looked into a second model produced by a different manufacturer (a special thanks to Enforcer who has provided both kits for the development of this project).
This last is wireless like the first one, but it has an LCD screen instead of a LED display.
The main unit of this Parking Sensor kit is different from the previous one, but the main difference is in the data sent to the display.
The whole data packet of this second kit is composed by 10 half periods where the logical "0" has a time duration of about 2 mS and the logical "1" is about 5 mS, so when it is powered, a series of 10 bits will be transmitted to the display many times per second.
The 10 bits sequence contains the data (distance from the obstacle) detected from all the ultrasonic sensors, this means that with this Parking Sensor kit each data sequence carries all the distances detected from the four ultrasonic sensors, contrary to the first kit, which sends a single data sequence for each ultrasonic sensor.
The first nibble (4 bits) contain the shortest distance detected by a group of two ultrasonic sensors (A and B or C and D) expressed in decimeters (10 cm).
The second nibble contain the longest distance detected by the other group of ultrasonic sensors.
The penultimate bit indicates if the shortest distance (first nibble) is related to the ultrasonic sensors A and B (left side) or C and D (right side).
The last bit is always "1".
Doing a quick comparison between the two systems (the one LED and LCD) we can see that:
The resolution of the LED system is 8 bits, so the accuracy is 1 cm (0.39 inches), the LCD system has a resolution of 3 bits only, then an accuracy of 10 cm (3.93 inches).
The LED system transmits the data of each ultrasonic sensor individually, so we can display 4 sliders on the PC (one for each sensor), the LCD system handles the ultrasonic sensors in pairs, then we can have only two sliders, one for the right side and one for the left.
Also, the LCD system needs to be connected to the USB interface only trough a cable, instead the LED one can operate also trough a wireless connection (bat this will be better explained later).
5 Attachment(s)
USB interface construction
As mentioned above, the interface is based on the PIC microcontroller 18F2550.
The schematic is relatively simple, the microcontroller gets the signal from the Parking Sensor trough the PIN 13, performs the data sampling and sends them to the PC through the USB port.
Through the transistor T1, connected to the PIN 22 of the PIC microcontroller, is possible to drive an active buzzer (or beeper), that will provide an alarm sound like the buzzer inside the original display of the Parking Sensor kit.
The advantage of this solution is that when the system detects an obstacle in the dangerous range, it will give out a beep also if the PC has not yet booted.
Brief note on the transistor used to drive the buzzer:
I've used a BC547 (European), but it is not critical and can be replaced with an equivalent general purpose transistor like a 2N5818 (USA).
The header pins JP1, JP2 and JP3 are optional and must to be placed on the board only if is used the wireless connection (available only with the LED Parking Sensor kit).
The connector SV1 is used to connect the buzzer and the main unit of the Parking Sensor kit (just in case it's not used the wireless link), in accordance to the following connection diagram:
Communication protocol, FAQ and related downlads
The communication with the PC is performed through the USB port and, as this is a Plug & Play HID device, it doesn't require a driver installation.
This make easy the development of software (stand-alone programs or plug-ins for many Front Ends) without the need of special APIs.
In order to facilitate the communication between the device and PC, I have developed a very simple communication protocol.
Basically the device waits for a request from the PC (1 byte) and, if need, returns the information required (5 byte).
The following table shows the protocol details:
20H (31) Data request --> Returns: A,B,C,D,Bz
40H (64) Buzzer mute --> Returns: Nothing
41H (65) Buzzer un-mute --> Returns: Nothing
Where:
A, B, C and D are the distances (in centimeters) detected by the four ultrasonic sensors sets at the rear bumper. FFH (255) indicates the sensor inactivity (the reverse is not inserted), any other value between C8H (200) and 00H (0) is a valid distance.
Bz is the buzzer status, 00H (0) muted and =1H (1) un-muted.
As example of how to use this device in your code, you can download a RoadRunner plugin and its source code here.
Related downloads:
Schematic & PCB (created with Eagle CAD)
Parts list & PCB scaled 1:1 (PDF - Adobe Reader)
RoadRunner PlugIn (Bynary and source code)
Centrafuse PlugIn (Developed by Wolfgang)