Theme

April 26, 2009 · Posted in Blog · 1 Comment 

I’ve been playing around with the theme of the site a bit. I felt that the previous theme, while not looking bad at all, was too difficult to read (and too difficult to make stuff appear how I want it to appear). Also, since it was intended for a much older version of the blogging software, things didn’t really work 100% anymore. I’m almost satisfied with this one now, and will probably stick to it :)

Also, don’t forget the post(s) below this one!

Edit (27-04): I’ve tweaked the template a bit further and upgraded the software as well. I’m going to stick with how it is for now :)

Playing

April 26, 2009 · Posted in Electronics · Comment 

Lately I have, largely out of a lack of better things to spend time on, been playing around with PICs a bit. Since you are probably asking questions such as ‘what the hell is a PIC?’, or ‘why does it sound like a Dutch word for penis?’, here’s a short explanation. A PIC is a small chip that is essentially a tiny computer. It has a CPU, memory to store a program in, RAM, and usually a number of peripherals like an UART (a module to communicate on an RS-232 line), USB, timers, EEPROM memory for more long-term storage of data (such as configuration), and so on. They vary from the extremely small PIC10F200, which has only 4 pins that can be used for I/O (say, blinking a LED) to large 32-bit chips that run at 80 MHz or more and have more than 100 pins. The most popular series however are the PIC16, and more recently, the PIC18 series.

As for why it sounds like a Dutch word for penis, I have no idea. PIC could stand for Programmable Integrated Circuit, Peripheral Interface Controller, or a whole lot of similar acronyms (but according to Microchip, it doesn’t really mean anything).

Developing stuff on a PIC is a whole lot different than normally developing software. For starters, you’re not just developing software, but the hardware as well. This means that at least a basic knowledge of electronics is invaluable, and with that comes things like knowing which parts or ICs may be useful for your project and probably at some point you’ll want to be able of designing your own printed circuit board (and making those/having them made for you). Second, it’s great to have software on your PC, but you’d probably rather have the software on the PIC – so you need a programmer. A programmer is a device that does exactly that – it ‘uploads’ software to the PIC. There are lots of programmers on the market, but what I’ve been using so far is the Wisp648 sold by voti.nl, combined with Bumblebee as PC-side software.

The fun part however is the actual programming for the PIC. Microchip offers some free development tools (MPLAB), but I never liked that, and you’re going to be stuck to using assembly. Writing a program in assembly isn’t as bad as it sounds – especially if you have programming experience and the program remains small – but on a larger chip, say, a PIC18F4550, assembly quickly becomes a huge, unmanagable mess. That is when you will realize that a higher programming language would be great, and for this type of thing, C is probably the best choice. There are a number of C compilers for PICs on the market, but most are staggeringly expensive, and come with a lot of proprietary stuff, so you’ll be stuck with that particular package for the remainder of your natural life. There is, however, a great alternative: SDCC, the Small Device C Compiler. It supports all the most common PIC16/PIC18 devices, but there’s a great lack of documentation and source code, so you’ll have to figure out a lot on your own.

Not that figuring out stuff on your own is uncommon: developing hardware (and software) can be pretty much a trial-and-error process.

Installing SDCC is pretty simple, both for Linux and Windows (yes, it works on more than one platform! hooray!). To work, SDCC will also need the gputils package, which is again pretty straight forward to install. I do strongly suggest that you enable the option to include the binaries in the PATH variable in Windows, it makes life easier. After installation, you’ll probably be thinking ‘okay, what next?’ and that’s were it gets funny.

Since you’re doing stuff for an embedded device, this version of C is not something you can really compare to what you use to write software for your PC. Sure, the syntax is identical, and most of the standard C libraries are implemented (printf, math, stdio, …) but that’s about it. Half of the code you write will be directly accessing registers on the PIC (since they control all functions of the device). Half of the time you’ll be looking up stuff in the datasheet (which is usually over 400 pages) and the other half you’ll be wondering how the heck you are going to debug your code – after all it’s running on a small, isolated chip and getting anything at all on your computer screen isn’t quite as easy as with ‘regular’ software. Then there’s the limitations of the device – you probably have a lot of functionality you’d like to include, and only so much I/O pints to work with, and only a limited amount of code memory and RAM. Especially when using C, it’s easy to run out of any of those. Also, everything you’re doing is quite low-level code – you’re directly telling the chip which pins are doing what, handling interrupts, and so on – no fancy multithreading or whatever.

