Saturday 10 December 2022

Software development tools (in which I moan and probably display my ignorance of all good things)

 First of all let's get some things out in the open:

1) I don't really like developing large pieces of software. I quite like embedded systems stuff, but that rarely feels like it counts as "software development" as the systems are usually small and really focused on a small number of pieces of functionality that are closely tied to the hardware.

2) As many people who I've worked with over the years have observed, I'm not a good software engineer. I'm often lazy in the wrong ways and inconsistent in how I do things... both not good when writing software.

3) Despite the above, I do still write software. Sometimes people even pay me to do it, and I do manage to make it work well enough to be useful.

Right, enough of the scene setting, on with the moaning!

Moan #1

"Everything has got so complicated"

Writing code is essentially a pretty simple activity. You open a file, you type in some appropriately formatted text and you then run it. The "run it" bit might involve a few steps, like compilation or whatever, but that's essentially it: type it in and run it. It is still possible to work this way, and many people who do back end types of work will still do this for knocking up scripts and utilities to keep the wheels turning, but it's actually very difficult (and frowned upon, it seems) to try to work this way for even slightly more complicated systems. As soon as you have any sort of user interface you are sucked into frameworks, IDEs and multi-layer systems.

Moan #2

"Everything has got so big"

Recent projects have made me realise that the baggage associated with things getting complicated comes in many forms, but they mostly trace back to how big their footprint is. Many IDEs seem to be very big and resource hungry, even for the smallest project because they are offering facilities to do all sorts of fancy debugging and bundling in of hooks to other systems, much of which any individual project won't use. This also spills over into deployment methods, which seem to be almost an afterthought and regularly neglect simple ways to include dependencies and runtime environments or components of runtime environments. Or they just bundle everything into a mahoosive blob and demand 1Gb of disk/RAM to run "hello world" really slowly (I'm looking at you JetBrains).

Moan #3

"Everything takes so long to learn"

Over the last few years I have downloaded and installed various IDEs to use for a number of projects that I've worked on in Java, Python, C and C++ and I've never managed to get anything non-trivial working without spending several days (usually at least 3 or 4) working out enough of the detail of how the IDE works to know that it doesn't really do what I want it to in an easy way. That's sort of OK I suppose if you're going to spend a month or more buried in that project, but for anything much less than that it's a bit full-on. They also usually assume that you're also going to become an expert in some GUI development framework and shoehorn your project into some very particular template, that is broken down in their particular way. Maybe I'm just crap at learning this stuff, and always want to do things in stupid ways, but I regularly end up in a nightmare of scope problems and passing stuff around in stupid ways or with globals just to get stuff working.

So what's my answer?

We'll of course I don't have an answer and part of the reason for posting this is that unpleasant fact. But I do now have a couple of approaches to try to minimize grief:

1) I avoid IDEs. I'd rather spend the time writing code than learning some behemoth of a system that gaslights me by hiding things and trying to lock me in a cupboard with a weird toolkit consisting of the software equivalents of a toothpick, a sledgehammer and a very high end oscilloscope for which there is no documentation.

2) If I'm in a real rush and the system allows it then I'll hack together GUI stuff using a (probably horrible) webserver and lowest-common-denominator PHP. At least it will (genuinely, unlike Java) work more or less anywhere and I don't have to learn a new system every time, bundle system dependent libraries or worry about whether it has the right runtime installed etc. just to get a button for a user to click.

3) If I want/need to do something "native" (and for my work stuff this now almost always means in Windows) then I will build stuff using plain C, the win32api and a command line compiler like minGW. I can make statically linked executables that are tiny, fast and run on any windows box with no installation other than copying the executable. The GUIs look like something out of the stone age, but they work and are quick and easy to put together.

Is there a point to this?

Not really, other than to point out that I'm a bad person and probably have completely failed to understand anything about modern software development. I do, however, think that we're probably barking up the wrong tree if we've got to the point where 1) the easiest way to make a system "easy to run anywhere" is to bundle it with an entire virtual machine... I believe that's not really what they were invented for but that seems to have become a common reason for their use... and 2) I have to invest months of my life in learning one framework that's been honed in/for one IDE and one programming language. I don't believe that we need very complex tools to build very complex software... we need very *good* tools to build very complex software.

