Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ Electronics ➜ Microprocessors ➜ Programming the PICAXE 08M

Programming the PICAXE 08M

Postings by administrators only.

Refresh page


Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Sun 02 Jan 2011 11:15 AM (UTC)

Amended on Tue 26 Nov 2013 02:23 AM (UTC) by Nick Gammon

Message

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.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 02 Jan 2011 11:57 AM (UTC)
Message
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



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 02 Jan 2011 09:25 PM (UTC)

Amended on Mon 03 Jan 2011 06:36 AM (UTC) by Nick Gammon

Message
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).



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 03 Jan 2011 12:24 AM (UTC)

Amended on Mon 03 Jan 2011 10:39 AM (UTC) by Nick Gammon

Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Joe Walburn   USA  (2 posts)  Bio
Date Reply #4 on Thu 07 Jul 2011 03:39 PM (UTC)
Message
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

"If we don't hang together, we will most assuredly hang separately." Ben Franklin during dark days of American Revolution
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


29,405 views.

Postings by administrators only.

Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.