perjantai 20. joulukuuta 2019

Controlling things remotely


We have a small "summer cottage" some 100km away from here. Since it has running water, it needs to be heated during winters, and we're using electric heaters for that. This obviously is somewhat expensive and wasteful, since outside temperature can vary a lot; when it's close to zero (celcius), only minimal heating is needed; but when temperature drops below -20, a lot more is needed.

Also, it would be nice if we could up heating remotely. Like a day or so before going there (yes, actually we go there, for a day or two at a time, during winters too) I could set heaters to 20 degrees so it would be a bit warmer when we get there. For this remote control systems exist, but are somewhat expensive to install and run, so I'd like a bit different setup.

So the rough plan is to have "all-time-on" heaters (set to minimal temperature, around 10c) that keep base heat up, and then maybe another set that can be activated when temperature drops too low (additional heating on very cold weather, this will be done automatically by the system), and third set that is set to 20c, to heat place up before we go there. This setup should make huge improvements to both overall energy consumption and comfort.

Of course it would be nice to get fully remote-controlled heaters where both "on/off" and target temperature could be set via remote system, but so far all I've found are proprietary systems that are controlled with their own hub and mandatory cloud bullshit, so that option is off the table -- for now at least.

I already have set up temperature monitoring system there (I can see from home how the temperature actually is - especially inside, in case there are power outages or periods of extreme cold; frozen water pipes is something I absolutely, positive don't want), so I was thinking I could add heater controls to that system. It already has own GPRS module to send temperature data, so it could equally well receive commands back when contacting my server (every few hours or so)

The current heaters, like said, are mains electric powered, 4 total, and their individual power varies from 1000 to 3600 watts, total power being somewhere in 8 kW range. A figure that I take seriously; I don't want anything to overheat or worse, burn if something goes wrong with control systems.

Easiest way is remotely controlled power outlets, and there certainly are many of those available. Many require their own SIM (each, not good) or proprietary protocols (zigbee with central hub) to control them, so those aren't great or easy to use.

Then there are simple sets available from neighboring shop, cost being full 16€ for three 3.6kW-capable outlets and handheld remote control unit, using I think 433 MHz band. I don't even need to mess with outlets (therefore keeping them as safe as they could be), I just can hack the remote!

Remote control comes apart easily, and as expected it's simple unit; single chip as controller, few RF components and buttons. Unfortunately (but I kinda expected it) buttons are in matrix, and after some measurements I determined it's 3 outputs and 4 inputs, for 10 buttons total (channels ABCD on/off, and one master on/off). Single input per button would been easier to interface but this can't be helped.

Buttons are usual type for this kinds of devices; just pads on board, and pressing button shorts them with conductive material. My original idea was to solder a FET on button pads I needed to control (three channels, on/off, so six total), but they are covered with carbon contact material which made this idea impractical (I didn't feel like peeling the carbon off, as it might damage the board/contacts).

So next best option was to put these to separate board, a bit like this:


This is just for first test. I've only connected channel A here (pin 6 being output for first four buttons, and 12/13 inputs for buttons 1/2 and (so far unconnected) 5/6 and also 9/10 (master channel I don't need so I leave unconnected.)  And it works; I can control channel A by pulling gate of those FETs high or low. Nice!

I already placed all needed FETs on small board. On horizontal are "output" channels (I need only two out of three),  and on vertical "input" channels (all four needed). Now I just need to connect remaining wires between these boards, and then FET gates to pins controlling them on third (main controller) board. Remote uses 3v battery, so that power comes from main board as well.

All in all, I should have nice test setup running shortly.


sunnuntai 15. joulukuuta 2019

ATV electric conversion part 3: fitting in


Previous part here .

Last time I mentioned apparent problem, and here it is. The picture shows how I originally planned installing the motor, but note the small arrow indicating rotation direction.


Yeah, that is not going to work. Installed like this the ATV will run in reverse, which is pretty far from my intention. After some reading, it's apparent that this motor type doesn't like running in reverse, as it could just burn out or shorten its lifetime a lot, so that simple solution is out of the question. Not to mention the motor's sprocket attachment nut; it might rotate open and drop off if motor were ran in reverse. So not good.

I considered rotating motor around and adding transfer axle between it and rear sprocket. That is, there is one chain going from motor to this transfer axle, which then and pulls another chain that is in line/connected to rear sprocket. I quickly gave up with that idea though; too much complexity. And finding suitable axles and sprockets ended up being near impossible, as they come with different center holes (star-like attachment; D-shaped hole, double-D/oval shaped and so on. No suitable combination was readily available. I don't consider my machinist skills to be good enough to make adjustments to parts so they should be ready as ordered.


This doesn't show angle very well but you can see the rear axle and chain sprocket behind the motor. Square tube is there to mark straight chain path. This is my alternate plan at the moment. This is under rear mud guard so motor fits there nicely, but so far I haven't figured out how to build new attachment for the motor. Or, more precisely, I have a rough idea how it should be built, but no idea how I make the placement match when attaching everything together in the end.

There's also few other attachment position ideas I have, I need to think about them as well.



torstai 24. lokakuuta 2019

ARB waveform generation


I've had GWInstek AFG-2005 pulse generator for a while, but so far I haven't needed to arbitrary function generator part of it. Now, however, I ran onto a case where it would be useful so I downloaded the PC software to see how difficult it would be to generate sequence I need.

Knowing that many of these manufacturers' software is, shall we say, of dubious quality, I kinda expected at least some amount of frustration, although GW's reputation isn't even close to worst.


First troublesome thing is that it uses memory points as horizontal axis, instead of time. I don't care about points! Give me time axis! Going through menus quickly, there is "period or number" selection but that doesn't seem to change anything. Figures. (pun intended)
 
On vertical axis; generator has 10-bit (so 1024-level) output, so values go from -511 to 511. -512 is not apparently there (so 1023 levels, not 1024), which doesn't bother me too much actually. Again, I'd prefer voltage, but meh, this works for me, at least for now.

(later note: actual output level can be set via generator itself, and -511..511 matches set full peak-to-peak range.)

I wanted to start with simple square wave, and there is handy dialog for this.


There was output rate selection when opening the software, and I think I selected 100 samples/s there. I wanted 10 pulses over 1 second, and it took me a while to figure this out. Points, period and freq here indicate same thing; total length of generated sequence. Below those, 'cycle' indicates how many cycles of signal to create. A bit confusing but okay-ish...

So after this I got the first screen. My signal is kinda tiny there, on right hand corner, right? Okay, let's zoom in and ... What?!?

Why is this zooming also vertical axis (so with some zooming vertical is reduced to 500), I wanted to keep my whole signal range on view? And why is there that brief period of inactivity in start? And why is there some 12 cycles instead of 10? What?

(later note: after some more fiddling around, it seems that this generate button is "apply more data to end" and not "generate signal", so I guess there was something already from what I did before getting here.)

But okay, let's try this. Send to instument.. I don't feel like taking another picture anymore, but why is this suggesting some random range by default (start 0, length 20), instead of the entire signal I just generated here? Sending worked well enough with USB and generator switched to it automatically. And yes, generated output is same as here, with that unwanted blank period in there as well. Although I had to set frequency on the generator itself to 1 to return this signal to the length I actually wanted.

The waveform is saved with CSV extension, but unfortunately it isn't CSV as in Comma Separated Values file generated by for example Excel. It is text file nevertheless so if (I think that's "when") needed I can generate it manually. Why is there that comma between "Start:" and value though?

Start:,0,
Length:,100,
Sample Rate:,20000000,
511,
511,
511,
511,
511,
...


...All in all, this thing is not great, but I can work with this.

Edit a bit later: After turning the signal generator power off and back on the next day, I was pleasantly surprised that it had previous mode set; ARB with frequency I set. After some puzzled testing I was somewhat less pleased to find out that this was effectively a lie; it was not outputting the waveform I used last time but some basic square wave instead. Not nice.






sunnuntai 20. lokakuuta 2019

Keyboard layout issues

Bit of mild rant, bit of memory lane...

Back in the 90s, when I first got into flight simulators, I learned the hard way that I had to switch the computer to US keyboard layout to even play the games. This was because Finnish keyboard layout has keys 1-0 and + and ´ on top row (excluding whatever is the leftmost key, and backspace), while games expected US layout where keys there are 1-0, - and =. On Microprose simulators and many others these keys were typically used for throttle controls, so without them even take off was impossible. Between different keyboard layouts only A-Z and 1-0 are common between layouts (completely ignoring non-latin alphabets, and even within latin charset there are exceptions like AZERTY layout), and pretty much all other characters move around when switching between them.

I recently bought Stardew Valley and found it surprisingly fun game. It did, however, bring me back few decades due to this very same keyboard issue I though long since solved.

Why this came into my mind is that Stardew Valley has keyboard shortcuts, 12 of them to be exact, for quick access to items. Short cut keys being 1-0, - and =, to be specific. So, the abovementioned US layout. And of course it doesn't work properly with Finnish layout, not with the actual keys, nor by using, say, - character (which happens to be in bottom row in this layout). So I can't use two rightmost items with keyboard. And here I thought we had left these issues behind some 20 years ago.

Funnily enough, it shouldn't be that difficult to make game keyboard universal. Almost all keyboards have operated, and as far as I know, still operate only on "scan codes" that indicate physical position of a key on keyboard that was pressed or released, and translation to actual characters doesn't happen until your operating system gets involved. Keyboards are all standard these days regarding normal keys, and only vendor-specific keys do require specific driver to translate them to useful function.

Last time I actually dealt with the scan codes was some 20 years ago so my memory may be a bit hazy here, but I seem to recall that it mostly went top to bottom and left to right; ESC being 1, F1 2, then proceeding to I think F10 (F11 and F12 being added later to sequence and therefore had different codes) before proceeding to next row; the leftmost key, 1 onward until backspace, then tab... And keypad portion later on sequence.

Operating system (or more specifically, keyboard driver) typically takes care of translating these codes to actual characters so often you don't have to even know about them on application level. Only when building things like Stardew Valley's 12-item shortcut bar you'd want to take different route to avoid the layout issues like this.

Most, if not all common APIs do report keyboard scan codes as well on key press, so all game would have to do here is to track them instead of characters to make your game work regardless of user's keyboard layout.

The other part, showing user the key "name", I haven't ever used, but I am certain that somewhere there is a application-level function to translate scan code to key name too, just for this purpose. And voilá, no more keyboard layout issues!

Now I just have to wonder, if user isn't using QWERTY layout (but something else like AZERTY), do character movement break too, since game uses ASDW for directional movement? I'd hope not.



tiistai 15. lokakuuta 2019

ATV electric conversion part 2: The parts


Previous part here .

I avoid mentioning any brand names here, for no special reason, I just don't want to. It is not hard to find similar (or exactly the same) parts for yourself.

Looking for components was kinda annoying. I started from US-centric site and found many great looking alternatives, but almost without exception they were not shipping to Europe. Fortunately Ich kann wenig Deutch sprechen so I could go to German site and for parts there. The selection appears to be much smaller for some reason, so some compromises needed to be made.

It took a few tries (first on US side, then German) to refine my searches to suitable keywords so started getting what I wanted. For motor and controller I searched for "24v motor kit" in few variations, eventually ending up with 350W set that included controller, throttle, motor, chain and few other parts (for total of about 100€).

Next was battery. While a lead-acid battery (or two) could be obtained for less, this kind of use requires deep discharge batteries that tend to be more expensive, so I went for lithium-ion battery.
I quickly found suitable-looking 24v 20Ah unit (for about 200€), so no problem there.

A quick mention of prices: At no point I expected this to be, shall we say, frugal project, as already built electric ATVs can be found on market for less. For me, this is learning project first and foremost, and getting dead ATV running (instead of calling it a total loss) for enjoyment of kids will be nice incentive to get this done.

Before going any further I of course wanted to test that things work properly. Battery had wrong kind of connectors (as I pretty much expected), but changing it was very simple operation as motor kit came with correct connector blank. Just be very very careful not to short those battery wires during this operation...


Connect everything (well, main parts), turn key and it came alive. Twist of throttle starts motor, and although everything works nicely, I also immediately see that my previous fears of a serious build problem are confirmed and I have to figure out solution to that before build can proceed much further.
 
Next up, taking apart the ATV itself.



perjantai 4. lokakuuta 2019

DF-DFERH-01


Rant time, and as usual, some strong language is involved. 

Kid wanted to make some purchases in Google Play. Specifically in-app purchases for a game. While I am not too happy about this, I could begrudgingly allow it - as long as it isn't too often, and not too expensive stuff (although it's kinda relative, I guess.)

