Intro: Micro Bluetooth Low Energy (BLE) Robot (for Roborally?)
This instructable shows you how to build a real small BLE-controllable robot.
I have also developped an android app for the control, which I might introduce in another instructable.
My initial idea was to build a "real moving" robot for the game roborally. Currently I think I missed this goal by a factor 2 or 3. Mainly because of the big BLE-module.
Cypress already has 10x10mm modules, but that would mean to develop a custom PCB and unfortunately I have no time for that.
With this instructable I want give you all the chance to do this! If you want to make a PCB for it, please contact me an we will see where it goes!
Step 1: Gather the Parts
To build this robot you need the following:
- Cypress BLE-Dev-Kit to program the BLE-chip: cy8ckit-042-ble-bluetooth-low-energy-ble-pioneer-kit
- a solder iron
- a PC running at least win7 (for the PSoC-Creator)
- a smartphone or a PC-application to control the robot
The robot itself only consists of this parts:
- The BLE-module: cy8ckit-142
You can either use the BLE-Module that was provided with the DEV-Kit, but if you want to buy a new one you can buy the cheapest one with the smallest memory, because the application is very small. The above link is to a 10$ module. If you want to use the module for other purposes too, I recommend buying the newest available, which is this one with 256kB-Flash and BLE 4.2: cy8ckit-143A
- A piece of breadboard
- some pins to connect the module
- a battery holder for 16340 Li-Ion cells https://www.amazon.de/gp/product/B000PENC60
- a 16340 Li-Ion cell
- two geared motors, like these
I started out with two gear motors with around 40rpm at 6V, and the robot was rather "slow".
The second motors had 120rpm at 3V and this is much better.
The H-Bridge doesn't need to have a high load-rating, the motors use only 30mA without load.
The maximum I expected was 50mA.
Step 2: Set Up a PSoC-Creator Project
Before I really started to solder something I set up the PSoC project and wrote the software.
Because most of the time you notice that something doesn't work as planned or you need something else to get the job done. And software is the most easy thing to change!
So why would I limit myself with existing hardware from the beginning?
You can also much better debug the whole system when you are still working with the debugger.
In the next step you can download my project and start with it.
Step 3: The BLE-Project
At this point, I don't want to make big talk about the software. Just download the zip, unzip it and open the project with the PSoC-Creator.
Just a short explanation of the principles:
- A "movement" consists of (direction, distance, ledcolor).
- You can upload up to 250 Movements via the MoveControl-Characteristic.
- After each upload the number of current uploaded movements is notified via the Moveacknowledgement-Characteristic.
- If you want to start the robot, just write a "1" to the MoveControlGo-Characteristic.
The direction is encoded in the enum "MC_Direction".
The LEDs are encoded in bit-flags, to enable multiple LEDs to be active.
The ping-pong with the notification is implemented to give the BLE-central (App or PC) the signal: "Hey, I understood the last command you sent me. Currently I have this #number# of movements saved. Please give me the next."
I will refer to this, when we start to test the robot.
Step 4: Solder the Main Breadboard
The bread-board just keeps everything together.
If you already know the PSoC-microcontroller, you know that you can apply nearly every function to every pin.
This is what I did when I set up the motor-control. I chose some pins that are on the lower and inside end of the module ( 2.2 and 2.0, as well as 1.6 and 1.7) It is very handy to have the module pinout available as a printout.
The LEDs I connected to the same pins as in the programmer-debug-board. This way I could test my software before I really deploy the module.
I added a small capacitor to reduce the voltage drop, when the motors start or stop, but this is really optional.
And in the first version I added to pins to apply power, while in the second version I directly power the H-Bridge and from there power the BLE-module.
Step 5: Prepare and Mount the H-Bridge
The H-Bridge came with screw-terminals and a pin-header.
But the screw-terminals are really big, and I don't need it. and the pins from the pin-header face the wrong direction...
So desolder the screw-terminals completely and de- and resolder the pin-headers in the other direction.
This way you can directly screw the H-bridge to the bottom of your robot.
Step 6: Mount the Battery Holder
The 16340-cells are only a bit wider than the BLE-Module and they provide a good voltage between 3-4V.
For the first version I connected the battery with wires to the bread-board, but this was not good. So in the second version I chose to power directly the H-Bridge.
Because I didn't want to add another piece of wood underneath the battery, I drilled two holes for the terminals and wired them from the bottom. Very neat and tidy.
Step 7: Prepare and Mount the Motors
For the first version I had to use double sided sticky tape and duck-tape to fix the motor to the housing. These motors were quite heavy, because they are of metal and the gear is metal to.
As wheels I used some plastic washers with a sanitary seal, which fit quite well.
For the second version the double sided sticky tape was enough to fix the motors.
As wheels I used the end of a roll film reel. I still have several of them at home, because I used to do black and white photography. They have a good center hole in it. I only had to use some plastic putty to fix the motor inside and it works excellent.
Step 8: Put All the Parts Together
... and you get a small controllable BLE-Robot.
But before you power up the device I recommend measuring for correct voltages without the BLE-module. If you mixed up anything while soldering, the you could seriously damage the module! Also if there is a short anywhere, it could damage the battery or other parts.
So first check for shorts with a simple multimeter.
Then apply power, but without the BLE-module. First measure the current and immediately shut it off if the current exceeds a few mA. This proves that you have no undetected short or a broken H-Bridge.
Then measure for correct voltages on all power and GND-pins of the breadboard.
Additionally you could even connect the output pins to high or low and measure the respective current one after another. If you do this, you can also observe if the function of this pin is correct. That means, if you connect pin 2.6 to GND, then the red LED should light up. To observe the motor movement, you have to connect one pin to low and the other to high.
If you did everything right, you should always measure a current below 4mA. Each pin on the PSoC module can source 5mA and sink 7mA. If your values are higher, that means you have to take counter measures. But that should not be the case if you used the same stuff as I did.
Then finally you could plug in the BLE-module and power up the robot by inserting the battery.
Initially I wanted to build my own paper-model for this robot, but it turned out to be more difficult than I expected. Fortunately you can find a lot of models out there. So I only had to look for one that would provide some kind of cubic space inside for the electronic. I found it with this red robot. I'm not really sure where I got it from and what's his name or from whom this model was. Maybe I should have used a Dalek instead?
Step 9: Test Your Robot by Programming Some Movement
Once your robot is running, use the CySmart Software to connect to the device.
Plug the BLE-Dongle into the PC and start CySmart. Press "Scan" to find your robot named "Robbo".
Once this is found press "Connect" to connect, and then "Discover all Attributes". This gives you a list of all Service present on your robot. Impressive huh?
I suggest to minimize the unnecessary services and focus on the last.
Press "Enable all notifications" to enable all notifications. You remember that this was the way the robot says "ok"?
Click on the MoveControl-Characteristic, then enter some valid numbers in the field and press "write" to send it to the robot. Immediately after that you will notice that the notification characteristic changed from "00" to "01".
Repeat the step a few times and watch the notification count up.
Then send a "1" in the MoveGo-Characteristic. This results in the notification-value to be reset to zero and the robot should move now.
So that is all you need to control your own robot.
Of course you could also change the way the robot moves to direct control, where each command is executed immediately. Or you could build large Movement-Lists and transmit it to the robot. there are many more possibilities.
Maybe I also make an instructable on how to make an android app for it.
Step 10: The Obligatory Video-proof!
Here are two videos of my robots (version 1 and 2) in movement.You sure notice that the first version is very slow and inertial, while the second one is much more dynamic. For unknown reasons Youtube keeps deleting my first video because of some guidelines violations. I don't know how to fix this, so please excuse if the first video is not available.
On problem still exists: How to calibrate the movement in operation?
This relates to the capability of the robot to perform exact 90° turns or adjust the width of movements.
Step 11: What's Next?
Well, you have several options:
- create an App for convenient control
- add sensors and modify software
- make the hardware smaller.
- use a different outer (paper) model
- Add a red laser instead of LEDs
- 3d-print the mount and the outer model.
- Use another power source (i.e. 500F ultracapacitor)
I guess you can even think of more usecases and improvements!
Have fun and share your result with us!