JdeRobot / base

GNU General Public License v3.0
94 stars 124 forks source link

Support for electromagnetic parking sensors #301

Closed jmplaza closed 3 years ago

jmplaza commented 8 years ago

There are parking electromagnetic sensors in the market that use an anthenna to detect distance to obstacles near the car (under 1m approx). As output they use a buzzer to signal one of three levels on the measured distance. Supporting these sensors opens the door to new applications

lr-morales commented 8 years ago

Progress report

Check list

Locate and acquire sensor for testing

Searching around the net, finally decided to use one good price sensor system composed by a central unit, a buzzer and a metallic adhesive antenna band.

The antenna of this sensor system is intended to be fixed inside the rear plastic bumper of the car; the central unit and the buzzer are fixed with an adhesive inside the car. The central unit is designed to be connected to 12V - ideally to the reverse light - and a valid ground.

sensorsystem

Preliminary system analysis and working test

For a first analysis, soldered a connector to the power input lines to allow a commercial 12V adapter to be used instead a real car; the antenna was partially unrolled on a table leaving a distance of more than 1m to other obstacles in one side.

After powering up the system, the buzzer beeps 3 times to signal that is ready to operate. If there is a bad connection, something wrong with or touching the antenna or another problem, the buzzer beeps with a sequence of deep tones.

When working in good conditions this behaviour can be observed:

Study the output signal

In order to connect the sensor to JdeRobot, a method to interface the sensor against some kind of computer is needed. The main output of the system is the buzzer, so a good approach is trying to adapt the signal sent to this buzzer to a device with JdeRobot.

Analysing the signal sent to the buzzer in a quick way with an oscilloscope we get this kind of results:

output1

output2

output3

It seems to be a low frequency PWM-like signal in the range of 1~3V.

After making additional tests, some peaks around 5~7V were detected during power-on phase. In order to avoid receiver input damage, a 7V maximum will be considered unless a significant signal drop is detected during next phases.

System response characterization

TODO

Devise good connection method to RPi2

After some initial designs for adapting a PWM-like output with possible peaks of 7V to the 3.3V maximum GPIO input of a Raspberry Pi 2, an optoisolated aproach was selected.

sensoraparcamiento

In the left side of the schematic, Vss is the input signal positive and PGND its reference; the resistor for that side is the current limiter for the optoisolator. In the right side, the 3.3V output, input pin from which the signal will be read and the ground GPIO pins are shown. The resistor for that side is a pull-down resistor (an arbitrary value was used) to ensure that the input pin is set to the reference value when no input is received.

The optoisolator used is an PC817B as it was available for testing at the moment, but any compatible component could be used instead.

In this schematic, when the central unit sends the PWM for the buzzer, the optoisolator input will receive the signal and close de output circuit according to this input.

In order to check the viability of the idea, four steps were taken before making the final connection: 1) Setting the input to a constant 3V and the output to a LED. 2) Setting the input to a constant 3V and the output to a piFace - I/O protected board - connected to a Raspberry Pi B. 3) Setting the input to the central unit and the output to a LED. 4) Connecting the central unit to the piFace board.

Last step was connecting the complete system for verification with ano auxiliary buzzer in order to check the working state.

Receive signal from sensor

For checking the signal received a simple mixed websocket/static webpage server in python 3 was written. This server launch a data acquisition process, a main handler process and a server process. The idea is encapsulate the functionality in these three processes, allowing the modification and adaptation of new modules for each part; specially changing between the piFace and the direct GPIO connection.

Rpi webServer

In the previous image, one of the capturing tests against the GPIO can be seen. These tests have shown that is possible at first glance to detect quickly enough the PWM signal variations.

JdeRobot driver encoding

Having a working input to a RPi2 GPIO input pin, the next step is to encode a new driver for this sensor. To achieve this, a GPIO controller library, a new dedicated interface and JdeRobot system in the RPi2 are needed.

The driver, called "emSensorDriver", has three explicit threads to do its work:

Driver testing

TODO

lr-morales commented 8 years ago

Updated the first comment of this issue (#301) with the progress achieved.