Category: Alaric

Preparing for Apocalypse (by )

Even before global warming became painfully obvious over the past few years, there's a long history of people preparing for some kind of collapse of civilisation. I grew up in the last throes of the Cold War, and the threat of nuclear annihilation hung over us; and because of that, my mother and I lived with a relatively casual dependency on civilisation, growing most of our own food on an allotment, our house was heated by burning wood, and so on.

The full-on collapse of civilisation is very unlikely. More likely are temporary breakdowns that last for days, or months at most; and much more likely are failures of just one or two of the things we rely on other people for.

Why bother?

"Preparing for the worst" means thinking about all the infrastructure we depend on, and deciding how we'd cope without it or find a substitute we could manage with. Preparing for the worst doesn't mean you're only preparing for the worst; it also means you're preparing for all the little things that could individually go wrong - or in combinations. Preparing for the unlikely worst is the most efficient way to prepare for all the likely but annoying things that could go wrong!

Even if you're very lucky and no infrastructure ever fails you, preparing for it still has some benefit. Being aware of the infrastructure we use and how it works means we're better placed to use that infrastructure well when it's working - and it makes us better able to understand and take part in discussions about the development of that infrastructure. It would be nice if, in planning debates about cellular network towers or power stations or flood management systems, people were more aware of how these things actually help them!

Also, preparing for infrastructure failure is a good exercise to hone your problem-solving skills. When I take my Scouts out on a navigation hike or a camping expedition, it's also a fun social activity for them, as well as developing their teamwork skills. Any group that plans and practices together for infrastructure failure will gain similar benefits.

After all, as a scout leader, I am doing exactly this: teaching young people to look after themselves on camps, make shelters from natural materials, cook on open fires, and so on. Although I hope it will be of use to them in the tiny chance that they need to go out and live in nature, I am mainly doing it because those problem-solving skills and self-sufficiency mindset will serve them well when they leave home and need to figure out how to use a washing machine.

And finally, having an awesome off-grid survival setup means you'll have a great time on camping holidays. And those holidays are also good practice in off-grid survival...

How much time and money is worth spending on it, though? And with many exciting things you could buy or do, how do you spend your budget wisely? There's a certain stereotype of "The Prepper" who tricks out their offroad vehicle with guns and exotic radio gear, driven by fantasies of hunting for food in the forests then living a Mad Max-inspired life of nomadic road combat by day. There is the usual human desire to buy cool toys, and a darker impulse too: if you feel constrained by the rules of modern society, you can start to fantasise about the breakdown of that infrastructure, so that you can finally be "free" (to commit rape, murder, theft, ...).

But don't sneer at those people. They are enthusiastic, they're learning things, and they're having fun, and they're driving the prices of useful survival equipment down by buying lots of it so supply steps up to meet demand. Sure, they're also creating a market for poorly-thought-out "tacticool" equipment, but being thoughtful about choosing what gear you buy is something you need to do anyway!

And if they start properly getting into it and hearing about other people's preparations, they'll think a little deeper about their actual survival plans. And the few who are craving The End so that they can make up for their insecurities by threatening those around them with violence - they'll either get turned off the idea by realising that everyone else is setting up to work as a team that will outnumber them greatly, or if not, at least everyone else can figure out who they are and know to avoid them.