So I went and bought a small Google Play gift card. This is after all what they are for, right? To allow someone to make purchases without having to have something like credit cards.

When I went to activate this card on his account, I only got this completely useless error, "DF-DFERH-01" and something about not being able to load data (exact phrasing escapes me; no matter what I gave as code, even "123" gave same error) Googling that message is completely useless too, all I got was same "reset app data" advice (from several years ago, so not exactly current info), just in way more words than necessary. As you can guess, all that was completely useless.

Now, kds account is under Google Family Link control, and I started to suspect this is related. And sure, after some digging through various pages it seems that kids under 13 cannot use these gift cards. What The F***? Why?!? And if so, why doesn't the system give actually useful error about that, instead of that useless error? Guess that's google for you, half-assing everything that isn't used by 90+% of their advertising targets (I'm seriously temped of using certain other words here, but I'll hold my proverbial tongue her.e

Okay, there was this mention of family account. Of course that doesn't work at all in my computer's web browser at all (another half-assed thing) so I had to use that via android app (which I hate since it's sloooooow). Except now it only allowed me to use credit card as payment option for this shared account (despite my personal account still having some 10+ euros on it since I got myself a gift card before; nevermind this gift card I'm still holding.)

So, Google, let me get this straight: I am supposed to use my personal credit card that I am by bank's rules not supposed to give to anyone  to allow  anyone in my family, including kids to make purchases with? Think carefully about that before responding. Last I checked this is 100% against any credit card agreement, even us US - and this is EU where even more stringent regulations just came in effect.

To make this worse, I can't even use this gift card I paid actual money for to top up this family account funds so those could be used first. It only accepts credit cards. Again, What The Actual F***, Google?

At the moment, I am almost pissed off enough to contact few certain financial agencies (note plural, not limited to local ones) to make some queries about exactly how dubious this kind of arrangement actually is...


keskiviikko 2. lokakuuta 2019

Windows 10 and mandatory Microsoft account


On trade fairs, I've used a monitor and my laptop for presentations. Usually I have somewhat related slideshow running, and when I need to present something I bring out other windows like browser.

Laptop there is not great. It has relatively small screen and takes up some space on the table, so when a new fair-like event was coming up now, I checked if I could find something better, remembering that I had somewhere seen small PCs that attach directly to back of display.

Instead of those, I found Intel Compute Stick. Not cheapest option, but since it's very small, the simple ease of plugging it in is hard to ignore so I ordered one.

Yes, I could get new Raspberry Pi and used that, but since I haven't used those that much, there would have been some learning curve involved with that option (including building it up with enclosure and everything else required) and here I was under time constraints here so this was the easier option.

This one came with Windows 10, unsurprisingly. When first starting Windows, it prompts you to create an user. It used to very heavily suggest "online" (networked, be it Outlook or Microsoft or whatever) account and make "offline" (local computer only) account creation kinda unobvious, so Microsoft very obviously wanted you to make a hard connection between your identity and the computer. This is very, very seriously something I absolutely refuse to do.

I've done Windows 10 install a few times now and it seems that in every release Microsoft has made the offline install a bit more difficult to do.

This time I almost couldn't. The option for local account creation just wasn't there. Only options presented were (IIRC) Outlook account or phone number.

After some attempts, it eventually occurred me to cut the wireless access (that was the previous step in installation, set up internet access) and tell the installer to "create new microsoft account" (or whatever it was). And what do you know, when it couldn't access the internet for that, I was finally presented the offline option. Victory was mine!

Only few days later I find this on hacker news. So many others have also run onto this issue and many - but not all, unfortunately - have found the same solution.

For now.

The unpleasant thought is, since Microsoft seems to be hell-bent to make every user to register to their services, at which point they try to make this mandatory. Not at once, of course. I imagine that there will be one feature update where windows will start presenting you with a nag screen every login or every few weeks to register if you're on offline account. But not until you're online, of course.

