HullPixelbot Code takes shape

Building on the work yesterday, I've now made a little code editor that can be used to control the HullPixelbot motor controller. You can load and save programs and send them via a serial port into an Arduino. The programs are stored in EEPROM inside the device, so that they run when the robot starts up. Next step is to distribute the programs over MQTT using the esp8266. Then I'll be a lot closer to my dream of autonomous robots that I can easily reprogram.

The program above starts a movement and then tests a conditional branch behaviour that fires when the motor stops running. You can use this to write code that starts the robot moving and then responds to events.

The nice thing about the programs so far is that they are very frugal. I've got everything running on a single Arduino Pro-Mini and it seems to work OK at the moment.

Potential Dividers for Pixelbots

..a divider with potential

I've been working on the HullPixelbot hardware today. I want to use an HC-SR04 distance sensor so that a robot can detect when it is getting close to something. These devices are not perfect, but they are very cheap (less than a pound from China). Snag is they are 5 volt devices (i.e. they are powered by, and produce signals at, a 5 volt level).

The Arduino Pro-Mini that I'm using to control the motors and sensors is a 3.3 volt device. Directly connecting a distance sensor to it would not end well. It might actually break the Arduino. There are special converter chips thatyou can buy to addressthis, but they are expensive and need to be wired up. Fortunately the only signals you need to worry about are those going into the Arduino, and the only input signal is the echo pulse. So I just have to adjust the level of that signal.

The way that the sensor works is that you give it a signal to say "please measure the distance". The sensor then makes an ultrasonic "squeak" and times how long it takes for the squeak to bounce back. It generates a pulse, called the echo signal that represents this time. The longer the echo pulse, the longer it took for the sound to bounce back, and the further away the target is from the sensor.

The echo signal provided by the distance sensor is either at 0 volts or 5 volts. We want to convert the 5 volt value to 3.3. I've used a potential divider to do this. This uses the principle that the voltages in a circuit are distributed according to the resistances in each element. The higher the resistance of one part of the circuit, the more volts are "dropped" across this part. This probably doesn't seem sensible, but it is how a lot of electronic devices work.

In the old days we used to use lots of low voltage bulbs in our Christmas lights. The mains voltage of 240 volts would be spread over, say 20 bulbs, each designed to work with 12 volts. All the bulbs were connected in a chain, so the voltage dropped across each bulb was 12 volts (a twentieth of 240). Bad news, if one of the bulbs fail the whole chain goes out.

Worse news, if a human being (who has a resistance a lot higher than a 12 volt bulb) puts themselves into the circuit trying to fix this they will find that nearly all the voltage is dropped across them, which is how until recently Christmas was always accompanied by grisly stories of people electrocuted when they were fixing the lights on their tree.

Anyhoo, back to the robot circuit. The total resistance of our two resistors is around 3K. The voltage dropped across the 1K resistor will be around the third of the 5 volt input. These are the volts I don't want. The voltage across the 2K resistor will be around two thirds of 5 volts, which is as near 3.3 volts as makes no difference. And it works, which is nice.

If you think about it, what I've made is a machine that can divide by 3 at close to the speed of light. Any signal going into the potential divider will be divided by 3 on the output because physics. The speed of these two resistors massively outperforms even the most powerful of digital computer, and so-called "analogue" computers like this were much used in the past.

HullPixelbots at AzureCraft

HullPixelbots on parade

Well, that was fun. It was the first proper outing for my robot army. We were all at AzureCraft in London. It was an absolutely great event, kids getting together to make things in MInecraft. And learn to program along the way.

I'd set up my Robot Arena in one of the board rooms at the fantastic venue. Over the day groups of kids and parents came to take up the challenge of controlling their robots and getting them to line up in the arena with no collisions. Harder than it looked, but everyone who came along was up for the task. Quite a few folks came back for another go, which was nice. 

Great fun. Thanks to the folks at the UK Azure User Group for setting up the event and inviting me along. 

A tense moment as the pixels line up...

