Random thoughts about software, hardware and electronics. And other things too...
maanantai 25. joulukuuta 2017
Power supply #2
I've had this lab power supply for close to ten years now. It was pretty cheap, with pretty typical specs (3 outputs, 1 with fixed 5v output, two adjustable 0-30v and 0-3A), and it wasn't used much. Lately it started to annoyingly click its relays when nothing was going on (supply was good all the time), so I moved it to aside and got another cheap one, with similar specs. After all, this was not used much so why spend too much...
Then that one broke too (not long after warranty period. Figures...) Now it shows maximum current all the time and limits voltage accordingly. So it's useless. And I found out that no, that power supply was actually used a lot. All the time, actually, but since things I used it for were simple and brief - testing small things and what not - those didn't feel much. Until I didn't have that supply any more.
Suddenly things started to get difficult to get done, with that one testing station effectively out of order.
Guess it's time to find yet another supply. Maybe one that is bit more reliable (i.e., expensive) this time...
lauantai 2. joulukuuta 2017
BT121 evaluating kit update
Bluegiga - now owned by Silicon Labs - makes pretty nice RF modules. I think I've mentioned their WLAN modules previously; not as cheap is those ESP8266-based ones, but at least these come with pre-tested and with actual paperwork needed for properly done CE marking & DoC (although I've heard that some ESPs these days do have necessary CE paperwork too)
Now, I just bought evaluation kit for BT121 (Bluetooth module), hoping to be able to use it to develop my new embedded BT library on PC without having to build actual hardware for it yet. When I can connect development kit with USB to PC and write and run the software there, it makes things so much easier.
I plugged USB in the development kit and ran their own interactive BGTool. Nifty one, that; it allows you to interactively run commands to the module, showing content of command, response and event packets, making starting up with module much easier as you don't necessarily need to read through full loooong API manual to get things started.
Except no. Didn't work.
The development kit is by default in demo mode where you can connect to it various ways - remotely, serially and whatnot - but not control it directly via API like I wanted to. And the manual says absolutely nothing on how you can actually write - or even upload - your own software package to it!
I almost - almost - wrote entire thing off as wasted money. Just 100-ish € or so, but nevertheless.
Now, the very basic setup the chips (as in, on reel intended for PCB assembly) would be more than sufficient for my needs, though. 115kbps serial link and raw API commands I want to use to control it. With that knowledge (okay, assumption) and few educated guesses I was able to upload the software on the kit anyway. Despite completely useless instructions. Nice.
So if you want to update it too, here's quick how-to:
Set up the board as quick start guide instructs (especially "USB to UART" converter, that's needed).
Set board to be powered by USB.
Plug out current sense jumper labeled BAT, below the BNC connector, and plug it in so that it shorts BOOT0 pin (slightly below and to the left of header you took it from) to 3V3.
Press "Reset module".
Open BGTool, then go to "View -> Upload tool".
Select "project.xml" as project, and "bt121_bgapi_uart115k" as binary.
Change port to correct one, and hit Upload.
And if everything goes well, you should see green bar flashing and shortly it's done.
Take out jumper from BOOT0 and replace it to its original position.
Reset module again.
And now you should be able to connect to it via Interactive view.
lauantai 25. marraskuuta 2017
Where did my code crash?
If you don't have suitable JTAG debugger handy, program crash in microcontroller can be annoyingly difficult to trace, especially if it happens only occasionally. Here is one trick for tracking those crashes with relatively low overhead;
char dtraceBuff[32];
void dtrace(char *data) { memcpy(dtraceBuff, data, 32); } void dtraceOut() { dtraceBuff[sizeof(dtraceBuff)-1] = 0; printf("DTrace: %s\n", dtraceBuff); }
And now you can sprinkle dtraces liberally around the code;
dtrace("intHandler"); dtrace("intHandlerEnd"); dtrace("mainloop 1"); dtrace("mainloop 2"); ...
And in the beginning of main() (after your output system is initialized, of course) put call to dtraceOut(). Replace print here with your favorite method of getting debug data out of your MCU.
So, when the code crashes, you can see immediately that DTrace says "mainloop 1". So what happens between "mainloop 1" and "mainloop 2"? If the issue isn't immediately clear, put more outputs there and try again. Eventually you will find the crash point.
But wait, if you just copy paste above to your program, you will quickly find out that this doesn't actually work. No matter what happens, DTrace will only print out empty string. Why is this?
The C standard requires that all uninitialized data is initialized to zeros. So when program crashes, MCU is reset and the C startup code will wipe all data - including dtraceBuff here.
There are however ways to prevent this, and exact method depends on compiler used. For Microchip's XC16, there is persistent-attribute:
char dtraceBuff[32] __attribute__((persistent));For GCC (ARM), I couldn't quickly find similar simple attribute to make this easy. So next best option is to play around with linker script and related __attribute__s, allocating part of RAM for persistent (non-cleared) data and putting your data there. This is however a bit more complex task than simple attribute, so I will not go into details in this post. Personally I have modified the startup code I use to not clear any variables - but if you do that, you absolutely must remember to initialize everything yourself. And this can be cause for more subtle bugs by itself.
There is also option of using nonvolatile memory for trace data, but I'd recommend not going that route unless you absolutely, positively have to. Nonvolatile memories typically can only handle so many writes before they are worn out (Flash some 10k erase cycles; EEPROM some 10M; MRAM and FRAM on the other hand have "infinite" life), and they (unless embedded to MCU core) are slower to access. Sometimes, however, that may be only option.
lauantai 18. marraskuuta 2017
Super AAA
It seems I found an supercharged AA battery today.
While for moment this seemed very interesting, after few seconds of consideration I came into a conclusion that my multimeter is more or less at fault here.
This specific meter one is one I have at home. It retails (in brick-and-mortar store) for something like 20€ (or at least it was, some 10 years ago), and today you could get similar one for some 5-10€ or so on ebay. While it claims to be CAT III rated, I wouldn't let let it anywhere close of high voltages. In other words, it's a PoS that is barely sufficient for checking if a battery is full or empty. And apparently it can't do even that that well.
But I don't blame the meter for all that. I knew what I was buying when I got that one.
Now, if you take a closed look at the picture above, you may see a small "battery" symbol on the screen of the meter, meaning that its battery is almost empty. Unlike newer models, this one has toggle-button for power. You always must remember to turn it off after you're done with it.
What isn't immediately obvious is that the same battery symbol also means that the readings aren't to be trusted anymore, as we can see here. I haven't really bothered to check how these things work (in circuit level), but I guess that there is a reference voltage somewhere - generated from battery voltage by some kind of accurate reference, be it of shunt or whatever type - which isn't correct anymore due to low battery voltage and this is causing readings to be higher than they should be.
As proven by quick battery change. With fresh 9v battery the reading is much closer to what I'd expect it to be. Old battery read about 4,9v when I took it out so it clearly was at end of its life.
So, in short, if your multimeter reading seems suspicious, take another meter and cross-check. And never, ever, take these cheap ones anywhere close to mains voltages, for any reason. The protections they contain are simply insufficient and they will kill you for that.
torstai 9. marraskuuta 2017
This is supposed to be a server?
Annoyed ranting ahead. I've been incredibly busy lately and will be for some time still, so I guess there'll be no exciting posts coming anytime soon.
I just bought a new server to our office. This is essentially backup machine, in case main system lets the operating smoke out, with planned use for other, less important purposes like staging/testing and whatnot in the mean time.
Since this is supposed to be server, it will eventually be headless, accessible via SSH key login only. Before that, however, I do need monitor of OS installation and so on.
But here I hit a problem: Some un-friggin-believeable idiot has decided to equip this server with no other display connections than two Displayport 1.2 connectors. Which cannot even be converted to more useful signals - like, oh, HDMI - without nothing less than active converters (so no, DP-HDMI cable won't just work. I tried.)
And really, two displayports? What is this machine supposed to be, some movie prop with separate huge monitors scrolling text logs for anyone to see?
Guess what: I don't have even one display that has displayport here anywhere. And by quick review, displays that have DP aren't exactly the cheapest ones there are. I don't like the idea of having to get a new display just for this, but damn it if I just have to... Or maybe I'll have to get a converter. We'll see...
lauantai 28. lokakuuta 2017
Privacy by Directive
New European Union privacy directive - 679/2016/EU or GDPR as the common term is - will be either reason for celebration or horrible business-breaking problem, depending on how prepared you are. And of course how invasive your information excavation happens to be (*cough*facebook*cough*).
From purely personal perspective it's pretty great - no longer can these huge privacy-sucking corporations just vacuum out everything about you and post it for anyone to take without you having any say about it.
But for many businesses it can be a huge problem, scope of which many haven't realized yet. Aside the typical issues mentioned just about everywhere, there is also how personal data is defined;
‘personal data’ means any information relating to an identified or identifiable natural person (‘data subject’); an identifiable natural person is one who can be identified, directly or indirectly, in particular by reference to an identifier such as a name, an identification number, location data, an online identifier or to one or more factors specific to the physical, physiological, genetic, mental, economic, cultural or social identity of that natural person.This is direct copy from directive text. If you start reading this like the proverbial devil reads the bible, this is a huge can of worms. For example, if you have web page somewhere, there very likely is an access log there too, one that logs IP addresses. Now, that IP address may not tell you who the user is, but indirectly it can be used - when combined with other data, say, logs from other services - to identify the user.
No, I am not kidding. I was just recently in a meeting where a lawyer actually said this - there is already a court case that essentially said this.
This meeting went on, but the end result was that just about anything can be 'personal data' and must be treated as such. By this point I had loads of alarm bells going on in my head, and the IP log mentioned above wasn't even close of top issue in my mind.
How are your logs and databases doing, by the way?
sunnuntai 8. lokakuuta 2017
STM4F469 and USB HID
At some point I started playing with STM32F469 chip - essentially newer, bigger and better version of STM32F429 I've mentioned before. Mostly it was really simple just to drop it in the design in place of older -429, almost everything worked right away (there are minor changes in pinout though, even with nominally same package, so consult transition info first!)
Almost.
Unfortunately the old two-way USB HID routines I had working with -429 were essentially dead. They compiled and ran, but did not do anything. And since they were build from ST's horrible mess of "libraries" (those things do not really deserve to be called that, they're just that bad to read), there was not much that I could do to figure out why they wouldn't work. Some tiny change in USB, somewhere.
So I took newer version of same horrible libraries and adapted them. And the result was...
"The device cannot start". Well, thanks, windows, mind elaborating a bit here? (if you have ever tried to program USB in windows, you know the answer to that already - "no!". And that is the short, cleaned up version, add few expletives and you'll get the real answer that windows usually offers in these cases)
I spent way too many hours trying to find the issue. Maybe some USB descriptor field is a bit off? Maybe this or that... Tweak something, try, fail, repeat. Frustrating effort, to put it mildly. Even tracking USB handshake sequence progress by tapping into it proved fruitless.
And eventually I thought of changing the PID - the USB product ID the device is identified by. And the damn thing worked right away!
So, my guess here is this: Previously I used different chip, with different libraries but with identical USB descriptors and VID/PID codes. As USB is (should be) identified and made working with this information alone, different chip and libraries shouldn't matter as they offer same descriptors and services windows sees.
But apparently something somewhere did matter. Windows most likely had stored something it expected to match the VID/PID pair, somewhere, and when it wasn't exactly as it wanted, it refused to work altogether and just gave that completely useless error message, instead of - say - discarding old, obviously stale data and starting over. Figures.
The good news is, this typically isn't something that you would run onto in production, as there everything should be fixed and just stay the same. And if there is a major revision - change of USB chip or something, for any reason - just change the PID. It seems to make life so much easier.
Oh, someone want to get a example copy of those USB HID libraries for STM32F469 or -479? Raise your hand...
lauantai 30. syyskuuta 2017
Looking for help at the net
Gotta love Analog Devices. They make absolutely great chips, such as nice ADuM4160 USB isolator. This chip offers full isolation for USB bus, completely separating electronics on your PCB from PC controlling it and preventing that magic smoke from escaping due to serious voltage differences between the two devices, and this without having to use secondary power source on PCB (granted, in case of USB this is of a lesser deal, but for buses like RS485, not having to build isolated power supply for is a big deal - and there's chip for that too.) But the thing is, this chip - and many others AD makes - aren't cheap. This one was around 10€ a piece in low quantities, if my memory serves. But then again, if your industrial PCB costs something hundreds of euros, taking precautions against stupid users might be worth it. That's who the main customers for this chip - and others like it - are.
That being said, I was testing this chip in case I need it one day, and found out that when using it, USB wasn't working properly. It tried to, but failed to establish connection. Hmm. Curious, as I thought I had followed documents to the letter when designing test board. And since AD hadn't bothered to even include an example schematic in their datasheets (why?!?), I fired up google image search with "ADum4160 schematic".
And oh boy, I don't envy anyone trying to get their circuit working based on those schematics. There are functional ones there, sure, but some work only in specific cases, some of them are completely wrong, and quite a few subtly wrong so that it may work - or not. Like this add-on board (that I shall not name here) that doesn't have any bypass caps for ADuM anywhere on the board. If that one works with any reliability, it'll be due to pure miracle.
Anyway, I managed to get my ADuM working eventually - small issue with supply rails that I didn't notice when initially reading datasheet, going to "specific case" mentioned above, found out by examining some schematics and then doing some very careful reading of datasheet - but damn if I had to rely on internet with things like this more often, I'd be in a real trouble.
So, go on and search the net for information. But be wary of any information supplied - it might be wrong. And yes, that includes stuff I write here, too.
lauantai 23. syyskuuta 2017
Shortest camera life yet
Our old Canon point-and-click camera that we got maybe 6 years ago finally got damaged enough not to work anymore. So wife went and bought just about cheapest possible camera - specifically Nikon Coolpix A10. Price wasn't that bad either, some 85€, taxes included.
And kid dropped it on the lens which broke on the very same day. Specifically the objective/lens mechanism that moves it to storage position got stuck, most likely by breaking or jumping off the thread (rail?) or whatever.
So what are our options? Home insurance? With deductible of ~120€, that's a no go.
Return it for refund? I'm too honest for that kind of fraud.
That leaves me with option three; open it and see what could be done. But I wasn't too hopeful to begin with. Those mechanisms tend to be damn complex and in general difficult to work with, and this being plastic didn't exactly fill me with any confidence.
I can almost hear someone out there screaming about opportunity cost, but a) I just happen to be curious enough to want to see how they're build, and b) unless you actually do get paid in full for the time spent, opportunity cost is generally nothing but an excuse to avoid things you don't really want to do. Like actually saving money by cooking yourself. But I digress here once again...
Opening the camera wasn't that difficult. Some six screws and small amount of force popped front and back covers off. After looking for way to get logic board off, I peeled some tape off the boards. And next thing I found out - painfully - that camera apparently keeps the flash capacitor (330v 100uF) charged all the time. Ouch. If you open this up, be careful with it, 10k resistor is handy for discharging it. Just don't hold the resistor leads with both hands! (doubly ouch, and might do more than just hurt). Preferably hold it with no hands, like with well-insulated pliers.
After that display and it's holder came off with few screws.
The system integration is damn impressive on these things. There is a small PCB on front of camera, just for LED, and on top there is another for for buttons and flash circuits. Those are connected to each other and main logic board with solder joints, as well as the battery contacts from holder come through the main board and were soldered on. It took a while to figure this out and to pry main board off. Lead-free solder joints are damn annoying to get off sometimes, especially if there are large ground planes involved.
After getting logic board off, the lens mechanism came off as module, pretty much as I expected.
This package itself was hold closed by I think five plastic clips. Four of them are easy to get to, but fifth is under the motors flex and damn small. Small, sharp and sturdy pin with small screwdriver is the best method to get it open.
Left is the cover with CCD, right is the mechanism.
And this is pretty much where I gave up. The motor (large-ish and metallic colored, on left of mechanism) seems to drive the opening mechanism, but the large wheel down there was seriously stuck. I could not find out any way to open this non-destructively so that was it.
I put it together (making sure to salvage that nice flash capacitor first), leaving everything (including battery holder) unconnected. This is kept as reminder and practice piece for the kid - no more cameras for him until he can handle them without dropping them constantly. Sure, it won't be fun to play with as it doesn't do anything, but that's all he's going to get for now...
If I could salvage another A10 somewhere, with, say, broken screen, I might be able to build one functional camera out of them (again, more for curiosity and practice than saving money), but even that is only worth the trouble if I get the other camera for essentially free.
lauantai 16. syyskuuta 2017
Whether one should have hobby projects
Long time ago, when I was just studying and not being working, I enjoyed having my own projects to work with. Being primarily software guy, this of course was projects I could think of. Utilities, games, tools, anything like that. Lots of them, in fact. Some gained some interest, but nothing spectacular. I had plenty of time and energy for that.
Then I got work as software developer. Part-time at that point, but still. So now I am programming some four hours a day for work (plus studying, this being while I was still in university), and much of that (work) was actually learning about things around the main job as well - things like physical environments and how they affect signals, math around stuff, programming tools and concepts I hadn't encountered before and so on. Fun stuff, really. I always love to learn new stuff that interests me, and money is kinda big motivator for learning.
Then I graduated and previous part-time gig became a full-time job. And suddenly I didn't really have any energy left for my own projects any more. Will, sure, but energy, not really.
Over the years I've figured this out in more detail. Part by reading, part by experience.
It's said that programming is creative work. I absolutely agree with this, even if you are dealing with what could be called boiler plate code. There is just so much of creative effort you can squeeze out before it gets depleted. While I may not be painting Mona Lisa, or sculpting David, there still is is structure of program I'm writing that I have to keep in my head while working. Small problems are almost nothing, but big frameworks, bug structures, still existing only in my head, are fragile things. Keeping them in my mind is an effort, and a very taxing effort at that. And badly timed interruption can smash entire thing to splinters. There is a limit on how much you can keep such thing in your mind.
My personal hard limit seems to be at around five to six hours. After that there is a wall I run onto, and no matter what I do, I will not be productive software developer again until after proper rest - that is, a good night's sleep.
I can do other things though - say, assembly line type work, or anything completely different that software stuff - but then again, at my current position I am kinda lucky I have that escape route. If I were working in usual 8 to 4 office setting, there might not be anything else to do but sit there feeling useless.
Documentation, testing, all that - it's essentially same work, in different format, with different difficulty applied. I can try to do it, but in the end the quality will be sub-par. It's better I don't even try. So, five to six hours of serious work. And I am not even surprised that I don't have energy for hobby projects any more after that, not any more.
I'm not the only one, mind you. The consensus on the field seems to be that six hours per day is already pushing it.
Now, common theme in industry seems to be that one should have those hobby projects. Employers seek to people with those interests.
Now, wait a moment here - as an employer, you want that your people have energy left after work day to seek out extracurricular activities? Really, do you really want that your people you employ just waste their time - time you pay for - doing whatever, only to have enough energy for those hobby projects too?
Really?
torstai 31. elokuuta 2017
Battery backups
Here's a pretty common scenario: You've got a low powered device with a RTC (real time clock) - be it internal to the processor or external chip. When your device is powered the clock uses external power - like mains or larger battery - and when not, either small lithium battery (coin cell type) or a super capacitor.
Typically this is achieved by having two separate VCC supply lines; one for external power which is used when available, and one for battery backup when main power is not available.
Lithium batteries (CR1232 or something like that) are nice - lots of "slow" capacity in small package. Enough to run your clock about two to five years (depending on battery size and power consumption of your RTC). However, when it runs out it runs out, everything that was on chip (and I'm assuming that storage is RAM like it usually is) is gone, for good. If there were critical data on the RAM, it's gone. But then again, if your device has been unpowered for years, that data might not be relevant anymore. Or then again, you might have wanted to keep the data anyway.
Supercaps on the other hand have capacity for maybe a week or two, but at least they can be charged again and again. This is nice if your device is externally powered most of the time (like mains power), but if power does run out, same limitations as mentioned above apply. The time will be much shorter though - week or two, tops, with common supercap sizes.
But wait, what if you wanted to use simple, cheap capacitor? Something like 330u electrolytic caps are cheap these days. Well, sure, if your device is almost always externally powered, like, say, an alarm clock. It would be able to keep charge for maybe few hours, max, but at least it would tolerate short power outages. Unlike my current one, which isn't even cheapest one available but still loses all the settings even if power goes out for few minutes.
But dissing Sony designs aside, how do you choose your back up solution? That, of course, depends.
How long you want the data to be retained?
What happens when power eventually runs out?
There is no single answer, it's something that you'll need to weigh case by case.
Older Nintendo Pokemon games are an example of this. The save game data in the cartridge was stored in low-power RAM, backed up with large coin cell battery. Those batteries are now dying, and your precious Pokemon collection is about to vanish - unless you replace the battery (not an easy task, as cartridge must have that backup power supply enabled during entire operation!)
Personally I prefer actual nonvolatile storages, like EEPROM (or MRAM/FRAM these days). On paper they have limited life - quoted as 20 years or so - but in practice it is much longer. And they keep their data without being externally powered. Internal clock may stop after its power runs out but it is easy to set again - other data however may be worth a lot more. Like those Pokemons.
But apparently few pennies more for actual nonvolatile memory was too much for them...
torstai 24. elokuuta 2017
I could have used SD card?!?
I have stayed away from SD cards (in my projects) because of two assumptions;
1) They require difficult and fast SD control hardware and software, and
2) They're unreliable pieces of s***.
2B) It is possible that I have heard at one point about licensing required and thus (subconsciously) didn't even bother. But I'm not sure so this doesn't really count.
Only now I found out, almost by accident, that SD cards have SPI mode. I love SPI. It's dead easy to implement even in software, allows many devices to share a bus (kinda-sorta) and is very reliable. So if I, all this time, could have just put a SD socket on board and instantly gained huge amount of nonvolatile memory... Daaaaamn.
But point 1) still kinda-sorta stands. If I would need to implement FAT filesystem (instead of treating it as raw bulk storage), that would still take some software to do. At the moment I'm kinda struggling with current product line as I'm almost out of program flash, and there is still years of development to do. Even few kilobytes more would make my life very difficult.
But if could treat it as a raw storage. Instead of "small" SO8 flash chip (of just 16 or 64Mbit or so), SD card could be put there with more space than I could ever use. For my current purposes even 2 GB card would be nearly unlimited.
Did I mention I still like to program small? I just checked - Google home page is over 200kB, excluding any pictures (like the logo). That's just a bit less than program area of the current MCU I use, and it is packed full of functionality (the MCU, that is). Data structures I transmit over web (between devices) are few hundred bytes each. HTTP headers are often larger than that! So, comparatively, essentially unlimited storage.
But then we get back to point 2). Failure mode of flash memories is notoriously bad. At least early SSDs had habit of suddenly going completely inaccessible. One moment it would work fine, no issues, the next -- nothing. You couldn't get anything out of it.
SD cards have similar track record, although being commonly removable, exact failure is harder to track, and might often be related to less than careful handling of cards.
I've dealt with those already mentioned SO8 flash chips. They may have "just" 64Mbit of storage or so, but they often promise something like 10000 erase cycles. That number is actually something I could trust - or at least believe.
SD cards, on the other hand, often seem to like to hide that number. There is this load balancer circuit that tries to hide that stuff from view, replacing it with meaningless "real world use" numbers for marketing purposes.
But still. Take 2 GB memory card. Write, say, 512 bytes to it, every second. Let's assume that this specific card can tolerate only 100 erase cycles. This number, by the way, is highly conservative - even cheapest of the cheap flash chips these days offer at least 1000 erase cycles.
Even then this would mean more than 10 years of usable life for the product. Assuming, of course, that the balancer doesn't lose it mind in between and destroy everything.
It's still very, very tempting...
maanantai 21. elokuuta 2017
"Are you sure?"
Kid, now 6, loves to play Lego Batman 2 on my laptop. I even got him XBox controller to play it with. At first he needed help with some parts (some tricky jumps mostly) but it seems he has gained some skill there as he managed to completely finish the story with just small help here and there.
Then he found out that after finishing the game that you can play with any (unlocked) characters you want, anytime. Talk about excitement! I'm guessing the save he was using was nearing 70% completion or so.
Now, I deal with the problems of my clients often. Many people seem to learn technology with a method of "press this, then three times this, then this". They do not read what is on the screen, they just press the memorized-by-rote combination. And if anything they didn't expect shows up (like an error message), they way too often don't even bother reading it and instead start wildly pressing anything and everything to make the error go away.
After that they typically call me.
Take a deep breath. Count to ... well, three, as it is a phone call and I can't really delay much longer. And calmly explain them how to salvage whatever's salvageable at that point. Really, that's all I can do. And quite often, that's all that needs to be done. Next time they (hopefully) are wiser.
I'm pretty sure kid isn't like that. He seems to be - in general - remarkably resourceful when figuring out how to get whatever he wants. At the moment he doesn't read because he can't - yet at least. And I'm guessing that's why he chose "new game" and then his (70-ish percent complete) save slot.. and then even confirmed the erase of the old save...
...And proceeded to ask why there was the (unskippable) intro movie playing, again.
After I figured out and explained to him what had happened he took it relatively calmly. But he hasn't asked to play that game again afterwards either... But then again, I wouldn't be too happy to start everything over again either.
Lesson learned. Maybe. Hopefully.
lauantai 5. elokuuta 2017
Transmit errors
When you dig down deep enough, everything is analog. And this means certain degree of uncertainty.
I've mentioned WiFi module I'm using previously, and deep down the communication with it - via serial link - is again nothing more than stream of bytes. It's up to application to assign meaning to that with software.
And boy, is that fun. The protocol the module uses assumes that serial link is mostly immune to transmission errors - that is, that absolutely no bytes are corrupt or lost during transmission from the main processor to the module or the other way around. If a singly byte is lost, synchronization is lost and data received becomes incomprehensible. And since frame format has no checksum, single corrupt byte may render entire transmission (either single frame, or your gigabyte data within) irrelevant or at least broken until repaired.
So, while the underlying TCP/IP link (assuming that one is open at the moment) itself may be resistant to errors, suddenly the data link from the module to processor might not be (and in case of my application, it definitely isn't due to module being placed on an external module connected with cable). And this will easily lead to corrupt data being transmitted.
Fortunately I have a personal, deep distrust on data integrity of any such transmission link - be it point-to-point one inch serial link contained within a board, or wireless link over thousands of kilometres, so I have tendency to design my applications' data transfer protocols to contain rudimentary integrity checks too, in order to avoid just this kind of situation. If data is lost (to either way), connection (read: entire module, if error is persistent) is reset and application will try again.
Whether this is efficient depends on your point of view. Is it fastest way to transmit data? Absolutely not, as constant data transmits and respective acknowledgements take a lot of time, especially over slower links (protocols designed for fast but high-latency links are nice, but I don't have any at my disposal at the moment.) But then again, I'm not transmitting blockbuster movies at 4k resolution here, but infrequent, small(ish) data packets that I want to be processed by receiver exactly once. It's up to receiver to make sure received package is handled only once.
If you happen to be modern (web) programmer, working exclusively with high-level languages, this may seem a bit excessive to you. But when you're working on lower level, with no operating system or high-level language libraries to hide all the nasty details of unreliable links beneath, these things need to be done.
And guess what? I still like it, just the way it is. It might be unreliable, but still is fun to work with.
sunnuntai 30. heinäkuuta 2017
"Your internet isn't working"
Few weeks ago I got a call from our office internet operator, informing us that our internet modem had gone down, they couldn't contact it. I wasn't at office, and since we run web service there too, I had of course go to have a look. Fortunately this happened when I wasn't on the other side of globe at least.
At the office I quickly noticed that pretty much all computers have gone down, causing the office to be eerily quiet (I'd love an quiet server that doesn't sound like friggin' 747 taking off on full load!). The mains fuse for critical systems fhad tripped! Switch that fuse back and everything starts waking up.
Our power supply for computers isn't exactly highly redundant. Single mains fuse feeding UPS that can take a load for good a while. Now was first time that it hadn't been enough. So when all the critical computers and services are back up, I get back to what I was doing, which at that time was heading out towards frisbee park with the kid.
Next day at office, I start going through logs and start noticing some remaining issues. One network storage was inaccessible. With a quick glance it indeed was - it was still off. Curious, those should come back up pretty quickly when power is restored.
Some more research and it seems that its internal power supply had died. No sign of life of any kind (specifically +5v standby; without it nothing of course works anyway). Not a first power supply that has gone down on me (in a bad way), and very likely not last one either.
Fortunately this wasn't critical storage, but "only" secondary backup storage that I had just month or so earlier retired from its main storage role and moved to its current role. I don't remember its exact age, but I'd guess it was some 10 years old now. Running pretty much 24/7 of course. I have to say timing was very lucky - few months earlier and I'd be far less happy about the situation.
Now I'm trying to make a decision here. Find a replacement power supply - which might be a bit difficult, due to less than common form factor - or retire storage device and its disks now. At the moment I'm leaning more on the latter option, especially since disks, too, have never been replaced during its lifetime. It's very likely near end of its useful life anyway.
There's no high need to replace it immediately either, as this was secondary backup. My primary one, of course, is off-side on third-party server and updated constantly and automatically... With data encrypted at our end, of course. You don't really think I'd be stupid enough to allow any data out of office unless it's encrypted with keys held only by me?
lauantai 15. heinäkuuta 2017
Let's not block those trackers
Many of you know that just about everyone is tracked in the web. By advertisers, by facebook, by google, by pretty much everyone. And many people don't like it. I certainly don't. And many and seek to actively block any attempts of such tracking.
I have started to feel that such attempts are pretty much for nothing, and while they may obfuscate some of the information, at least temporarily, too much information remains to be gathered.
As long as they can track people, to figure out their interests, they keep doing this.
So here I suggest an alternate approach, difficult as it might be:
Poison the well. Instead of blocking those trackers, I want an add-on that actively lies to them. Send them random, made up (but preferably plausible) tracking cookies.
Even more fun would be tracking cookie exchange. For every session you open, browser would switch personality (of tracking sites you explicitly set to do so) with some completely random person. This wold not be necessary, but it would hurt those data hoarders way more than just completely random identity.
Suddenly much of the information they gather is worthless. They can never be sure the information gathered with tracking is from real person -- or some random person with completely different interests.
Anyone up for some real fun?
lauantai 8. heinäkuuta 2017
Do you remember..?
Memory is a curious thing. The current consensus seems to be that you don't really remember an event, you have markers in your memory that (in programmer speech) encode that event in a lossy way, meaning that every time you recall it it gets corrupted a bit more. Essentially, when you remember something, it's nothing but warped, distorted recollection of events.
Kinda makes one wonder why we place such a high trust on eyewitness testimonies... But once again, I digress.
I've mentioned but me and my wife run the business together. She takes care of most of the deliveries and accounting, I do most of the development, manufacturing (although it's mostly outsourced) and customer contacts.
My phone number is openly listed. I don't really have need to hide it - we seem to not have any hostile customers or enemies - at least at the moment. I still receive only handful of calls on typical day.
I actually encourage my customers to call me whenever they have a problem. Some things - especially social services' drives where there are multiple payers involved - may be difficult to perform in some cases. When in doubt, I instruct to call me the instant they have problems, even if it's late and I'm officially off the clock. Maybe some 95% learn after one (phone-)assisted walkthrough. And it makes people happy to have help when they need it. I like happy customers. They are likely to do business with me again.
Now, sometimes I discuss other things with customers too, you know, kinda small talk-ish thing over the phone. And that drives my wife crazy sometimes.
See, often I say things that might need her attention. Like talking of products, deliveries, replacements and so on. Most of the time it's just talk - prospects, speculations - no need to do anything at the moment. I may instruct customer on some detail, discuss some stuff that is not immediately relevant and end the call.
Somehow I have trained my memory to just drop these calls. They're just business as usual. No need to remember them at all. So unless something exceptional was discussed, after few minutes of the call I don't even remember what was discussed.
If there was something that needed her attention, I make a note (often during the call) and deliver it to her.
Yet, too often often, there might have been something I said that caught her attention, even if it didn't need any immediate follow-up action. So she asks me of it later and I can't even remember what it was about. Since it was considered non-critical, my brain had already forgotten the discussion, and I really have no idea what she is asking about, aside some vague recollection of some discussion where something might or might have not been mentioned...
And even with this, my memory still constantly brings up some old, long irrelevant crap that would better be stay forgotten.
Memory. Curious thing, indeed.
perjantai 30. kesäkuuta 2017
Don't mess with tab stops!
New, better, improved. Yeah, right. It seems it always is the same. Your user experience gets worse.
Say, this little thing here. You may know this is as "Google login" screen, which is now - after those new and exciting and great changes - they totally fucked up.
That red arrow was my addition to focus onto the primary problem. It's in Finnish, but it says, roughly, "Forgot your email address?".
And it's always next tab stop after entering your address. So I enter my address, hit tab once, then space to submit (expecting focus being on that "next" button like it should f****** be!) and then stare few seconds next completely unexpected screen trying to figure out what just happened, why I am not in password screen?
You know, this is user interface 101. "user name" next "password" next "you're in!". But no, they had to go and mess this very simple thing up by randomly adding that "you don't know what you are doing?" button there, in between.
Yeah, it isn't even there every time, just about half or one third or so of time, by my estimate so far.
Is this really the best UI you can think up these days, Google? Because I do have a few suggestions where you can shove these "improvements" ...
Say, this little thing here. You may know this is as "Google login" screen, which is now - after those new and exciting and great changes - they totally fucked up.
That red arrow was my addition to focus onto the primary problem. It's in Finnish, but it says, roughly, "Forgot your email address?".
And it's always next tab stop after entering your address. So I enter my address, hit tab once, then space to submit (expecting focus being on that "next" button like it should f****** be!) and then stare few seconds next completely unexpected screen trying to figure out what just happened, why I am not in password screen?
You know, this is user interface 101. "user name" next "password" next "you're in!". But no, they had to go and mess this very simple thing up by randomly adding that "you don't know what you are doing?" button there, in between.
Yeah, it isn't even there every time, just about half or one third or so of time, by my estimate so far.
Is this really the best UI you can think up these days, Google? Because I do have a few suggestions where you can shove these "improvements" ...
sunnuntai 25. kesäkuuta 2017
Electric motorcycle
In addition of the solar heater project I've been playing around with idea of DYI electric motorbike. Actually I've had this idea for long time now - maybe ten years - and it is possible (even likely) that I'll never get around doing it, due to component sourcing issues (mainly the battery pack), but planning is kinda fun nevertheless.
This would be strictly for nearby city cruising. Total driving time some 60 minutes or slightly more (at inner city speeds), top speed maybe 120km/h or so.
So first some research about required power. From some site I found out some information for scooters and power requirements there. It turns out that about 100km/h should be doable with just 10kW power. If I were to limit speeds above 80km/h to short duration only, even smaller engine would do - 8 or even 6 kW might be enough. This would not be fast bike, though, so maybe I should target about 10kW at first.
Then the battery voltage. I thought about 120v pack first, but currents required at high speeds (maximum power) would be uncomfortably high. But for now I go with that figure.
For the frame I was thinking about getting old Suzuki GS500 frame (which happened to be my first bike - light and nice to drive, although not great for longer cruises due to vibration caused by small-ish 2-cylinder engine), but those, too, tend to be "a bit" expensive here at the moment. But I keep that as a starting point yet.
Now, the engine. At first I was thinking about using permanent magnet DC motor for this, but it turns out that suitable motors are damn near impossible to get, at least in sane prices. So scrap that idea.
Then I read some more about 3-phase induction motors, and they seem like suitable alternative with proper control scheme. Naive control implementation will be horribly noisy (EMI-wise) but for a hobby project - and with loads of shielding - that might be okay. 120v Y (star)-connected motors are also available quite easily, although I will need to up the battery voltage for that; 120v AC is very different than 120v DC.
Then the battery pack. This turns out to be hardest part actually. Full, ready-made packs aren't really available, and if they are, they're too big or shaped so that they won't fit the bike frame. I would have to go for full DIY-pack, individual batteries, with all the protection, control and charging electronics included. While at this point I am fairly comfortable with high voltages involved, the charging and general safety is very different thing. And this, unfortunately, might be problem that will kill this project. Especially since things like zero motorcycles are already available, although the price is a bit high-ish; nearly 20k€ here ... But I suspect my DIY bike might easily be equally expensive, in the end, even if I weren't calculating price to work required.
But hey, even if this idea will never be realized, it's still fun to think about all the issues and solutions involved. And like always, some of the ideas will almost certainly carry on, to upcoming (possibly more profitable) projects.
lauantai 10. kesäkuuta 2017
Learning Ruby
Back when I started to think about server-side web programming (several years back, now), I thought of picking some nice, modern language to start with. My only previous experience was with Java, during early 2000s when I was still at university, and I wasn't too happy with it.
Ruby seemed to be hot topic (Python too, but I have severe allergic reaction to languages that want to force their way of thinking on me so I ignored that) so I started looking for some tutorials.
What I found:
"Now that you want to build a blog..." And this repeated many times over, in several variants. Granted this was ruby on rails - as an afterthough I guess that latter part somehow indicates that "there is only one way to do this, our way". Yeah, remember what I just said about language forcing their way just before this...
No. I already had a database schema at that point, I just needed to make a front-end for it. For some reason I just couldn't find anything useful that could help me get over this initial starting situation.
I am not happy with "hello, world" approach in learning. When I want to learn something, I usually have an existing problem I want to solve, and I'm giving new tool an option to do it, often learning something useful during the process. Anything that tries to go against this is just a nuisance and will be swept aside.
Of course, considering the level of my expertise in general this means that when I get there the problem I have is rated "pretty damn difficult" already, and web quite often offers very little help, often due to topic being fairly specialized. I end up doing most the learning myself anyway, from scraps and pieces of information littered around. C'est la vie or something like that.
Either way, in this specific case I went with PHP. Many people will hate me for this, but realistically, it was there, close enough to my existing path of thinking, and most importantly, not fighting me when I wanted to get things done. I'm not too happy with uncompiled, dynamic languages in general, but at this point it was the lesser evil.
Passive learning has its advantages too. By the time of this I had read a lot about web programming, just in more general sense. Most common pitfalls, like dangers of unverified and unsecured parameters and so on, so I was able to work around the most dangerous issues with just a few additional searches.
And I still have no idea on how to write any Ruby code. Ah well, maybe one day interesting problem will appear and I'll find some motivation for it.
lauantai 27. toukokuuta 2017
Games.
Back in late 80s I managed to get my hands on a first computer, this being Sinclair Spectrum. Not greatest machine around, but for me it was awesome machine - despite other devices likes Commodore 64 or upcoming Amiga 500 being so much superior technically. I was way too young to really learn programming then, so it was mostly experimenting. And I loved games. I wanted to make games. But without knowledge, that didn't happen.
Next I got a PC. Actually my dad got one, for his work, a PC AT, a 8086 (way back when that actually meant specific thing!) with single-color display, and I was allowed to play with it. As he tells it, when I called him and asked him "how do I load the shuttle to this autocad?", he knew that I'd be okay with computers. This was, after all, when user interface meant DOS and command like, yet I had managed to start the program myself...
And after that hardware upgrade after upgrade. Every step on the way games got better and I'd love to make them. Did make some, too, although they weren't really popular.
Later on I went to work as a software developer so much of the interest kinda withered away. As far as I've understood it's quite usual - you don't really want to do same things as hobby you do for work. But the yearning never died out, it just got kinda supressed.
Even now I still like to play with game ideas. One part own engine, with OpenGL (screw directX and its platform lock-in), one part Unreal engine, one part Cryengine (because go underdog!), part GoDot (because open source) ... These ideas never get very far, mostly because time shortage, because games these days take a lot of effort, but it's still a fond dream of mine to someday get something really finished.
I still got a head full of ideas. I've got this one, kinda based on this one Valerian comic I read long time ago. Not that specific story or characters or even universe, really, just idea loosely based on the very general idea or surroundings in that comic, and I'd love to make into full single-player RPG (with capital R, very unlike latest Fallout excuse-of-a-RPG). But it takes lots of programming - and more importantly, lots of graphics and audio, neither of which I don't really have any talent - nor time - for.
But I still can dream...
lauantai 20. toukokuuta 2017
High cost of free breakfast
Way too often I see bean counters ruining things. The following may or may not be completely accurate, as part of it is what I heard, and part of it is my own deductions. Read with some care.
I worked briefly at Nokia in late '90s. I was essentially subcontracting; work for hire, as the company I worked for was not Nokia itself. Nevertheless, even back then it was obvious (to me) that the company culture was fairly toxic and I would not be returning after my (short) period there. For example, I was implementing some small(ish) feature to an upcoming phone, which I did, and this was then shelved because it (as I was told) would have competed with some other (more expensive, I guess) phone model.
Since this happened to be during the boom period, a lot of the work force there was like me - young people in their early twenties, many being just second to fourth year students of the nearby university or higher trade school (I am not exactly sure how education translates here, so this has to do for now.) And like so many young engineers, they liked to work slightly odd hours - like 12 to 8 PM or so. Which understandably is a small problem for management - how do you arrange meetings when people aren't there?
So Nokia chose to offer a free breakfast for all employers, only available in the morning, before 9AM or so. The idea being that free breakfast would encourage people to come to work earlier, and thus making management so much more easier as everyone would work somewhat similar hours. Breakfast wasn't anything too fancy I think; some bread, porridge, juice - generally cheap but filling stuff.
Unfortunately this didn't last long. Someone somewhere decided that this is actually something that is called roughly taxable benefit, which means that people would have to pay taxes for the value of the food (essentially paying taxes of money they never had in the first place). This of course didn't go over too well and free breakfast was shortly gone.
Another great idea ruined by zealous accounting practices.
perjantai 12. toukokuuta 2017
Never assume...
Another post about travel. And there will be some harsh language and possibly disturbing themes involved. Consider yourself warned.
Just recently I watched some travel show, the episode was about Cambodia. And pretty much instantly I wanted to go there, again. We were there, my wife and me, just over ten years ago (damn how time flies these days...) I've posted about this before, but there's just something different there, something that keeps tempting me to go back, unlike Thailand and Vietnam (which do have a kind of draw too, but just lesser one). I haven't visited Laos (mostly due to time constraints on previous visit) so I really can't speak of it.
When I entered the country, I already knew of the recent history of the place, Khmer Rouge and all. But when you read something like that from the books, it doesn't really click, not like when you see it yourself.
I wonder if that is true for everything (news) we see in TV these days... But I digress.
First stop was (coming from Thailand, so this was quite natural) Siem Reap and Angkor Wat. We took only one day to see it. Looking back, it is a shame, but back then we had a (relatively strict) schedule. But still, of course we were there on sunrise, as well as apparently hundreds of other people.
And still, the place is amazing. Pictures will never do it any justice, you just have to see it yourself.
We ran through all these absolutely gorgeous places, just barely appreciating beauty and all the work that was spent creating the place, the history (well, what we know of it) and so on.
...Then, moving on. Phnom Penh, the capital.
Like I just said, when we're just reading about it or seeing pictures, we don't really understand. I knew of the places, had seen pictures of this before, but it never clicked the same. But actually visiting Tuol Sleng and Killing Fields is so much more real than anything pictures can show ... Shit. It still brings me down when I see the pictures I took and remember the place.
All the misery. All the horror. All the fucking waste of human life caused by fucking ideology, by a dream of agrarian society where there is no place for intellectuals.When you could actually touch the remains of the victims (but please don't, like the sign says; I of course didn't), you understand - and it hurts, it really hurts. Photos or videos can never express it. You just have to be there. But still, I highly encourage you to do visit these places. Do experience the human misery. In the end, it is enlightening. I am not saying it has to be this one, exactly, as there are other similar sites (like WWII concentration camps in Europe.)
Despite this, Phnom Penh was nice place. We had our adventures there (I think I did mention the late night taxi ride at some earlier post), we took a river boat for a cruise (got a bit more than we paid for, thanks to our (I think French) co-passengers who apparently made a sweet deal with out captain) and all that.
And moved on again, to village of Kep. It was not really planned, but passing through the village some local tourism promoters entered the bus and asked us (the general us, all the tourists there) to visit the village. I think we were the only ones that actually took the offer - after full two seconds of consideration. And I don't regret it for a second.
Small, very quiet, mainly fishing village by the sea. There really weren't that many foreign people around, maybe few dozen, max. Recently I took a look at the current map and I think it has grown a bit since - but I could still find the places we visited. I'd really love to visit the place again. As well as all the other places there. I don't know why, but Cambodia really felt different than Thailand or Vietnam (I'm repeating myself here, sorry.) Too bad I never managed to find the places that sell fried insects (ants and spiders, I think) - I would have loved to try them. Ah well, next time.
And no, we didn't visit (in)famous Thunder Ranch. There's just something about the whole concept that seriously rubs me the wrong way...
But finally to the actual topic of the post. While we were at Kep, there really weren't that many tourists around, maybe few dozen max at the entire area. Nevertheless, one day we were there, having breakfast, just the two of us, and there was maybe one other person in the hotel restaurant aside of us. We were discussing our plans for the day and what not (in Finnish, obviously), and this other fellow, finished with his breakfast, gets up and walks past us - greeting us in Finnish. This took us by surprise, but since we hadn't been discussing anything insulting or volatile, it was no problem. But this really carved in proverbial stone a wisdom I had heard at some point earlier:
Never, ever assume that people around you can't understand what you are saying.
No matter where you are in the world, no matter how obscure language you are using, these days it is highly likely that someone around you will understand what you are saying. So keep your shit to yourself. Just behave like a civilized human being, for fucks' sake.
I did warn you about rough language at the top, didn't I?
sunnuntai 7. toukokuuta 2017
Universal Basic Income
At this moment robots and automation are starting to take over jobs, and quickly. Some estimates talk about full half of (human) jobs being gone within US (or Europe) in twenty years. At this moment unemployment of 10-20% is bad news, but with these projections we're talking unemployment of about 40-50%! (of course, assuming that no other jobs materialize to replace these that are lost. Estimates of that vary, from none to all - but let's just assume that just about one third to half of the jobs lost are replaced with new jobs.)
Now, one might argue that progress is slower than this and robots can't really take over all those works, but even half or quarter of that figure will be pretty disrupting.
This is where UBI - Universal Basic Income, or perustulo as it is called in Finnish - comes in. Society with that many people with no income really can't function properly. And this is putting it mildly. Note that I used word income here - people with no work not may not be very happy, but if they don't have unemployment benefits or other income either... well, that is the point where things turn ugly. Bread and circuses have been benefit to rulers since days ancient, but when population can't afford them, they (and modern equivalents) lose their calming effect pretty quickly.
And people really expect about half of the current work force to be unemployed without society experiencing a serious meltdown? Not gonna happen.
UBI will be necessity. Yeah, there are problems, very serious ones, starting with the one where there isn't sufficient amount of government income anywhere (read: taxes) to fund any serious UBI scheme. Not even close. Now. But it is doable, but many people (I suspect myself included) will balk at the tax figures (both personal and corporate) that needs to be implemented.
And I'm completely ignoring the other problems raising the corporate tax rate will cause. Like corporations moving elsewhere. Or just moving their money elsewhere, at least on paper. But then again, that is exactly what they are doing now anyway...
But still, I do think that this is something that absolutely must happen, or the nice societies we have here will experience one serious cataclysm that will turn things very, very unpleasant. We do have the means to make it happen. We can - nay - will make it happen eventually.
But that being said, want to hear the really bad news?
US, Europe and similar countries have maybe total of 1 billion people, out of total world population of maybe 10 billion (estimated; now the figure is 7B but it will go up yet) when proverbial shit really starts to hit the fan.
So, assuming no major changes elsewhere, total of maybe some 10% of world population would enjoy the benefits of UBI. Remaining 90% of population would still be out of reach of any such plans, realistically. So they will have no jobs, no income and pretty much no hope either.
You think the current situation in middle east is bad?
I fear we haven't seen anything yet...
tiistai 2. toukokuuta 2017
Hardest part of electronic design
What is the hardest part of designing a board?
No question about it, it is selecting the connectors.
Over the years I've picked few favorite MCU types I like to use. For applications needing a bit more power (as in processing power with loads of peripherals) I'd go for STM32 ARMs these days. For lesser needs, possibly some PIC24 series chip. For really low power, MSP430. I'm familiar with all of these (and few others, too) and can design a circuitry around them pretty quickly.
Familiarity is a bonus, too; I recently even had a customer calling me a bullshitter when I told him that his board was pretty much done (that is, schematics and layout) in less than 20 hours - and this included design meetings with said customer, studying some dozen exotic parts they needed and making library parts for them. But since I could base the "usual" difficult parts (MCU with parts around it, and DC/DC converters) on things I had done previously, rest was fairly straightforward, especially since board wasn't lacking space (so routing was fairly easy to do).
Whenever I have to use some unfamiliar but complex MCU, I usually have to spend maybe hour or two just reading manual and datasheets before I can even get started with it. You know, minimum necessary components, how peripherals work, or clocks and so on. More complex the part is, more time is spent just studying it. So I prefer to stay with ones I more or less know. This means that less of my and customers' time wasted there. But sometimes there is a special need that calls for some special and/or exotic MCU. Well, then I just have to quietly sigh and start reading.
I got a bit sidetracked there, but continuing. Same goes for DC/DC converters. Most of the low-power (speaking of current, less than 1 amp or so) is relatively easy. If I want really good one, I go for a Linear's devices - although they tend to be a bit more expensive. Others make nice chips too, but often quiescent current consumption is a killer - if my board will typically be using some 1mA or less on standby (which is 95% of the time - remaining time would be some 20mA on running, with occasional 300mA peak), it's out of the question for buck converter to use another 3 to 5 mA on top of that, especially in a battery-based product! .. and way too often I have to actually go and read the datasheet to find that value, since they don't really advertise it. With that kind of wasted current, no surprise, really... But still, relatively simple stuff.
Most of the remaining stuff is then either common as dirt (like chip resistors and capacitor) or something less common, but with good datasheets they're simple to use. Although there are nasty surprises there too sometimes.
But those connectors. Yeah, I know, there are literally hundreds of thousands of them, but that kinda is part of the problem. Even if you have figured basic parameters - like pin count, through hole/SMD, single wires/ribbon/other - out, there's still massive amount of options. And then you need to start picking them out by price and availability. That nice cheap connector you picked for this one-time 50-board product? Sure it's nice, available in rolls of 5000 pieces only, thank you. Hope you noticed this before ordering the boards...
In some cases it's easy, either surroundings (like existing devices) forces some type of connector or customer has his favorite already, but remaining time...
I've wasted way too many hours just browsing connector catalogs already. Really.
lauantai 29. huhtikuuta 2017
No OBD for you!
Well, this certainly will be interesting, depending how it will play out.
http://www.smart2zero.com/news/german-car-industry-plans-close-obd-interface?news_id=93237
Short version, some car manufacturers are not happy that OBD2 is used for things that it isn't really designed for, like having real-time vehicle data - such as speed, RPM, turbo pressure and all the other parameters one might be interested of - shown to driver via third-party OBD adapters (like ELM327-bluetooth modules everyone loves) and third-party software (like any suitable software you can install on your phone).
So they plan to limit "free" OBD2 access to stand still only. You could still get error codes and everything via third party tools, but only when car is not moving.
All other data would go through authorized (cloud) server, and you might still be able to access it via third party tools. It just won't be really free data any more, and certainly not real time.
If this really gains traction, I know a lot of people that won't be happy about this. Me, I don't really care (I don't use these features of OBD2, although I have considered it), but I do think that this is a step in very wrong (more closed) direction either way.
keskiviikko 19. huhtikuuta 2017
So you got a heavy load of hazardous cargo...
Some time ago I had some interesting time playing around with a fun problem that needed solving. That is, solving it was fun to me, but quite critical for customer.
In this problem, this company needs to transfer a very heavy load (something in excess 100 metric tons) through a sloped serpentine road. As the cargo is somewhat hazardous (so not just some raw ore), they obviously do not want to put any excessive strain on it or its attachment during the transit, where it is loaded onto a transport vehicle. In essence, they wanted to measure the front-back and sideways loads (strain) the cargo were to be subjected to during the transit and especially during turns.
If this sounds a bit vague, sorry about it - although I am not under any NDA, I do not wish to tell exactly about the application as a courtesy to customer's privacy.
As it turns out, I already had suitable hardware for this - our slope meter. It can measure acceleration over multiple axis, so I just had to work out suitable formulae to calculate the load - which I did, after some pondering (over pen and paper - but it also helped that I had already previously worked with similar problems, just in more limited circumstances). I did some preliminary testing and found out that my solution would nicely and with very nice accuracy over all the transit vehicle axis.
What I love about my situation is that I can actually work towards problems that do not necessarily pay out. I can do forward research - sometimes failing by not finding solution, sometimes finding a solution for specific problem but not getting any sales for it here and then.
This time, unfortunately for me, they chose a solution from another company, so I never got to see my finished solution in action. A pity, as it would have been very interesting.
So this problem falls to latter category. I did some work, but it didn't pay out. Nevertheless, I still did solve the problem at hand, and I never throw things like this away - it is still there, waiting for suitable client that needs something similar.
It is really surprising how often some research I did one time without reward suddenly finds a new client or even clientele, in a place I never expected. This specific one remains unsold, but I still have the solution in my tool kit.
One day a customer will come that desperately needs it. And then I can deliver just what they need.
Just like so many things sitting in the same proverbial took kit. Eventually, most of the research I do will pay out. Not all, mind you, but since you never know what will turn out profitable in the end, you just have to go by a hunch sometimes and take problems that might seem less than profitable at first.
But then again, sometimes it happens that I make things that never sell enough to make up the initial (monetary) investment. Such is life. Fortunately those things are in minority overall.
torstai 13. huhtikuuta 2017
Solar project: general ideas
Before I mentioned my solar panel project, in general. The general requirements were simple:
- Supply additional heating to reduce electricity cost
- No grid-tie
- No batteries
- Monitor the temperature and grid supply in cottage
- Control connected (solar powered) heaters
- Monitor voltage and current of solar panels.
- Supply mains-compatible AC power if requested
- Control grid-powered heaters
And, of course
- Do everything above safely
So that is, in nutshell, my ideas of this project. More about the actual design later on when I start moving the ideas from my head onto the paper. Or CAD, actually.
maanantai 10. huhtikuuta 2017
Project: Auxiliary solar heating
I've mentioned this before, but here up north solar isn't exactly greatest energy source, no matter how much environmental nuts try to push it. Summers do offer lots of sun, but winters, when the power need is at its peak, the production is pretty much zero. Days are short and sun is very low at the horizon, at northernmost part of the country sun doesn't rise at all! Good luck with solar panels under these conditions.
I've also mentioned that I have this summer cottage with running water and grid power, and keeping it warn (due to water supply) is somewhat expensive. I'd love to reduce that expense a bit.
So I came up with auxiliary heating /power supply idea with some solar panels, say 6 or 7 250-watt panels, bringing DC voltage up to 220v or so (with variations up and down, depending on load and supply).
So the basic idea was controller box where can can measure incoming voltage and control loads - that is, resistive heaters and auxiliary DC/AC inverter that is not connected to main grid (used for other power needs, like fridge, in summers).
Say, four to six channels, each with varying sized heaters (for example 800w, 200w, 100w, 50w), that are toggled separately on depending on voltage and current supplied by panels, and with a user input power can be supplied to DC/AC inverter.
During the darkest part of the winter the production will be next to nothing, but by the time the days start to get longer (or shorter, during the fall) there still will be plenty of sun to supplement normal heating and hopefully cut down the cost of grid power.
Whether this will really ever be economical is separate issue. Panels aren't too expensive, less than 1000€ total (taxes included), and the controller box isn't too expensive either - PCB and parts will be make around 100€ total. Heaters will be another few hundred euros. Most expensive part is the DC/AC inverter to run equipment that expects normal 220v AC grid power, but that won't be used for heating anyway so it's kind of a extra. And since there will be no batteries and no grid-tie, there really aren't any other major costs.
This of course completely excludes all the labor needed to actually design and build the system, but then again, this is a hobby project (at least right now) so that doesn't really count. Being hobby project doesn't mean that I don't take this seriously though - there are large current at high voltages involved, so I am taking the safety of the design very seriously indeed.
Let's see what I can cook up here...
perjantai 7. huhtikuuta 2017
Politics: This may turn ugly
News of the date. Truck drove in the crowd in Stockholm. This, being our neighbor country, is the main headlines now here (some six hours after the fact). Nevermind that there is almost nothing but guesses and speculation going around, no real facts. So I'm not really interested, not yet. Tell me some facts, news men!
What is more real is that USofA just earlier spent several millions of dollars by bombing Syrian air base (news just speaks of cruise missiles without specifying the type, and I'm taking (probably way too low) estimation of some $500'000 each, times 50 or so). The company that provided these missiles must be lovin' it.
What happened just before this is that there was chemical weapons involved, with many civilians exposed, many seriously wounded or dead. Now, I have no idea whose chemical weapons those were but I find it to be unlikely that rebels of Syria suddenly managed to manufacture large amount of chemical weapons. Not impossible, mind you, just very unlikely.
Was it government then? In that case Bashar al-Assad either got very, very cocky, or just stupid. Attacking population center with chemical weapons? Even if it were just rebels they hurt ir would be really, really stupid move, as he was bound to know that such move would draw some really unwanted attention.
Be it either way, it happened, and the president (with very, very small p there) of US deemed it fit to retaliate by bombing Syrian army base. Where there very likely were Russian troops. They did warn Russians first (AFAIK), which was kinda nice, but nevertheless, this was bound to raise some serious issues between these two major powers.
What did happen was that Russians chose to drop out of their agreement with US to inform each other of what they were doing. At the moment I heard of this, I went 'uh oh, this won't be good'.
I would not be surprised if Russians were to attack some US troops now. Purely by mistake of course, they just happened to be where rebels were as well. Maybe few times over, before they re-neg their previous tell-then-kill agreement.
Or possibly it will turn out worse. Both of these major powers will benefit if Europe suffers, so what if they turn this conflict into a proxy war? Russian supporting government (ie. al-Assad), US supporting rebels. No direct contact between nations (I'd guess they'd try to avoid that as much as possible, otherwise they'd run a risk of turning this into real WWIII), but that would mean even more refugees and unrest within Europe, potentially being of benefit to both of them. And then there is the possibility of situation turning turning into "whoever controls the region controls the oil".
I just hope I am being paranoid. Because these scenarios sure aren't fun.
lauantai 1. huhtikuuta 2017
I killed the drill
Wife asked for seemingly simple thing; a board where she could place small mason jars so they wouldn't move during the use when training the dog (course is called 'nose work' I think.) I didn't really have much to do right now, so I got to it immediately. First checking what would be needed - as it turns out that I'd need pretty much everything, as we were fresh out of suitable pieces of wood, not to mention hole cutting drill bits and everything. Except the drill.
After a brief visit to local hardware store (and grimacing of the cost of seemingly simple hole-cutting drill bit) I got back home and got to work. I noticed pretty much immediately that my cheap 550w Skil drill isn't happy about this job - guess hole drilling is a bit too much for it. Not to mention six holes that were needed.
I never got the sixth hole made - the drill died. I was hoping to get the sixth done with it, despite it's smoking calls for rest (or help), but alas, it wasn't to be. Dang.
This drill was not my first, going against my self-imposed tool-buying guidelines, but then again, I bought this drill before these rules (or guidelines) were really set in my mind. Although I kinda think the first drill doesn't count - it was extremely shoddy 20€ thing that promised a lot in its specifications - and actually broke the very first time I pressed the trigger. I got it almost as an afterthough from some store. Too bad I lost the receipt, I would've returned the damn thing otherwise for refund...
So now I got a half-finished dog training ... thingamajic and no drill. Guess I need to get a new one pretty soon - this time a quality brand one.
maanantai 27. maaliskuuta 2017
Are we in a simulation?
One of the old philosophical problems, also tackled by movies like Matrix, along with many others, is, simply: Are we living inside a simulation?
Without going into philosophical aspects of that, I've got to say that if we are, it is damn impressive simulation indeed.
Take issue of observable universe, for example. Let's for starters assume that the rules of the universe must be fixed and running from the beginning and whoever is running can't just improvise general rules at some point. I make this assumption since as far as we've perceived so far, the rules have not changed - system (in our solar system level) has been the same from the start, introducing us such weird things as epicycles when we got it wrong.
But this is just small potatoes so far. Let's expand this a bit. Our galaxy, Milkyway, has estimated of 100-400 billion stars (so, 100*10^9 - 400*10^9, in a bit more easily readable notation when talking about huge scales), and by now we can assume that quite many, if not most of these stars have at least one, if not more, planets. So we're talking at least trillion (1*10^12) major objects, and we're completely ignoring things as asteroid belts and such.
And expanding this again. Ultra Deep Field shows just tiny, tiny fraction of sky we see (way smaller area than the moon!) and it alone shows something like 10000 galaxies. Expand this to entire sky and we're talking about hundreds of billions of galaxies (100*10^9) again. Each with trillion (1*10^12) major objects. Which would place total number of major objects to somewhere around 1*10^23 range. That's 1, with 23 zeros following.
It's late when I'm writing this so there might be some stupid math errors, but nevertheless, I don't think I'm too far off. And again, we're still discussing only planet- or moon-sized objects and larger; smaller objects are so far ignored.
So again, returning to assumption that the simulation must be mathematically perfect from the start, it would have to consider gravity interaction of all these objects, all the time.
And here we are, where we can't even analyze such problems with mere 3 objects (three-body problem) but only in some very limited scenarios!
So I say again, if this a simulation, it must be backed by some pretty impressive mathematics to be able to simulate all these objects, since we certainly don't have capabilities for even infinitely tiny fraction of something like it. Without cheating, of course, but such cheat would be kinda obvious later with sudden changes in system behavior when exposed to detailed observation...
Of course system might be limited to things we can observe, but this was kinda my point with this - at the moment we can observe stupidly huge amount of objects - not necessarily directly, nor all the time, but still the behavior of objects previously observed must remain consistent during the simulation, in case we are to observe them again later. So even with cheats, things get pretty heavy.
I know, there are arguments to counter things I've said here, but nevertheless the energy cost for running such simulation would be simply enormous. Even if the rules if this universe don't apply in universe that is running the simulation.
keskiviikko 22. maaliskuuta 2017
It's so ...
Again, this post has nothing to do with electronics, but some anecdotes about tourism in Finland.
One thing many foreigners don't get when talking about Finland is how sparsely populated this country actually is. Huge land area, combined with just 5 million or so inhabitants mostly centered in larger population centers at southern part of country means that there are literally thousands and thousands square kilometres of ... well, you could say nothing, but there's forests, lakes, rivers and such mostly natural things. Entire northern part of Finland, Lappi, has over 100000 square kilometres of area, with some 120000 people on it (excluding Rovaniemi - largest city there - that has about 58000 people living there).
When I decide to take a car for a work trip, the first three to four hours from Oulu - at highway speeds; 80-100km/h - is usually spent for just getting to main population hubs of this country, first being typically Jyväskylä (about 300km away from Oulu). For the first 200-300 kilometres or so the scenery is mostly forest among main roads (and when traveling southwards, there is only four major routes - I know them all my the heart by now). Later it turns to fields and forests along roads.
I was told this story some time ago now, but I think it's worth repeating here.
Some persons I know had a friend of theirs from (I think) Germany visiting them here at Finland one summer, years ago. Like many Finns, they had a summer home/cottage by a lake, with all the usual accessories; pier with small boat, sauna, and nothing but forests and lake nearby as their nearest neighbor was kilometers away (or possibly there was another cottage nearby, just with no one in there at the moment).
They had good time, going to sauna, having some beers, talking and so on. It was getting a bit late (but it was still light; due to northern location, there is plenty of light in summer nights here) and suddenly someone noticed that it had been ages now since they had seen their German friend.
They got worried and went looking for him. Quite soon they found him, too. He was there, just sitting at the end of the small pier, by the lake, just staring at the opposite end of the lake.
They asked him what he was doing. He didn't respond for a while, and when he did, all he said, in quiet and almost trance-like voice was:
"It's so quiet here..."
Having just the sounds of nature around you, with no man-made noise, can be a real experience alone, one that being native here don't necessarily appreciate as much as one could.
Mandatory ad:
More about Finland tourism, click here.
torstai 16. maaliskuuta 2017
Just one misclick ...
Well, that was some fun hour or so.
See, here I was, trying to figure out how to make it possible to connect from office WLAN (which is kinda limited, for a reason) to my desktop for testing purposes.
So I am browsing through the firewall settings, trying some things, and ...
...Shit. Everything just stops working. That last setting (some bridge rule) apparently was Very Bad Idea.
As pretty much nothing works (and remaining live interface happens to be DMZ, from which I can't do anything anyway.) So only option I have is to hit factory reset in the router. And start desperately rebuilding everything from scratch. All the settings, all the firewall and forwarding rules, everything.
And I realize I have absolutely no recollection on how to do it. The setup has been there for some two years now, virtually untouched aside some minor tweaks here and there. At this point I'm getting a bit nervous, especially since I have no internet access - until I manage to reconfigure it correctly.
This isn't a very pleasant feeling.
But then a small memory hits me. Last time I did this, didn't I make notes?
Yes I did. Not very clear ones - I'm quite certain that no one but me could rebuild the setup from those - but they were just sufficient enough to allow me to set up everything quickly. First outbound access (damn Cisco boxes provided by ISP make that annoyingly difficult), then inbound services one by one.
And now we're back. At least some of the obsolete port forward tweaks that were needed at some point for testing got thrown out too.
I think there is a lesson here somewhere, but guess I'm not seeing it, not right now...
Tilaa:
Blogitekstit (Atom)