Then update or two later it will throw that screen on your face every few days. Then hours. Then it will just not go away until you do register.

I have to wonder what will my pain tolerance be when they do this... Fortunately at this point I have very few 'strings' holding me in Windows, so I could just make the leap and go Linux-only.

And kid will be getting PS4 (not that I'm happy with Sony's behavior either), so no xbox in our house either.

Make my day, Microsoft. Just try to make my day here. Do you really want me - and many others - to pull that proverbial trigger, especially since it's getting easier day by day to make that jump?




maanantai 23. syyskuuta 2019

Change is hard


This isn't about climate (although it's important too), but this is primarily about programming.


I've used various code editors over the years. I started programming with Turbo Pascal (TP), so its IDE was quite natural first step (I'm just ignoring anything related to BASIC before that).

Then came C, and specifically DJGPP. I think it used similar IDE - and specifically similar keyboard shortcuts - as TP so transition there was kinda easy.

A bit later I got my first actual job where Visual Studio C++ was used, and since I used it so much all the keyboard shortcuts used there became very familiar.  So, when a bit later I got C++Builder 4 for my personal use (think of Turbo Pascal for Windows (aka Delphi), but for C++), I set it to use Visual Studio emulation for keyboard.

Later I started working on my own, and since I work mainly with embedded ARM, and with limited budget, C (gcc) and makefiles were natural choice. So no IDE. But I still needed an editor.

Eventually I ended up with editor called syn. It did what I needed, and albeit a bit clunky and limited, it worked for me very well, for long time.

Until now.

Syn hadn't been updated for a while, and some things were starting to annoy me, so I started looking for modern alternatives. I am not fan of, well, massive IDEs like Eclipse so those were immediately out, I just wanted a fast (responsive) code editor.

This process took a long time, but eventually I ended up with Visual Studio Code. Out of the box, so to say, it doesn't do all things I want, but fortunately add-ons fix a lot of that. And in process, I've found several very nice features I hadn't even thought of before. I think I will be using this for a while now.

But there's few things I haven't been able to figure out. One being, how to fix include paths in C/C++ module? There are instructions I've found, but I think they are for older version of VSC as they don't work anymore. Yes yes, go to module settings, fix variable and done. But I just haven't been able to find that setting no matter how I try. Minor issue (as I use make output in shell for issues), but still kinda annoying as there's those red wavy lines everywhere.

Second being "match bracket", as in "go to matching bracket on cursor". Document says something like "shift-ctrl-/". Thanks, how about non-US keyboard layout, please? This I fortunately don't need so often, but when it's needed, it's invaluable.

Now, if only I could also include my make process there with line highlight... But let's take this one step a time...

But I guess I find solutions eventually. Change is hard. Changing code editor, especially so.


lauantai 14. syyskuuta 2019

Debugging level: psychic


Over time, I've developed a kind of unofficial policy on error reports considering our devices.

Report one of issue: "Weird." (might be user error, might case of cosmic rays, might be something else)
Report two relatively close to first: "...Okay, that's curious."
Report three: "I need to take a look."

Getting a good, detailed report also helps. You know what I mean, as opposed to "I did that and it said something and then I just pressed everything and anything and now everything is gone." (cue facepalm.)

Yes, this situation happens way too often as people react to unexpected situation by panicking, when somewhat more correct procedure would be to take a step back and consider what to do. Like picking up the phone before touching anything.

But when it comes to actual troubleshooting these cases (actual issues that is), these days it seems I do most of the most of that just by reading the most-likely-relevant code and trying to figure out what needs to happen to cause the reported issues. Not that I could do much else, when a customer calls me to inform of a very rare case of weird behavior, it usually is something I can't reproduce in my test environment, at least not easily.

Most of the time that doesn't help and I have to drop the issue. But like I've said often, the mind keeps working on these things even when they are in back of your mind. In background some processing happens, and next time when I open the editor things looks a bit different, and maybe some other location needs to be examined too. That might not be enough for breakthrough, but repeat this for a few more times and usually I can construct a theory on what could go wrong to cause observed issues and fix it.

Of course I might be wrong and it is something else. But even then, at least that single potential issue is now in order. Moving on to the next.

I think this - ability to think what is going on, as opposed to using debugger or logging - is a skill anyone one develop. I do use debuggers and logging too, but when issue isn't one that I can observe directly, those don't help. Having written all of the code, including interrupt handlers, helps as well as I know it inside out, but knowing everything is not required. What is required is knowing parts that interact, even indirectly. Reading, say, data processing code doesn't help if there is for example an interrupt handler that also touches said data elsewhere and you don't know of it.

After that, it's mostly about figuring out what could happen. This is not rocket science (well, unless it quite literally is something like rocket control module), but it takes some practice and suitably paranoid mindset to think about unexpected events you might have seen or, really, thought of.



maanantai 2. syyskuuta 2019

Project: ATV electric conversion


Few years back we got a small, cheap 50cc ATV for the kid to drive at our summer home. Originally we ordered (and paid for!) one with electric starter, but those were out and we settled to one with pull-start instead. This was cheaper so we should get refund for difference, right? Of course not, this seller (name escapes me, but IIRC from somewhere near Vaasa region) is one of those you shouldn't ever make business with. Eventually we got the refund, but only after numerous more or less thinly veiled threats of legal action. This left pretty bad taste so there's just about no way in hell we'll be doing any business with him ever again.

Cheap chinese kids' ATV. What can you expect? Well, bad quality, obviously. Entire pull-start system broke after just few total hours of use (numerous starts though, it stalls a bit too easily, especially in hands of less experienced rider) and even managed to damage the cast casing in the process.


The only way to start it now is with a drill. Mains-powered one, none of the battery drills I have have enough power for that. Considering tendency to stall easily, not exactly great option as it's a long way to push it back to the yard if it stalls somewhere far away. Note that engine is running in this picture and the "cooling fan/fly-wheel" is a exposed. Very dangerous for restless fingers... So I would have to start this up, attach some kind of cover and then hand it over.

While I might find some spare parts for this, I don't really want to. It's loud, smelly (requiring 4% two-stroke mix!), and as-is, dangerous to fingers. Yet it is fun for the kids, so I don't really want to get rid of it either.

So, why not take the two-stroke engine out and replace it with electrics? That's certainly not cheap nor easy either, but as a project and especially learning experience it might be kinda sorta worth it.

When I'm writing this it's start of September, so there are roughly month or two of "driving season" left for this thing before the winter. As my plan goes, I am planning the process and choosing and ordering suitable parts first, leaving the ATV to its current state for a while now so it can be driven yet. And when the winter rolls in I bring this to home and start the real work with it.

I've been doing some preliminary browsing, and at the moment I expect majority of the work being on metalworking side: Removing old parts (only if/when absolutely required), creating new structural assemblies for new parts and so on. I've never welded before, but I expect to learn some of that too - which actually is major motivation for this project. Work with electronics I expect to be almost trivial matter with variety of ready modules available these days.

So I will be posting some updates here as things progress. Like I said, I expect this to take better part of winter so updates may be quite infrequent. We'll see as I go.













maanantai 26. elokuuta 2019

Emissions of electric car battery


