PICAXE Questions & Answers

Part 3 - Hardware Issues



Everything's easy, once you know how.



Part 1 - Common Questions

Part 2 - Software Issues

Part 3 - Hardware Issues

Part 4 - Miscellaneous and Esoteric Issues

Part 5 - Known Bugs and Other Problems


What is the PICAXE Operating Voltage ?

The operating voltage of the PICAXE reflects that of the underlying PICmicro it is based upon, and the operating frequency of the PICAXE. Because the PICAXE does not operate below 4MHz by default, the minimum operating voltage is not as low as the absolute minimum voltage the PICmicro can operate.

From information in PICmicro datasheets I've examined, the following is a list of operating voltages which I have been able to determine ...

Variant

PICmicro

4MHz

8MHz

16MHz

Maximum

PICAXE-08 12F629 2.1 .. 5.5 - - 6.5
PICAXE-08M 12F683 2.2 .. 5.5 3.0 .. 5.5 - 6.5
PICAXE-18 16F627/A 3.0 .. 5.5 - - 6.5
PICAXE-18A 16F819 4.0 .. 5.5 4.0 .. 5.5 - 7.5
PICAXE-18X 16F88 4.0 .. 5.5 4.0 .. 5.5 - 7.5
PICAXE-28A 16F872 4.0 .. 5.5 4.0 .. 5.5 - 7.5
PICAXE-28X 16F873A 4.0 .. 5.5 4.0 .. 5.5 4.0 .. 5.5 7.5
PICAXE-40X 16F874A 4.0 .. 5.5 4.0 .. 5.5 4.0 .. 5.5 7.5

The 'maximum' voltage is that which can be sustained for periods without damage being caused to the device. Operating at or above the 'maximum' voltage may cause permanent damage to the device.

Although it may be possible to operate below the specified operating voltage ranges, correct operation is not guaranteed.


Can I run a PICAXE from a 9V / PP3 Power Supply ?

NO.

Connecting 9V to a PICAXE even momentarily is likely to permanently damage the PICAXE or completely destroy it and may damage or destroy any other hardware that is connected to the PICAXE or its board.

Although some PICAXE Starter Kits and other hardware is supplied with a battery connector which will fit a 9V, PP3-style battery, the PICAXE must not be connected to 9V.

The only exception is when the PICAXE board has a voltage regulator which will convert the 9V to something safe for the PICAXE - Such regulators are not fitted to the PICAXE Starter Kits nor necessarily to any other hardware.

The PICAXE Starter Kits are fitted with what many think is a 9V / PP3-style battery connector because those batteries have the same connections and this is what most people are familiar with. Most battery boxes, such as those supplied with the PICAXE Starter Kits, also use the same connectors and the presence of what one might think is a 9V battery connector does not necessarily mean that it is for connecting a 9V battery to.

If you have damaged or destroyed your PICAXE by connecting a 9V battery to it, there is little else you can do other than to pull its legs off and buy a replacement chip, while reflecting upon the importance of reading the instruction sheets which accompany a product and other manuals and documentation before you dive in and power it up.


Can I run a PICAXE from a 6V Power Supply ?

Although the manufacturer did once suggest that PICAXE's ( except the PICAXE-08 ) could be run from a 6V Power Supply, and the absolute maximum power supply limits are 6.5V for the PICAXE-08 and 18 and 7.5V for the PICAXE-18A, 18X, 28, 28A, 28X and 40X, a limit of 5.5V is also specified in other parts of the component's data sheet; in common with many other Integrated Circuits, the typical operating voltage is 5V, although PICAXE processors will work at lower voltages.

It should also be borne in mind that, where the PICAXE is used in conjunction with other electrical devices, they may not be as tolerant to voltages above 5V as the PICAXE is, and using a voltage that is too high may cause irreparable damage to those devices and the PICAXE.

My recommendation is that the PICAXE should not be powered by anything other than a 5V (nominal) power supply, and where battery operation is required, they should be powered at 4.5V ( 3 x AA/AAA 1.5V Alkaline cells ) or 3.6V ( 3 x AA/AAA 1.2V NiCd or NiMH cells ).

Note that rechargeable batteries, although nominally rated at 1.2V or 1.25V depending upon whose information one reads, will often present a voltage greater than that when fully charged ( reaching nearly 1.5V ), so using four rechargeable batteries can often be greater than the 5.5V maximum stated in the datasheets.

