The Wrong Kind of Magic at the Hardware Meetup

Arthur C. Clarke memorably wrote that “Any sufficiently advanced technology is indistinguishable from magic”. This is especially true when it breaks. We have robots that can talk perfectly, for hours and hours on a network. Then we bring them and their network into the Hull Makerspace and they break. Not completely, or reliably, but enough to make Robot Rugby an impossibility.

We had some long and earnest discissions this evening. Test code was written. Brute force algorithms were created to force hardware resets on recalcitrant robots. No dice. The only thing that seemed to work was moving the network device further away from the robot itself.

Magic. Just the wrong kind. But it is not going to beat me. I will win. If I have to write my own MQTT client to do it…..

Mind you, dinner was nice. The next meetup will be on the 15th of October.

The Art of Code Instrumentation

I spent a chunk of today getting an ESP32 version of the Hull Pixelbot software running. Snag was, it was crashing when it tried to fire up the motor drivers. Each motor is controlled by four signals which drive the coils which turn the motor output. So I need eight outputs for two motors. But half way through turning these on the program exploded. I could have hooked up a debugger and stepped through the code but this is quite a slow business. So instead I did this:

void initMotorHardware()
{
  Serial.printf("Motor initialisation 1\n");
  pinMode(motorSettings.lpin1, OUTPUT);
  Serial.printf("Motor initialisation 2\n");
  pinMode(motorSettings.lpin2, OUTPUT);
  Serial.printf("Motor initialisation 3\n");
  pinMode(motorSettings.lpin3, OUTPUT);
  Serial.printf("Motor initialisation 4\n");
  pinMode(motorSettings.lpin4, OUTPUT);
  Serial.printf("Motor initialisation 5\n");

  pinMode(motorSettings.rpin1, OUTPUT);
  Serial.printf("Motor initialisation 6\n");
  pinMode(motorSettings.rpin2, OUTPUT);
  Serial.printf("Motor initialisation 7\n");
  pinMode(motorSettings.rpin3, OUTPUT);
  Serial.printf("Motor initialisation 8\n");
  pinMode(motorSettings.rpin4, OUTPUT);
  Serial.printf("Motor initialisation 9\n");

  leftTimer = timerBegin(0, 80, true);
  Serial.printf("Motor initialisation 10\n");
  timerAttachInterrupt(leftTimer, &onLeft, true);
  Serial.printf("Motor initialisation 11\n");

  rightTimer = timerBegin(1, 80, true);
  Serial.printf("Motor initialisation 12\n");
  timerAttachInterrupt(rightTimer, &onRight, true);
  Serial.printf("Motor initialisation 13\n");
}

The posh name for this is “code instrumentation”. I call it “lobbing in lots of print statements”. When I ran the program the device crashed just after step 6. So I instantly knew which of the pins I really shouldn’t be using as an output (it turned out to be one which was connected to the onboard flash memory). I did a bit of digging and found some workable connections and I got all 13 messages. So I discarded all the changes on the source code file to get rid of all the print statements and got on with my life.

I could have wired up the in-circuit debugger, rebuilt all the code for debugging, downloaded the code into the device and then stepped through it until it broke. But I reckon this is quicker. If you have a tricky problem it is worth remembering that adding print statements that help you figure out what is going on is a good idea. You can even (whisper this) do horrible things like print out messages in interrupt handlers. Anything that helps you work out what’s going on is something you can do.

The next step in the project is to make builds for the different devices select different pin assignments. It might also be fun to create a flag variable that is checked after reboot so that the device can produce useful diagnostic information when it fails, rather than just stopping and leaving it to the user to figure out what went wrong. But that sounds a bit like scope creep to me, so I’ll not do it just yet.

Windows Phone has still got it going on

They say it is important to keep in mind how far we’ve come in technology. But I think that sometimes it is a good idea to consider how far we haven’t come as well. In the trip into the garage that yielded my Zune HD I also found a couple of Lumia Windows Phones, including the wonderful 1520 that I got in 2013. It still works fine (although it took a few reboots before it got past a recurring alarm). Even the battery is holding up. I also found a 1020, the one with the amazing camera. That works fine too.

If either of these phones worked like they did in their heyday, with all the apps and integration that are now long gone, I’d be back on them in a heartbeat. Apple AI or no Apple AI. In my opinion the user interface beats the iPhone hands down. All this “Liquid Glass” stuff is really lipstick on a very old pig.

