Building stuff!


Overblown Egg Timer, part 3

by on Apr.10, 2020, under General, Hardware

Part 1 covered the overview of what I wanted to achieve, while part 2 covered the construction of the hardware. In this third part I’ll give an overview of the software running on the Arduino to coordinate button presses and lights.

But first, some revised diagrams – in part 2 I found that using the D0 and D1 pins for communication with the Grove LED bar was a poor choice, and had to rework things to use D7 and D8. Here’s how that change looks in glorious technicolour diagram form (click to enbiggen):

The software to support this project splits into roughly four pieces:

  1. The Arduino sketch (the core code to set up the board, and do something in a loop)
  2. Some code to control the LED in the illuminated switch button, and to read button presses
  3. Something to implement the overall behaviour of the system.
  4. The Grove LED Bar support library, used to control the LED bar

You can find the code for 1, 2, and 3 in this repository in GitHub. I also had to make a few changes to the Grove LED Bar library, and you can find that in this repository, also on GitHub. I won’t delve into the code here in any detail – there’s a lot of documentation in the code, and if you’re interested that will hopefully be sufficient to explain what’s going on in there – other than to note the correspondence between the above-noted code parts and the files in the repository that implement those parts:

  1. laundry.ino is the arduino sketch file. This contains the setup code, and the loop() function that fetches events from the switch control code, and passes them to the FSM.
  2. SwitchControl.h and SwitchControl.cpp contain the definition and implementation of a C++ class that handles communication with the push button switch and its illumination LED.
  3. FSM.h and FSM.cpp contain the ‘brains’ of the project, the Finite-State Machine and the implementation of the various states the system can be in.
(continue reading…)
Leave a Comment more...

Adventures with Arduino (pt 2)

by on Mar.25, 2020, under General, Hardware

In part 1 I outlined the general – if crazy – idea I intend to attempt. In this part, I’m getting down to actual hardware – starting with the switch and illumination LED I left off at in part 1.

Picture of RJS-K16-291-GE-65J

The switch I ended up buying was a RJS-K16-291-GE-65J , a momentary push-button switch with a green illuminated button that is lit up using a LED set up for use with a 12V supply. This is, as previously noted, less than ideal for use with the 5V supply used by the Arduino Nano – so the first thing to do is take the switch apart to see how easy it might be to replace the resistor or the LED assembly with something more suitable.

Switch with the button removed

The datasheet for the switch isn’t entirely helpful about how the switch goes together, so I approached the problem by the tried and true method of pulling on bits until something gives. Thankfully, the green button actuator pulls off to reveal the LED module behind it.

Disassembled switch

Less helpfully, the LED module has the resistor built-in, and it is a pretty-much sealed unit – this is the little green module at the bottom of the picture to the left. I couldn’t work out a way to get inside without irreparably damaging it, so I decided it’d be best to just replace the whole thing, and solder the current limiting resistor to the contact on the back of the switch rather than inside it.

(continue reading…)
Leave a Comment more...

And now for something completely different (pt 1)

by on Mar.19, 2020, under General, Hardware

And by “different”, I obviously mean “anything at all”. Normally I wouldn’t write up something like this – which part of  the reason this site gets updated so infrequently – but right now I’m not burning a chunk of the day commuting, so what the heck…

Back in the ancient and near-forgotten times of the last days of 2019, our venerable washer-dryer stopped working. This was honestly not overly surprising for a device nearly nine and a half years old, but it was… inconvenient, at the very least. Better yet, it wasn’t showing any error codes! It would simply refuse to run any programs with an “Err” message. In order to find out what was really happening I had to put it into a maintenance diagnostic mode, where it finally gave an error code… except it was an error code that doesn’t appear in the manual! After much consultation with the great Internet Oracle I determined that the error was trying to tell me that either the heater element was out, the heater relay was broken, or that the deep state had infiltrated our lives in a subtle plan to use our washer-dryer as a portal for alien overlords.

Upon opening it up and applying lots of cursing I discovered the real culprit: the relay was fine, as was the heater, but a SMD diode was blown, and a corroded track on the main board had broken. And no trace of aliens, either. I was able to replace the diode with an equivalent scavenged from another old board I had in my pile of it-might-come-in-handy-some-day parts, and solder in a wire to bridge the damaged track, but the machine was obviously not much longer for this world. After much intensive research by my better three-quarters, we bought a new machine and awaited its delivery with baited breath.

And it works great, does a good job, except for one issue: it turns itself off a few minutes after it has finished a program. When the old machine finished a program, it would leave the display on and you could tell there was stuff in there that needed to be taken out… the new one, in the name of power efficiency, doesn’t do that and that has lead to things being forgotten in the machine for hours. Normal timers aren’t useful, because they go off and might be ignored at the time, and then forgotten about.

So, I’ve decided to build something a bit more in line with our needs.