The Robots are coming to c4di

Sam drives some robots..

I took my working pixelbots down to c4di and gave a talk tonight about how they worked. Before the talk I set out a small part of my robot arena and we all had a bit of fun steering them around using my chatbot client. 

Thanks to everyone who came along. Some very useful conversations. I left with some good ideas for improving the system. I'll be putting the presentation and the code up soon. Keep watching the blog for details. 

Adventures with the ESP8266

I love the esp8266, as far as I'm concerned it's the embedded processor with the mostest. 

But It does have one or two foibles. I ran into them today as I was trying to improve HullPixelbot reliability. My little robots work fine to start with, but then have an annoying habit of crashing or getting stuck after a while. 

Today I found out why. The HullPixelbot is a two-brained robot. The wheels are controlled by an Arduino Pro-mini device, and the esp8266 does the networking and stuff. The two devices are linked by a serial connection, so that commands received via WiFi can be passed into the motor controller which then makes things happen. 

I'm using the SoftwareSerial library to create a serial port on the esp8266 which then sends commands to the Arduino device. This is a software implementation of a hardware device, fast running code does the same task that is normally performed by a piece of dedicated hardware. 

And therein lies my problem. The SoftwareSerial driver was causing my network code to fail. It works fine sending data, but incoming messages cause interrupts in the esp8266 that seem to upset the  connection. I've changed to using the hardware serial port and everything seems to work a lot better. 

Oh, and one other thing I've discovered about the esp8266. Pin 18 (identified as D3 on the Wemos Pro-Mini board) controls whether or not the device can be flashed with a new program. If this line is held high it can stop your programs from downloading. I've been using D3 as a serial connection and having all kinds of problems. And now I know why. 

HullPixelbots at Azure Craft

I'm taking some HullPixelbots out on the road in December. I'm going to try out some group exercises involving 8 robots being controlled at the same time. 

Which means I need 8 robots. 

I'm feverishly building them at the moment, then I'll have to write some code and get it all working in time for the event on the 10th December. Such fun.

This is all at the AzureCraft event in London, where they are also having lots of fun activities for kids (bring a parent) involving Minecraft and whatnot.

Places are limited, but if there are any available you can sign up here

Hardware fun at C4DI

I could tell you what this is, but then I'd have to kill you....

We had another great hardware meetup at c4di this week. Some new folks who turned up to see what all the fuss was about, quite a few HullPixelbot devices wandering around and some very enjoyable technical chats about this and that. 

The next meeting is at the start of November. You can find all the Hardware Group meetings, along with other c4di meetups, here:

http://www.meetup.com/Hull-Digital-Hull-Open-Coffee/

HullPixelbots racing at Techdays NL

We had an amazing session today at TechDays NL. I was talking about the use of the Microsoft Bot framework to control physical robots via the Azure IoT Hub. I had a couple of robots linked via MQTT to the cloud and delegates could use a web interface to a chatbot to try to drive them around the room.

This was the web interface we were using. Half of the room was controlling the red robot and the other half were driving the white one. It was quite fun to watch as the robots inched towards the finish line. Eventually the white robot managed to win and one of the white team was awarded the big prize of a HullPixelbot platform.

The slides for the presentations will be available via the TechDays NL site soon. I'm also going to post all the source code (minus all the keys and passwords) next week. 

A tense moment in the race

Would you buy a used HullPixelbot from this man?

 

 

Hull Pixelbot Problem Solving

We had a great time at the c4di hardware meetup last night. We had some more new faces drop by, including one family who were out for a walk around the waterfront and just came into see what all the fun was about. This was great for me, as I was able to try out some HullPixelbot arenas that I'd made up.

The idea is that you get a robot, an arena and a programmer interface that makes the robot move and turn. And then you have to navigate the robot from the start to the finish. 

The one on the left is quite simple, except that you don't know what the numbers used to control the robot actually mean. 