Some time ago there were huge articles about how bad electric cars actually are as battery manufacturing generates huge amount of carbon dioxide (co2). According to most extreme claims BEVs (battery electric vehicles) would always be worse than ICE (combustion engine, let's use gasoline here) powered car.

Okay, let's do some math.

Note, I write "of co2" often below, but generally it's "co2 equivalent" number that considers also other greenhouse gases like methane also.

According to a some figures, grid electricity in Finland has 0,1kg co2 production per kwh. A liter of gasoline generates total of 3,4kg of co2 (not exact figure obviously, but close enough.)

Let's say our electric car uses 15kWh/100km, and equivalent gasoline gar uses 5l/100km. Therefore we have figures of 1,5kg of co2 for BEV and 17kg of co2 for 100km.

So, the battery. I'll use my Kona as example, and apparently it uses LG Chem batteries. Quick googling finds a like to LG Chem/Ford reference that says that production of battery generates 140kg of co2 per kWh. Kona has 63kWh battery, so 8820kg total.

We'll just assume for rest of the calculation that excluding the battery, manufacturing gasoline and electric cars generates approximately same amount of co2, so we can ignore that for now.

So with some quick math with these figures we find out that approximately at 57000km the total co2 production of these cars match, and at 100000km electric car has generated 10320kg of co2 total, and gasoline car already 17000kg of co2 total.
Double the co2 of electricity (to 0,2kg / kWh), and match point moves up a bit - from 57000 to about 60000km.
Even if you were to use horribly dirty lignite, it's still better than gasoline - at around 0,41 kg co2 / kWh or 6,15kg co2 per 100km.

So, effectively, if you have to have a car, electric is pretty much always better, but obviously not having a car at all would be even better. For many that is unfortunately not an option.

May I bring your attention to another option though? Biogas (sorry, couldn't find english version of the page with quick glance). Gas (as in natural gas or biogas) vehicles aren't very common, and if you were to use natural gas (I hate that name, it makes it sound so much better for environment than it actually is) there would be little point. But if you use biogas to run this vehicle the situation is much better. And almost all cars use gasoline as backup, so you don't lose flexibility either. Too bad the gas and gasoline tanks in these vehicles seem to be quite small so often...

But wait, there is more!

According to same study I used above, manufacturing BEV (Ford Focus BEV specifically, with 24kWh battery that takes about 3360kg of co2 to produce) generates about 40% more co2 total than manufacturing a ICE car. So, working these numbers backwards tells us that manufacturing a new ICE car generates approximately 8400kg of co2 (and BEV with 24kWh battery approximately 11760kg or co2 total).

So, if you upgrade your gasoline car that used 7l/100km, to a one that uses 5l/100km, reduction of co2 produced by gasoline is 6,8kg per 100km. In order to cover even co2 produced by manufacturing this car (assuming calculated co2 above), you would have to drive some 125000km first. So if you are worried about environment, fuel economy actually doesn't do so much difference - unless there is huge improvement.

So, if manufacturing battery for electric car is bad, so is upgrading your old gasoline-powered car, especially if actual consumption figure isn't significantly better. Both cause a lot of co2 emissions.

All together I'd definitely say that upgrading to BEV (or at least PHEV) is much better option than plain gasoline car for majority of people who need a car. For huge number of people, "charging is slow" (and other similar issues) is nothing but bad excuse to not change their habits. I know, getting used to charging PHEV daily took some time, and all it takes is to plug the car in. But then, driving past gasoline station and remembering that last time I refueled was 2 months and 1500km ago and I still have half tank of gas remaining, it kinda pays off...

And maybe, if you absolutely, positively have to have gasoline powered vehicle, maybe it could be one that can use biogas as primary fuel and gasoline only as backup? Assuming, of course, that you have a refueling (regasing?) station somewhere nearby.



And obvious disclaimer: The figures used above are the ones I've been told or have found and they do vary from region to region, and with seasons as well.






perjantai 16. elokuuta 2019

A happy call


Am I bragging? Maybe just a little bit.

A customer called me today. He had a problem with WiFi connection from our device - specifically that it keeps dropping out and needs to be manually reset constantly.

Unfortunately I was away from office and could not check what is going on (from server logs), nor could I give him any suggestions other than try with another access point as he was using hotspot from phone which are notoriously unreliable for any extended use.

And he was happy about this!

See, he also has devices from other vendor (who are far more expensive than we are and have much larger staff) devices in other cars, and apparently this wifi issue is nothing compared to all kinds of problems he has with those devices. And to add insult to the injury, this vendor has Very Expensive help desk phone that they don't even answer to. So, in effect, nothing works, no one will even answer the (Ridiculously Expensive) phone when they try call for help, and there is no other way to contact them either (this all according to him and several other people who are in the same situation, I obviously can't know any of this first hand.)

Sometimes it feels like my devices have serious issues here and there. But calls like this, every now and then, make me feel really good. I actually appear to be providing good service after all.


And I repeat: Information about the vendor mentioned above is all hear-say, as told me by other people. I have no way of knowing how much of that is really true. Still, when you hear same things told by many different people, over longer period of time...




lauantai 20. heinäkuuta 2019

JBC vs FixPoint solder station


I've used JBC's soldering/rework station for some 10 years now, and despite price (IIRC close to 2400€ for solder/desolder station I have) it has been a very good investment. Nice to work with, easily changed tips for different needs and so on. It is not easily movable, though, since it has separate control units and holders, so recently I went and bought cheap-ish soldering station for "field" use for whopping 95€, VAT included.

There are cheaper irons available too, but like I've said so many times - never take the cheapest one, go one price group up and choose from there. Cheapest ones are always pure crap.

First impression is not great, but not horrible either. It's plastic-y, but feels solid enough so there should not be need for padded bag for it. Although I wouldn't throw it in my toolbag like a wrench either.

Name on label is fixPOINT EP-5, although I am almost certain that this very same station is sold under several names elsewhere. Display isn't as bad it seems on picture, but not great either. Since by JBC was set to 350C, it set this to same temperature too.

I turned both stations on at same time, and after just several seconds JBC was already up to correct temperature. Fixpoint however took easily minute or two to get to requested temperature - or, at least reported temperature.


For reference, here is JBC holder (control unit itself not shown). Width is about third of Fixpoint, but iron tips makes it much higher. Tip can be changed by pulling old out (see empty slot on bottom left) and pushing new tip in, without using other hand to hold tip at any point. Great when you suddenly find yourself needing other tip for larger or finer work.


In my work, I find that it is best if you can hold the iron as close as possible of the tip, and JBC (on top, obviously) is absolute winner here. The green holder is thin (just 12mm in total width), so it can be held like pen and distance between tip and holder is less than 60mm, allowing you to have very nice, fine control there. And although holder is very thin, I find that only after very long period of working (4+ hours of continuous building a prototype/test board) it gets a bit warm - but even then, not excessively so. For shorter rework times you don't even notice the heat.

fixPoint on the other hand... Well, let's just to say that I don't even bother trying to do anything fine with this. It is long and clumsy. Definitely not recommended for fine reworking. But that's okay for me, this time; I bought this for crude-ish field use exclusively. That's why there's solder wire wrapped around the handle; it's best place to hold it when hauling this around.

I wouldn't want to change fixPoint tip when working either, as it requires unscrewing the metal part completely and changing tip part. And since cooling/heating it takes a long time, you'll be waiting for long time to be able to do it.


I don't have suitable thermometer for measuring actual heat of tips, so Flir thermal camera will have to do as substitute. Emissivity is very likely far off (metal parts are shiny/reflective so camera can't measure them properly). Note also "multispectral" ghost images below; when taking images from very close range, images don't overlay properly.
As reported, Flir apparently can't reach these temperatures (showing just ">280" for JBC), but assuming that JBC is approximately correct, the fixpoint is... not even close. Both irons were set to 350, both showed 350, but fixPoint here seems to be significantly cooler. Hot enough for leaded soldering, but I think I wouldn't want to try lead-free with it.

But again, FLIR isn't greatest tool when trying to measure temperatures of relatively shiny metal objects.


So, I wouldn't recommend fixPoint for general work, but if you need iron only occasionally and just for small fixes with larger-scale work (no tiny SMDs), it might be okay. You get what you pay for.






perjantai 12. heinäkuuta 2019

USB type C


When I was designing newest board layout, around two years ago, I briefly thought about using USB C-type connector in it. Device itself doesn't use any new USB-C related features, but new connector at least would get rid of "which way up" problem of microB.

After some reading and pondering, I found few schematics showing how to wire USB C to backwards compatibility mode, but even these were somewhat complex and with some gotchas that might have needed changed if I were to run onto them. So I abandoned the idea and used plain old micro B connector instead.

Just now we're hearing that Raspberry Pi 4 boards have problems due to new C-type connector, as they have wired CC pins incorrectly which makes board to not work with some (more expensive) cables due to power negotiating failure.

Eben Upton, co-founder of Raspberry, says; "A smart charger with an e-marked cable will incorrectly identify the Raspberry Pi 4 as an audio adapter accessory and refuse to provide power."

