Arduino based Lidar Scanner
For my first electronic project I decided to build an affordable lidar scanner to produce my own lidar data for future 3D projects.
The first hardware version was built with two Arduino Nano – one to control the motor stepping and scanning and one for writing data on an SD-card. For the two stepper motorsI used two a4988 controllers. The sensor is the LIDAR-Lite v3 HP from Garmin, with an distance measuring rate up to 1000hz. After some test runs and debugging on the breadboard I soldered all parts onto an pcb board.
In the next step I wrote the software in C++ which fortunately is pretty similar to python. It is necessary that the two motors run smoothly, therefore I decided to use two Arduino Nano and send the data from the first unit via I²C bus to the second one. The second unit collects the data into 512byte packets and writes it onto the SD-Card. If you are interested in the code, you can find a link at the end of this post.
My brother, a mechanical engineer, helped me and created all parts I needed with a lathe and a milling machine. So I only needed to order gears, bearings and belts. I decided to use an 1 to 4 gear translation to improve the scanning resolution.
- Step motors have 200 positions in one turn at full step mode, additionaly you also can interpolate positions to archive 400, 800 and more steps (half step, quarter step…) depending on the controller.
- Full step 200*4 = 800*400 points
Half step 400*4 = 1600*800 points
After everything was assembled I started the first scan and it worked!
..the only problem was the loud noise from the step motors and the slow scanning speed caused by the only 16Mhz slow Arduino.
I decided to rebuild the hardware, this time with an Arduino Due (superfast 84 Mhz! compared to the Nano ), an Arduino Nano for the data writing and two TMC2208 controller to reduce the motor noise. After some problems with the I²C bus, which could be solved with an pull-up resistor, the new hardware worked fast and quiet.
Data and Import
The data is written in binary saving only the meassured distance and a header with information about starting angle and the scanning resolution, everything else is calculated later during the import to Houdini. To get the point positions you only need to know the two viewing angles of the sensor and the distance. Then you convert the position from spherical coordinates to cartesian coordinates:
x = sin(x_angle) *sin(y_angle) *dist;
y = -cos(x_angle) *dist;
z = sin(x_angle) *cos(y_angle) *dist;
The default scanning resolution is set to 1600×800 points with an range up to 20m and takes about 10-20 minutes depending on the scanning angle. In the link is a hiplc file containing three test scans including the import script.
1* Arduino Due
1* Arduino Nano
1* OLED Display
1* SPI SD Shield
2* Nema 17 step motor
++ gears, bearings and metal parts