Deciding how much time and money it's worth YOU spending on this stuff depends on your personal situation. Factors to include are:

  1. How much time and money do you actually have spare? Actually living your current life is far more important than worrying about possible futures.
  2. What are the likely risks to you? A dweller of a large city is quite unlikely to face a disaster that they can do much about - if they survive it, their choices are to stay put and live on supplies until civilisation can be restored, or flee the city (along with everyone else fleeing the city, which won't be much fun). So stockpiling a few weeks' essential supplies and hoping for the best is probably as good as it gets, unless you can prepare an accessible countryside hideout. HOWEVER, if you live out in the countryside as I once did, flooding, extended power outages, and being snowed in for weeks at end were things that happened fairly frequently and our preparations were routinely tested - and we had the space to grow our own food.
  3. Do you enjoy it? If you like self-sufficiency for its own sake, because it gives you a warm feeling inside, then you might as well indulge that in a way that's potentially very useful.

However, be careful you're not obsessing about the collapse of civilisation - and if you find you are, try to think about why. Fear is a great way of controlling people, and many rather unpleasant movements exploit this by encouraging people to be afraid, then offering them a feeling of security. If the disasters you're concerned about drift into conspiracy theory territory, you're on a dangerous path. And if you find yourself looking forward to the collapse of civilisation because you think you'll be happier without it, you may have anger issues or problems with authority that you should address.

Things to Worry About

There are a number of things we need to live, and things we'd like to have to live well, that we tend to depend on infrastructure for. It's a good idea to make a list and think about how you'd deal with a failure of each, and how long that failure might last.

Food supply

In the short term, you can stockpile food that lasts a long time (dried, tinned, etc). In the long term, you're going to need to be able to grow your own, or hunt (if you have access to an environment with a suitable population of suitable animals to eat, that can sustain the number of other people who will also be trying to hunt in it). Having the tools, starting supplies, and knowledge to grow your own food / farm your own animals will be necessary in the long term.

Water supply

In the short term, you can store water. In the longer term, you need a source of water, and possibly a way to make it safe to drink if it isn't already. Boiling and filtering are good, but chemical toxins are hard to remove without distilling it.

Shelter

You need to get out of the elements to remain healthy, unless you're in a very nice climate. And a place to store your food and other supplies that keeps them out of the elements, keeps rats from eating them, and so on.

Whatever shelter you have, you'll need to have a plan to repair it. That means tools, materials, and expertise in applying the tools.

Heat

Heat isn't strictly essential unless you're in a cold place, but it's very very useful: to cook your food, to stave off hypothermia, to dry your clothes, to sterilise water, and to keep you comfy and happy.

Fire can also be your light source at night, although it's not very convenient for that.

In the short term, bottled gas, candles, and spirit stoves are great. In the long term, you're going to need to be able to obtain firewood and have facilities to safely and conveniently burn it inside your home.

Rocket stoves are a good (and portable) way to turn wood into cooking-grade heat; rocket mass heaters are a good way to turn wood into house-heating warmth.

Medical support

More so in a disaster than usual, humans get injured or sick, and their survival chances are greatly improved by proper medical care. In the short term, you can stockpile medical supplies, but the important thing is the knowledge to use them - bandages can be improvised, if you know how. First aid classes are a good investment. In the long term, you're going to need at least books on topics like delivering babies, setting broken limbs, long-term would care, and minor surgery.

Cleanliness

Humans are very vulnerable to infections. Ways to clean your cooking/eating utensils, wash your hands, cleaning wounds, cleaning yourself and your clothes so you don't get sores that become itchy then get infected, etc. are very important to help us live long healthy lives. In the short term, hot water and soap will do us well, but what if the soap runs out? Being able to distil alcohol to disinfect things might be useful (and it'll be a fuel for lamps and stoves), or a way to make soap. You can get quite far by boiling things in water to sterilise them, but that's not so great for hands and table tops.

Rotting teeth was a big cause of death in the not-so-distant past. What are you going to brush your teeth with?

Security

This is contentious, and depends a lot on your philosophy. In the weeks after a major disruption to civil infrastructure, it's quite likely that gangs will start robbing supplies, and possibly even enslaving people (although making themselves responsible for additional mouths to feed may prove unpalatable).

Defences against them might include:

  • Not being easy to find in the first place.
  • Making your home hard to break into. Think "gang of people with hammers, not worried about attracting attention" rather than the usual home security risks of conventional burglars. Covering your home in massive steel shutters might make them go and find easier targets at first, but later it might make them more interested in what you've got hidden in there.
  • Collaborating with your neighbours to collectively defend your neighbourhood. Such gangs will probably rely on being a few times the size of a typical family, so they can easily overwhelm a family. An entire street of thirty households all willing to defend the street as a whole will probably form quite a deterrent, and you can cooperate to build physical barriers around your entire community - and patrol them in shifts 24/7.
  • And as a last resort, maybe having your own weapons will help. I mention this last despite it being the first thing many may think of. But actual armed combat is a numbers game - no matter how skilled and well-armed you are, you are likely to get hurt. Military battles are between large groups of well-armed people who are trained to work well together, and still, they have high casualty rates. That works in a military context, because if your "side" wins, their losses are acceptable. If you're defending your family, losses are not acceptable, and you can't get new recruits in to replenish your armed forces as you fight off repeated waves of raiders. If your confrontation actually gets as far as combat, then you have really failed in protecting your group because there's now a high chance some of them are going to get injured.

Communications within your group

Within you house / cluster of houses / etc, you can general shout and ring bells to attract attention, organise regular meeting times to discuss the day, and so on.

But getting everyone together in the first place if disaster strikes while everyone's out at work/school, or keeping in touch if you have to send a party out to forage for food, is going to mean some kind of radio.

Mobile phones are, of course, a form of radio - but one that depends on a network of radio towers, with limiting capacity. When bad things happen in a built up area, that network tends to become jammed with people trying to call each other (this affected us in the 2007 floods). That network relies on central control and has limited power distribution, so in an extended disaster, it will fail before long anyway.

