LiDAR information to MINIMOSD via Arduino Nano

Post Reply
SeanK
Posts: 1
Joined: Sat Jul 04, 2015 1:21 pm

LiDAR information to MINIMOSD via Arduino Nano

Post by SeanK »

Hi All,

First time posting on this forum as my searches have not come up with what I'm after yet. I don't believe there has been a successful implementation of this sensor with MultiWii 328p FC's yet, however I would be very interested if there are. Heights above 40m do not matter to me for this application so the barometer is not needed if that makes any difference.

For those interested, this LiDAR sensor is also mounted on a gimbal to keep it oriented vertically.

I am attempting to overlay the height reading acquired from my LiDAR-Lite rangefinder onto my FPV screen. I would prefer to achieve this by simply sending the altitude reading directly from an Arduino Nano to my MinimOSD as I do not need any other OSD capabilities for my application.

Is there a way to achieve this without using a MAVLink data stream over the serial ports? Getting the arduino MAVLink to work is driving me insane.

I'm a mechanical engineer so I have a lot of holes in my software engineering abilities (which I am trying to patch up slowly).
Any help would be hugely appreciated as this problem is driving me up the wall.

Here is the code for my LiDAR sensor which works fine on the Arduino Nano.

Code: Select all

/*
http://pulsedlight3d.com
LIDAR-Lite Continuous Pulse-Width Modulation
The LIDAR-Lite has the ability to read distance without the use of I2C, simply
by reading the amount of time a signal from the mode pin is HIGH. We then take that
duration (here measured in microseconds) and convert it to centimeters using the
LIDAR-Lite constant of 10usec/cm. We then print that value to the serial monitor.
Technical explanation is on page 15/16 of the operating manual:
http://pulsedlight3d.com/pl3d/wp-content/uploads/2014/11/LIDAR-Lite-Operating-Manual.pdf
*/

unsigned long pulse_width;

void setup()
{
  Serial.begin(115200); // Start serial communications
  pinMode(2, OUTPUT); // Set pin 2 as trigger pin
  pinMode(3, INPUT); // Set pin 3 as monitor pin
  digitalWrite(2, LOW); // Set trigger LOW for continuous read
}

void loop()
{
  pulse_width = pulseIn(3, HIGH); // Count how long the pulse is high in microseconds
  if(pulse_width != 0){ // If we get a reading that isn't zero, let's print it
        pulse_width = pulse_width/10; // 10usec = 1 cm of distance for LIDAR-Lite
     Serial.println(pulse_width-25); // Print the distance
  }
  delay(20); //Delay so we don't overload the serial port
}

Post Reply