Making a LiDAR – Part 3

Embedded Software and Platform Choice

By: David
Principal Consultant, Data Exploration

10th April 2019

3 minute read

Home » Insights » Making a LiDAR – Part 3

Embedded Software and Platform Choice

Do you remember as a child counting how long it took for thunder to arrive after the lightning flash, and then working out how far away the storm was? Well, a LIDAR uses the same principle but with light rather than sound. I think that’s amazing. Imagine switching a torch on, pointing it at the wall in front of you, and using a stopwatch to time how long it takes for the light to get reflected back to you. That seems ludicrous, but that’s exactly what our laser range finder is doing. (Did you know that one light Nanosecond is approximately one foot in length? So, I’m about 5.66 light Nanoseconds tall.)

Now, at the back of our laser range finder we have some wires that carry the measured distance data (I2C for the technically minded), so the first job of our software is to read the data, and just like a digital camera we need to write it back to an SD card. We also need to worry about controlling the scanning stepper motors. If you’ve no experience of stepper motor control, it’s quite straight forward; each time you generate a pulse the motor moves a tiny fraction. If you generate a continuous pulse train the motors spins. If you count the number of pulses you know how far the motor has moved. It’s all very straight forward, and just the sort of task a microcontroller was made far.

However, before we get started we need to pick a microcontroller, and this is where it can get contentious. Whatever you choose; somebody else will tell you that you should have done it their way instead. In my opinion, that’s frustrating, and they are usually wrong. I’ll defend that by saying only one thing matters. You need to pick a technical solution that’s within your capability to deliver to, and ideally exceed, the expectations of the people paying you. The great thing about engineering is that there will be many equally good ways of doing that, so you’re only wrong if your way isn’t one of them!

Personally, I’m not too keen on Arduino. It’s great for hobbyists and proof of concepts, but I do find its “simple educational” environment constraining. Likewise, the thought of days wading through thousands of pages of data sheets is equally unattractive. I want to write the embedded code to make the LIDAR work; I’m not interested in writing the code to make the microcontroller work. That’s why my own choice is the STM32 microcontroller family and the STM32CubeMx tool. It lets me “auto-generate” the framework to configure the microcontroller, I don’t have to read every minutia of detail in the datasheet, and it gives me a professional IDE development chain with full visibility of exactly what the hardware is doing if I should need it..

To sum up, with an STM32 I can get the job done, and I can meet all expectations. But importantly, if a BeagleBone running a Python interpreter lets you get the job done, and leads your customers to success, then don’t let anyone tell you that you’re wrong. Of course, don’t be closed to new ideas either. Learning and exploration are what makes life interesting!

Do you remember as a child counting how long it took for thunder to arrive after the lightning flash, and then working out how far away the storm was? Well, a LIDAR uses the same principle but with light rather than sound. I think that’s amazing. Imagine switching a torch on, pointing it at the wall in front of you, and using a stopwatch to time how long it takes for the light to get reflected back to you. That seems ludicrous, but that’s exactly what our laser range finder is doing. (Did you know that one light Nanosecond is approximately one foot in length? So, I’m about 5.66 light Nanoseconds tall.)

Now, at the back of our laser range finder we have some wires that carry the measured distance data (I2C for the technically minded), so the first job of our software is to read the data, and just like a digital camera we need to write it back to an SD card. We also need to worry about controlling the scanning stepper motors. If you’ve no experience of stepper motor control, it’s quite straight forward; each time you generate a pulse the motor moves a tiny fraction. If you generate a continuous pulse train the motors spins. If you count the number of pulses you know how far the motor has moved. It’s all very straight forward, and just the sort of task a microcontroller was made far.

However, before we get started we need to pick a microcontroller, and this is where it can get contentious. Whatever you choose; somebody else will tell you that you should have done it their way instead. In my opinion, that’s frustrating, and they are usually wrong. I’ll defend that by saying only one thing matters. You need to pick a technical solution that’s within your capability to deliver to, and ideally exceed, the expectations of the people paying you. The great thing about engineering is that there will be many equally good ways of doing that, so you’re only wrong if your way isn’t one of them!

Personally, I’m not too keen on Arduino. It’s great for hobbyists and proof of concepts, but I do find its “simple educational” environment constraining. Likewise, the thought of days wading through thousands of pages of data sheets is equally unattractive. I want to write the embedded code to make the LIDAR work; I’m not interested in writing the code to make the microcontroller work. That’s why my own choice is the STM32 microcontroller family and the STM32CubeMx tool. It lets me “auto-generate” the framework to configure the microcontroller, I don’t have to read every minutia of detail in the datasheet, and it gives me a professional IDE development chain with full visibility of exactly what the hardware is doing if I should need it..
To sum up, with an STM32 I can get the job done, and I can meet all expectations. But importantly, if a BeagleBone running a Python interpreter lets you get the job done, and leads your customers to success, then don’t let anyone tell you that you’re wrong. Of course, don’t be closed to new ideas either. Learning and exploration are what makes life interesting!

Top