VHF/UHF radios are great for local communications; most countries have licence-free "walkie talkies" that can be used over distances of a mile or two (depending on terrain), which are cheap to buy. Amateur radio gives you access to VHF/UHF radios that can reach across tens of miles.

However, you have to be careful: The smarter gangs of raiders will also have radios, and will listen to your communications, and be delighted to hear you discuss your stockpile levels, and to know exactly when your strongest and bravest are leaving on a mission to search for more bandages. Consider developing a system of codes, and strong discipline about never mentioning certain things, and keeping radio communications to the absolute minimum (don't natter because you're bored on watch duty). Smart folks will be able to cobble together direction finding gear and find where you're transmitting from, even if you don't mention your location.

Communications with nearby groups

On VHF and UHF, you'll quickly bump into other groups in your area using radios, who are therefore presumably also reasonably organised. They might be great people to ally with and form a larger, stronger, group - or they may be raiders (or about to turn into raiders). Careful diplomacy to feel them out, and starting by cooperating on some projects without giving them unrestricted access to your home, might be a good start to build trust.

Although you do need to be careful about letting your guard down and being taken advantage of, I can't stress enough that humans are at their best in groups - forming a larger group will significantly increase your chances of survival. You may well want to form a kind of federal structure; small groups with strong internal trust and their own stores, and then a hierarchy of larger groups that have less internal trust but bring more groups together. If you are successful, you will build a new civilisation. If you are not successful, you will build a new autocracy, or waste your life in endless political bickering and then starve because you never got around to actually building that irrigation system because you never agreed what colour it should be.

Radios are delicate electronic devices. You'll need plenty of spares; it would require quite a large group to make the concentration of specialist skills and tools to build and repair them worthwhile.

Long distance communications

If your disaster is regional, then ways to communicate with the outside world will be useful. In large weather disasters, amateur radio folks with HF equipment have been able to guide relief efforts to the areas that need it. Long range comms is useful for:

  • Calling for help
  • Finding out information about the disaster, that will help you to know how long it will last, what subsequent disasters to expect, etc.

And, in the event of a major disaster, it'll help you to communicate with other groups beyond your local VHF/UHF range if you want to establish larger levels in your federation.

I'd say the first priority here is to have receive capability - FM and shortwave radio receivers are cheap, licence-free, and safe to use. Being able to transmit requires more equipment and training and licences, and opens up the risk of leading raiders to your location, and is less useful.

Power supply

If you want lighting at night beyond what fire can provide, or want to power radios, or you want to use computers to manage your stores inventory, or have ebooks full of information on farming and medical practices, then electricity will be useful.

In the very short term, batteries are good. In the slightly longer term, petrol generator sets will serve you until the fuel runs out. In the much longer term, solar / wind / hydroelectric systems with battery backup can be built to last for tens of years if spares are stockpiled.

Transport

Perhaps, to survive long-term in your environment, you'll need to become a nomad. If not, having a means of moving heavy things around your local area is still useful. Being able to bring back a truckload of firewood from a trip to the woods that are ten minutes' drive away, rather than just what you can carry back from the woods that are an hours' walk away, is a great time saver.

Vehicles with engines will require fuel to keep going in the short term, and spare parts and tools and expertise to keep going for more than a few years.

However, wooden carts pulled by animals can be built and maintained with simple tools. If you are worried about a long-term disaster, plan for how to obtain the required animals, and the tools and skills required to build wheels.

Tools

If you depend on technology, you'll need tools to repair/extend/duplicate it. So you'll need the technology of tool-making.

It's possible to build a forge from natural materials, but it's a lot easier to get started with modern tools, even if you have to use them to build their replacements in a decade's time. Blacksmithing will give you the ability to make wrenches, screwdrivers, axes, knives, hoes, ploughs, hammers, hinges, brackets, spoons, cooking pots, and all sorts of other things. If you want to establish any level of technical civilisation going forward over timescales of a few years or more, somebody's going to need to learn blacksmithing, and it might also be a very useful skill for bartering with other groups with.

I'm not sure if it would be practical to maintain a workable welding facility for long after civilisation collapses: my TIG welding setup depends on somebody being able to distil argon gas out of the atmosphere, a signification electricity supply, and supplies of various esoteric elements to make the tungsten electrode and proper filler wire that will produce strong joints. Oxy-acetylene welding is little better. I'm afraid we'll have nothing finer than forge welding on an anvil.

