Servers by jDrones

How to make the TFMINI rangefinder talk I2C

(ppoirier) #158

Then it looks like TFMINI is not set to proper mode

(Grant Erickson) #159

I have connected my TFMINI to benewake tf, received output that made since, and sent “42 57 02 00 00 00 01 06”.
This is how the benewake window looks after a reboot…

I have also ran a test in which I hard coded a non variable distance measurement into the Arduino sketch. I was able to read my entered value in qgroundcontrol’s analyze widget. The problem is cornered to the output of the TFMINI, but it is almost as if the mode change will not stick. Thanks for your help.

(ppoirier) #160

Ok I see you send in cm , try switching to mm

Modify output unit to mm output: 42 57 02 00 00 00 00 1A
Modify output unit to cm output: 42 57 02 00 00 00 01 1A

(Grant Erickson) #161

I changed to mm… still no readings.

I went through the code and added the blink command after condition tests. I indicated which blink tests worked and which didn’t. Any thoughts??

(ppoirier) #162

It shows that you are not reading TFMINI serial stream or its not in right format.
I asked before but are you 100% certain that you connect TFMINI TX to Arduino RX ?

(Grant Erickson) #163

Yes I am 100% sure the TFMINI’s TX is connected to the Arduino’s RX

(Grant Erickson) #164

I solved the problem. I substituted my Arducam PRO Mini Atmega328 Development Board with an Arduino Uno and the program emulated correctly. It looks like it was a hardware compatibility problem. Thanks for your patience

(chris rey) #165

thanks @ppoirier, now migrated from serial to I2C, a summary of the procedure find on this blog:

Load the sketch BeneWake_TFMINI_I2C_Maxbotic_Outdoor_Limit (for me)
Upload it to the Arduino Pro board (FTDI connected)
A4 is SDA A5 is SCL
Open TF GUI connect TFMINI via FTDI
The command of standard output is 42 57 02 00 00 00 01 06 Arduino Compatible
Modify output unit to mm output: 42 57 02 00 00 00 00 1A
Connect to MP and apply the following settings:
RNGFND_TYPE 7 (LightWare)
RNGFND_ADDR 112 (70 Hex is 112 Dec)
Reboot the FC and it works perfectly

(chris rey) #166

did you try your code with a Pico?

(ppoirier) #167

No, does the Pico expose bothe the Serial and the I2C ?

(chris rey) #168

Do not know, just seen this and was impressed by the very small size:

(ppoirier) #169

Did you know that I made the Multi-Sector TFMINI detector using ATtiny ?

(chris rey) #170

:clap: yes, WITH and Arduino Pro Mini as controller as I can read in your blog…

(ppoirier) #171

The Arduino acts a a multiplexer for the I2C bus and sends the rangefinder distance and corresponding angle signals to the FC over serial MavLink.

(.) #172

Hi to all.

I have a question about the arduino code for translate the serial output to i2c.
At the state of the art i can only read the distance measured from the lidar.
If it’s setted as “proximity sensor”, the drone can reach at minimum the distance written in the code.

Is it possible to upgrade the arduino code in order to send the readed distance to a pixhawk and let the drone to maintain that distance?

Thanx to all.

(ppoirier) #173

This is basicslly what avoidance is doing. Take a look on ardupilot avoidance wiki to see how to setup rangefinder and parameters

(.) #174

i can set the rangefinder as:

  1. terrain following;
  2. object avoidance

Setted on 1, it means that the drone maintain the heigh (for ex. during translation).
Setted on 2, it means that the drone doesn’t go nearest than the distance setted.

In other words, with option 1) the drone follow the terrain trend (maintain a distance); with option 2) the drone doesn’t follow the wall trend (avoid a distance < than the one setted).

Am i wrong?
If it doesn’t, the question is: Is there a way to implement a code that let the drone to maintain the setted distance, when it is on “proximity sensor” ?

Thanx to all.

(ppoirier) #175

Yes , I have one of my quad with 2 TFMINI installed and I set I2C address 70 to altitude and address 71 to avoidance.

Have you look at avoidance library ?

(.) #176

I try to redo my question in a better way.

If i install a lidar as altitude holder (pointing on the ground), and i move in a transaltion motion, the drone follows the ground and maintain the altitude.

If i install a lidar as proximity sensor pointing on the wall), and i move in a traslational motion, the drone doesn’t follow the wall. It only avoid to reach at least a distance from the wall, but it can get away form the wall (direction not parallel with the wall, wind gusts, etc…).

The question is: Is it possible to maintain constant the distance from the wall, during a translation?

Thanx to all.

(ppoirier) #177

Altitude is ‘‘easy’’ to detect because the IMU has a fixed vector called Gravity.
In the case of a wall following, it is different matter, because this surface is not in a fixed plane so in this case, you could use a scanning Lidar that would allow this type pf avoidance.

I suggest you open a new discussion in the forum, because the question is not directly related to the subject and you would benefit from more input with a new discussion