Make Electronics

(nextflipdebug2) #1
What Next? 305

Experiment 34: Hardware Meets Software

FundAmentAls


Basic PICAXE parameters


Here are some of the most useful parameters of the PICAXE:



  • The PICAXE requires 5 volts DC, regulated.

  • The inputs and outputs of the PICAXE are compatible
    with 5-volt logic chips. You can attach them directly.

  • Each PICAXE pin can sink or source up to 20mA. The
    whole chip can deliver up to 90mA. This means that
    you can run LEDs directly from the pins, or a piezo
    noisemaker (which draws very little current), or a
    transistor.

  • You can use a chip such as the ULN2001A Darlington
    array (mentioned in the previous experiment) to am-
    plify the output from the PICAXE and drive something
    such as a relay or a motor.

  • The chip executes each line of your program in about
    0.1 milliseconds.

  • The 08M chip has enough flash memory for about 80
    lines of program code. Other PICAXE chips have more
    memory.

  • The PICAXE provides 14 variables named b0 through
    b13. The “b” stands for “byte,” as each variable occupies
    a single byte. Each can hold a value ranging from 0
    through 255.

  • No negative or fractional values are allowed in
    variables.

  • You also have 7 double-byte variables, named w0
    through w6. The “w” stands for “word.” Each can hold a
    value ranging from 0 through 65535.

  • The “b” variables share the same memory space as the
    “w” variables. Thus:

    • b0 and b1 use the same bytes as w0.

    • b2 and b3 use the same bytes as w1.

    • b3 and b4 use the same bytes as w2.

    • b5 and b6 use the same bytes as w3.

    • b7 and b8 use the same bytes as w4.

    • b9 and b10 use the same bytes as w5.

    • b11 and b12 use the same bytes as w6.

    • b13 and b14 use the same bytes as w7.
      Therefore, if you use w0 as a variable, do not use b0 or
      b1. If you use b6 as a variable, do not use w3, and so on.

    • Variable values are stored in RAM, and disappear when
      the power is switched off.

    • The program is stored in nonvolatile memory, and
      remains intact when the power is off.

    • The manufacturer’s specification claims that the
      nonvolatile memory is rewritable up to about 100,000
      times.

    • If you want to attach a switch or pushbutton to a pin
      and use it as an input, you should add a 10K pull-down
      resistor between the pin and the negative side of the
      power supply to hold the pin in a low state when the
      switch is open. Figure 5-143 shows how pull-down
      resistors should be used in conjunction with a SPST
      switch or a pushbutton.

    • On the 08M chip, if you apply a varying resistance
      between Logic Pins 1, 2, or 4, and the negative side of
      the power supply, the chip can measure it and “decide”
      what to do. This is the “Analog-Digital Conversion”
      feature—which leads to our next experiment.




10K 10K


1
2
3
4 5

6

7

8

PICAXE

08M

Figure 5-143. The PICAXE can respond to the state of a switch
or button attached to any of its input-capable pins. A 10K resis-
tor must be used to pull down the state of the pin when the
contact of the switch or button is open. Otherwise, you may
get unpredictable results.
Free download pdf