I had previously installed the software that came on a CD with my kit. This installed the "PICAXE Programming Editor," the manuals, which I didn't look at much (it's a guy thing), and a driver for the USB programming cable (which I didn't have). Installation was quick and easy. The screen is simple and fairly intuitive and there are large icons for the common tasks as illustrated below:
(Click here to see a larger, more detailed image.)
In my case, I had to change the COM port from COM1 to COM3 -- using the "Options" tab -- for my USB-to-serial lead. I then entered -- from memory -- a program that was on the instruction sheet for my kit, whose purpose is to make the three LEDs flash in sequence. Here's that program:
The first time I tried to download the program to the board, I was presented with an error message telling me that the wrong hardware was connected -- the environment was set up for a 20M2 chip and it had found an 08M2. I corrected this (the error message helpfully took me to the "Options" screen to do this) and I tried again. This time I got another error message telling me that Pin C.3 was input only. My port numbers should have been 0, 1, and 2, not 1, 2, and 3 (d'oh!). This was also quickly corrected and my little board was soon flashing its three LEDs in sequence. Observant readers may have noticed that the correct program (without comments) is in the screenshot above.
I quickly tried a few other things. I had earlier skimmed through the tutorials and recalled that there was a "SOUND" command that made tones. The editor, through the "Help" tab, offers easy access to the manuals. These are in three parts: "Getting Started," which offers a wealth of general information on how microcontrollers work, and more specific information on the PICAXE Chips and system; "Basic Commands," which -- as you might expect -- provides a command reference; and "Interfacing Circuits," which has some basic electronic circuits for inputting to and outputting from your PICAXE pins.
A few seconds later, having consulted the command reference for the "SOUND" command, I had a loop program going making a rising tone. I then tried making a 3-bit binary counter using nested FOR…NEXT loops. I cut and pasted a bit here and got distracted and did not notice that my last "NEXT" statement referred to B0 instead of B2. When I tried to download the program, the error message told me specifically that B0 should be B2. Probably not the hardest thing to deduce, but I was impressed at how helpful the error messages were whenever I did anything wrong -- this is a big plus for anyone starting out.
With my previous experience with BASIC, I found the programming very easy. I did have to refer to the manuals a bit, but mostly for commands and naming conventions. For instance, variables will be named "bitx," "bx," or "wx" depending on whether they are bit variables, byte variables, or (16-bit) word variables. Also, these variable overlap in memory; for example, 'bit0' through 'bit7' are the same as byte 'b0,' so you have to keep your wits about you there. On the plus side, this can be extremely useful if you want to extract bits from a byte. To read a digital input, you use the "PINx" statement, where 'x' refers not to the actual pin number but to the port number. Meanwhile, outputting digital values -- as shown in my program above -- uses "HIGH x" or "LOW x." Some of this is a bit tricky at first, but really -- as compared to the GWBASIC and QuickBasic that I was used to -- it's just a matter of getting used to some new commands and inputting and outputting using pins and ports instead of keyboard and screen. So, not too much of a learning curve at all.
Max was right. I am having a lot of fun. I can already see the limitations of the PICAXE system, but that is looking from the viewpoint of professional applications. For the kind of stuff I get up to in my workshop, the PICAXE platforms are pretty much ideal. I am already thinking about more programming -- using the ADC for example -- and using some of the finer features of the programming environment, and getting a bigger PICAXE chip to play with, and... But my bed is calling, so I'll leave all that for another day and -- if Max will let me -- another blog.