That made me smile - just a bit. Note subtle blame-shifting there? No, it's not charger does identifies Pi4 incorrectly; it's Pi4 that identifies itself as audio accessory by shorting those two pins, and charger quite correctly reacts to this by not providing power to it.

Either way, I think I'll stay away from type C for a bit longer, even if the connector itself is quite nice. There's just a few too many traps there yet.

maanantai 8. heinäkuuta 2019

Meat substitutes


Note; this post was written almost immediately after mentioned IPO and has been sitting in my queue for a while now; I haven't tracked how the stock has performed since.

'Beyond Burger' went public some time ago. If I could easily invest in it, I might actually have throw few grand that way during IPO. Unfortunately I'm a bit (read: very) lazy and couldn't be bothered in finding out how to invest directly across the pond, so I guess I will go for other investment options nearer to me.

There is also another reason why I might just skip this company.

If you haven't heard of this company I don't blame you. They are primarily developing a fully plant-based hamburger "meat", which, if it were to replace real beef, would reduce carbon dioxide output a lot. As far as I know (again: lazy, this time in research front) they are aiming for full replacement. Look, taste, texture and so on. And then other similar replacements too, I think.

At this point I have to stop to ponder this goal. Why go that way?

In western world we have really one-sided view on diets, and these days meat in some form is included in almost every meal. If you look for even vegetarian (not even mentioning vegan) option, you very likely will get something bland, tasteless and possibly even gross to eat. There are exceptions, and situation definitely is getting better, but for the most part this still is too true. If (when) this is your experience on vegetarian options, beef replacement sounds pretty damn good.

On the other hand, people in India on the other hand make absolutely wonderful vegetarian and fully vegan foods. Unfortunately my skill isn't there to replicate them well enough so that is a bit difficult route. If you have tried (and liked, like I do) these, there might not be need for beef replacement.

Back to burgers. I might be an exception, but I don't particularly even like usual beef burgers. To me they're ... bland. Common burger is almost tasteless, to the point that you need to drench them in condiments before it can be eaten (before you protest, have you eaten and liked a burger without ketchup/mustard/mayo?)

Again, I might be exception, but most of the time however I don't really even want a "meat substitute" anyway - especially for a burger - but to replace that protein with something else. Often this implies beans, peas and/or lentils.

Some time ago I found a chickpea-feta recipe that is great replacement for burger patties. It does not taste the same as beef but like I said, I've never been really a fan of beef burger anyway. So this recipe was great, and better yet, tastes good even as-is - although I replaced feta with different type of cheese as others in family are not exactly fond of (strong taste of) feta.

In general I've followed this same path when reducing meat usage. Most of the time simply replacing meat with something and expecting it to taste same is nothing but route to major disappointment. It's almost always better to alter recipe more to suit taste of chosen meat replacement than to expect it to be good with just the replacement. I realize that this is not easy and requires some experimentation and ability to figure out spices or other changes you need to make recipe work. Then again, good things rarely are easy, and cooking isn't an innate gift - it's something everyone can learn. I've practiced for two decades now and still rate myself a passable cook at best.

And this is the reason why I am a bit skeptical with meat replacements. They won't taste the same anyway, so why really bother, when it's usually easier - and cheaper - to adapt the dish itself to suit new ingredients. Last I heard, mentioned beyond burgers aren't exactly cheap.

All that being said, there is one dish I still make with meat as I haven't found even closely suitable replacement for meat in it: chili. But since I make it about once a month or so, for now I allow myself to indulge in it. It's still better to make good effort on the other days and allow that once in a while than to fail there and fall directly back to old habits.


tiistai 2. heinäkuuta 2019

USB scanner


Ages ago I got a Canon FB630U USB scanner. I'm not exactly sure when, exactly, this was, but I'd guess this was around turn of the millennium. It's hasn't been up to current standards for a long time now, but it is still functional. At least I think it is, haven't used it over 10 years now, and it has been just sitting in storage.

So, what's inside?

For once, it's (kinda) easy to see; it's all visible by simply opening the lid!


At right is the control board (okay, hidden underneath that metal), on left scanner head and guide/drive system and... Well, there's nothing else, really.


Scanner head moves across the scan area, guided by metal bar (on left) and moved with chain pulley system driven by a small stepper motor. Here drive mechanism is upside down, usually it's hidden underneath scanner head assembly. Motor was already taken out in this picture as it could prove useful yet.

I am no mechanical designer but the drive system seems pretty robust, with minimal change of slippage or other such failures.



The scan head itself is single row, with light bar and dot scanner built in single, tightly integrated unit.On left here is light source (two leds, it seems; on mechanics assembly there is light bar to distribute light evenly), and on bottom first few scanner units can barely be seen. On top of that was focusing array, essentially large number of short (approx 5mm) light tubes, there to improve pixel resolution.

I don't have equipment for taking pictures with large magnification so this, unfortunately, will have to do.  I am not familiar on how exactly this works, but it would appear to be some kind of serially-driven array, as there is only 7 signals (light not included) going to main PCB. Based on PCB it is some kind of three-color CCD row array.



From date codes on PCB I'd expect this to be designed in 1999, and very likely I got this early 2000 or 2001.

Botton left is USB connector, then power filtering and regulation (done with classic 34063 buck converter). Components that are underneath scanning head need to be very low, so capacitor have been angled to 90 degrees, placed in slots on board.

GLUSB97SC08 appears to be USB to IEEE 1284 (parallel printer) converter. If I remember correctly, this scanner was also available as parallel printer port version, so they took that designed and shoved USB converter in there. This was around the time when Windows 2000 and then XP took away applications' ability to access printer port directly so USB was a bit of forced update there.

On top is IS51C1024, SRAM memory chip, and below it LM9830VJD, a built-for-purpose flatbed scanner controller with illumination, motor control and CCD reading all included in single package. I almost feel betrayed here as I was expecting more discrete approach, but guess even then these were already built to bring the price down.

All in all, this is neatly done design, but in case of Canon, I wouldn't expect anything else.



keskiviikko 26. kesäkuuta 2019

Inside another DVR


Our older top-set box/DVR unit was replaced actually long time ago now and this old unit has been sitting on my desk for a while now. Although I expected it to be as boring insides as previous one I opened, I decided to see what's inside it too.

And surprise surprise, it is as boring as I expected.


On top are rear connectors, from left to right power (black one), ethernet/USB, scart, HDMI, audio out, SPDIF and TV antenna in/out.

Under the heat sink is processor. I didn't feel like taking heat sink out; underneath there's very likely another MediaTek all-in-one media processor. And supporting chips around the board.

Curiously board has been divided to squared in silk screen print; from this view it's bit difficult to see but it's there, labeled A-D on vertical and 1-6 on horizontal. At least A and B can be seen at the right edge of the board. My guess is that this is for rework for (machine) visual inspection; "component 6042 missing at B2" or some such. Not something you see often.

Power button, led, front USB and IR reception are on smaller daughter board at the bottom, sitting above main board in a slight angle. I just wonder why they decided to use two cables to connect it to main board, instead of just one a bit wider flex, as other cable adds a bit to BOM price.

But on that daughter board is the most interesting part of this device; CC2533, which is Zigbee RF one-chip remove control solution. Not used, unfortunately, the remote that came with this is usual IR based one.

And nothing much more. Ah well, to trash - well, recycling - this goes.


sunnuntai 23. kesäkuuta 2019

Sold my bike


Herein you will find nothing but some personal nostalgia.

I got my motorbike driving license early 2000s, and since then I've always had a bike. First Suzuki gs500, but it was a bit light for longer two-person trips so I upgraded to Kawasaki ZR-7s in 2005 (2003 model). That bike was great. Simple, nimble and generally fun to drive. And it also looked nice. I've had it ever since.

During few last 5 years or so I really haven't had time to drive it though. I managed to drive only handful of times, for some 200km per year total, which, considering insurances and everything makes it pretty expensive fun. But fun nevertheless. When not riding I look at it and though how useless that bike was and how I should get rid of it. And when riding, I again remembered how much I like to ride, how much fun it is, pushing that uselessness feeling back. I wanted to keep it.

And now I sold it. I wasn't planning to, but I put it in internet sales forum - mostly as an experiment really - and eventually one guy came and bought it straight away.

When he drove away with it, I took a deep breath and swallowed the feeling of loss. I've always had a motorbike (for certain definitions of "always")

