collapse

Welcome!



Welcome to Robot Rebels, an online robot maker community.

Register today to post your projects, ask questions, share knowledge and meet like-minded people from around the world.


The RobotRebel.org Community

Author Topic: Double_ing up the "Time of Flight" sensors  (Read 978 times)

Gareth

  • Member
  • ****
  • Posts: 54
Double_ing up the "Time of Flight" sensors
« on: November 07, 2018, 03:42:30 AM »


Two is better than one...... (or 4 or 8 etcetcetc).

Following successful experiments with 1 single Time of Flight distance sensor mounted to Stepper, watching the scan process its seems to lend its self to setting the scan to just 180° and mount two sensors back to back to extract the whole 360°...... (or 90° scan with 4 sensors, hope you see where I am going with this :-)

Generally I2C devices come with a fixed address, so doubling up the same I2C animals with the same I2C address is not possible...... unless Slave address's are implemented.

The VL53LOX sensor has a trick up its sleeve ... the "XSHUT" pin   (aka... reset pin!).

#include <Wire.h>
#include <VL53L0X.h>

#define XSHUT1 4
#define XSHUT2 5

#define TOF1_I2Caddress 41
#define TOF2_I2Caddress 42

VL53L0X TOF1;
VL53L0X TOF2;

void setup()
{
  Serial.begin(115200);
  Wire.begin(21,23);
  pinMode(XSHUT1, OUTPUT);  pinMode(XSHUT2, OUTPUT);

// the magic part happens here .....
  TOF1.setAddress(TOF1_I2Caddress); pinMode(XSHUT1, INPUT); delay(10);
  TOF2.setAddress(TOF2_I2Caddress); pinMode(XSHUT2, INPUT); delay(10);
 
  TOF1.init(); TOF1.startContinuous(); 
  TOF2.init(); TOF2.startContinuous();
}

void loop()
{
  Serial.print(TOF1.readRangeContinuousMillimeters());
  Serial.print(':');
  Serial.println(TOF2.readRangeContinuousMillimeters());
}

During runtime it is possible to slip any address you wish to each individual sensor.

The TOF comes with a default I2C address of 00101001BIN

The above code is generic so if you have multiple TOF's then the code is easily expanded.....

If you are just using 2 TOF's the simplified code can be used below due to one TOF defaulting to address 41 :-

#include <Wire.h>
#include <VL53L0X.h>

#define XSHUT2 5

// no need to program I2C address of TOF1 as it defaults to 41 anyways \ö/
#define TOF2_I2Caddress 42

VL53L0X TOF1;
VL53L0X TOF2;

void setup()
{
  Serial.begin(115200);
  Wire.begin(21,23);
  pinMode(XSHUT2, OUTPUT);
 
  TOF2.setAddress(TOF2_I2Caddress); pinMode(XSHUT2, INPUT); delay(10);
 
  TOF1.init(); TOF1.startContinuous(); 
  TOF2.init(); TOF2.startContinuous();
}
void loop()
{
  Serial.print(TOF1.readRangeContinuousMillimeters());
  Serial.print(':');
  Serial.println(TOF2.readRangeContinuousMillimeters());
}


My stepper has a hollow spindle shaft... 5 wires will pass easily through... a 360° rotation would screw the wires up... a 180° rotation would only half screw the wires up... however a 90° rotation would be even better... (i.e. eliminating need for WiFi/BlueTooth OTA data transfer ...FlyByWire becomes an interesting solution again).

maelh

  • Member
  • ****
  • m
  • Posts: 25
Re: Double_ing up the "Time of Flight" sensors
« Reply #1 on: November 11, 2018, 05:22:23 AM »
Nice! I also got a couple of theses sensors a couple weeks ago. I have yet to solder the pins on and use them.
To create a point cloud I think a Intel Realsense would be better.

Curious to see where you go with this!