Anyhoo, we managed to navigate the above arena and make the robot stop in exactly the right place. Then we moved onto a more complicated one and then I got clever, tried to make the robot retrace its steps and had it turn the wrong way and nearly fall off the desk. On well. 

The great news for me is that the folks who happened to drop by left with a kit of parts for the robot chassis and the intention to come back with a completed robot for the next Hardware Meetup. 

If you want to come along the meetups are open to anyone who fancies a bit of hardware fun and games. You can sign up here

Fishing with WireShark

The software for the Hullpixelbot is coming along nicely. I'm using the amazing esp8266 chip to provide a WiFi connection to the robot and network them all together. Snag is each robot (and whatever we use to tell them what to do) needs to know the network address of all the other robots. 

There's a technology known as mDNS that is supposed to make this easy. It's a local area network version of the Domain Name System that ties the internet together. It uses cunning broadcasts so that systems can find themselves and exchange messages. It's also the basis of the Apple Bonjour zero configuration networking, and there's now an api you can use with Windows 10 Universal Applications to allow them to find and use devices on the local network. 

I couldn't make it work. I tried for a few days and then I used an old software development trick. I asked someone for help. That someone was number one son, who actually took the trouble to read the DNS documentation and tell me what I was doing wrong. And we fixed it.

During our investigations we used an awesome tool called Wireshark. This can capture all the packets on a network, and then provides a set of fantastic tools that let you decode the messages. I think it's great fun to play with, even if you don't have a problem to solve. There's something fascinating about seeing all the messages bouncing around the cable. 

The good news is that we'll be able to appear with a bunch of Hullpixelbots, turn them on and have them all find each other and be found by other machines. I'll publish the software when it's in a state fit for the outside world.

Big Fun Hardware Meetup

Firstly, if you were planning on coming to the Hardware Meetup tonight I'm sorry about the traffic problems. These were caused by road closures for the Hull Freedom Festival which is this weekend. And during our meetup we had an awesome choir practising on the stage near c4di.

It was great to see some new faces in amongst the regulars. I gave out four or so Hull Pixelbot chassis and I'm looking forward to seeing some working robots next time we meet up. It was a great atmosphere and there seem to be lots of things going on at the moment, which is lovely. If you want to come along too you can sign up here

And you can find our more about the Hull Pixelbot, including new revised assembly instructions, here.

Hull Pixelbot goes public at the Amy Johnson Makerfaire

Today was the first public outing of the Hull Pixelbot at the Amy Johnson Makerfaire in Hull. I was interested to see what folks made of our little plastic robot with a pixel on top. Turns out that people seemed to like it, which was nice. We had lots of hardware group members who turned up to tell the Hull Pixelbot story (thanks folks) and how to get involved and it all went really well. 

We're going to develop this robot of the next few months and with a bit of luck I'll realise my dream of 100 Hull Pixelbots all wandering around together making art. Or something. 

If you want to get involved you can find out more at hullpixelbot.com. Next meetup is on Thursday 1st of September. I can't wait to see who comes along. 

We've even got a spiffy new logo now. 

 

Very Busy Hardware Group at c4di

We had a really busy Hardware Meetup last night at c4di. Plenty of new faces, and quite a few folks who'd taken HullPixelBot kits and brought them back made up. I showed off the latest software and the HullPixelBot improvements and it was lovely to see so many people on the night. 

I'm going to be releasing some new software for HullPixelBot in the next week or so, to coincide with the first public appearance of HullPixelBot at the Amy Johnson Maker Fest on August the 27th next week. If you want to come along and see what we are doing we'll be in Zebedee’s Yard, Whitefriargate, Hull HU1 2EX along with lots of other folks between 10:00am and 16:00 pm. 

If anyone fancies helping me "man the stand" over the day then I'd love to hear from you. Ping me a message via twitter (@robmiles) or email (rob@robmiles.com) and we can get some kind of timetable together. 

If you want to come along and take part in the hardware group (you don't have to build a robot, but we'd love it if you built something) then you can keep track of the meetups and sign up here