The next level up is to have a metal casting facility, so you can mass-produce cast iron/steel/aluminium things (there'll be lots of scrap metal around to melt if civilisation collapses). If you've got that, you can also consider building yourself a basic lathe, at which point repairing and manufacturing precision machinery (such as steam engines, or even internal combustion engines) becomes practical.

The most comprehensive resource I know of for this is the "Gingery books", which explain how to build a lathe and other precision machine tools from the basics. The lathe is the cornerstone of it all, as it's a precision tool (meaning: able to make things precisely) that doesn't require any precision tools to build. But starting from scratch is quite difficult; it's a good idea to obtain a lathe while civilisation still functions, because building a spare lathe is a lot easier when you have a lathe to start with to cut the leadscrew on. However, it is possible to start from nothing (after all, our ancestors managed it). And once you've got a lathe, everything else is possible.

Morale

Meeting everyone's physicals needs is all well and good, but a post-apocalyptic world is no picnic. The comforts everyone was used to are gone, and quite possibly, many people you liked or loved are dead, possibly after having agonizingly died in front of you. After the initial shock of everything has worn off, you and your group are going to have some rocky psychological ground to cover.

You will probably all be relatively busy a lot of the time - without washing machines and dishwasher and ready-made food, a large amount of time will be spent cooking and cleaning and gathering firewood and so on. Having something to do will help people cope, but it will also allow people to avoid thinking about the things they've seen or their new situation, saving up trouble for later. So in free time, or over meals, it will be important to give people a chance to discuss their feelings, and to openly discuss the possibilities for the future of the group and form plans together, so they feel a sense of hope that things will improve.

Develop a rota for all the tasks required to maintain your little outpost of civilisation; this will ensure everyone is kept equally busy, which will help to prevent people from sliding into depression, and will help to avoid resentment from any perception that some people aren't pulling their weight. Ensure there's free time for people to be alone or to form into small groups as they wish, as well as time when everyone is brought together (eg, mealtimes) to establish a sense of community.

If possible, have a supply of board games, fiction books, etc. for people who enjoy those sorts of things. Make sure you have a good stock of condoms.

Protection against Whatever The Heck Went Down

The disasters you anticipate happening may demand extra tools and supplies to deal with them. If being snowed into your home is an issue, then snow shovels and grit to put down to make roads driveable would be worth storing. If it's a plague you're worried about, suitably rated breathing masks and gloves might be wise. If you're concerned about nuclear explosions, there's a lot of specialist things you need to know about that I shan't go into here (although it's perhaps the disaster I know the most about preparing for, as it was a big concern in my childhood).

General Notes

Even if you are concerned about the likelihood of permanent infrastructural collapse, you probably don't need to be fully set up for completely self-sufficient living at a moment's notice. If you have enough supplies stocked up to last you several months, you can use that time to set up your own infrastructure to manage after that - just as long as you have everything you'll need to build that infrastructure in time.

Also, plan for your resources being damaged. If you have a fantastic off-grid living setup in your house, and the disaster that hits you destroys your house, that's a problem. Think carefully about where things are stored and what the risks to them are. Avoid having everything in one place. Have spares of things, and the knowledge/tools/parts to repair things that get broken. Choose equipment and supplies that are sturdy so they're more likely to survive a disaster, and easy to fix if they do get damaged.

Useful Information Sources

  • https://theprepared.com/ looks pretty good, if a little US-focussed.

Conclusion

All the measures I suggested to prepare for stuff above are potentially useful for common, minor, emergencies. Many of them can actually improve your life when there isn't an emergency, too. Preparing for all of them will then mean you'd be able to manage even if everything went wrong, but that should probably be considered a side benefit rather than your primary goal!

I'll probably update this post with more things to consider as I think of them. Suggestions will be welcome in the comments 🙂

Thoughts on Nice Clothes (by )

As I have previously opined, I like practical clothing with lots of pockets; I am generally more interested in practicality (storage capacity, comfort, keeps me warm and dry) than looks in my clothes. So where I get to choose colours or designs, I tend to go for "black" most of the time; the exception being t-shirts and hoodies, where I of course often get things with amusing cultural references or logos of things I'm proud to support. Although I'm agender, my feature-driven taste in clothing is entirely masculine because, sadly, female-gendered clothes tend to be designed for style rather than features...

However, a discussion I was tangentially involved in a while back got me thinking: if I chose to disregard practicality for some reason and wanted to choose clothes purely for what they look like, what would I want to wear?