They don’t feel heavy, they don’t feel slow and they don’t feel old. We watch the Apple presentations and then dutifully traipse along to buy the latest upgrades (and I’m as bad as anyone for this) but it seems to me that the fundamentals of my life could be quite easily underpinned by a 12 year old design. There must be something which has moved us beyond what the Lumia can do but at the moment I’m not sure what that is.

Raspberry Pi 500+ First Look

Nicely packed

It was fate. On Wednesday I discovered that I’d earned some some more royalty payments. On Thursday I discovered that Raspberry Pi had released a new keyboard computer, Raspberry Pi 500+. So, one thing led to another (keyboard lighting joke there) and so yesterday it arrived. It’s very nice.

Size comparison

It is slightly larger and a lot heavier than the Raspberry Pi 500. It has proper clicky keys which are backlit If you don’t like the keycaps (and I do) you can swap them out for different ones. You are even given a key puller to remove the existing ones. You can get replacements (but make sure you buy low-profile keycaps or they might not work when you press them). You also get a tool to make it easier to take the computer apart, although bearing in mind it has 16G of RAM and a 256Gb built in solid-state disk I’m not sure why you’d want to get inside.

Use FN + F3 to step through other colours

The backlights work very well. Hold down Fn and press F4 and you can step through a set of different presets. Hold down Fn and press F3 and you can step through colour options for the presets.

There’s even an animated rainbow effect that looks awesome but might be a bit over the top.

Setting up the 500+ is a breeze because the internal hard disk has the Raspberry Pi operating system already loaded onto it. Just turn on the power and work through the very well organised setup. If you fancy something different you can always plug in a MicroSD card to boot from instead.

The machine has the same core components as a Raspberry Pi 5 with 16G of RAM and a 256G hard disk. There is no internal clock battery (boo) but you can buy one and plug it in. There’s no extra cooling, but it doesn’t seem to need it. There is a little internal extra in the form of a PICO which looks after the keyboard mapping and light display.

You can get direct access to the keyboard from Python. There’s a program which you can install and use to configure the keyboard from the command line. You can find instructions here. If you want to get your hands properly dirty you can write programs that interact directly with the keyboard lights. You can find all the source you need here. I’m looking forward to spending more time with the machine and making my own programs that use the coloured keys.

The Raspberry Pi 500+ is a lot more expensive than the Pi 500, at around twice the price. For that you get oodles of memory, an SSD, clicky keys and key lighting. I really like typing on the new keyboard. If you plan on spending a lot of your time typing you might find it is worth it for that alone. I wish the 500+ had a bit more personality though. It is just a minimal keyboard with sockets on the back. Of course you can add your own personality with keycaps and colours, but a strip along the bottom proclaiming its origins wouldn’t have come amiss. But I’m glad I got one and I’m looking forward to spending more time with it.

Web Security and Wasm at The Tech Sessions

We had a couple of great talks at the Tech Session yesterday. If you are in the Hull area you should keep an eye on what they are doing. You can find them here. The first talk was from John Smith (yes, that is is real name). It had the title “Your cloud got hacked, and they like it”. John is a senior security architect and did great job of explaining just how vulnerable cloud applications are to bad actors. He put the bad actors into categories, from the “Chancer” (there for the money, only knows how to use freely available tools) all the way up to “Ghost” (has the tools, skills and persistence to live in your systems indefinitely without being detected). Things I took away from the talk:

  • There are freely available tools that make it easy to do things like search GitHub repositories for keys to online resources. Use them yourself to see if you are vulnerable. Start with GitLeaks and remember that the bad guys use these all the time.

  • Avoid using long term credentials. And change them regularly - like your underwear.

  • Monitor your resource usage to detect changes. And set limits.

  • Don’t have “one ring to bind them all”. Put different resources under different accounts.

  • Code is a depreciating asset. You must budget for the effort needed to keep it up to date and secure (and to test for security).

  • Open source can be dangerous. Bad actors will target tools used by millions of applications to inject malware into your systems.

  • Developer systems in a company are the holy grail for hackers. They usually have lots of extra permissions and interesting source files on them.

  • At the end of the day it is all about Risk (how surprising). Actively attack the security risks you are running, and keep looking for new ones.