Where a regulated power supply is used; this should be of the 5V (nominal) type.


How do I build a Regulated 5V Power Supply ?

A complete discussion of power supply design is unfortunately beyond the scope of this article, however the principal of a standard 'Linear Power Supply' is as shown below ...

                                           REG1  7805
               |\| D1                      .--------.
10V DC/AC  ----| >-----.------------.------| I    O |-----.--------->  +5V
               |/| +   |            |      |        |     |
                       | +          |      `---.----'     |
                     --^-- C1     --^-- C2     |        --^-- C3
                     =====        --.--        |        --.--
                       | ?uF        | 100nF    |          | 100nF
                       | See text   |          |          |
           ------------^------------^----------^----------^--------->  0V

Power Diode D1 is used to allow either an AC or DC voltage to be applied to the power supply, rectifying the AC voltage, and providing reverse polarity protection for DC. It is highly recommended that this diode is fitted to all power connections, although it may not be suitable for battery powered devices, as the diode may drop up to 0.7V of the input voltage.

The Electrolytic Capacitor C1 is to smooth the rectified AC voltage and any minor changes in DC voltage. It should be a reasonably high uF rating, and rated according to the input voltage to be applied, often twice the voltage for AC. A good choice is 470uF/16V for 9V battery operation and 4700uF/25V for an external 10V mains plug-in power supply module. Take care to mount the capacitor with the correct polarity; one of the legs will normally be marked as '-' which should go to the 0V power line.

Capacitors C2 and C3 are to 'stabilise' the Voltage Regulator, and should be fitted as close as possible to the Regulator legs.

The Voltage Regulator REG1 is a standard +5V Regulator whose physical format will depend upon its current capacity. The current capacity needed will depend upon the current drawn by the PICAXE and all other components connected to the same power supply. As a rule of thumb; every LED will draw 10mA and an LCD backlight will draw 50mA. The PICAXE itself may draw up to 300mA. It is always best to be cautious about current consumption, and assume that everything which could be powered is, and will draw its maximum current. Most TO220 ( slab-style ) regulators can handle 1A of current, and are designed for mounting to heatsinks. Other Voltage Regulators will provide even higher currents.

Smaller regulators, capable of supplying circuits where only 100mA will be drawn, are available and will often be in a transistor-style, TO92, package.

Regulators dissipate the difference between input voltage and the 5V they produce as output as heat, and therefore the higher the input voltage, the greater the amount of heat will be generated. The amount of heat will also increase as the current drawn increases, and it may be necessary to fit a heatsink to the regulator.

While a small difference between input voltage and 5V will reduce the amount of heat dissipated, most regulators require that the input voltage is about 8V to work correctly. There are Low Drop-Out ( LDO ) Regulators which will work with a lower input voltage, and are very suitable for regulating battery supplies such as 9V PP3's.

It is recommended that you check the specification of the Voltage Regulator to determine its minimum and maximum input voltage range, its current capacity and what short-circuit and over temperature protection it offers, and, in particular, its pin-out. Likewise, a Voltage Regulator should be chosen based upon the current drawing requirements of your circuit and the power source which is to be supplied to it.

Although it is possible to construct a regulated power supply using nothing more than the regulator itself, it is recommended that all the components in the above circuit are used, to prevent problems occurring which are difficult to track down should they emerge, especially if they are intermittent.

A project to build a more comprehensive power supply with a fixed 5V plus variable 1.25V to 20V output is described on the following page ...

  Variable Voltage Power Supply


What are De-Coupling Capacitors ? Do I need them ?

De-coupling capacitors are usually 100nF capacitors which are placed across the 0V and +V power supply lines close to every chip connected to those power lines. They are used to supress any electrical noise that is on the power supply or caused by the chip's operation and can help to ensure reliable operation of the circuit.

It is not always necessary to provide such de-coupling capacitors, especially when a battery power supply is being used, but the general recommendation is to fit one decoupling capacitor for every IC on a boad.

One of the best answers to this question I've found is from Wouter van Ooijen in the Netherlands ...

"Probably ( let's say 9 out of 10 times ) no. Do you need to look right and left to survive crossing a quiet street ? Probably not. Is that sufficient reason not to ?"


How do I drive more than one LED from an Output Pin ?

To turn on a LED when an Output Pin is high, connect the pin through a resistor, into a LED which has its pointy end to 0V.

To turn on a LED when an Output Pin is low, connect the +V through a resistor, into a LED which has its pointy end connected to the Output Pin.

You can connect both of these to the same Output Pin; the one to 0V will be on when the Output Pin is high and the other will be on when the Output Pin is low. The downside is that one of the LED's will alway's be on, and only one can be on at a time, but you can often make them both appear to be on together by repeatedly toggling the Output Pin high and low rapidly.

+V ----------.-------------------.------------
             |                  .|.
             |                  | |
             |                  |_|
             |                   |
       .-----^-----.      .------{
       |    +V     |     _|_     :
       |           |    _\./_    :
       |           |      |      :
       |    Output |------{      :  Optional
       |           |     _|_     :    link
       |           |    _\./_    :
       |    0V     |      |      :
       `-----.-----'      `------{
             |                  .|.
             |                  | |
             |                  |_|
             |                   |