After much deliberation, I think I like the cut of garment called a Thawb - although it took me a while to find out that's what it's called! But I'm not keen on the white ones as pictured in that Wikipedia article, I'd like a nice dark black/blue/purple one with some kind of angular pattern embroidered on it in white, silver or gold thread. Perhaps a Hilbert curve around the borders, too?

I'd quite like to dress like Tilda Swinton's character in the Doctor Strange movie, in fact!

Not that I'd wear it much, mind; I only really dress up for weddings and stuff like that (The jacket I got married in is somewhat similar to a thawb, although shorter; that's served as an inspiration). Although in principle it might be kind of nice to dress up just to lounge around the house and stuff, it would be rare for me to have a day without having to go out in the rain, brave mud, cook, drill holes in walls, etc - not to mention dealing with the unexpected demands that I carry all that stuff in my pockets for!

Designing software (by )

One thing that has often annoyed me in my career as a software designer is coming into conflict with people who want me to do the worst possible job that is "just good enough".

This often comes out in statements like:

  • "There isn't time to design it properly, just hack something so we can start demoing it"
  • "We'll have to rewrite it anyway, requirements always change"
  • "Supporting more features than we need right now is a waste, add them when we need them"
  • "Can't we just do something quick and simple?"

Reading between the lines, they seem to think that "more designing" will mean more complicated software with more features, that will take more time to build.

I think the problem comes from how product management thinks of software - they want a feature, they request the engineers add it (ideally specifying the feature well enough that they actually describe what they want), they get that feature. And there's often some discussion about reducing the scope of the feature by removing some criteria to get it implemented sooner. It seems very much like "more features with more acceptance criteria equals more work".

I'd like to dispell that myth.

I assert that better-designed software.will take less time to write, and will be better due to being more flexible rather than through having more features, and through being easier to extend in future when new requirements come up.

There's a paragraph in the Scheme language standard known as the "Prime Clingerism", and it reads thus:

Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary. Scheme demonstrates that a very small number of rules for forming expressions, with no restrictions on how they are composed, suffice to form a practical and efficient programming language that is flexible enough to support most of the major programming paradigms in use today.