Now I suddenly don't have one. And I'm not planning to get one, either; I really can't justify the expense with the extremely low mileage I've put in it lately.

It's weird feeling. Hollow, like a part of me is missing.

       Norway, 2006. Side bag removed as camera was in there.

At the moment I'm moving on to electrified traffic; I've got a full EV and a PHEV cars. If (when) I get a bike, it will be electric too. It may take a few years. But I've got a feeling I will get a new one. Sooner or later. They just are too fun.

At the moment there really isn't many electric bikes available (for practical and safety reasons moped class vehicles limited to 45km/h are out), so that might be later.

I'll wait.


perjantai 14. kesäkuuta 2019

Work to die.


Tech sector has been for ages had an obsession for long work days, at least from 80s when personal computing started to take off - it was passion for the tech. Love the job you do and you'll never work a day in your life, right? And that has been a thing ever since. Love the work and work long hours. But it's not just that, not anymore. Passion argument has been taken over and now everyone should - must - have it. And everyone must work long days. Not too long ago Jack Ma praised his underlings' for working very hard, with so called 996 schedule - 12 hours a day (9 to 9), 6 days a week - but bringing on some hard criticism towards the practice.

Long time ago I found out that even typical 8 hours a day for 5 days a week isn't fully productive on creative side of things, and I do believe this applies to repetitive work (like assembly and other such production) as well. On a good day I can do maybe six hours (minus breaks) of creative work, after which my mind seriously needs some recharging time. Sometimes productive time is even less. After that all that happens is just sitting there, staring the screen without getting anything worthwhile done. Fortunately I at least can just get out and go home, instead of being forced to waste both my and company time by pretending to actually do something.

Really, anyone who has done this kind of work who is also not lying to themselves (and others) knows this perfectly well, yet for some reason so many are still willing to "work" insane hours for oftentimes no rewards at all (no overtime pay). These days corporate doesn't even reward this - people are just replaceable cogs in machine that are to be thrown out when they inevitable burn out and break. Only thing this does is to make long work hours without pay a norm and thus not playing the long work hour game becomes a punishable offense. And a new, fresh (and cheaper) cog is brought in to replace that now worthless (to them) cog.

Fortunately I don't have to play that game. In Europe (generally speaking) situation is much, much better so not paying overtime is much harder for corporations to get away with (yet it still happens), and since I own my own business, I can set my own work hours. And I do.

I still do occasionally work for longer days too, of course, but only rarely and then it is to get one single critical thing done, and in general I have set myself a strict 8-16 schedule in office, and work is left in the office at the end of the day, allowing me to relax properly before the next day. Without this I very quickly find myself in highly strung, anxious and even angry state, with blood pressure being through the roof.

Even if I do directly benefit from the work I do over time, it still isn't reason to kill myself by overworking myself right now. Especially when I know I would not be productive working long hours anyway.

And you really should admit this to yourself too. Playing stupid games gets only stupid rewards, and risking ones health for essentially no benefit is one of the stupidest rewards I can think of.





torstai 6. kesäkuuta 2019

What we leave behind

Warning: Although I have tried to avoid preaching tones here, some may be involved.


There is absolutely no doubt that humanity is the reason for massive carbon dioxide increase over last hundred years or so. There also is absolutely no doubt that if this process keeps going, co2 levels will keep going up fast, and the end results will be ugly. It has also come in to light that these issues were already well known by oil and coal companies in 80s; the internal memos from that period that have leaked have climate change predictions that closely match the scientific predictions of today.

Something needs to be done. 

Sometimes other issues we successfully managed are brought up as counterexamples to make this issue sound less severe. Ozone layer? We took action and solved it. Acid rains? Likewise.

Issues mentioned above were "fast". They appeared relatively quickly and when corrective actions were taken, situation was observed to improve (relatively) quickly and within decades, they are effectively gone. And worse, mostly forgotten.

Co2 is different as huge amounts of it are needed to have an effect, and equally huge amounts of it have to be removed from circulation again to undo said effects. Currently we're releasing around 36 gigatonnes - that is 36 billion tonnes - of co2 per year, a figure so huge that you really can't even grasp it - and even with that amount the change from year to year is nearly inobservable. Compound that over tens of years and the total amount grows even more incomprehensibly large, but compounding effects start to be visible for all.

Only now we're starting to feel its effects, but still in relatively insignificant way. Few more floods here, some unseasonal cat 5 storms there, drought elsewhere... All still almost normal, although now there's a bit more of them, a bit more often than before. Outside normal, but just barely.

If we stopped all co2 emissions right now, the effects of all co2 emissions so far would still accumulate over next decades, if not centuries, and disasters mentioned above will still get even worse for a while until nature finds new balance.

A paraphrased quote from Sahara (by Clive Cussler) somehow has branded itself in my memory:
"Let's say that this algae growth doubles in size every week. Let's also say that it will take a year - 52 weeks - until it has filled every ocean and killed everything in them.
"Governments will not take action until seas are already half full. How much time it leaves for us?
"One. Week."
This of course is gross simplification of the idea, but the general trend is still there, and not just among the governments - all humans share this behavior, more or less. We tend to not take action until issue gets really bad. I know I am guilty of this too. Climate change so far isn't even close of being bad enough to make us react. But the problem is that if we wait until it gets bad, we don't have even that "week" to fix the situation (quotes because I'm speaking proverbially here, referring to that quote above). By that point we are "months" past the one year marker.

We do absolutely have to react now. And fortunately many people are waking up, but there is huge amount of resistance to change. I know, and I can't fully blame most of those who are resisting as the things we need to, have to do are - and will be - painful and difficult.

And now we enter the next issue. Many people are effectively saying "why should I do anything, as those people are emitting more co2 than us?" Or even worse "why should I have to do anything, I will be dead by then!"  Especially the selfishness of the latter towards their own children and grandchildren is absolutely disgusting.

But all those are exactly wrong questions or arguments. The correct question is "why should I be able to do nothing to fix the situation?"  Everyone must start to do what they can.

There is also "we will adapt so this is no problem" argument. This is a more dangerous, as it sounds plausible and might even be true in the long run, but problem here is that this is the same "I will be dead by then" argument, just veiled better in good sounding argument. "Our children will clean up the mess we've made." Of course they will deal with it somehow, as they have been left with no other option. 36 billion tons of co2 a year. While it is possible that someone makes absolutely wonderful new invention that can remove massive amounts of co2 from air with low enough energy usage to make it actually feasible, it's irresponsible to count on that. And while nothing is done, the world will drown in wars and unrest caused by mass migrations caused by increasingly worse floods, droughts, famines and other catastrophes caused by slow and gradual climate change.

That is not the future I want my children and grandchildren to live through.

Drive less. Fly less. Eat less meat, and instead of beef, have pork or chicken more often. Buy less stuff and use older things longer.

Note that at no point I am saying to stop doing these things, as that will be difficult or even impossibly for many. Just do less of them. And while at it, start requiring for industries to do their part too. Voting with your wallet is always an option there. Single individual's effect is small, but it is still there. With enough individuals change will happen.

Also, do support replacing all coal and as much as oil/gas (or fossil fuels in general) energy production with nuclear. While renewables, especially wind and solar are great, they're horribly intermittent (no sun at night) or variable (wind can drop from 100% to 5% over few hours), so without sufficiently massive energy storage options (and again, numbers involved are so massive that you can't even comprehend them) they are quite simple useless. We do not have time to wait that technology to mature, we need action now.

Nuclear has bad reputation, but even if you count two worst accidents there have been, Chernobyl and Fukushima, we're still talking about thousands of deaths. If we let climate change progress much further, thousands of deaths are something we can only dream of. That death toll will be measured in millions if we let the situation escalate.
Currently nuclear is slow and expensive to build, but if we could, say, standardize for example two to four standard designs, all fully and thoroughly inspected and reviewed, with power output of, say, 100-500MW per plant, it suddenly would get much easier and quicker to build nuclear power plants (with obvious requirement of very strict periodic inspections of every factor of operations of every single plant). This would be exactly what we need to get rid of carbon power with accelerated schedule.