Next up was a talk from Joe Axon This content was a little more relaxing (at least for me) but no less interesting. Joe was talking about using Web Assembly (Wasm) to write games that can run on your machine in your browser. Running programs in your browser usually means JavaScript, which is a great language but not really good for games. JavaScript is a scripting language. It contains lots of high level abstractions and behaviours that are kind of hard to convert into simple machine code. Web Assembly (or Wasm) is a simple stack based language which, from the examples Joe showed us, is very close to what hardware does. This makes it very easy to convert into native machine code that would run at much higher speed. Things I took away from the talk:

  • Wasm is stack based and looks like assembler to me. The text format (i32.add, etc.) is deliberately low-level and easy for humans to read if you’ve seen assembly before.

  • Wasm looks very easy to convert into machine code.

  • It supports integers, floats and blocks of data (although the are now SIMD - single instruction, multiple data vectors too). Anything else you have to structure yourself.

  • You have to do all your input and output (including the display) by passing blocks of data between Wasm programs and JavaScript. The code to do this looks easy to use, but comes at a price in terms of performance.

  • You can get compilers that take most high level languages you’ve heard of and convert them into Wasm - making this an interesting way getting things like C++ or Rust to run in a browser at a sensible speed

  • There is a tool (KNI) that can take XNA games (written for MonoGame) and, after a bit of fettling, create Wasm code that runs at speed in the browser.

So, after a really interesting evening I drove home thinking about scanning my repositories and porting some of my old games to the web. Great stuff.

Jurassic World for Microsoft Flight Simulator

The Jurassic World plugin for Microsoft Flight Simulator is bit more expensive than the Humber Bridge one I mentioned earlier. But you do get a lot more stuff to look at, including a complete archipelago to fly round complete with wandering dinosaurs. It all looks great and we had a lovely time last night flying around in helicopters. We’ll be back again next week. Well worth a look.

Tech Sessions on 25th September at Hull University

Tech Sessions are great fun. And there’s usually free food and drink. You get to meet up with a bunch of tech folk and learn something. The next one is on Thursday this week and s all about WebAssembly & Cloud Attack Stories.

Joe Axon will be talking about high performance computing and browser based game development using WebAssembly. Then John Smith will describe how things go wrong when cloud installations aren’t as secure as their operators thought they were.

I’ll be there, taking notes. The sessions start around 6:30 pm and are in the Brynmor Jones Library at Hull University. You can sign up here.

Liquid Glass - Thanks but no thanks

First reaction to Apple’s new “Liquid Glass” display: “That’s pretty”

Second reaction to Apple’s new “Liquid Glass” display: “I wonder how you can turn it off”

Note to graphics developers who have impressed themselves with their ability to overlay text on a background image and make the background blurry: There’s a reason why newspapers, magazines and books are not printed on semi-transparent paper. It’s because a distracting background makes something much harder to read.

LCD Panel coming to Connected Little Boxes

I thought it might be useful to add an LCD panel to the Connected Little Boxes. It took a bit longer to get it working than I expected, mainly because the library I’d been using wasn’t compatible with the suspiciously cheap LCD panels that I’d bought.

If you have problems getting your PCF8574 driven LCD2004 panel working with a PICO I would suggest that you do two things:

  • Remove the jumper on the back of the PCF8574 board and connect the LED pin to the VBUS pin on the PICO so that the backlight is powered properly.

  • Use this library to drive the device. It’s the only one I’ve found that works.

Installing FreeCAD on a Raspberry Pi

We had a really nice Hardware Meetup last night. Although I’m still having network woes. Simon and I were talking about FreeCAD as you do. Simon mentioned that it turns out to be tricky to install the latest version of the wonderful FreeCAD program on a Raspberry Pi. I’ve had a little look and he is right. So I’ve done a bit of digging and come up with this. I’ve also added it to my FreeCAD tips.

Install FreeCAD

If you have a Windows PC, a Linux PC or a MAC you can obtain the latest version of FreeCAD from here There are installers for all these platforms.

Rasbperry Pi installation

If you have a Raspberry Pi things are a little trickier. The most recent versions of FreeCAD have yet to be built for the platform. You can have a go at building it yourself, but this is not a job for the faint hearted (and it takes overnight to build the program). You can get version 0.20.2 very easily:

sudo apt update
sudo apt upgrade
sudo apt install freecad

The above commands install Version 0.20.2 from 2023 and this works OK.

Version 1.0.2 on Raspberry Pi

