I have thought of creating a sensory system to be put on a self-driving mini toy car. This mini toy car is controlled by a Raspberry Pi 3 on which I have installed the ROS (Robot Operating System).
Step One: K-board
1 / 4 • Self-driving mini toy car
The sensory system is composed of three KEMET SS-430L-BK sensors rotated by 70° in order to have a greater surveillance area and understand if the person is moving from right to left or vice versa.
I have designed an electronic board (I have called it “K-board”) with a Cypress PSoC CY8C3866PVI-021 48-SSOP microcontroller that reads the status of the three KEMET SS-430L-BK sensors.
I have associated a different colored LED to each sensor: it lights up when a person is detected. The K-board is equipped with a buzzer that emits an acoustic signal when one of the three sensors SS-430L-BK detects a person. The system also performs multiple detections; they consist in the simultaneous detection performed by two or three SS-430L-BK sensors.
The PSoC reads the status of the three KEMET SS-430L-BK sensors every 100ms. When a person is detected in front of the sensor, a beep is emitted from the buzzer and the respective LED lights up. The LEDs are red, green, and yellow. Red refers to sensor 1, green refers to sensor 2 and yellow refers to sensor 3. The beep has a duration of approximately 200ms and three different tones. The LEDs turn on for about 500ms.
The K-board is equipped with UART, I2C and USB. In this case I will use the USB to send an ASCII string with the state of the sensors to the Raspberry Pi 3. The string consists of five ASCII characters:
K : Start of string;
x : Sensor 1 status | 0 = no human body | 1 = human body;
y : Sensor 2 status | 0 = no human body | 1 = human body;
z : Sensor 3 status | 0 = no human body | 1 = human body;
\r : Carriage return | End of string.
The string will be sent with an interval of about 100ms.
Note. There is a small mistake in the text on PCB: I have reversed the abbreviation NC with GND on the connectors text of the KEMET SS-430L-BK sensors (see the image below).
- 5V = Power supply;
- C = Comparator input;
- GND = Ground;
- NC = No connection.
Detail of a mistake in the text on K-board
I have attached the electrical schematic, the bill of materials and the Gerber files of the K-board, in order to give users the possibility to replicate it. In addition, I have attached the hexadecimal file to program the CY8C3866PVI-021 48-SSOP PSoC microcontroller. Finally for the most experienced people on PSoC I have attached the source code in C and the internal diagrams of the PsoC microcontroller.
Step Two: Case
1 / 2 • Internal diagram of the PsoC microcontroller
I have designed and printed in 3D an orange PLA case in order to fix the three KEMET SS-430L-BK sensors and the K-board. The case consists of two parts: the lower part which contains the hardware and the upper part which is the lid. In the lower part there are openings for the USB cable, for the buzzer and for three KEMET SS-430L-BK sensors. On the lid there are three holes from which the three LEDs come out.
Here attached you will find the two files that you need to 3D print the two parts of the case.
1 / 7 • Lower part of the case
Note (see the image below):
- I have soldered the wires directly to the connector on KEMET SS-430L-BK.
- I have used hot glue to fix the KEMET SS-430L-BK in the case.
Step Three: Robot Operating System
Positioning of KEMET SS-430L-BK sensors
I have created a ROS node in Python that reads data sent by the K-board through the USB serial port and publishes them on three ROS Topics. The node is called "kemet" and the data rate is 10Hz. Topic names are kemet1, kemet2 and kemet3. The type of data published on the topics is unsigned int 16 and the values are one (0x01) or zero (0x00). The value one indicates the presence of one or more people. The kemet1 topic refers to sensor one of the K-board; kemet2 topic refers to sensor two of the K-board; kemet3 topic refers to sensor three of the K-board.
I have attached the source code of the kemet ROS node.
I have inserted the K-board on a self-driving mini toy car and I have created a simple algorithm that uses kemet1, kemet2 and kemet3 topics: if sensor 1 detects a human body the mini toy car rotates to the right; if sensor 3 detects a human body the mini toy car rotates to the left; if sensor 2 detects a human body the mini toy car stops.
1 / 3 • Execution of kemet ROS node
I have attached some videos explaining how it works.Future evolution
This system can be expanded by creating a matrix of sensors with different lenses and arranged for example on a hemisphere. This way you could have a larger surveillance area with different detection distances. Furthermore, other sensors of different type could be coupled to make the system more reliable and able to be certified, for example as Cat. 3 and PL.That's all!
If you have any questions or suggestions don't hesitate to leave a comment below.