It has been my experience that this approach applies to all forms of software design, not just programming languages. As a software architect, I see designing a feature as more like Michelangelo making the statue of David (famously, he said that the process of making a statue is just to get a big enough block of stone, and remove all the bits of it that aren't the statue).

Rather than thinking in terms of each acceptance criterion in the specification for the feature as a thing that will have to be done separately (so more ACs means more work), I like to work the other way: what's the simplest piece of software that can do all of these things? Most problems have a "core" that it can be boiled down to, plus some "details". I try to design software that has to meet specific requirements by making the "core" with the fewest assumptions and then adding "details" to tailor it to the exact requirements - which tends to mean I can add more details later to fulfill more requirements.

An example

For instance, many years ago, I worked at a CRM SaaS company. A big part of the app was sending out HTML emails to subsets of a user's customers to offer them some special offer, serving up the images in the email from our HTTP server (and tracking who saw the email by including the email message ID and the recipient ID in the image URL), and tracking what links they clicked by replacing URLs in the email body with URLs hosted by our HTTP server that would log the email message ID and recipient ID then redirect the user.

I was given a feature request: people were occasionally forwarding the emails to their friends, and when they did so, their viewing of the email images and their clicking of links would be logged against the original recipient, as their ID was in all the URLs. Our server would see the same person viewing the email lots of times and clicking the links lots of times. Learning how users responded to these messages was a big priority for our customers (we had extensive reporting systems to analyse this data!), so they were tetchy about this, and desired the ability to put "forward to a friend" forms in the email HTML. The recipient would put their friend's email address into this form and hit a button, and our system would send a fresh copy of the email to their friend, with their own recipient ID - so our user would know the forward had happened, and could see the friends' response separately.

Now, the "simplest" solution would be to add an extra feature to our HTTP server, accepting a form submission to a URL containing the recipient and message IDs, extracting an email address from the form submission in the usual manner, creating a new recipient in the DB with the email address (or finding an existing one), recording a forward from the original recipient ID to the "friend"'s ID, and sending a copy of the email to the "friend" - then responding to the form submission with either a hardcoded thankyou page or responding with custom thankyou-page HTML uploaded by our user, or a redirect to a URL set by the user.

A quick chat with the boss revealed that being able to host custom thankyou pages was a very desirable feature, and as that would involved embedded CSS and images (and maybe javascript), I clearly needed some kind of generic user-uploaded-content HTTP serving infrastructure. So I threw that together, letting customers created websites in the application and upload files, and an HTTP server that would server resources from them with a URL containing the website ID and the path of the file "within" that website - and with the ability to tag URLs with email message and recipient IDs for tracking purposes. We already had an engine to "personalise" HTML message content for a specific recipient, which also handled modifying all the URLs to embed email message and recipient IDs, so I used that again for hosting textual content such as HTML, meaning that if a link came in from an email message with message and recipient IDs, they would be fed into all further URLs returned by the system. To prevent spoofing of the IDs in the URLs, I reused the method we used on the image and redirect server URLs: the URL itself was "signed" with a short cryptographic signature when the software generated it.

But rather than hardcoding the forward-to-a-friend feature into that, I did something that took perhaps ten minutes more programming: I allowed an arbitrary number of named "commands" to be included in a URL. The only named command I implemented was "forward" that would do the forward-to-a-friend logic (finding all form submission fields called "forward-to" and using them as recipient email addresses, so you could make forms that accepted lots of addresses; making it loop over all fields with that name rather than just looking for one was the first assumption I removed to simplify the software while making it more flexible) then proceed with handling the HTTP request in the normal way.

But when a requirement came in to support unsubscribe forms, I just added an "unsubscribe" command, which took all of five minutes. Adding an "update" command handler to let people update their details in the master DB took a little longer, just because I had to list all the supported field names in the documentation and include a more lengthy example. And then, because I'd implemented the recipient and email message IDs in the URLs as optional things from the start, adding a "subscribe" command handler that created a new recipient in the DB from scratch, along with a tweak to the UI to let the user get an anonymous URL for any file in their website took an hour or so - and meant that users could now create subscription forms and generate a URL they could publish. I think I also added a "send" command handler to send a copy of a specific email message to the recipient ID in the tracking context; as the "subscribe" command put the new recipient's ID in the tracking context, a URL with a "subscribe" command followed by a "send-" command would handle a subscription and then send a welcome email to the new subscriber...

I added a few other command types that did various other things in the system, and all was good.

Now, I didn't "set out" to design an "overcomplicated super-flexible" HTTP server system that could do all these things when I was asked to add the forward-to-a-friend system. I just spotted that the following assumptions would be really easy to NOT bake into the core of the implementation:

  • Forward to a friend is always to a single friend; it's easy to create multiple form fields with the same name in an HTML form, and easy to make my server loop over any it finds.
  • Every visit to the new generic HTTP server will have a recipient ID and an email message ID; although forward-to-friends will as they will be linked from an email, it's easy to imagine that we might want to host subscription forms in future. So making the tracking IDs in the email optional (or allowing for other kinds of tracking IDs in future) by making the URL structure by a series of tagged fields (it looked something like http://domain/sss/Rxxx/Eyyy/Wzzz/foo.html for a request for file foo.html in website ID zzz for recipient xxx from email yyy, with sss being the anti-tamper signature) was worth the few minutes' work.
  • Requests to the web server will be forward-to-friend requests or just static resources in support of a response page; it was easy (given we already had an ordered list of tagged components in the URL) to added an ordered list of arbitrary commands (with URL path components like forward, subscribe, etc; any component before the Wzzz/filename part was considered a command or tag, and tags started with an uppercase letter).

The "extra work" required to do things that way rather than the "simple" way was tiny. But it meant that the core of the HTTP server was simple to read and didn't need to change as we extended it with more and more commands (by adding them to a lookup table); it made a powerful system that was easy to extend, easy to understand, and capable of things we didn't have to "add as features" (some or our users did quite creative things by stacking commands!). As the HTTP server core and the commands were small separate modules with a clearly-defined interface, they could be understood individually and were well isolated from each others' implementation details, the benefits of which are well documented.

So please help me fight the assumption that putting thought into designing software means it'll be complicated, more effort to implement, and that "it'll need rewriting anyway so there's no point"! Let me do my job well 🙂

Enthusiasm (by )

When I was a child, I was full of enthusiasm - as a keen self-taught engineer I was soaking up knowledge about the wonderful things that could be done, and my future was full of promise; I lacked the tools and money to build many of the things I planned, so focussed on tinkering with software (once I had a computer, programming was free!). But I was confident that I would be able to turn my skills to employment and earn enough to buy tools, and then I'd build so much cool stuff.

However, it took a while to get there, and along the way, I accumulated lots of pressures on my time as well. These days, when I have free time, I'm often too physically exhausted to do much, and that enthusiasm is all gone - nothing seems rewarding any more, and I fritter the free time away.

But it's not always like that. A few times a year, a burst of enthusiasm comes to me (and I think I know how to trigger it deliberately, too).

This weekend, I did a lot of DIY. I worked on the van, tidied the house, sealed the skirting boards in the kitchen (I've learnt how to apply sealant neatly!), caught up on my emails, did some financial admin, wrote up a lot of scrappy notes I had into my filing system (re-organising some bits of it on the way), and caught up on work hours I'd missed in the week due to visiting my sick father in hospital (he hurt his knee, and is recovering well!).

The combination of dealing with emails, filing my notes, and organising my filing system, however, brought back The Enthusiasm.

Which, on the one hand, is great - I used that energy to get a lot more done than I usually do.

On the other hand, it also meant that when I went to bed at 10:30pm (for a 6:30am alarm clock start), I couldn't sleep as my head was buzzing with ideas. I wrote them up in my bedside notepad, which usually releases the pressure of thinking about them, but one of them was exciting (a really nice way of supporting HTTPS in my Web hosting stack), and one of them wouldn't stop going around in my head - I came up with a simpler design for a new desk/shelving system I want to build in my workshop, combining my computer desk and an electronics workbench. This was stuck in my head because I couldn't just think it through to completion and then record it; I was trying to visualise all the fine details to work out how it would fit together, and it wouldn't fit in my head. So about 2am I gave in and went downstairs and fired up OpenSCAD and bashed out a 3D model of it, which also spits out a cutlist of what lengths of square steel tubing and areas of plywood I'll need to make it:

Figuring out all the fine details and seeing how they'd fit together finally relieved the mental pressure, and sometime past 4:30am, I fell asleep... getting somewhat less than two hours' sleep.

Today I've been able to divert the energy to my work, which is great, as that's what I'm supposed to be doing - and using that energy to make up for the fact that I'm dog tired. But I still spent my lunch break writing up my overnight notepad notes into the filing system and doing a few of the tasks I'd thought of, including planning a comprehensive consolidation of my sewing supplies into a proper sewing box plus a tiny sewing kit for emergency repairs, that can go into my bag. And writing this blog post!

I'm confident this is not evidence of bipolar disorder, because I'm fully aware of my slightly manic state, and I'm following tasks through to completion! But it's still not an ideal situation.

I've observed in the past that The Enthusiasm can be invoked by doing "infrastructure" work - updating my filing system, tidying my workshop, building tools, maintaining the van, building software infrastructure, etc. so my plan is thus:

  1. Book out infrastructure days.
  2. Work on infrastructure projects in the mornings. Try to remember the Enthusiasm I've felt before (this blog post will help as a memory jogger) plus sheer willpower to get me started, even if I don't feel like it.
  3. Let my enthusiasm take me where it takes me in the afternoon.
  4. Do this frequently enough that it's not all backed up inside me somewhere, so just a bit comes out at a time in a controlled manner, rather than big multi-day sleepless orgy of creativity.

Wish me luck!

Radio Waves (by )

I really love learning things, and recently I've finally been removing a long-standing thorn in my side - the fact that I don't really understand radio frequency electronics and the propagation of radio waves.

I've tried to fix this a few times in the past, but the resources I'd read never seemed to quite explain the whole picture - and I couldn't see how to piece the things they explained together into one coherent understanding of the electromagnetic world; they were clearly only shedding light on little corners of a totality that still remained mysterious to me.

Well, there are still gaps in my understanding... but I've made some progress, and in the hope that I can help others struggling with the same confusions as I was, I'd like to share my way of understanding it all.

One thing that bothered me was that explanations of transmission-line behaviour seemed to flip between talking about instantaneous voltages and currents at some point in the line, sampling the analogue signal traveling down the line - or talking about an RMS average voltage or current, and thereby causing me to struggle to make sense of what they were saying. But I think I now get transmission lines to some extent (although I'm still hazy on wave guides, because I've not gotten around to looking into them yet). And I was never quite sure what the impedance of a whole transmission line really meant, regardless of its length. If I had a transmission line and put a resistor over the end of it, and hooked it up to a battery and an ammeter, I knew that the current flowing would depend on the total resistance of the line and the resistor at the end - which would depend on the length of the line, as its resistance would be in ohms per meter. So what the heck was this impedance thing about? How did impedance mismatches cause reflections?

So, here's how I think about transmission lines now. The "DC model" of hooking a battery up to one end of a line and reading the current that flows into it is, of course, perfectly true - we can set the circuit up and test it; the reason it doesn't contradict with this weird parallel world of impedances is that the DC model is a steady state model of the system. When you first connect that battery to the line, current is going to start flowing into it, crawling along at a sizeable fraction of the speed of light; but until that current has reached the end, flowed through the terminating resistor, and flowed all the way back, it can't possibly have communicated any information about the total resistance of the line and its terminating resistor... So how much current initially flows from the battery, and why? Of course, the line can be thought of as two series of tiny inductors (with resistors in series, if we assume the inductors are perfect) with tiny capacitors connecting the two conductors, due to the inherent inductance of the wire and the inherent capacitance of the gap between them; you can imagine that the current from the battery has to charge the capacitors through the inductors for the voltage/current surge to propagate down the line. But what made "impedance" really click for me was going back to the basics of Ohm's Law and seeing it as a ratio of voltage to current. At any point along that transmission line, a certain instantaneous current will be flowing - and there will be a certain instantaneous voltage between the two conductors at that point; and the voltage divided by the current is the impedance.

So, if a 12 volt voltage source is connected suddenly to a 50 ohm impedance cable, an instantaneous current of 0.24 amps (12̣̣̣̣÷50) will flow. Now, as Kirchoff's current law tells us, the currents flowing into a node must sum to zero; so with the imaginary node at any point on the transmission line connecting two halves of it, the input current must equal the output current (although some current may be lost to resistive heating or leakage, that's not relevant in this case). So what happens when there's a change in impedance at some point in the transmission line? The current must remain the same, but the impedance changes - so the voltage must change, to make Ohm's Law still hold. If my 50 ohm cable is connected to a 75 ohm cable, that 0.24 amps flows into it and changes into a voltage of 18 volts (0.24×75). Which is why high impedance transmission lines are less lossy; a transmitter putting a watt of power down such a line (with proper impedance matching) will push out a higher voltage with less current that one putting a watt of power into a low impedance line - and resistive losses in the cable are worse for higher currents.

How about the reflections when impedance changes? I'm still a little hazy on this, but I think it's something along the lines of this: imagine a point just where the impedance changes in our example of moving from a 50 ohm cable to a 75 ohm one. A current is flowing into that point, but the voltage is higher after that point than before - which is going to create a current traveling back the other way. Where I'm hazy on is how this happens at junctions where the impedance falls (is it to do with the fact that the current flows alternately backwards and forwards, so the junction is traversed by current in both directions anyway, and the phases where the current travels from low to high impedance are what create the reflections? If so, isn't that a kind of rectifying action, that will create harmonics and intermodulation? But what is the "direction" of a signal traveling along a line, anyway? If we froze the signal in time, we'd just see a sine wave of voltage and a sine wave of current along the transmission line - if we restart time, how does it "know" what direction to propagate in? Something to do with the relative phase of the voltage and current waves?) So, yeah, I've a little more to learn there.

But this model of impedance does explain a lot. I wondered why the angles of the radials of a ground-plane monopole antenna affected impedance, but now it makes sense - the end of the transmission line basically spreads out to become a dipole, or a monopole and its ground plane; the electrical field of the traveling signal has to cross a larger region of space, so it makes sense that the voltage required to do so might vary depending on the amount of space crossed. All the mysterious constants, like the fact that a dipole trimmed to 0.48 times the wavelength has an impedance of 70 ohms are really down to the electromagnetic stretchiness of space: the impedance is the voltage required to push one amp along a transmission line (a dipole antenna just being an oddly-shaped transmission line, handing the signal over to the even weirder transmission line that is free space itself), and that is a function of the permittivity and permeability of that space.

This model also explains how impedance matching transformers work. A 1:2 turn ratio transformer will transform X volts and Y amps on the "left" into 2*X volts and Y/2 amps on the "right"; as the impedance is V/I, that means it converts R ohms on the left into R*4 ohms on the right, simply through changing the voltages and currents. A 1:N turn ratio transformer makes a 1:N^2 change in impedance.

Antennas with multiple elements are confusing, but I'm not sure anybody really understands them - as far as I can tell, the design process is almost always to mock it up in a finite-element computer simulation or build a prototype and tweak the design until the desired parameters are obtained experimentally; the mutual interactions between the elements (not to mention ground, support structures, and the transmission line feeding the antenna) are just too complicated to analyse.

I really don't get why there's a near field and a far field (or that funny one in between that, I think, is just a mixture of the two). Does the antenna both far and near fields at once, and the near field is stronger but doesn't spread out far, so the far field is negligible when close to the antenna? Or does the antenna create a near fields, which "decays into" the far field as it spreads out? Nothing I've found seems to explain.

I'm not very clear on why a balanced transmission line that's shorted at one end and open at the other end has varying impedance along its length, and can be used for impedance matching, but it doesn't create reflections from the ends.

But, I can understand how to run a cable to a dipole or monopole antenna, manage the impedance transitions, and make it radiate efficiently. That's progress!

WordPress Themes

Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales
Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales