Update: 19/12/2022
Currently working on implementing an ESP32 and a pair of NEMA17 steppers – part of this testing procedure means that there is a need to build a digitally controlled laser pointer. Great fun for all the pets:
Origins
This project began in August 2021 out of sheer curiosity: can you scan your surroundings using an Arduino, bog standard HC-SR04 ultrasonic sensor (<£2) and SG90 servo (<£3)?
The initial test rig was constructed from cardboard (as always) and produced an .xyz file with 90 points. This was then exported to a CAD program to view.
While the results might look underwhelming, I could see the potential – the sensor was detecting objects and the maths and mechanics were aligning. It was effectively a very basic SONAR system.
This was all the encouragement needed to progress the project further. All there was to do was increase the coverage area in 2D and 3D while increasing accuracy.
Over the following days/weeks, the following works were done:
- Full 360 degree rotation was added with a 28BYJ-48 stepper motor and ULN2003 driver. (<£4)
- An MG996R servo was implement to add pitch control and add a 3rd dimension. (<£8)
- In order to increase accuracy and narrow the beam, a fuzzy cone was added to the ultrasonic sensor (to give a bit of a Clockwork Orange vibe, if nothing else).
- A rotary encoder provided a very basic user interface to prevent wires from becoming tangled during the scan.
After all of the above changes were completed, the contraption was put on a test scan and the following point cloud was produced.
Garbage. So after some debugging, testing, more fettling, testing again, debugging and adjusting and finally testing again, the following scan was was produced:
At this point, it became apparent that there were two factors which were limiting the accuracy of the scans: the sensor simply wasn’t precise enough and neither was the rotational control.
A new sensor was purchased: the Benewake TF-Luna offering a beam width of 2 degrees (x 7.5 times more precise than the HC-SR04)
In addition to this, the rotational control was handed over to a NEMA 17 stepper motor and A4988 driver.
The servo angle was also increased to 135 degrees, thus giving a theoretical maximum resolution of 432,000 points.
This project had grown from a sheer curiosity with some cheap components to now producing three dimensional scans of rooms using a £40 LiDAR sensor. I was impressed with the results
The Next Step
There was a problem. The scanner couldn’t “see” around objects in the foreground. Therefore creating ‘shadows’ in the background.
If you could link a second scan of the same room from a different viewpoint then it the ‘shadows’ would greatly decrease.
To do that you need to make the scanner self aware. Then you have to be able to make it locate and remember a point. Then you have to move the scanner and aim it at the original point. From that you’re able to triangulate your position.
All of this self-awareness made the program size balloon past the capabilities of the Arduino Uno/Nano (328P chip). Therefore an Arduino mega was implemented.
A custom shield was designed to accommodate all of the necessary components and modules while itself sitting atop of the mega.
What Happened?
Alas; production kills most projects.
Although, if I’m honest; I was really struggling with the algorithms and control structure for the program, especially how the scanner should interface the user. This was enough of a blockage to slow the project down to a stop.
Upgrading the original cardboard rig also involved a sizeable amount of fabrication (3D design and printing). The final nail in the coffin for this project was starting the ender3Dscanner (which also failed at production).
To this day; the project remains in a box with many of the parts missing after being donated to other projects.
What Next?
Have to admit that writing about the project has given me inspiration to pick it up again. I now know things that I didn’t know back then, and the problems may not be insurmountable anymore. Also, I would probably implement an ESP32 MCU as it can handle double-point floating-point numbers for greater precision.
The Version 2 project does have real-world applications and it could help with real-work, as such it’s featured as a future project.
Last updated: 06/10/2023