-
Explode and Connections
07/10/2016 at 18:01 • 0 commentsere's the exploded view:
And the connections:
-
Programming
12/02/2015 at 18:36 • 0 commentsOnce I had the mechanics done, I started to work on the programming. Setting the speed of the servos was easy enough:
import microbit microbit.pin0.set_analog_period(20) microbit.pin0.write_analog(int(25 + 100 * degrees / 180))
But then making it turn exactly 90° or travel exactly 10cm required some careful experimentation with timing.
Once I had that, hooking up the distance sensor was easy. It's an analog SHARP range finder, so all I needed was to read the analog pin. Then I added some simple logic for finding out in which direction the obstacle is further away, and voila, object avoidance:
And that's it. All the code sits in the repository: https://bitbucket.org/thesheep/micro-bot/src
-
The Simplest Bot Possible
12/02/2015 at 18:28 • 0 commentsI knew what I wanted to do with the micro:bit -- I wanted to put it into robots and program them in Python. So I decided to start with the simplest thing possible -- a two-wheeled robot, with continuous rotation servos and a caster wheel. I only had two criteria for choosing the parts:
- I had to have them already, because I only had a few days, and they had to be off the shelf -- no salvaged or custom-made stuff, so that it can be replicated easily.
- No soldering, laser-cutter, 3d-printer etc. Just two-sided tape and some glue.
I started by gluing everything together with the two-sided tape in several different configurations. At the beginning, I didn't have the white depron bar to hold the screws, so I simply hotglued them to the servos:
This is actually the only interface the robot has with the micro:bit, because I didn't have the edge connector for accessing all the other pins yet. But three pins is enough for me -- two for the servos, and one for the distance sensor.
After assembling and testing it with some simple code, I noticed that the servos have a lot of problems with the PWM signal generated by the micro:bit. They would basically rotate at maximum speeds in random directions... So I went to the nearby hackerspace and used their oscilloscope to look at the signal. Turns out that you have to set the frequency of the PWM signal several times for it to have the desired effect. After just one time, the frequency is off by an order of magnitude:
But then if you actually start sending a signal and set it again, it becomes correct:
Well, correct apart from some twitching, and it would still change directions randomly. Since I couldn't find the reason for that in the signal, I turned to the power. And yes, replacing the two alkaline AAA batteries with a 3.7V LiPo battery solved that problem.