Saturday 28 May 2022

Our solar and wind power systems

Over the last few months I've been asked by a few people about what we've done in terms of PV and wind turbine electricity generation, so I thought I'd lay out the basics of our systems here. I am not a qualified electrician, but I do understand electricity and the dangers associated with it, and I spend a lot of time reading datasheets and learning about how to do this stuff before starting. If you do go down this path then make sure you have a clear understanding and be careful. Having said that, in my opinion, there is nothing stopping any competent DIYer from building an effective and useful off-grid system safely and at relatively low-cost. There is lots of information out there from manufacturers of bits of kit and from enthusiasts and YouTubers.

So, what do we have?

Two systems:

1) A standalone system that we use almost exclusively for charging our cars. This system can supply 4kW max to the car charger, and can also store energy in a 24kWh (nominal) 48V lead-acid battery bank. This system is housed entirely in the shed and was the first one that I put together. It has been in use for 5 years now, and seems to be working as well as it did when first installed. We have had one failure very early on (the inverter), but the manufacturer sent new parts and it has been working without any faults ever since. The battery bank was expensive (~£2000) and being lead-acid needs regular water top-ups, especially in the summer, so is a bit of faff but seems to be holding up ok. When I installed it I estimated that it would have about 5/6 years lifespan, but it still seems to have reasonably good capacity, so I'm not thinking about changing it yet. Last year I added a manual changeover switch so that we could run the house from this setup when the cars were fully charged, but the 4kW limit was a bit irritating as we'd often forget and switch on the kettle at the same time as the washing machine and the inverter would cut out (not popular with the gamer in the household). The more normal mode of use (pre-COVID) was that the battery bank in the shed would charge up during the day and then be transferred to one of the cars in the evening. This is not a nice mode of use for lead-acids (being fully discharged daily), so I set the voltage limit very conservatively which means that we only actually use about 10kWh of the 24 available in order to improve the battery lifespan. This system has a total of 6kW of PV panels (second-hand 5 years ago) and a (fairly poorly sited) 500W wind turbine, and provides about 70% of our car charging needs throughout the year. For about 7 or 8 months of the year we use this almost exclusively, with the exceptions being when we have multiple long trips on consecutive days. We usually do one or two round-trips to town per day. A round-trip is about 25 miles and has ~1,300ft of climb. I spent a bit less than £5,000 on this when I installed it and suspect that it has paid for itself around twice over by providing electricity for about 50,000 miles of driving (probably actually a bit more than this).

About once a month in summer and a couple of times through the winter I spend a happy 20 minutes topping up the battery electrolyte (that squeezy bottle is perfect for the job).

Rather dusty bank of 16 Trojan T105s. Still going strong after a bit more than 5 years.

Very impressed with this 4kW Voltacon inverter/charger. Not very proud of the wiring job mind .

The watering kit for the Trojans is a god-send. Would be a nightmare having to do 48 individual caps by hand each time.

What it's all about.

These QUBEV chargers were very cheap and seem to work pretty well. Box is getting a bit rusty though!


2) A system for the house. This system is relatively new and has a newer model inverter that can supply up to 8kW. We have a 9kWh LiFeP04 battery bank on this which is charged from 3kW of (again second-hand) PV panels (soon to be expanded to 4.5kW). We are also considering another 500W wind turbine, in a better site than the one for the car charging system. The 8kW capacity means that we have not yet hit the limit using our normal domestic load habits, and we can run the washing machine, dishwasher and heat-pump simultaneously although this almost never happens in practice! It is on an auto-changeover switch, so when the battery runs out of juice it switches back to the mains. As this was only recently commissioned (in the middle of summer), I don't really have a feel for how much of our usage this will provide when the PV is less productive. As I type this we have been "off-grid" for about 48 hours, including one rather grey and one fairly sunny day. This includes a couple of loads of washing, a couple of dishwasher runs, the immersion heater and a batch of cupcakes (yum). My rough calculations indicate that to be completely off-grid through the winter, and using the heat-pump for heating, would need about 30kW of PV and about 20kWh of storage: probably not realistic, but we'll keep adding bits and pieces of generation and see where we get to.