If you want the latest version (1.0.2) you have to do a bit more work and install Flatpak. Flatpak is a Linux app packaging and sandboxing system that lets developers ship applications with their dependencies so they run consistently across different distributions. Flatpak works well, but it does increase the size of installed applications. Make sure you have around 4G of disk space free before installing. These are the steps you follow to install Flatpak and FreeCAD.

sudo apt update
sudo apt install -y flatpak

sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo

sudo flatpak install -y --system flathub org.freecad.FreeCAD

flatpak run org.freecad.FreeCAD

This should start up FreeCAD 10 on your Pi running within Flatpak. If you reboot the Pi you will find that FreeCAD shortcuts have been added to the Education and Graphics program groups. If you've already installed version 0.20.2 you can install version 1.0.2 alongside it.

Flatpak management

Note that Flatpak applications are not managed in the same way as those installed using apt. These commands might be useful.

# List flatpaks
flatpak list

# Update just flatpaks
flatpak update

Hasselblad H1

I now have a new favourite camera. It weights a ton. Two tons if you don’t use the “stock” lens and switch to the super-heavy wide angle or telephoto. It is over 20 years old. The shutter sounds like a small mechanical explosion. It can’t take video. On a good day you can take one shot every few seconds. It has no image stabilisation. In poor light the results can get grainy. In bad light you have to fetch the tripod. But the pictures it produces are some of the best I’ve ever seen. It’s a Hasselblad H1.

I took the above pictures in York. Admittedly the light was lovely and I could have got vaguely similar results with my phone. Except that everything would have been in focus and artificially crisp. Phone cameras are amazing. But they do lots of things to your pictures that you might not want. They add dynamic range. They sharpen everything. They tweak the colours. They add digital blur to separate foreground and background elements. And their images look unreally good.

The Hasselblad has super sharp lenses, so no need to sharpen the image. These lenses are a long way from the sensor, so you get your out of focus effects from physics. It takes real effort to cart the camera around and you have to work hard to line up shots. The viewfinder is optical and shows you the view straight from the lens. The good news is that this makes taking the pictures super fun. The bad news is that it is very hard to see exactly what the camera has captured. My camera has a tiny screen (also around 20 years old) which shows me what I’ve photographed but I need to view my shots on my computer when I get home to discover what they are really like.

However, it turns out that I really like this way of working. I really feel that I have a hand in the results that I get. At the moment I can’t think of taking any other camera out if I go and take pictures.

The Hasselblad brand is associated with very pricey cameras, but the good news is that the very old ones are not that expensive. And the really good news is that all the lenses for the system are all superb and reasonably cheap (certainly compared with modern ones). My complete setup has cost me less than just a camera body for one of the modern systems.

I realise that I’m running a few risks. A device this old could suddenly fail and turn into a paperweight. But I bought most of the bits from MPB.com who give you a one year warranty. And because the camera is made up of separate bits (body, lens and sensor), failure of one component won’t affect any of the other bits. So if the body fails I’ll simply pick up another one and use it with the lenses and bits I’ve already got.

If you are thinking of getting into photography and want to stretch yourself a bit I would strongly advise taking a look at the Hasselblad H system. The older H models (H1 and H2) don’t cost that much and the Phase One digital backs that work with them are not that pricey. The newer versions can be scary expensive but are completely awesome (and you can use all your old lenses with them). The cameras have large sensors which makes for a lovely look to your pictures. And they help you build upper body strength too.

Thunderbirds on the Big Screen

To celebrate 60 years of Thunderbirds (blimey!) they’ve re-mastered a pair of the best episodes and are showing them in movie theatres in the UK. You can find out more here. The show was shot on 35mm film so it should look great on the big screen. They’ve re-mastered the audio too, so it should also sound terrific.

We’ve got our tickets. Looking forward to it.

Wevie Stonder are wonderful

If there’s one thing I’m sure of at the moment, it’s that the world needs more silliness. Stuff that is just daft. Wevie Stonder are silly, but clever too. Their new album, Sure Beats Living, is a hoot (with some very atmospheric touches). It’s a while since I’ve heard a record that made me laugh out loud. And they can build a mean soundscape too.

You owe it to yourself to listen to at least track 9, Customer Services. Splendid stuff. It is as if the Bonzo Dog Doodah Band were back in business and using synths and samplers.

Oh, and have you worked out how they came up with their name yet?