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 403 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: 24
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

Web TIme API - by Gareth
[December 07, 2018, 04:34:37 PM]


API Directory by Gareth
[December 06, 2018, 03:34:16 PM]


The Original Prusa I3 Mk3 by tinhead
[November 30, 2018, 02:49:52 PM]


Email notifications by CraigCox
[November 28, 2018, 10:26:06 PM]


And another one. by CraigCox
[November 28, 2018, 10:17:54 PM]


MKS Gen L 1.0 by jinx
[November 28, 2018, 02:23:50 AM]


This kids a freaking genius by ossipee
[November 21, 2018, 04:55:40 PM]


Time of Flight >>> Rounded Corners !!! by Gareth
[November 15, 2018, 03:21:51 PM]


Double_ing up the "Time of Flight" sensors by Gareth
[November 13, 2018, 04:05:02 AM]


Point cloud anyone !!! maybe 3D scanner by maelh
[November 11, 2018, 05:38:33 AM]


removable magnetic print surface by Gareth
[November 09, 2018, 10:53:45 AM]


Robot Cop by Valeriex
[November 07, 2018, 05:48:20 AM]


it's lukeyes by Valeriex
[November 07, 2018, 05:47:16 AM]


TOF gets a local DEBUG screen by Gareth
[November 07, 2018, 03:47:29 AM]


BlueTooth elves choose "BlueTeeth" by Gareth
[November 07, 2018, 03:40:19 AM]

* Recent Posts

Web TIme API - by Gareth
[December 07, 2018, 04:34:37 PM]


API Directory by Gareth
[December 06, 2018, 03:34:16 PM]


Re: The Original Prusa I3 Mk3 by tinhead
[November 30, 2018, 02:49:52 PM]


Re: The Original Prusa I3 Mk3 by Bajdi
[November 30, 2018, 02:26:48 PM]


Re: The Original Prusa I3 Mk3 by tinhead
[November 30, 2018, 04:38:53 AM]


Re: Email notifications by CraigCox
[November 28, 2018, 10:26:06 PM]


Re: And another one. by CraigCox
[November 28, 2018, 10:17:54 PM]


Re: MKS Gen L 1.0 by jinx
[November 28, 2018, 02:23:50 AM]


Re: MKS Gen L 1.0 by Prokktor
[November 27, 2018, 08:35:38 AM]


Re: The Original Prusa I3 Mk3 by tinhead
[November 26, 2018, 02:42:26 PM]


Re: The Original Prusa I3 Mk3 by jinx
[November 26, 2018, 02:24:05 PM]


Re: The Original Prusa I3 Mk3 by Bajdi
[November 25, 2018, 07:54:21 AM]


Re: The Original Prusa I3 Mk3 by tinhead
[November 25, 2018, 06:11:22 AM]


Re: The Original Prusa I3 Mk3 by Bajdi
[November 25, 2018, 04:40:31 AM]


The Original Prusa I3 Mk3 by tinhead
[November 24, 2018, 12:02:51 PM]