Changing individual habits is always hard, so start easy. About two years ago I decided to reduce the amount of meat I eat, primarily for health reasons but climate was a (smalller) factor in that decision too. I started easy, replace a meal once in a while with plant-based one. It was difficult at first, but got easier, and not long ago now I suddenly realized that we hadn't eaten any meat for several weeks and I hadn't even noticed. Difficult things start that way but they also get easier as time passes.

Every gram of co2 not released counts towards better future, and many people doing small things have significant effect in the long run.

"World grows better when men plant trees in whose shade they know they shall never sit."

Maybe ancient proverb, maybe not. Does not matter; either way, it is still very true. Especially now. Also, do plant non-proverbial trees. More than one. It will also help.


perjantai 31. toukokuuta 2019

Bad air


At some point I noticed that my office air was getting bad, especially in late afternoon. As this building is somewhat old, and doesn't have good air exchange now that old fireplace isn't used anymore this wasn't very surprising. How bad it was though was a bit more unknown.

I managed to get my hands on a carbon dioxide sensor for some time and was surprised to see co2 levels reaching nearly 2000 ppm during afternoons. No wonder I was getting really tired towards end of days. So I got some improvements made (added intake vents, and wind-powered vacuum at top of old chimney) to improve situation. After this I did notice improvement, but at that time didn't have tools to find out how much the situation really improved.

This was close to a year ago. Out of curiosity I now got a few sensors that should be able to determine this. Specifically, Sensiron SCD30 carbon dioxide sensor and SGX Sensortech MiCS-VZ-89TE air quality sensor.

MiCS measures VOC levels (Volatile Organic Compounds, measured in ppb or parts per billion) by using semiconductor sensor. Datasheet doesn't exactly tell how that is done, but in many similar sensors (as far as I know) this involves hot plate (very tiny one, but nevertheless) on which chemicals and compounds react and change the resistance of this plate which in turn can be measured. This technology isn't very specific, but to put it bluntly, is is still useful to detect many kinds of, well, volatile compounds (most, if not all of which can be considered to be less than healthy to breath in.)  Although datasheet mentions co2, it doesn't really directly measure it and instead gives "co2 equivalent" reading mostly based on VOC reading. Many times these correlate, but not always. But even then, the good side is that these sensors give out a relative reading of air quality and are relatively cheap to be embedded in many consumer-level goods. Think of your phone signalling you that "yeah, you might want to get out of here" when you enter area with less than great air. That at least is target for many of these sensors.

SCD30 on the other hand uses nondispersive infrared sensor (NDIR) to measure actual carbon dioxide level in air, and pretty much nothing else (although I guess some gases/chemicals with similar absorption characteristics as co2 might somewhat affect the reading.)  So this doesn't detect nasty solvents, cigarette smoke or other such things that might be in air. These sensors tend to be a bit more expensive too so they're not that often seen in consumer equipment.

I left these sensors running for some time, below being graph from one day period (noon-ish to noon-ish next day). Sensors actually had been running much longer at this point but I managed to screw up logging (several times, actually) so previous data was lost. Ah well.


Here the co2 level measured by SCD30  is on blue. The level drops when I leave office, eventually falling to current outside air levels (400ppm), and on next day starts to rise immediately when I come in, despite improved air circulation. At least it no longer gets anywhere close to previous 2000ppm levels, instead maxing out at 1200ppm. Not great, but much better than previously.

Red graph shows "equivalent co2" as measured by MiCS. At start of graph it follows SCD30 results relatively closely (not bad!), but veers wildly off at start of next day for some reason. Huge spike you can see in that and VOC reading are because I put small amount of denatured alcohol on tissue and left it near the sensor, to which it reacted immediately. Note that actual (blue) co2 levels weren't changed; only now there was volatile compounds in air that this sensor detected, resulting severe degradation in reported air quality.

I now hope I didn't damage the sensor by leaving alcohol too close to it. Hot plate sensors shouldn't be that sensitive (we're talking about table spoon's worth of alcohol total here) but who knows how this one reacts. Its behavior at end of graph doesn't look too good though. I need to follow its behavior some more to see how it behaves now.



torstai 23. toukokuuta 2019

A part of Finnish history


Recently a map where cities of more than 500 people were placed on world map. Terminology aside, I was of course first checking out how Finland looks on this map.

Entire map here

And here is cropped Finland where I very very quickly copy pasted rough current country borders on top of it. Borders are skewed, badly placed and very likely of incorrect size but they are close enough to illustrate my point:

I noticed that for some reason, there is interesting clear divide inside the country, southwestern part of having cities (towns, whatever term you prefer) quite densely, and northeastern part of being very sparse. Hmm. Curious, wonder if there is an historical reason..

Although I was almost certain already, I did quick googling found this article, listing historical borders of Finland. Historically (granted, part of following is my opinion) Finland has been either wild frontier, part of Sweden on west or Novgorod (later Russia) on east, often having been divided up by these two powers. Frontier part being areas, inside or outside these countries allocated borders where their respective governments couldn't or wouldn't reach. Although due to climate, this frontier never was anything like later western frontier of USA, more like wilderness where people could just vanish to live their own life without having to bother with tax collectors, army recruiters and other nuisances of foreign government.

But I digress here. As I remembered, the density border I imagined in above picture matches very closely border agreed by Sweden and Novgorod in 1323, 'Pähkinäsaaren rauha' (as it is known in Finland, Treaty of Nöteborg more internationally). This border stayed in place for next centuries, and changed next time only in 1595 and then 1617.

While I am not familiar on how Sweden and Russia treated this land over this time, I can, based on above map make a guess where Sweden encouraged people moving out and forming communities, while Novgorod .. didn't, and as a result of this one historical border, the entire northeastern part of Finland still remains mostly empty land.

Maybe pointless, but I found this interesting nevertheless.


maanantai 6. toukokuuta 2019

Car charger (bigger one)


If you are planning on owning an PHEV (plug-in hybrid electric vehicle) or full EV (electric vehicle), you would be absolutely insane to even think of using public charger network, as they're very expensive compared to electricity price you're normally paying. This with some notable exceptions,like Teslas with free supercharger usage.

This is with mainly Finnish focus, but might apply elsewhere too. The electric grid is primarily 3-phase, nominal 230v. Typically normal single-family home receives all three phases, each phase with single "top-level" fuse, typically 25 amps, and within the home all three phases are distributed in a way that this current is not exceeded in any single phase. So for example washing machine and drier, each that can use 16 amps, are placed in different phases.

At home you wouldn't likely be using high-power charger, but instead 2.2 (10-amp) or 3.6kW (16-amp) charger. But there's a problem there: you don't want to overload the main fuses with new high load, so careful planning will be needed.

You can of course switch to larger main fuses (like 3x32A or even higher), but that will increase the electric bill even if you don't use the increased capacity so you don't typically want to go there.

In my case I wanted to install 3.6kW charger, so I had to calculate very carefully how the current wiring in the house goes and what is the expected maximum load of each phase. Fortunately fuse box is very well marked, so it was easy to calculate loads involved in each phase.

As it turned out, stove, sauna and washing/drying machines were the main loads. Phases 2 and 3 were essentially topped out (couldn't use drier when charging the car - not great), but with some care phase 1 could be utilized without too much worry of an overload - especially if charging is timed to happen mostly at nights when other usage is low, so when we got charger installed, I timed car to charge only between 22-07 hours.

Figuring these things out is a bit of an headache, but needs to be done to get things working. And at this point I'm just too fond of electric driving, I wouldn't want to go back to archaic combustion engines.



perjantai 26. huhtikuuta 2019

Car charger


Some companies have been distributing these simple car power adapters - takes 12v in from car cigarette lighter and puts out 5v at whatever current. As they're often freely available at trade fairs, I've ended up with few.

Currently I have a specific one at hand, which appears to be distributed by a norwegian company, and promises 5v @ 700mA. And of course it, after some time of use, doesn't work anymore. Not too surprising, really, I expect these things to be really cheaply made.

After opening it up, I found pretty much what I expected. Simple buck converter, using a chip labeled AD85063. Well, at least this one is kinda honest - this chip is rated max 700mA. There appears to be quite a few of similar adapters that promise something like 2 amps, using this same chip.

The bad part; there appears to be no real protection on the chip, and no real current limit anywhere on the circuit. USB data pins are shorted, so devices can pull high currents, damaging the chip in process. And, apparently, based on few posts I've found, the failure mode of this chip isn't very pretty - it'll short the input to the output after which there's plenty of +12v coming in the USB. This can happen with buck converter if chopper transistor shorts out, which seems to be all too common failure mode. Hope the protections in phone are up to their job.

Now, I have few of similar converters around here, looking almost same but this one is with 2 ports and higher output current rating (total over 3 amps). Now I'm kinda curious to open it and see what's inside...




sunnuntai 21. huhtikuuta 2019

Certificate of Authentic Windows


Some time, around mid '00s I was assigned to handle licensing of Windows operating system for embedded devices manufactured by a company, as the person who previously handled this had left the company. The paperwork wasn't too bad (which was kinda surprising) and licensing conditions weren't too bad to read either - maybe around 10-16 pages (I don't remember exactly), and not written in too bad legalese. In other words, much easier read than common EULAs (End User License Agreement) even then - and I'd guess EULAs have gotten worse over time.

