Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

PWM programming of Lidar-lite


Phenomics Nov 18, 2015 09:50 PM

Hello All

I am trying to program a Lidar-lite rangefinder (http://pulsedlight3d.com/products/lidar-lite-v2-blue-label) to give me accurate distance using a CR3000 datalogger using the PWM function (http://lidarlite.com/docs/v2/connection_i2c_pwm/). Another useful document is (https://www.robotshop.com/media/files/pdf/operating-manual-llm20c132i500s011.pdf)

Looking at the PWM wiring on the second link, I assume that the wire from pin 3 (mode) needs to be split, with a 1kΩ resistor placed in line with the trigger wire(RX (C6) on CR3000), and the monitor wire going to TX (C5). Is this close to correct? If so, where would I get a 1kΩ resistor?

My second question is how to then program the CR3000 for this device. Below is some Arduino programming code:

/* =============================================================================
LIDAR-Lite v2: PWM operation
This example demonstrates how to read measurements from LIDAR-Lite v2 "Blue
Label" using PWM
The library is in BETA, so subscribe to the github repo to recieve updates, or
just check in periodically:
https://github.com/PulsedLight3D/LIDARLite_v2_Arduino_Library
To learn more read over lidarlite.cpp as each function is commented
=========================================================================== */

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); // Print the distance
}

* Last updated by: Phenomics on 11/18/2015 @ 2:51 PM *


aps Nov 19, 2015 09:23 AM

This is going to be difficult to get work. The first problem is that device seems to work at 3.3V logic levels, so will only output 3.3V signals and also expect them. This creates an issue with the CR3000 (not the CR6) as it only supports 5V logic so may not even see the outputs from that sensor.

I say "may not" because if the sensor outputs are on the high side and the nominal minimum input of the CR3000s are low on your logger (the spec is 3.5V) this might just work.

The logger does not have a built in function to read a PWM signal directly, but you can measure the width of pulses using the timerio function. This would require you to connect the PWM output from the sensor to 2 or 3 control ports depending on whether you need to just measure the lo-hi pulse width or measure the true PWM ratio.

Good luck


scrisp Jul 11, 2016 10:03 PM

I am using arduino as well to output a signal of 0-5V. I am currently using a 100uF capacitor to smooth out the PWM output (see http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/ ) , but every couple of seconds my 'hypothetical' 4.5V signal dips and goes all over the place. Is this a frequency sample issue, or do you think I need a different capacitor?

Which brings me to my main question. How would I go about using timerIO to measure the PWM output as a voltage? And why do I need 1 or more control ports? I only have a Vin and Vout in the setup I am using. 

Thank you. 

(Should I post this as a new topic?)


JDavis Jul 12, 2016 02:43 PM

To get data from an arduino to a CR3000, I suggest finding a Modbus library for the arduino. You can then transfer a bunch of values over a serial connection between them.

Another option is to remove your capacitor and use your PWM output to output a 50% duty cycle pulse with an adjustable frequency. You can read the frequency of a high speed square wave really well on a CR3000 control port. It would be read with a PulseCount() instruction.

Refer to the help in CRBasic as far using TimerIO to measure the length of a pulse.


mduthoit Oct 14, 2019 07:23 AM

@scrisp and @Phenomics, did you sucess to connect the Lidar lite using a datalogger Campbell with using the PWM function?

I don't have many information to connect it and measure the PWM ?

Thank you so much if you could help me.

Regards,

Log in or register to post/reply in the forum.