collapse

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

Gareth

  • Global Moderator
  • Member
  • *
  • Posts: 60
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

  • Global Moderator
  • Member
  • *
  • Posts: 60
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

"1984 Nixie Time" by Gareth
[August 22, 2019, 05:59:29 AM]


Just wanted to say Hi. by ErwinCanto
[August 18, 2019, 10:11:28 PM]


SDR (Software Defined Radio) by Gareth
[August 14, 2019, 01:12:21 PM]


It may be dangerous to work in the virtual realm by fritsl
[August 09, 2019, 09:52:05 AM]


PLX-DAQ by AmandaG
[August 06, 2019, 01:58:42 PM]


DIY Yellow Servo by AmandaG
[August 06, 2019, 01:08:09 PM]


Comp? :o by Impala
[August 02, 2019, 07:32:20 PM]


Website to do list by Killer Angel
[August 02, 2019, 05:38:30 AM]


I Like the new front page! by James
[July 31, 2019, 12:29:53 AM]


Pictures on the front page! by tinhead
[July 30, 2019, 05:17:20 AM]


4x5 Macro Keypad by James
[July 28, 2019, 08:30:41 PM]


My name is Frits and I am Making a Game called TIXITAXI by Killer Angel
[July 08, 2019, 04:01:58 AM]


Coding a Nano i2c Slave by AmandaG
[June 11, 2019, 02:48:03 PM]


repetierHost 2.1.6 not working? by MEgg
[June 09, 2019, 03:11:34 PM]


Servo Calibrator by Bajdi
[May 24, 2019, 04:01:10 AM]

* Recent Posts

Re: "1984 Nixie Time" - Update 20190822 by Gareth
[August 22, 2019, 05:59:29 AM]


Re: "1984 Nixie Time" - Update by Gareth
[August 20, 2019, 11:15:36 AM]


Re: "1984 Nixie Time" by Bajdi
[August 20, 2019, 09:35:39 AM]


Just wanted to say Hi. by ErwinCanto
[August 18, 2019, 10:11:28 PM]


Re: "1984 Nixie Time" by viswesh
[August 18, 2019, 01:48:07 AM]


Re: "1984 Nixie Time" by James
[August 16, 2019, 06:37:11 AM]


"1984 Nixie Time" by Gareth
[August 15, 2019, 06:16:37 AM]


Re: SDR (Software Defined Radio) by Gareth
[August 14, 2019, 01:12:21 PM]


Re: SDR (Software Defined Radio) by fritsl
[August 09, 2019, 09:54:11 AM]


It may be dangerous to work in the virtual realm by fritsl
[August 09, 2019, 09:52:05 AM]


Re: PLX-DAQ by AmandaG
[August 06, 2019, 01:58:42 PM]


Re: DIY Yellow Servo by AmandaG
[August 06, 2019, 01:08:09 PM]


SDR (Software Defined Radio) by Gareth
[August 06, 2019, 11:12:09 AM]


Comp? :o by Impala
[August 02, 2019, 07:32:20 PM]


Re: Website to do list by Killer Angel
[August 02, 2019, 05:38:30 AM]