AP_Periph not working with LightWareI2C

I have been testing the AP_Periph with the LightWare rangefinder and I cannot have it to work.
The same rangefinder works when I use it with my Pixhawk over I2C by setting TYPE=7 and ADDR=102.
However, when going to the AP_Periph, and setting the same parameters over UAVCAN GUI Tool, I can never get the uavcan.equipment.range_sensor.Measurement message out.
When trying my old rangefinder LidarLightV3HP by change the TYPE=21, everything works.
Since my LightWave is working with the Pixhawk, and the AP_Periph is working with other rangefinder over I2C, am I missing some parameters?

For this I have tested the latest AP_Periph 1.4.1.

Yep, confirmed , I have the same issue.
I did not had time to dig deeper ATM, but I minimally we should open an issue.
@rishabsingh3003 would you be interested to investigate ?

Thanks for the tag @ppoirier . Fortunately, I have a matek L431 and a lightware L20. I will investigate and fix it if I find a bug… but cannot guarantee a time frame for the possible fix

3 Likes

@rishabsingh3003 have you had a chance to test this?

I think this PR will fix the issue:

I attach a test firmware for MatekL431-Rangefinder with the changes.
@ppoirier @RoverHunter please test and comment on the PR. Thanks!
AP_Periph-MatekL431-Rangefinder-fix.bin (126.3 KB)

1 Like

@tridge tested but no reading, more info on github

can you check if the MatekL431 has pullups on SDA and SCL? If it doesn’t have hardware pullups then I2C won’t work.

I found an old chat with Sampson from Matek who said the MatekL431 does have 4.7k pullup on SCL and SDA
@ppoirier do you have a logic analyser? If so can you check the traffic on SCL and SDA?

OK I’ll check with pull-up and connect annalyser if no start

@tridge Here are the results

Firts , I started with something working :
Lidar Lite connected wit dedicated power and I2C terminators (param rangefinder type 3)
Reading OK

Same configuration with LW20 (params Add. 102 Type 7)
NO Reading

@ppoirier thanks, can you save those captures to a google drive for me to look at?

and can you include a capture of the same LW20 working correctly when directly connected to the flight controller on i2c?

note that for sf20 i2c its best to decode the bytes as ascii, not hex, as its really a string oriented protocol
decoding your hex data:
image
the first write of 0x3f 0x50 0x0d 0x0a is the sf20_get_version() call
using iprint I get:


so it sees version “SF20,4.0.0,16 "
which means that i2c clearly is working
then we see the sf20_disable_address_tagging() call
sf20_send_and_expect(”#CT,0\r\n", “ct:0”);
we then see:
sf20_send_and_expect(“#SC,0\r\n”, “sc:0”);
and then:
sf20_send_and_expect(“#LC,20\r\n”, “lc:20”)
then:
sf20_send_and_expect(“#LO,0.00\r\n”, “lo:0.00”)
then:
sf20_send_and_expect(“#LM,7\r\n”, “lm:7”)
then:
sf20_send_and_expect(“#LB,0.00\r\n”, “lb:0.00”)

all of that looks like normal AP_RangeFinder_LightWareI2C::sf20_init() calls. Your screen capture is cut off at that point, so I can’t tell if the sf20_init() call completes.
once you send me the saved captures I’ll know more

Hello @tridge
here is the file for Matek Capture
SF20-Capture.txt (181.4 KB)

Here is the file for direct connection to FC
SF20-FC-Capture.txt (279.8 KB)

Looking at the signal on the I2C bus of Matek, I confirm I have consistent reading from the SF20

@ppoirier thanks. That log shows the SF20 is completing init and giving distance when connected to the L431. The distance readings are around 1.95m.
Assuming in this example you checked if you were getting range_sensor_measurement packets on the bus and were not getting them then something is going wrong between the driver backend and the AP_RangeFinder frontend. We’d need some GCS_SEND_TEXT() calls to try to work out what is wrong.

@tridge agree, I can test a bin with some GCS_SEND_TEXT() calls , could you build one ?

Responding in this old thread since I also have problems getting the LW20/C working with a CAN node. I am using a https://arkelectron.com/product/ark-cannode/ . It has AP_periph flashed. The LW20/C is set to use I2C. It is working when directly connected to the I2C port of the Cube Orange AP. I have checked as a Subscriber on DroneCAN GUI tool and it is not sending any data.

Did anyone find a solution to this? @ppoirier

No, AFAIK it is still an issue, meanwhile I switche to an other sensor

Oh crap. I got 2 of those sensors and need them working by next week. Guess I am out of luck then…

@tridge might be interested to push (or have a team’s developer working on that)