Showing posts from April, 2020

Virtual Pi Wars 2020 was outstanding!

This year Pi Wars went virtual , and it was a huge success. Mike Horne did a superb job as compère, and the Robot videos were wonderful: always informative, often amusing and of very high quality. Over the next few days we'll have a chance to vote. It's going to be a very difficult choice! The Teams presented creative and individual solutions, but some common themes emerged. Lots of teams made use of simulations. Some used custom software based around standard libraries; others were based on specialised open source frameworks like VTK. Most Robots were programmed in Python, but several used Pi controllers with peripheral Arduino nanos or teensies programmed in C. Some teams used ToF (Time of flight) sensors for distance sensing and SLAM (Simultaneous location mapping and mapping). A growing number of entrants used OpenCV or plan to use it next year. Many Teams share their software and designs. I'm looking forward to exploring several of the projects on GitHub as

The micro:bit is talking to the VL53L0X ToF sensors!

This chip is no more :( This morning I got my Arduino sensor driver talking to a micro:bit using SPI. The Arduino Uno runs at 5 volts, and the micro:bit works at 3v3, so I used a level shifter to connect the two. My first attempt failed disastrously. The level shifter I used was based on the TI TXB0108. I managed to connect the 5v power and inputs to the 3v3 side, and I fear the magic smoke has left the chip. It's a shame, as the board was my first attempt at soldering SMD devices. It's been sitting unused in my bits box for a few years, though, so it's not the end of the world. Fortunately I had an Adafruit level shifter breakout based on the same IC. It's well laid out with very clear pin markings and I managed to connect it correctly. The replacement worked perfectly and the micro:bit MicroPython code was very straightforward. I've listed it below, and it's with the other code on GitHub . from microbit import * import struct from time imp

Read distances from up to 8 VL53L0X sensors via SPI

I'v now got my two-Arduino version of a multiiple ToF sensor LiDAR working. I have only tested it with two sensors; I'll add one more later, and report, but the code should work with more. I'm a little hesitant about that claim. The Slave Arduino code has little spare memory but I've tried to  reduce requirements to a minimum. I have more VL53L0X sensors on order, and I am hoping I can handle up to eight. That would allow a robot to get a good sense of the closest obstacles. The Slave code uses an SPI interrupt routine modified from Nick Gammon's excellent example . The code that configures and then reads from the ToF sensors is a complete rewrite of Adafruit's example code for dual VL53L0X sensors. I'm no expert at C programming, so if you can see improvements (or bugs), let me know! The code is on GitHub , along with some minimal documentation. The next step will be go get the Arduino slave working with a micro:bit master; then I'll n

SPI access to multiple ToF sensors is working

I've been ploughing through the steps towards my goal of connecting multiple distance sensors to Anastasia's micro:bit. I now have a pair of Arduinos connected via SPI, with the slave reporting distances from two VL53L0X sensors. The wiring is a mess and the code needs cleaning up. But it's working, and replacing the Arduino master by a micro:bit should be pretty straightforward. I'll report on progress. The code is on GitHub .

7 steps to add multiple ToF LiDAR sensors to a micro:bit

I'm happy with the solution I came up with to attach multiple Time-of-Flight (ToF) sensors to a Raspberry Pi or CircuitPython board. Now I want to add one or more ToF sensors to Anastasia , my Python-powered micro:bit robot. Anastasia needs at least one distance sensor to stop her running into things. Since she can travel backwards as fast as she goes forwards, she really needs two sensors: one looking forwards, and one looking behind. I've been looking for a simple solution but I have hit a snag. I've found several Python drivers for the VL53L0X chip I'm using, but none will run on the micro:bit. Some are Python wrappers for C code; others are just too big to fit on the micro:bit. I finally came up with an approach which looks as if it may work. The goal is to use a board with an Arduino-ish clone, programmed in C, driving the sensors and returning results via SPI. Seven steps to ToF success I've broken the project plan into seven steps whic

Muliplexing I2C with the Adafruit TCA9548A multiplexer

I want to attach multiple VL53L0X Time-of-flight sensors to a single I2C bus. It looks as if that should be easy, but it's not. One solution involves disabling the sensors and then enabling them one at  a time to change their address. It's workable, but fiddly. If you only have two sensors you could use different I2C buses, but I eventually want to run 8 sensors, so that won't work. The TCA9548A I2C multiplexer There is another approach that is easy to implement and works out of the box. The TCA9548A is an I2C device that acts a little like a telephone exchange. You can use it to route I2C transactions to one of eight separate I2C busses. That allows you to have eight devices with the same I2C address, one on each bus. I did a first experiment using an Adafruit CircuitPython m4 feather. That worked well, and I've just confirmed that it works just as well with a Raspberry Pi. Since I'm using Adafruit's CircuitPython libraries, the same code run