P.S.: You could use a slip ring instead of a wireless connection.
« Last Edit: November 11, 2018, 05:57:46 AM by maelh »

Gareth

  • Member
  • ****
  • Posts: 54
Re: Double_ing up the "Time of Flight" sensors
« Reply #2 on: November 13, 2018, 04:05:02 AM »
P.S.: You could use a slip ring instead of a wireless connection.
ermmm 100% no  :P
As this project started with the idea of Cost effective LIDAR  (with my aversion to having a slipped disk)......
evolution went so :-
LIDAR with Hollow shaft Stepper     Workio
LIDAR with WIFI Mesh                    Workio slow unstable                   (trashed)
LIDAR with Bluetooth                     Workio Slow solid                        (trashed)
LIDAR 360° Wired Ping-pong style  Workio Fast however twisty wires   (trashed)
LIDAR*2 180° Wired Ping-pong      Workio Fast                                 (Current)

 

* Search


* Recent Topics

Meowth Abandoned by Nemesis
[April 11, 2019, 11:08:00 AM]


Bench Power: Help a rebel out by jinx
[April 03, 2019, 04:20:10 AM]


Just a short intro... by MEgg
[March 18, 2019, 05:49:28 PM]


MKS GEN L Servo Issue by cmptrguy1
[March 14, 2019, 01:18:28 AM]


Yes I am alive! by jinx
[March 10, 2019, 04:38:53 AM]


CZ-1 2.0: problems, calibration and printing, part2 by MEgg
[February 26, 2019, 03:35:15 PM]


Hi, Mushroom glue here. by nschreiber0813
[February 25, 2019, 02:09:13 PM]


Arduino IK by BaldwinK
[February 25, 2019, 05:54:44 AM]


Raspberry Pi / Python eBook - free for the next 11 hours! by MEgg
[February 24, 2019, 09:49:43 AM]


MKS Gen L 1.0 by MasterDomino
[February 24, 2019, 06:34:24 AM]


Fun Fact by Impala
[February 13, 2019, 11:05:01 PM]


Animabot Rev3 - Advanced Hexapod Robot by Smashley
[February 05, 2019, 03:41:50 PM]


Finally tried out a Chinese PCB service by Bajdi
[February 02, 2019, 08:40:49 AM]


PLX-DAQ by BaldwinK
[January 16, 2019, 06:44:18 AM]


Four Motor Leg Module by BaldwinK
[January 09, 2019, 04:55:14 PM]

* Recent Posts

Re: Meowth Abandoned by Nemesis
[April 11, 2019, 11:08:00 AM]


Meowth Abandoned by BaldwinK
[April 10, 2019, 06:35:48 AM]


Re: Bench Power: Help a rebel out by jinx
[April 03, 2019, 04:20:10 AM]


Bench Power: Help a rebel out by ZeroMax
[March 27, 2019, 10:00:53 PM]


Re: Just a short intro... by MEgg
[March 18, 2019, 05:49:28 PM]


Re: Just a short intro... by Killer Angel
[March 18, 2019, 06:55:35 AM]


Re: Just a short intro... by jinx
[March 16, 2019, 04:36:13 AM]


Re: Just a short intro... by Bajdi
[March 15, 2019, 04:22:09 PM]


Just a short intro... by cybersamurai
[March 15, 2019, 04:19:22 PM]


Re: MKS GEN L Servo Issue by cmptrguy1
[March 14, 2019, 01:18:28 AM]


Re: Yes I am alive! by jinx
[March 10, 2019, 04:38:53 AM]


Re: Yes I am alive! by nschreiber0813
[March 09, 2019, 03:59:04 PM]


Re: CZ-1 2.0: problems, calibration and printing, part2 by MEgg
[February 26, 2019, 03:35:15 PM]


Re: Hi, Mushroom glue here. by nschreiber0813
[February 25, 2019, 02:09:13 PM]


Yes I am alive! by nschreiber0813
[February 25, 2019, 02:08:12 PM]