Multiple LiDAR Sensors on Mega

Dear all,

I am trying to wiring 12 LiDAR sensors on a Mega via I2C. I also need to acquire RTC, GIS, and Gyro dataset to log into the GIS on-board SD card.

The manual has provided an example to wiring 3 LiDAR sensors together. I just wonder if the Mega aboard can handle that many LiDAR sensors and other sensors at the same time at a high frequent logging speed (~350 logs/sec).

Any ideas? Any suggestions?

Thanks a lot.

Hi,

You may face a few issues concerning this. While an I2C bus at fast speed should be able to have the throughput required for 12 sensors @ 350 readings per second, you may hit an issue with circuit capacitance.
One of the main issues with using I2C is that this technology was meant to be used on PCB to interconnect chips, not with cables. It is quite sensitive to capacitance (bus capacitance limit of 400 pF), which will reduce its ability to function quickly (and even at all, in worse cases). Therefore, you may have to split your sensors into multiple I2C buses.
one I2C interface.

Other than that, you will need to code your operations well so that they are quite efficient and not waste CPU time too much.

It should also be noted that if you are using LIDAR-Lite v3, you will need ~500 mA @ 5 V DC for each sensor at startup for them to initialize properly. Therefore, you may want to initialize them one at a time, maybe tying their power enable pin to outputs from the mega so that they do not all start at once and require 6 A from your external power supply. That being said, if you do have to power them up all at once, please note you will need quite a beefy power supply. If it does not provide enough current with a stable 5 V DC signal, the voltage will most likely be too unstable for proper initialization.

Also, please note that these devices should each have a 680 µF capacitor at their VDD/GND connections.

Sincerely,

Could I use the PWM mode instead of using the I2C mode? There are 54 (of which 15 provide PWM output) digital I/O pins. It seems the PWM mode is much straightforward to me. Do you recommend to use I2C-bus multiplexer (i.e., TCA9548A 1-to-8 I2C multiplexer)?

Are you referring the power enable pins to “5v” and “VIN” pins on the Mega board?

Does the LiDAR Lite library work on the Arduino Due board? The Due provides 12 PWM channels, 2 I2C bus, 800 mA 5V pins with the high-speed, high-power operation.

Any further suggestions and comments?

Thanks.

Hi,

Please find below in-line answers to your questions and comments:

Yes, you can. Though PWM mode is typically used in a project where only one sensor is used, such as an altimeter for a quadcopter (with the sensor pointing straight down). See more details below in the other answers.

The PWM mode is indeed straightforward. That being said, it does not work as directly as you think on the microcontroller side. The truth of it is that the Arduino Mega has 15 hardware-driven PWM outputs. What is needed for receiving the signal from the sensors are PWM inputs (really known as input capture). The mega does not have 12 hardware-driven input capture interfaces. They usually require a timer channel each with proper interrupts to count the lengths. In more advanced microcontrollers (such as many Cortex-M boards), you can have each channel calculate pulse length by themselves, with CPU intervention. In the Arduino Mega, from what we understand, only the 16 bit timer can be used and only one pin has this capability. Therefore, you could not read 12 inputs simultaneously.

Another option would be to use 12 digital inputs pins and read through each signal one by one in pure-software (blocking). This has the advantage of being very simple and easy to setup (use the Arduino pulseIn() function). But, of course, it is much slower since you will need to cycle through all of them once to get one group reading. You can find a small example of this here.

Yes another alternative would be to simply use dedicated hardware for PWM input capture. Of course, that requires a specialized chip or custom circuit, but it is certainly doable.

Actually, the manufacturer has a tutorial on this here. Please note that they actually use a PCA9544A multiplexer. They are slightly different, so you may need to look into the details and see if it is compatible (most likely can work too, just be attentive to details!).

We are referring to the power enable pins on the LIDAR-Lite themselves. Check the instructions for the v3 here, page 2 or the pinout document. The power enable wire is the orange one. It is pulled-up by default, but can be used to turn off the device by giving it a digital low.

The device should work fine with the Arduino Due, too. The library is a general Arduino library, so we see no reason for it not to work. That being said, we did not try it ourselves yet.

Sincerely,

Hello,

Thank for your help. I’ve received the parts and playing with it.

I wrote a code that has been compiled successfully for UNO and MEGA, however I have a hard time to compile it for DUE.

Would you mind if you could take a look the error message or perhaps you could try to compile it for DUE on your computer to see if that might be just my issue?

I’ve upload the message as a text file here (dropbox.com/s/6nked8nrr22nr … e.txt?dl=0).

Here is my working code for UNO (dropbox.com/s/ne5li19zwjgqm … r.ino?dl=0), but it cannot be compiled for board Arduino Due.

The official LiDAR Lite library can been found here – github.com/RobotShop/LIDARLite_ … no_Library

Thank you again for your help.

Hi,

There does not seem to be any good reason to not just use the Wire library for everything. Maybe try to remove the include to “I2C.h” and change the “I2C.begin()” to “Wire.begin()”:


Try that out and let us know how it goes.

We were able to compile it for the Due, but have not tried and see it if actually works, though.

Sincerely,

haha~ Thanks. You are correct. I also noticed that is the issue and have compiled successfully.

Another issue I have now is the power consumption. I hope you could comment on this.

One MCU can drive 4 sensors (I2C mode) at the same time when the MCU is powered by the USB port. However, it gets pretty hot when it is powered via the power barrel at 12 VDC.

I’ve also tried 8 sensors (I2C mode) on one MCU powered by the USB. It works for a few moment and then stops to work (sensors are fine in the end!).

Because I plan to use 8 sensors in the field, I plan to power MCU using a 12V 30A power bank (product link: servocity.com/12v-18v-30a-power-supply). I also plan just use one MCU to handle 4 sensors and add another MCU to work with other 4 sensors.

What do you think? Any comments? What will you handle the power supply for this situation?

Great to hearing from you. That’s a fun journey to learn from you. Thanks. : )

Hi,

Here are answers to your questions and comments.

Indeed, it was an easy mistake to correct. It is most likely due to the I2C library using AVR-specific assembly in its code which, of course, cannot be used on the Due and is therefore incompatible.

Would it be possible for you to reply with an attachment showing a schematic of your setup? How the sensors, I2C interface, etc are powered would be important when you get to such large numbers of sensors. Also, what gets hot? Is is an on-board regulator? The microcontroller itself? Something else entirely? More details are needed here to get a good idea of what is going on.

See answer above. It may very well be a power issue.

If you are using 8 LIDAR-Lite, you will need to provide roughly up-to 4000 mA of current on startup during the initialization of the sensors.

As for using one MCU per 4 sensors, well, you can certainly read data from all 8 of them from one MCU. Of course, the data won’t be read at full speed, but it should still be fine, depending on your use case.

If you want to use a power supply that had a barrel connector, you may be interested in our RB-Hap-06. It can provide up-to 15 A and has good short circuit protection (it simply turns off instead of burning up like regular power supplies). Very good for robots and robotic projects!

As mentioned above, this is where a schematic of how you expect to power everything would be important. Of course, a list of all the components to be used would help, too (assuming 8 sensors, some I2C interface chips and 1 (or 2) microcontrollers?).

I am glad to help!

Sincerely,