Programming the PICAXE 08M

Posted by Nick Gammon on Sun 02 Jan 2011 11:15 AM — 5 posts, 36,154 views.

Australia Forum Administrator #0

Below is a small video I made of soldering a PICAXE 08M microprocessor with a handful of components, and writing a small program to flash two LEDs in sequence.

The processor has 8 pins:

  1. Power in (around +3 to +5v)
  2. Serial in (for programming)
  3. Port 4 (in or out)
  4. Port 3 (input)
  5. Port 2 (in, out, or out for playing a tune)
  6. Port 1 (in or out)
  7. Port 0 (in, out, and serial out for programming)
  8. 0v (common)

More technical details at http://www.rev-ed.co.uk/docs/picaxe_manual1.pdf.

Amended on Tue 26 Nov 2013 02:23 AM by Nick Gammon
Australia Forum Administrator #1
This is the program I was running:


symbol red = 1
symbol green = 2

main:

  low red
  high green
  pause 400
  low green
  high red
  pause 400
  goto main


Australia Forum Administrator #2
This is the circuit I used:



The 22k resistor limits the current (from the PC) into the serial input port.

The 10k resistor stops the serial input 'floating' whilst the download cable is not connected. This is essential for reliable operation.

The 220 ohm resistors limit the current to the LEDs (that value is probably a bit high for the 3v battery - something like 100 ohms would give a brighter LED).

You can connect the 3.5 mm jack to a 9-pin (DB9) plug to go into the serial port of your PC. My PC is too new to have a serial port so I used a special USB to serial converter cable instead.

As you can see, pins 3 and 4 are not connected. They could be used for sensors or an additional output.

Once programmed using the "in-circuit" programming technique, the programming cable can be disconnected and the device located wherever it is needed.




Approximate cost of parts

Prices in Australian dollars. At present this is roughly the same as $US.

  • PICAXE 08M processor: $3.55

    Supplier: http://www.microzed.com.au/
  • 3.5 mm stereo jack to plug programming cable into: $0.95
  • Battery holder with switch: $2.80
  • IC socket: $0.40
  • AXE026 programming cable for serial port: $7.95

    or

    AXE027 programming cable for USB port: $33.95

    (If you have an older PC with a serial port the cheaper programming cable is all you need. The AXE027 has an imbedded chip (FT232RQ) and other components inside the cable connector that converts USB to serial).

    Of course, the cable can be re-used for future projects.

    Alternatively, skip the 3.5 mm jack and the special cable, and simply run some hook-up wire to a DB9 connector and plug that straight into the PC serial port).
  • 4 resistors (22K, 10K, 220 ohm x 2): $0.20
  • Hookup wire, insulating "spaghetti", and solder: $1.00
  • Soldering iron: $13

    (If you don't own one already, of course can be re-used for future projects).
  • LEDs: $0.20 each.


Based on the above, the whole project can be constructed for under $10, excepting the parts you could re-use many times (the programming cable and the soldering iron).


Amended on Mon 03 Jan 2011 06:36 AM by Nick Gammon
Australia Forum Administrator #3
Some interesting images from an oscilloscope connected to pins 5 and 6 (where the LEDs are connected to) ...




LEDs turning on and off



This shows that the red LED turns on at point "A" and at the same time (roughly) the green LED turns off.

Then at point "B" the red LED turns off and the green LED turns on.

Note that the period is 809 ms which roughly agrees with the program. Since we asked for each LED to turn on for 400 ms and then off for 400 ms then we expect the period to be 800 ms (the period being the time when the waveform repeats). The slight discrepancy (1%) can probably be accounted for by the fact that the processor is not crystal-controlled, and thus would not run entirely at the expected speed, plus the delay executing the instructions themselves, as discussed below.

Also note the reported voltage on the LED being 2.88v. This sounds about right, as the two 1.5v batteries should deliver around 3v (in fact, measured to be 3.1v). Thus the processor is able to source 2.88v from a 3.1v supply rail.




Delay between LEDs



Zooming in, this image shows there is in fact a small delay between the LEDs switching. You would expect this because the program does this:


low green
high red


Thus there is a small time after the "low green" before the "high red" is executed.




Measured delay between LEDs



This screen shot uses "cursors" to measure the time delay between one LED turning off and the other one turning on. It shows around 288 microseconds delay.
Amended on Mon 03 Jan 2011 10:39 AM by Nick Gammon
USA #4
What an EXCEPTIONAL little piece of instructional material on the 08M!!!

I am very grateful for the time and thought you have placed in this work. I've scoured the web for something similar, and have come up empty until NOW. As a retired high school physics teacher, I really don't think I could have explained this subject better.

I hope all the readers and forum members appreciate the energy it takes to help others. WELL DONE, Mr. Gammon!

With respect,
Joe Walburn, Athens, OH USA