(continue reading…)

Leave a Comment more...

The name of things

by on Dec.27, 2013, under General

Yes, I really suck at this thing. I blame the fact that the Earth spins too rapidly, inconsiderate ball of damp rock.

A couple of days ago someone mentioned the (broken) behaviour of a system they developed when people are added to it, but their names do not confirm to an expected format. This reminded me that a while ago a fellow member of the Secret Cabal of Shadowy Associates linked me to a blog post about programmer’s misconceptions and errors when dealing with names, specifically names of individuals. The entire thing actually irritated the everliving crap out of me: it is a prime example of a smug bastard saying “here’s a problem I’ve identified, and I know how to solve it… but I’m not going to tell you how! Aren’t I awesome?”1

Part of the problem is that, at the root of it, he’s technically correct: most systems you’ll run into have a horribly westernised concept of given and family names (forenames/surnames, whatever you want to call them) that falls down the instant the system has to deal with non-WEIRD individuals. Working for a university, I constantly run into cases where students with names that do not conform to the traditional western scheme have been kludged into systems that enforce it2. That blog author takes things to extremes, and if all his statements are taken as accurate, there is pretty much no way to realistically create a system that handles all of them sensibly. But it is quite possible to cover the majority of issues, and unlike the blog post linked, I am going to actually give some thoughts about ways to handle these things in real situations.

For a start, use Unicode: at the very least UTF-8 is widely supported either directly or via libraries in pretty much every language worth using (and several that aren’t, like PHP). If you’re still using ISO/IEC 8859-* and similar single-byte character encodings your code is broken. Seriously. You’re not doing anyone any favours holding onto that shit. Your code may work fine for very specific situations, it may even work fine most of the time, but for anything but toy programs you will eventually run into cases where you simply can not handle some characters, and fixing it will be an unholy mess of kludges and spiders. Avoid it from the beginning; use Unicode throughout.

Next, give up on the concept of given names and family names. Do not attempt to split the name data along any seemingly ‘sensible’ lines: there will inevitably be a naming scheme out there that will not work with your rules. Yes, this sort of thing will be entirely contrary to years of conventional western wisdom, and it means that things like sorting by last name don’t work – but if the individual has no last name (yes, it does happen), or comes from a culture that reverses or discards the forenames-followed-by-surname idiom3, that sorting would be invalid, or at least inaccurate, either way.

Do not simply assume that names will only ever consist of simple alphabetic characters, either. Hyphens and apostrophes are widely used even in western names, but some cultures can use a variety of other punctuation marks in names (and not just the ones commonly found on western keyboards!) Limiting the characters the user can input is artificial and undermines the whole point of trying to be better at supporting names: sanitise the input before you use it4, but don’t artificially limit it.

These steps will handle the vast majority of names out there. Searching and sorting are trickier, but storing an individual’s name in one UTF-8 encoded string means that pretty much every language and cultural naming scheme will work. Allow for optional names, and you can handle even the most weird edge-cases.

  1. My initial reaction to it was ‘”[I] have theoretically designed [whatever that means] their systems to allow all names to work in them” – Okay genius, how? Share your wisdom with us lesser mortals! []
  2. Embarrassingly, one of these is a very old system I developed before I was Enlighened. Some day I hope to go back and fix that thing… []
  3. While collaborating with some Japanese developers some years ago, I spent a lot of time being referred to as Mr Chris because of this… []
  4. Which you’re doing with all your input, right? []
Leave a Comment more...

So, housekeeping

by on Jul.08, 2013, under General

In a vague effort to keep this page from being utterly dead, I’m moving my dev blog (which is not quite dead… it’s getting better…) to the front of the site, replacing the old starforge primary website. I’m undecided about whether I will change the theme to something closer to the previous site, but for now I’m leaving it as it is in the vague hope of actually doing useful stuff elsewhere rather than faffing around with themes.

So, on that note, onwards!

Comments Off on So, housekeeping more...

State of development

by on Jan.13, 2013, under General

So, yes. Apparently I suck at this stuff – when I said, “Now we just need to see whether I actually keep this up, or whether I get a handful of posts in and forget about it,” I honestly did expect to make at least a handful of posts, not two and then let this sit unused for 9 months!

When I started this I had some clear ideas about what I wanted to start working on, and even some ┬ác and c++ code to get going with. Then Life happened, and other project got priority, and for a while I considered posting here about stuff I was working on… except that I originally intended this to be purely for the OpenGL projects I wanted to work on, and didn’t want to post about the rest.

I’ve decided that doing things that way is ultimately going to leave this thing stagnant for even longer, as there are Things I Need To Do, and none of them currently involve OGL at all. Whatever I originally intended, I’m going to treat this as a general dev blog, and post about things I’m currently working on rather than leave it unused.

Amativ alok, and all that…

Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!