Obviously I read it through like the proverbial devil reads equally proverbial bible. There were few things that needed a bit more attention and clarifications but in general it was all well. All conditions were met so we could just install the OS, attach Certificate of Authenticity (CoA) to device and it's done. It was also very explicitly said in that agreement that 'CoA' means the license number sticker. Essentially same small holographic sticker with 25-character license code just about every windows computer has.
  
CoA is supposed to be the final authority on whether computer has valid windows license or not. As a home user one might not care too much, but I've heard stories where BSA (Business Software Alliance, who are essentially hired goons of major software publishers. Legal goons, although I am tempted to say that they are just barely on that side of the line.) has refused to accept these stickers as proof that business' Windows installation is legal - that is, Authentic. Despite Microsoft's own licensing terms saying exactly opposite here.

Granted, I have only dealt with embedded licensing, and only relatively briefly, so things might have changed before I took that job and likely also after I left. License types might be different too. But situation where license provided says that CoA is just that - Certificate of Authenticity - and hired goons can just say that it's not - well, I can't but feel a bit uncomfortable here. Although my neck is at the moment quite safely out from that noose.



lauantai 13. huhtikuuta 2019

PHEV vs EV

 
As previously mentioned, I got PHEV Mitsubishi Outlander last year. It has 12kWh battery and best I've gotten out of it is around 40 km, 35 being more typical, even in optimal weather. So let's say 40km to be optimistic, which puts its consumption to around 0.3 kWh/km range. And this is in summer - in winter the figure is much worse, down to 20km (0.6 kWh/km!) with heating on, or even full zero km when it's cold enough (around -25 degrees C, if I remember correctly - at that point it just doesn't use the battery any more.)  Effectively, to get anywhere with electric power, it has to be charged every night.

Not great figures, those. Not at all. So I was somewhat doubtful with full EVs. As it turns out, if you do things right, the figures are completely different.

I got Hyundai Kona Electric just few weeks ago now, and so far I've put around 800km to it (including one 300km one-day business trip, with no charging on the way). At the moment it's still early spring, so temperature hovers around 0 degrees C now, so best figure I've gotten out of this car is about 380km. The car has 64kWh battery, so this works out to about 0.16 kWh/km figure. Almost half of the Outlander's figure! And this is with heating and everything running.

And just to clarify this, right now (temperature being around 0 C) the reported range of each car, with full battery, is as follows:
RangeConsumption
Outlander, heating on25 km0.480 kWh/km
Outlander, heating off38 km0.315 kWh/km
Kona, heating on380 km0.168 kWh/km
Kona, heating off400 km0.160 kWh/km

Aerodynamics certainly has some effect on these figures, although I can't say how big the effect is. Weigh shouldn't make that much difference, as they're near enough (around 1700kg for Kona vs 1800kg, if I remember right - battery in Kona is heavy.)  4-wheel drive of Outlander might have some effect too.

I guess the most surprising part with Kona is that the heating has so little effect to range. It apparently has system (heat pump?) that can use the waste heat from power electronics to heat the cabin, which is pretty nice in cold climates. How well it works when it's really cold is a question that has to wait until next winter though.

The primary difference, as far as I can see, is that Outlander is designed as gasoline-powered car first, and PHEV part is almost an afterthought, and thus there are too many compromises in design, each nibbling a bit away from the efficiency of the whole system, and end result is disappointingly mediocre. It's not horribly bad, but when comparing these two, the inefficiency is obvious. I can't help but wonder how the system would work if it were designed as electric first, but just with small battery and small gasoline engine put in some corner to function purely as a generator when needed.
Not to say that Kona is designed as electric first (as there are gasoline powered Konas available), but I am certain that requirements of EV have played significant role in design.

There's also battery life I'm kinda concerned about. With my current driving, I charge Kona once a week, or once in two weeks. Hyundai gives pretty amazing battery warranty of 8 years (or 200 000 km), and unless something goes horribly wrong, so I don't see issues there. Except possibly long wait for battery replacement, if things are as I fear they are.
Outlander, however, needs to be charged daily. As battery life typically is primarily set by charge cycles, this daily charging requirements is kinda bothering me. And of course Mitsubishi doesn't have as generous warranty as Hyundai either.

Now, a question many might ask: How does the Kona EV work as a car?

In short, I like it. Long range makes it perfectly fine for normal weekday driving, and since I find that I only need to charge it on weekends, longer charging period isn't really an issue either. My main gripe is that it's small. There's no way we could go for a weekend trip as whole family, dogs and all, without having some serious space issues (roof rack excluded; I don't like them, but I might have to reconsider). But if I go to business trip alone, or with just one or two persons with me, it would easily carry me, although longer recharge times between 300-400km of driving will change pacing of such trips in future.

So for now, when packing heavy, Outlander is the car of choice, simply due to its size. But I will be seriously considering switching immediately when similarly-sized all-electric vehicles become available - at reasonable price, of course.



lauantai 30. maaliskuuta 2019

Updating device remotely

Let's say you have a small-ish embedded device that communicates with remote server via network connection. It would be nice to update its software remotely, but since it is, well, remote, you generally want that the such updates are as fool-proof as possible. As in, no change (or very marginal one) of bricking the device.

This obviously means that the updates can't be done over active connection. Any issue with said connection might cause your update to be interrupted, causing it to fail and leaving system in unpredictable and likely corrupt state.
Solution for this is to load the software fully to local storage and to verify it against known checksums before starting the update, to make sure that everything is received properly.

Also, you generally do not want to software to perform full self-updates. If software is one monolithic block, any failure during update will easily leave it in corrupt state.
For this, the software must actually be in two parts; first is the bootloader, which in perfect world is immutable and never touched outside device production. And the second part is the main application software that can do everything but to actually perform the update (including downloading and initial verification of it).

The update process, then, is something like this:
  • Main application contacts server and receives a notification of update
  • Main application downloads update to local, nonvolatile storage reserved specifically for updates.
  • Main application verifies that the update is valid, uncorrupt and optionally properly authenticated
  • Main application sets nonvolatile system state to "perform update" mode, and starts system again
  • Bootloader, on startup, checks system state and notices that update should be done, causing it to branch to update, instead of starting main application as would be normal operation
  • Optionally bootloader verifies the update data again, to make sure everything is proper
  • Bootloader then loads update data from nonvolatile memory and replaces main application data with the updated version. 
  • If this process is interrupted (power loss for example), system is still in update mode and can resume update.
  • After update is done, bootloader verifies it once again, and when satisfied that everything is correct, updates system state to normal operating mode and starts main application.
Depending on how far you want to go to make sure everything keeps rolling no matter what, there may also be two copies of software, so you can go back to old version in case new version somehow doesn't work. There is also possibility of encrypting the software when it is in transit, so that only the bootloader can decrypt it during update, to retain secrecy of your code.

Now, if you ever wanted to update the bootloader... Well, it can be done with this setup, too, but generally you don't want to do that, as failure there may be unrecoverable, or at best, difficult to recover from. Generally speaking, though, you want to avoid this as much as possible.

You may notice that I haven't written a word on how to actually implement this stuff. That's right. Every single system is slightly different here, so there isn't single solution for this, and without knowing your exact setup I can't really give any ideas. Other than ones provided above.