Fancy new Pylontech US3000C batteries. Built-in BMS will talk directly to the inverter, so hopefully all properly managed and no more faffing with the squeezy bottle.

Fancy new 8kW inverter connects to WiFi and does all sorts of performance logging etc. Even the app (I'm a bit allergic to apps these days) works pretty well.



Sunday 22 May 2022

 Electric cars: some opinions after a few years

So we own two electric cars, a 24kWh Nissan Leaf that we've had for a bit over 6 years now and a Tesla Model 3 SR that we've had for about 2 and a half. They are both used regularly and we've put about 55,000 miles on the Leaf and 35,000 on the Tesla.

The state of the Leaf:

1) It's lost one "bar" from it's battery state meter (this is a Nissan thing) and seems to have lost between 5% and 10% if its range from when we first got it. Significant, but still fine for a couple of trips to town and back and some running around which is its primary mode of use. Seems to be happening very gradually and at this rate I reckon the battery will still have usable range at at least 150k miles.
2) It doesn't feel noticeably different to drive since we first got it. Maybe the suspension is a bit squishier than it used to be, but that's not really surprising considering the state of the track to our house. Acceleration and steering feel the same as the day we bought it.
3) I still really like driving it as it just feels like a normal car and is comfortable and easy-going.
4) Until this year when we paid ~£500 for new rear brakes and handbrake cable to be fitted (I was too lazy) we'd spent about £100 per year on maintenance. Apart from stuff like windscreen wipers and tyres the only repairs were a new rear fog-light (got shunted by a van that broke it), and the windscreen washer motor that got broken when it got crunched by a bit of less than careful parking: the child in question will remain nameless :-)
5) It's now getting pretty scruffy inside as I'm a terrible slob. Maybe I'll have a proper go at cleaning it one day.

Executive summary: still a decent "normal" car with plenty more miles of use in it.

The state of the Tesla:

1) At ~35,000 miles it's range is as far as I can tell exactly the same as it was when new.
2) It has all sorts of squeaks and clunks. None are functionally problematic, or even easy to identify the source of, but a tad irritating for such a low mileage vehicle.
3) I've been unimpressed by the servicing in Cardiff (one experience). They broke plastic clips, sheared off captive nuts and didn't get rid of the squeaky suspension. 
4) The range, acceleration and handling are all amazing and it's great on long trips. A really useful vehicle.
5) The under-trays fell apart very quickly (again probably to be blamed on our track) and have now been replaced by after-market aluminium ones.

Executive summary: lousy build quality (especially for the price), but really useful for long trips and fun to drive.

I actually prefer driving the Leaf as it has fewer squeaks and clunks and feels more like a normal car, and if it had the same range and charging network as the Tesla I would choose the Leaf every time. I guess that's just the effect of it being built by a long-established car company rather than a relatively recent entrant to the market.

Cost of ownership:

1) Because we've got an off-grid solar PV with storage setup we do more than half of our charging from that for "free" (around 70%). I don't remember the total cost of installation, but it was around £5k. Over the last five years I reckon it's saved us double that in equivalent diesel costs. Proper "Vimes boots" stuff.
2) Maintenance is absurdly cheap compared to the diesels we were running before: probably around 20% I think,
3) The Tesla will eat tyres when driven enthusiastically: I haven't kept track of this, but I suspect that we spend about 50% more on tyres than for previous cars, so it's significant. The Nissan doesn't suffer from this.

My conclusion:

I basically love electric cars. They just work with almost no maintenance in a way that the diesels we owned never did. They are cheap to run, quiet and relaxing. Slightly different from diesels on long runs (but barely in the Tesla). Even with the "standard range" Model 3 I can get from Aberystwyth to Edinburgh in 2 stops, which is what I'd do anyway, and even with charging I get there in about the same time as the Google Maps estimate.