Hi everyone! Here's a quick Instructable to show you how you can make your own fun little demo using tinyLiDAR in what's known as the "Arduino Radar". Its been done by others before using ultrasonic sensors but ours has some slightly new twists to it.
Step 1: Technology
For starters we're using our newly developed tinyLiDAR laser sensor board which features some of the latest FlightSense(TM) technology from ST Microelectronics in their part called the "VL53L0X" time-of-flight sensor. This little sensor is definitely "pro-grade" as its been used in well over a quarter billion smartphones to date since its introduction last year and has even made its way into the iPhone 7.
For a part that's only 4.4 x 2.4 x 1mm in size, it certainly has a lot of technology packed into it.
On the transmitter side, it has an eye-safe IR laser made from a vertical cavity etched into its silicon called the Vertical-Cavity Surface-Emitting Laser (VCSEL). On the receiver end, it has two arrays of over 200 super fast photodiodes called Single-Photon Avalanche Diodes (SPADs). Yes they said single photon! These diodes can trigger a current from as little as one photon and can do so in just picoseconds. Hence the reason for its ability to resolve down to the millimeter level.
See the slide above from ST which explains at a high level what Time-of-Flight means. Note that most optical sensors rely on the amount of light received to get distance. Time-of-Flight sensors don't care about the amount as long as the light is detectable. These sensors actually measure the time it takes for the light to travel to the object and back.
You can already purchase many different generic PCB's that fan-out the pins to the VL53L0X and allow experimenters to connect it up to Arduinos. But these boards will be limited to a max scan rate of about 40Hz due to the sensor libraries available for Arduino.
Thanks to a dedicated micro and some low-level firmware tweaks on tinyLiDAR - we were able to push this to over 60Hz! A nice 50% improvement.
If you Google for Arduino Radar you will find many videos showing slow rotating servos. Not very useful for robots moving around in a room at reasonable speeds. Now check out our real-time video (if you haven't already done so at the intro of this article). You can see for yourself how much faster ours is :)
0.5us PWM Resolution
Another twist/improvement to the radar sketch was to use the 16bit hardware timer/counter (TC1) in Arduino to control the analog servo directly. Others use the built-in "software only" servo libraries in Arduino but we found these to be very slow and inaccurate.
Our new approach gives 0.5us resolution PWM signals and, as you can see in the video, works very well with the fast response time of our tinyLiDAR sensors even on the UNO.
Yet another feature that's available for tinyLiDAR but not implemented in this sketch is the ability to accurately calibrate the VL53L0X sensor. If you search the web, you will find that most people agree the accuracy of VL53L0X is not bad but always seems to have some constant error term. You can calibrate this out easily with our "automatic offset calibration" function. In fact its recommended by the manufacturer to perform this offset calibration after SMD reflow of the part. The big cell phone manufacturers do this routinely as part of their laundry list of manufacturing test and calibrations after assembly, but aside from them, almost no one else does this except us ;) We will ship each tinyLiDAR board pre-calibrated with the calibration stored in non-volatile storage on the tinyLiDAR board. You can also re-calibrate as desired with a simple command. Check out our reference manual for more details.
Step 2: Let's Build It!
The first diagram above shows the dimensions of the right angle bracket we made from a spare piece of .063" thick 3003-O aluminum plate we had in the lab but you can also try 5052 or 6061 alloys. We used two of M2 x 6mm socket head cap screws with 0.4mm thread pitch to mount tinyLiDAR to this aluminum bracket but any M2 screw longer than 4mm will work. Thread pitch is not important as the aluminum is very soft and will accept any reasonably coarse thread when you drill a 1/16th inch pilot hole first.
We then used double-sided foam tape to affix the bracket to the round plastic platform which screws into the analog servo. This round platform was included with the Seeed servo. Make sure to cover the mounting areas with insulating tape like Kapton/polyimide tape, electrical tape, etc. before mounting tinyLiDAR in order to prevent shorts.
The second diagram maps out some of the technology we put into tinyLiDAR and the Fritzing diagram shows connection details to the Arduino UNO.
Sketches for the Arduino UNO and Processing development environments are provided below. Please read over the code to become more familiar with it before using.
The Processing programming language/environment maybe new to you but it will look very familiar when you download (from processing.org) and install it as this was the basis for the Arduino IDE. Programs on this system are also called "sketches" but this language was developed more for the visual arts field. This is the reason why you see draw() instead of loop() for the central repeating code block.
Operationally, your Arduino UNO is used to control tinyLiDAR via I2C and then send measurement and angle data over a virtual com port to the Processing sketch for display.
The only Processing configuration detail you may have some trouble with is the error that says "OCR-A" font is missing. To install it, just go to Tools\Create Font\, then choose the OCR-A font, set the size to 30 and press OK. This will create the required ".vlw" file in a data folder inside of your sketch folder.
Also if you don't have a Microsoft Office product installed already on your computer then you maybe missing this font altogether. If so, then you can download the "OCRA.ttf" file from here. After this, you can go thru the steps outlined above to create the font inside of Processing. As the two sketches communicate via a virtual serial com port on your computer, you will have to change the assigned port number as needed in the Processing sketch. It will be the same com port number that's used by your Arduino.
Thanks for taking the time in reading this Instructable and enjoy the sketches. If you liked this project then please be sure to visit our Indiegogo campaign running at the time of this writing.
As mentioned on our crowdfunding page, we have been working on the tinyLiDAR concept for quite a while now and we've been successful in bringing it to a stable working prototype stage. Your help is needed now to help us lower the cost of this sensor module for mass production so that everyone in the maker communities can benefit from this versatile little distance sensor at a reasonably low cost. Please help to bring this project to life by showing your support - back us now and spread the word to your friends. Thank you!