close-circle
Close
0%
0%

Very tiny Motor driver with Time-of-Flight sensor

Very tiny DC motor driver controlled by ATmega328 and its operation is sensored by "Time-of-Flight" IR-Laser sensor

Similar projects worth following
close
I always love to use new and exotic sensor. This time I found "Time-of-Flight" sensor, ST's VL53L0X which can measure the distance from sensor to object by "time-of-flight". It is far smaller than ultrasonic distance measurement and I got an idea to use it in N-gauge model train speed control. (enough small within it.) For motor speed and rotation control, TI's DRV8830 can be good companion. In order to accommodate within N-gauge model train, width should be less than around 10 mm and the smallest package of ATmega328, ATmega328P-MMH is applied. By the sake of all small packages, this tiny board fully contains USB-Serial, MCU, ToF-sensor, motor driver and 3.3V regulator within 1 cmx4 cm! This is a kind of successor of "SDuino" but much more useful than that.

The above picture shows the whole schematic contains CP2102, ATMega, ToF sensor, motor driver DRV8830 and 3.3 V LDO. ToF sensor and DRV8830 are connected through I2C bus. For ease of use, Arduino bootloader is burned to ATmega328. RGBLED is connected to PB3(D11), PB4(D12), and PB5(D13) for operation indicator.

This is the pinout of the board. This board has just 4-terminals, VDD, GND and two motor terminals. CP2102 is USB-bus powered and not powered for standalone operation. VDD can be applied from "rail" of model train but maximum applicable voltage is 7V (not 12V). Generally max rating of N-gauge train is 12V and this means we can not enjoy "full-speed" operation but full-speed by 12 V will be around 5-600 km/h scale speed (1/150) and, I guess, 7 V operation is enough for most of the case. This maximum is limited by DRV 8830's max rating. One capacitor (around 0.1 uF to 1 uF) must be added to motor terminal as close as possible to motor, in order to avoid noise interference from motor to ATmega.

This is a "temporary shape" of the model train, without covering body. ToF sensor emit Infra-Red Laser beam and receive from object and will need to make two small holes on the top roof of train body. The large blue capacitor is the "noise killer" of DC motor.

The actual operation can be found in the following movie (indeed software is still premature..)

And now it will have revision #2, with two sensors!

vl53l0x_twosens.ino

Very initial sample program to drive two ToF sensor. It's not clean written but works.

ino - 1.82 kB - 07/06/2017 at 14:15

download-circle
Download

Motordriver_test3.ino

Very initial Arduino test code for the board, which control speed and rotation by distance between sensor and finger. When the distance between sensor and finger is less than 5cm, rotation direction is flipped. More than 5cm, motor speed is controlled as a response of distance. If more than 50cm or no reflection (sensor is out of range, motor will stop. RGB LED will show the operation by color.

ino - 2.00 kB - 06/25/2017 at 08:55

download-circle
Download

  • 1 × ATmega328P-MMH Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × CP2102 Microprocessors, Microcontrollers, DSPs / USB Microcontrollers
  • 1 × VL53L0X ST's Time-of-Flight sensor
  • 1 × DRV8830 Power Management ICs / Motion, Motor and Servo Control
  • 1 × NJM2884 Power Management ICs / Linear Voltage Regulators and LDOs

View all 7 components

  • Uni-polarization by diode bridge insertion

    kodera2t07/24/2017 at 03:35 0 comments

    The tiny board is totally self-contained by still have a fear of "reverse voltage application". The applied voltage (taken from rail) is directly connected 3.3 V LDO and Motor driver and reverse voltage may destroy the circuit. Indeed this issue can be easily solved by diode bridge insertion between board and rail. By insertion of diode, we don't need to consider the direction of train (polarity applied to board) and just the train will work by "detected information" and "program inside ATmega328". Ease of use is very important for this kind of board!!

  • Now two ToF sensors on board

    kodera2t07/06/2017 at 12:00 0 comments

    Now two ToF sensors are on board!

    General I2S device has some selectable address but the ToF sensor, VL53L0X has a fixed address (non-switchable). Instead, it has "shutdown" pin and we can use it as if CS of SPI. In this board, two shutdown pins (low-active) are connected to D4 and D5 of ATmega328p.

    The white line on PCB is a cutting line and we can detach two sensor parts and connect with jumper or flat cable to main board. Of course, still motor driver DRV8830 is on-board!

    Sample code to drive two ToF sensors are uploaded in the file area of this project. Actual operation can be found in the following youtube movie,, have fun!

  • FAQ about "Very tiny Motor driver with Time-of-Flight sensor"

    kodera2t06/25/2017 at 13:36 0 comments

        1. Why don't you use WiFi or Bluetooth? They are already prevailed everywhere?

          Controlling something immediately (in emergency), can you switch on (wake up from sleep) smartphone or computer in less than 0.1 sec while connection establish and launch application? YES you can raise your hand less than 0.1 sec (even several seconds, still your movement will be faster than clever smartphones. Also, frequency is not infinite resources. Highly congestion easily breaks stable communication, but you can raise your hand even in thousands crowd.
        2. Why you play with toy? Are you child?

          YES, I am surely still child and needs to learn lots. The implementation in train toy is just a "proof of concept" and not final objective (of course, if model train is controlled smoothly, I am very happy though.)

        3. Gesture control is already well established. Why re-inventing wheel?

          YES and NO. Commercial-level technology is indeed sophisticated but when we just enjoy technology as a user, it is just "joy" and we will learn nothing. As everyone in hackaday knows how it is difficult to invent something new but for producing something new, we have to know what is possible and what is impossible. Even if ToF device is well known in your company or community or your office, at least I did not know how it works. By making, and also only by making, I believe, we can get knowledge through real experience. Actually, at hackaday, I am trying to share my experience of getting new knowledge and if this share will help your incubation of something new, it is enough.

    View all 3 project logs

    Enjoy this project?

    Share

    Discussions

    kodera2t wrote 5 days ago point

    Oh... thank you for very nice information!!

      Are you sure? yes | no

    x3msnake wrote 6 days ago point

    Thanks for sharing :). Actuallyy you can set the i2c adress you must boot each sensor at a time and set the adress on power up, there is a paper about it on the st site. I have written some code that implements it for another Project if you want check the implementation in https://github.com/altLab/EZEyes/blob/master/EZEyes_20171007/EZEyes_20171007.ino

    Best wishes

      Are you sure? yes | no

    Similar Projects

    Does this project spark your interest?

    Become a member to follow this project and never miss any updates