Making a small, low cost laser scanner for sense-and-avoid applications has been a objective of mine for several years. What makes this project challenging is the cost and complexity associated with motors and their drivers to provide the motion, position encoders to provide accurate aiming information and slip rings to pass the signals through the moving parts.

In a typically anarchistic response to these limitations, we decided to throw out all of these parts and start again with a simple, low cost, digital servo bolted directly onto an LW20 LiDAR. I've used the DS-919MG servo from Corona for this example although most digital servos will work.


The servo doesn't go all the way around, so the field of view is limited. For a forward looking sensor this is a reasonable limitation, given that it is so inexpensive, small and the whole system only weighs 50g.

It is simple to connect up the LW20 to a servo because the hardware and software drivers are built in. There is one wire that connects to the PWM control line of the servo and we used a separate power supply for the servo because they tend to be noisy on the power rail.


Through the comms port (serial or I2C) of the LW20, the servo can be told to aim in any direction. There is also a command to switch on fully automatic scanning.

To make an energy efficient scanner it is nice to be able to scan in two directions (clockwise and anti-clockwise) in a continuously reciprocating movement. Unfortunately, low cost servos are notoriously tricky to use in this way because their internal control systems are designed to aim the servo in a static direction. If you try to change the aiming angle of a servo before the shaft stops moving then the shaft position always lags behind the requested aiming position.

For most applications, "servo lag" isn't a problem because the servo moves quite fast. However, the LW20 is updating 388 times a second and this is on the limit of how fast a conventional servo can accept changes in position. The result is that the position of the scanned image from a CW scan is slightly different from that of the ACW scan.

You can see the lag in the image below where the black line is the ACW data and the orange line is the CW data. The data points in this image have been thinned out to avoid clutter but the actual number of points in each scan is much higher.


Fortunately for us, the LW20 driver software includes compensation for the servo lag and with a few tries it can be eliminated almost entirely.


For the purists out there who want precise angular data, there is also a uni-directional scan available as an option in the software. This eliminates the lag problem altogether but the servo draws a lot more power when it is returning to the start position.

To help with setting up a servo driven LiDAR, our software genius, Rob, has provided a fully interactive GUI that lets you put in settings, add 2 dimensional alarm zones, eliminate fixed obstacles like landing legs and generally have a lot of fun. This GUI is part of the LightWare Terminal application that you can download for free.


A final word about the performance of this system. The LW20 is a very powerful LiDAR module so I had no problem getting good maps out well beyond 50m with some points reaching 100m. I was also able to use the first signal / last signal capability to capture both nearby obstacles and more remote surfaces at the same time while looking through trees and long grass at a shallow angle. In the image below, the blue data is first return and the orange data is last return.


For more information about the LW20 you can check out the LightWare website.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • @laser developer. To be clear. 

    My intentions is to log readings. Im using i2C and want to log the readings.

    Im ussing Devantech i2c as stated and proposed in manual.

    Connection is okej, limited commands i2c test are working on terminal.

    Im wondering, can I via i2c using application set servo to work, and log somehow all readings during work ?

    We want to use the LW20 in our system, anticolision system, but firstly just log the data.

  • Hi Pawel,

    The LW20 has the same functionality on serial and I2C but the Terminal app doesn't support all the I2C features - just a test function only. This is because a PC don't have native I2C connectivity so a third party USB to I2C converter is needed. These converters don't conform to any particular communication standard and each one requires its own special software.

  • Do the termimal provided by lightware and LW20 software have tge same funcionlity on I2C and Serial laser interface ?

    Is it possible to log laser RAW readings, distances, via I2C interface on a PC ?

    I need to log two LW20 readings on I2C bus instaled on one  drone, for further research.

    Any help will be appreciated.

  • @Emin: You can manually control the servo position through the lw20, which makes it easy to point it in the same direction the drone is moving - provided you have a servo that can achieve that range of movement.

    As for the landing legs, any fixed obstacle will always generate readings within the same position relative to the lw20, therefore when processing the data you can simply ignore points in known regions.

  • Very nice....is it possible to tell Lidar servo to always look in direction of movement,automatically?Could you elaborate how Lidar will "eliminate fixed obstacles like landing legs..."?
  • @Gary - Even I am not too old to learn something new! Thanks for the clarification :).

  • Hi LD,

    The gear lash effect is mostly noticeable in applications where the servo is externally getting pushed in alternate directions.

    Then the servo has to actively respond and take up the gear the lash in the opposite direction, effectively producing a servo response lag.

    In this application, it doesn't seem like that would be much of a problem and you could always preload it slightly in one direction or the other to prevent it if it was.

    Digital servos tend to be so tight and fast, back lash may not be significant for this application in any case.



  • @Sergey - From our tests on an cloudy day we see about a 10% reduction in the signal strength when changing from 48 readings per second to 388 readings per second. The LW20 will still easily measure our reference wall 110m away but the results are more variable due to the lower signal-to-noise ratio.

    I must stress that this result is on a cloudy day with one sample unit only. There will be some variability in the absolute maximum performance of each unit and the range is reduced by bright sunlight or at higher ambient temperatures.

    @Gary - Thanks for the info about the grease.

    The gear tooth "backlash" effect is surprisingly small because the servo uses feedback from the output shaft thereby automatically taking up any slack. Also, you would expect the magnitude of backlash to be constant at all speeds but the servo lag varies significantly with speed. Who would have thought that a servo is such a surprisingly complex little device ;). 

  • Hi LD,

    Great application and these little high res, high speed rangefinders are perfect for it.

    A problem I have found is gear lash, some servos are worse than others - cheap Chinese ones for instance, but lash is always a problem especially when you need exact positioning and are reversing, my guess is most of the two way scan problem is from gear lash which allows cumulative tooth offset for each gear in the gear train each time you change direction.

    It is amazing they work as well as they do.

    I have found light Teflon containing synthetic oils/greases to work best such as Superlube with "Syncolon" (their version of Teflon.)

    Definitely will implement this myself.



  • Very nice device!

    Btw, what would be a stable measurment range of LW20 on full 388 readings/s speed? Or other way - will LW20 be able to measure up to 100m with good reflecting surfaces on the full output rate speed of 388Hz?

This reply was deleted.