0V  ---------^-------------------^------------

You can have more than two LED's from two pins by connecting LED's ( and their resistors ) between the two Output pins in opposite directions, plus adding more as described above. Not all LED's will be individually controllable and it takes a bit of effort to work out what configurations you want to use, but basically two pins gives you four possible LED display states, three pins gives eight.

+V ----------.--------------.----------.---------------------------------
             |             .|.        .|.
             |             | |        | |
       .-----^-----.       |_|        |_|
       |    +V     |       _|_        _|_      .--------.---------.
       |           |    A _\./_    B _\./_     |        |         |
       |           |        |          |       |       .|.      __|__
       |  Output 1 |--------{          |       |       | |    F  /_\
       |           |        }----------|-------'       |_|        |
       |           |        |          |                |        .|.
       |           |        |          }-------.       _|_       | |
       |  Output 2 |--------|----------{       |    E _\./_      |_|
       |           |       .|.        .|.      |        |         |
       |           |       | |        | |      |        |         |
       |    0V     |       |_|        |_|      `--------^---------'
       `-----.-----'       _|_        _|_
             |          C _\./_    D _\./_
             |              |          |
0V ----------^--------------^----------^---------------------------------

Checkout the useful Microchip Application Note which gives a number of clever hardware tricks ...


How do I read a voltage using a PICAXE ?

You can read a voltage into a PICAXE by using either an Analogue Input Pin or a Digital Input Pin. On some PICAXE's an Input Pin may be used as either an Analogue Input or a Digital Input depending upon which command is used to read that pin, while on others they may be separate pins.

The voltage which is fed into the Input Pin must never exceed the voltage at which the PICAXE is operating or the device may be irreparably damaged. If the voltage you wish to read is greater than the PICAXE operating voltage you must run the voltage through a resistive divider or some other active circuitry to bring it to an acceptable level. How to do this is beyond the scope of this article, but if you are reading a potentiometer or a Light Dependent Resistor ( LDR ) or an analogue Thermister in a resistive divider, one end of the potentiometer or divider should go to 0V and the other to the power supply of the PICAXE.

If the voltage you are reading comes from another chip which switches between a logic low and logic high level, you will most likely want to connect it to a Digital Input, and read it by using a 'pinN' variable ( when N is the number of the Input Pin ) or by using the 'pins' variable which will read all eight Digital Input Pins together.

You should check what the output levels of the chip you are reading from are from the datasheet and check that they are compatible with the PICAXE; the output voltage from the chip must not exceed the power supply voltage the PICAXE is running on. If the two chips are using the same power supply then there should rarely be a problem.

If the voltage to be read is variable and doesn't have just a high and low state, or there is a high and low state but the voltage takes a time to change ( "Slow Rising" and "Slow Falling" waveforms ) you will need to read these as Analogue Inputs or use an external Schmitt Trigger Gate before a Digital Input to create the fast switching change between low and high or vice-versa which the Digital Input expects. Any voltage line which has anything but minimal capacitance on it will be a slow rising and falling waveform.

Any voltage into a PICAXE Digital Input will be read as a logic low (0) when it is below a certain voltage, and will be read as a logic high (1) when it is above another voltage. Between the two voltage points, what is read is neither guaranteed to be a logic low or a logic high, and what is read will rarely be repeatable over time, nor the same on any other PICAXE. This is why Digital Inputs require two-state inputs ( low or high ) and why the signal must switch quickly between the two states.

A Schmitt Trigger has separate voltages to determine when its output will switch for rising and falling waveforms. The actual voltages at which the output will switch will depend upon the device used and this information can only be found in the device's data sheet, but we can describe how a Schmitt Trigger operates which switches at a rising voltage of 2V and at a falling voltage of 1V ...

As the input voltage to the Schmitt Trigger rises, it will reach the 2V point and the output will switch from low (0) to high (1). The output will remain high until the input voltage drops back down and reaches the 1V point when the output will switch back from high to low. The output will remain low until the voltage again reaches the 2V point and the output will switch back to high again.

The advantage that a Schmitt Trigger has over any mechanism which uses a single point to switch its output high or low ( such as an analogue comparator ) is that it is immune to noise on the input line. Even a very clean signal will have some noise on it, and, at the point where a single voltage point switcher would change, that noise may cause the output to switch rapidly between high and low at whatever frequency the noise has. It would be entirely by luck whether you read that voltage as being a high or a low. This is exactly the problem which a Digital Input intrinsically has, which is why it specifies that only voltages below a certain level are considered as logic lows and only those above another level are considered as logic highs.


Can I have a common reset to multiple PICAXE's ?

If you have a design which uses a number of PICAXE's it may often be necessary to have them all reset at the same time. This can easily be achieved by simply connecting all PICAXE Reset lines together ...

+V -----------.-------------------.-----------------------.------------
              |                   |                       |
             .|.                  |                       |
         4K7 | |            .-----^-----.           .-----^-----.
             |_|            |    +V     |           |    +V     |
              |             |           |           |           |
              |             |           |           |           |
              }------.----->| Reset     |     .---->| Reset     |
              |      |      |           |     |     |           |
              |      |      |           |     |     |           |
            | O      |      |    0V     |     |     |    0V     |
   "RESET" ||        |      `-----.-----'     |     `-----.-----'
            | O      |            |           |           |
              |      `------------|-----------^-----------|------------
              |                   |                       |
0V -----------^-------------------^-----------------------^------------

A push-to-make 'Reset Button' can be fitted to all PICAXE's except the PICAXE-08 and 08M between the Reset pin and 0v; pushing the button will reset the PICAXE. Having a 'Reset Button' is entirely optional but can often prove to be very useful.


How do I run a PICAXE-08 at 8MHz ?

The simple answer is; you can't. The PICAXE-08 can only run at 4MHz.


How do I run a PICAXE-08M at 8MHz ?

Include one of the following commands at the start of your program ...

        SETFREQ M8      ' Sets 8MHz operation
        SETFREQ M4      ' Sets 4MHz operation


How do I run a PICAXE-18 at 8MHz ?

The simple answer is; you can't. The PICAXE-18 can only run at 4MHz.


How do I run a PICAXE-18A at 8MHz ?

Providing you have Programming Editor 4.0.6 or later, the PICAXE-18A officially supports operation at 8MHz by including one of the following commands at the start of your program ...

        SETFREQ M8      ' Sets 8MHz operation
        SETFREQ M4      ' Sets 4MHz operation


How do I run a PICAXE-18X at 8MHz ?

Include one of the following commands at the start of your program ...

        SETFREQ M8      ' Sets 8MHz operation
        SETFREQ M4      ' Sets 4MHz operation


How do I run a PICAXE-08 or 08M at 16MHz ?

The simple answer is; you can't. The PICAXE-18 can only run at 4MHz, and the PICAXE-08M can only run at 4MHz or 8MHz.


How do I run a PICAXE-18, 18A or 18X at 16MHz ?

The simple answer is; you can't. The PICAXE-18 can only run at 4MHz, and the PICAXE-18A and 18X can only run at 4MHz or 8MHz.


Can I use non-standard operating speeds ?

You can operate any PICAXE at 4MHz and, for those which support such operations at 8MHz or 16MHz.

Some PICAXE's may be under-clocked and some may be over-clocked by either poking control registers within the PICAXE or by changing the crystal or resonator.

The Programming Editor will not however be able to communicate with a PICAXE if it is not running at one of the officially supported operating speeds for that PICAXE variant, which may require the code to have a 'PAUSE' at its start if the under or over-clocking is done in software, or a change made back to an expected crystal or resonator value.

For those who are operating their PICAXE's with crystals or resonators which are not officially supported, it would be advisable to build a download board fitted with a recommended operating speed crystal or resonator, to avoid having to change the crystal or resonator in your target hardware to download. The alternative is to switch between crystals or resonators on your target hardware to facilitate downloading and operation at the required speeds, but this can be complex to design and implement effectively and may cause unstable operation.


What are the consequences of using 8MHz or 16MHz operation ?

The entire PICAXE range is designed to operate at 4MHz and will do so unless the PICAXE has been told to operate at 8MHz using a 'SETFREQ' command, or, in the case of the 28, 28A, 28X and 40X by fitting an 8MHz or 16MHz crystal or resonator.

A PICAXE will not execute some commands as expected when it is being over-clocked or under-clocked. Commands which will not work, or work differently, when running at anything but 4MHz operating speeds are ...

  • INFRAIN and INFRAIN2
  • INFRAOUT
  • KEYIN
  • KEYLED
  • READTEMP and READTEMP12
  • READOWSN
  • SERVO

The following commands will not work the same as they do at 4MHz when a different operating speed is used ...

  • COUNT
  • DEBUG
  • I2CSLAVE ( and affects I2CREAD, I2CWRITE, READI2C and WRITEI2C )
  • PAUSE
  • PLAY
  • PULSIN and PULSOUT
  • PWM and PWMOUT
  • SERIN, SEROUT and SERTXD
  • SOUND
  • TUNE
  • WAIT

Note that on the PICAXE-08M, 18A and 18X, where 'SETFREQ' is used to change the speed of operation, placing a 'SETFREQ m4' before any of the commands which need to be executed at 4MHz and another 'SETFREQ m8' afterwards allows 8MHz operation normally and allows access to most of the 4MHz specific commands ...

    PowerOnReset:

        SETFREQ m8

    Loop:

        GOSUB Execute4MHzCommands
        GOTO Loop

    Execeute4MHzCommands:

        SETFREQ m4
        SOUND PIEZO_PIN,(100,10,120,20)
        PAUSE 1000
        SETFREQ m8
        RETURN

The SERVO and PWMOUT commands require continual 4MHz operation to work correctly and cannot be forced to work as expected using this technique.

Because the PICAXE-28, 28A, 28X and 40X have their operating speeds changed by crystal or resonator choice, it is not possible to force their operating speeds back to 4MHz using this technique.


PICAXE is a trademark of Revolution Education Ltd. These PICAXE pages are produced entirely independantly of Revolution Education Limited and may not reflect the opinion of Revolution Education Limited or its agents. The information provided is based upon and derived from information published by Revolution Education Limited, other sources of PICAXE information and the author's own experiments and prior experience. The views expressed by the author do not necessarily represent those of Revolution Education Limited or its agents. While every effort has been made to ensure that the information on these PICAXE pages is accurate and correct, the author can accept no responsibility for any errors or ommissions which do occur. The information provided is used entirely at your own risk.





Associated Articles

  The PICAXE Processors
  PICAXE News
  PICAXE Questions & Answers
  PICAXE Comparisons
  PICAXE Pinouts
  PICAXE Serial Interfacing
  PICAXE Serial Interfacing
  PICAXE Infra-Red Interfacing
  PICAXE Wireless Interfacing
  PICAXE LCD Interfacing
  PICAXE LCD Interfacing
  A Real-Time Clock for the PICAXE-18X
  PICAXE Optimisations
  The PICAXE Birthday Box Project
  PICAXE Telephone Exchange Simulator
  The Brainf**ked PICAXE
  The PICAXE Extended Programming Interpreter
  Build Your Own Basic Stamp
  Tech Toys



Sites to Visit

  PICAXE Home Page
  Revolution Education Ltd

  Tech-Supplies Ltd



Site Navigation

  Home Page
  What's New
  Search
  Add Bookmark
  Have Your Say
  Guestbook




First published on Thursday the 25th of February, 2004 at 14:38:14
Last upload was on Friday the 7th of January, 2005 at 15:57:14