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

Hull Pixelbot Version 2.0

I've just released a new set of design files for the HullPixelBot. I've made some improvements and also added holders for the pixel lights (always useful in a pixelbot) and the distance sensor. I was quite proud of the design for the distance sensor holder, until I tried to use it. 

I thought I'd been clever by providing mounting slots for the distance sensors so that the wires could come through the slots for the connections on the back. Turns out this was actually stupid. It turned out to be really hard to make the connections with the hole. 

The new design (which you can see above) has separate holes for the two sensor wires, and they are arranged vertically so you can just connect all the bottom wires together to a common ground (or reference voltage) and then take each of the top wires and connect them to their potential divider resistor and reference voltage (or ground). I'll be doing a detailed post about wiring things up a little later. 

Interrupts Interrupted

I've spent some time writing smooth movement routines for the motors for the HullPixelBot. I want the motor movement to run in the background, so that the program can do other things as the robot moves. This will make the drive very like the behaviour that you get from a traditional "servo" motor that starts turning when the program switches it on.

Thing is, the stepper motors only turn if the program sends the appropriate set of signals to the coils in them. The solution to this problem is to use the timer on the Arduino processor. This can repeatedly trigger a bit of program code at regular intervals using a hardware technique called an interrupt.

Interrupts are used by a computer to respond to real world events. Tapping a touch sensitive screen, moving the mouse or pressing a key are all things that interrupt a running program and cause the computer to run a special piece of code called an interrupt handler which deals with the event. In the case of a key press, for example, the operating system (perhaps Windows 10) responds to the interrupt by sending a keyboard message to the currently active program.

In the case of the HullPixelBot I'm using a timer to produce a sequence of interrupts at regular events which are then used to trigger code which moves the stepper motors to their next position. The code required to do this is quite tiny, and so once the move has been completed the "normal" program can be resumed.

I don't reckon you can call yourself a programmer unless you've written an interrupt handler or two. I've done quite a few and they are rather fraught bits of code. You're not allowed to touch any of the things used by the "normal" program (in case you confuse it), and you must complete your action in the shortest possible time, otherwise you'll bring the computer to a halt. Programming ninjas can write code that uses multiple interrupts from different sources at the same time. 

Which is what I want to do. 

I want programs to be able to use the distance sensor and the motors, and for both of these devices to work using interrupts. Now, I think of myself as a bit of a programming ninja, so I knock out the code and fire it up. And it doesn't work. 

I can have motors, or distance sensor, but not both. 

I'm not surprised by this because it can be tricksy if interrupts occur during interrupt handlers. So I check the hardware manual for the processor and get myself into a state where I'm convinced it should work, but it doesn't. Hmm. Perhaps I'm not a ninja after all. 

So it was back to the start, and a careful re-write of the code to make it as smooth as possible, and remove any ways in which the two handlers (one for the timer, one for the distance sensor) could interact. And it still didn't work. No fair. 

Of course, I eventually figured it out (otherwise you would not be reading this blog post). It turns out that it had nothing to do with the interrupts. It was just that when the program turned the motors on it dropped the voltage level in the robot power supply to such a low level that the distance sensors stopped working. I was testing the code on a machine on my desktop and I'd left the motor power supply turned off so that the robot wouldn't try to run away. That lack of power was my undoing. 

The good news is that I'm now pretty confident that the code I've written is solid, and the HullPixelBot can move in a very nice, precise way, measuring distance values as it goes. And I've learnt something about motor power and distance sensors, which is useful. 

I'll be showing the code off at the hardware meetup on Thursday this week. 

HullPixelBot is going places

I spent a happy chunk of today designing and printing a front sensor assembly for the Hull PixelBot. The new part provides an ultrasonic distance measure and three light sensors. 

This will mean that the robot will be able to find and move towards light sources and also detect obstacles in its path. 

You can find out more about HullPixelBot at the next C4DI hardware meetup on Thursday 18th August. Sign up here (it's free). Anyone can come along and get into building tiny cheap robots. I'll have some more chassis kits to give away. All you need to do is add around 10 pounds worth of parts and you have a wandering pixel bot. 

And if you want to see a bunch of HullPixelBots in action I'm taking a mini-swarm to the Amy Johnson Festival Makerfest in Hull on 27th of August. 

Who knows what they'll be doing by then....

HullPixelBot can now turn corners

Spent a bit of time today fiddling with timer interrupts so that I can get fine control of the speed of the motors on the HullPixelBot. Because they are steppers they are quite precise, which means I can get the bot to trace accurate curves. 

The next thing I have to do is put the light and distance sensor on the front (along with a bumper) and then we'll have a proper robot. 

Putting the Pixel into HullPixelBot

I've reached the point in 3D design where the hard part is not expressing the design. It's deciding what the design should be. I regard this as progress. Above you can see the new pixel mounts for the HullPixelBot that we've been playing with at C4DI.

Each bot will have two pixels. One at the top between the wheels to make it easy to do persistence of vision photography. And one at the back for other HullPixelBots to find and follow. 

I unveiled the new design to an awestruck audience at the hardware meetup tonight. Unfortunately I also unveiled a rather nasty power issue where the robot motors cut out when the lights were turned on. Oh well. It might be that we need extra volts for the pixels...

Anyhoo, I'll be posting the new designs in a little while, once I'm sure that it all fits together properly.  

I gave away a couple of 3D printed kits to new folks who had come along. If you want to come, get some parts and have a go at building your own robot (it won't cost you more than a tenner to build) then sign up for our next meetup on 18th August. All are welcome, young or old, experienced or not. Sign up here