For debugging/testing purposes, I’ve also been playing with this tool. It simulates a PIC processor on your PC and behaves (almost) identical to it. You can see what each register and memory locations (or ‘general-purpose register’) is doing as your program runs, how much time everything is taking, and so on. Of course you can never rely 100% on a simulation (after all, on the PIC there are loads of variables that the simulation tool does not include) but it is extremely useful. Unfortunately it’s not a free tool, but the basic home-use version is only € 29 and it seems to be the best PIC simulator I’ve seen so far (and also by far the most user-friendly, which is great because I want to be developing the software, not spending 3 weeks learning to use the simulation tool).

Altogether there’s an amazingly steep learning curve, but that only makes the satisfaction all the greater when you’ve got your first ‘blink a LED’ (the PIC equivalent of  ‘hello world’) working. And, of course, there’s a huge number of useful things you can do.

Note: as said before, there is an amazing lack of documentation and source code for this kind of stuff. Also for the electronics part: my father works with electronics, so I had already picked up a thing or two, but if you have zero knowledge on this kind of thing, you’re mostly on your own. Depending on how much time I have and whether I feel like it, I might be writing some tutorials and sample code/libraries for use with SDCC, which will probably show up in the menu bar on the right (but when something goes online, it’ll be posted here too, of course :) ).

Towels

April 17, 2009 · Posted in Blog · Comment 

Omg! Two posts in a very short time!

I would just like to make you aware of the fact that, at the time of writing, there are 38 days left until Towel Day (which will be on May 25th). Towel Day is a tribute to, and memorial for, Douglas Adams, the author of (amongst others) the Hitchiker’s Guide to the Galaxy, which, if you handn’t noticed yet, is one of the more brilliant five-part trilogies this world has to offer.

If you hadn’t, I strongly encourage you to read it ;)

(Also, I recently watched the original 1981 TV series, which unfortunately is only 6 episodes. As you can expect from a TV programme from that time, the quality isn’t really what people are used to nowadays, and the books are infinitely much better, but if you liked the books (in particular the first two, because the series more or less covers those) it’s worth checking out.)

Progress

April 17, 2009 · Posted in Blog · Comment 

Article about Windows 7 on Tweakers.net (Dutch)

I (sort of) read the article, and one sentence immediately stood out from the rest:

“De werkbalk is door de Microsoft-ontwikkelaars flink onder handen genomen en het resultaat kan gezien worden als een van de belangrijkste vernieuwingen van Windows.”

English: “The task bar has been drastically overhauled by the Microsoft-developers and the result can be considered one of the most important innovations in Windows.”

Great. A whole new OS release, and the most important new feature is a task bar that looks a little different.

When will Microsoft learn that people are not willing to spend money on a product that only makes progress for the sake of making progress? I mean,  if the taskbar image is the most important thing you can change, you should really consider just not making a new version for a while because apparantly what you have is good as it is.

Just look at Microsoft Office. Personally I’m using Office XP, partly because I can’t be bothered to get a newer version, but also because the one I have works just fine for me. I’m used to how this version works, I can generally find what I need quickly, and it’s easily got all the features I’d ever need to use. Upgrading would mean having to get used to a different interface, having to learn how things have changed since previous versions – not to mention the pricetag – and what do I get in return? A couple new features that I didn’t want anyway? The .docx file format? I don’t even want .docx, .doc is doing what it’s designed for perfectly well, and is in much more widespread use.

The same basic thing goes for Windows Vista or Windows 7. I just can’t see any reason why I’d want to use those over XP. Again, it’d only be a lot of effort to get used to those systems while I’m used to XP and I like working with XP. The only reasonably valid argument I can find for “up”grading is that XP is (relatively) old, but however old it may be, it’s working fine (well – usually – but that goes for any Windows version). And having more of my PC’s resources used up by the OS isn’t really a selling point either (Microsoft advertises that Windows 7 is lightweight and can also run on netbooks – but why does a lightweight OS need to take up 16 gigabytes of hard drive space? XP fits on a single CD for fuck sake, and I can think of a thousand more interesting things to fill my hard drives with).

Other applications are pretty much the same for me. I don’t usually bother installing a patch for a minor upgrade or fix (as long as it’s not a bug or whatever that has been bothering me). If I see there’s a new version I usually check out the changelog first, so that I know if it’s worth bothering to upgrade, and if it is, I know what has actually changed.

Oh well, maybe I’ll just switch to Linux some day. I’m already strongly considering making a dual-boot thingy, partly because some things are just easier to do in Linux. And until then, I ain’t upgrading anything unless it’s of at least some advantage to me to do so.

If it ain’t broke, don’t fix it.