The USBS-PA3 PICAXE
Programming Adapter
The simple mini-stereo jack adapter that we constructed in Chapter 1 is all we really need to connect a breadboard project to the AXE027 programming cable. However, this time around we’re going to construct another adapter that will further simplify the interface between your computer and any PICAXE breadboard project. This adapter (which we’ll call the USBS-PA3) includes the 10k and 22k resistors required in the standard programming circuit, so we’ll be able to use it in all the projects we’re going to implement in Part One of the book.
All the parts required for this project are available on my website and are listed in the Parts Bin. Two of the parts require a brief explanation. First, the high-profile mini-stereo jack has the same pin-out as the low-profile version that we used in our first project. The difference is that the
high-profile jack sits high enough on the stripboard to allow us to include parts underneath it before soldering the jack in place. This feature will enable us to significantly reduce the size of the stripboard. Also, both resistors need to be the smaller 1/6-watt size to save a little more space.
Figure 2-6 presents the schematic for the USBS- PA3 adapter, and Figure 2-7 is the stripboard layout, which includes column and row labels analogous to those of a standard spreadsheet. I’ll use this labeling arrangement in all our stripboard projects to make it easy to refer to specific locations when necessary; for example, “Next install the 22k resistor between holes D1 and D5.” Note that the row labels in Figure 2-7 are reversed for the top and bottom views—this reflects the physical reversal that happens when you flip the board to view the bottom. Of course, there are at least two ways to flip a board (horizontally or vertically). When working on the stripboard, it’s important to make sure you always flip the board in the same manner that the layout has been flipped to avoid the possibility of cutting a trace at the wrong spot.
One final point before we actually begin
construction: The leads on most of the components that we will be using in our projects (resistors, capacitors, diodes, etc.) are fairly long; when they are snipped off after soldering the component in place, most of them are still about an inch long. These “off-cuts” are worth saving because they can
Chapter 2 I Introduction to Stripboard Circuits 21
Stripboard, small
Mini-stereo jack, 3.5-mm, high-profile Resistor, 10k, 1/6 watt
Resistor, 22k, 1/6 watt
Resistor, 100k, 1/4 or 1/6 watt (see text) Header, male, 10-pin, “reverse-mountable”
serve three helpful functions. First, you can use them as short jumper wires. Second, because they are significantly thinner than standard jumper wire, the ends of two of them can fit in the same hole, which is sometimes helpful in a stripboard layout. Third, there are times when it’s necessary to solder a jumper between two traces on the bottom of a stripboard, and the thinness of off-cuts makes them ideal for this purpose.
Okay, we’re finally ready to construct the USBS-PA3 board. The following list of directions may seem a little long for such a simple project. In subsequent projects, I’ll assume you are familiar with some of the details involved and make the
instructions mercifully shorter. But for this project, I think the extra detail is helpful. Finally, it’s always a good idea to read through the entire project to be sure you fully understand the sequence before actually beginning the assembly procedure.
1. Cut a piece of stripboard to the required size (five tracks of five holes each) and smooth the edges.
2. Use a small pair of diagonal pliers to snip off the pin on the jack that would have been inserted into hole C4 (the one in the middle of the row of three pins).
USBS-PA3 schematic
Figure 2-6
Top and bottom views of USBS-PA3 stripboard layout
3. Use a 3/64-inch drill bit (1.5 mm should also work, but I haven’t tested that) to widen the holes at A1, A3, A5, C1, C3, and C5 to accommodate the mini-stereo jack pins and plastic supports. If you can’t find a suitable drill bit, file the jack’s pins slightly until they fit in the holes at A3, C1, and C5, and slice off the small round plastic nipples that would have sat in the holes at A1, A5, and C3.
4. Use a pair of needle-nose pliers to straighten the pins of the jack and test-fit it in the stripboard, but do notsolder it at this point.
5. Cut the trace between holes C5 and D5.
6. Clean the traces with a Scotch-Brite or similar plastic abrasive pad.
7. Insert the two resistors as indicated. Solder and snip the leads at B1, D1, and D5, but do
notsolder or snip the lead at B4 yet.
8. Snap off a three-pin section of the reverse- mountable male header and insert it from the top of the board in the position indicated in Figure 2-7. Using the same procedure we employed in Project 1, support the stripboard and header on a breadboard while you solder the header in place.
9. Remove the stripboard assembly from the breadboard and snip off the short ends (on the top of the board) of the soldered header. You may also want to file the cut ends of the header pins smooth at this point.
10. Insert the mini-stereo jack into the board so that its three remaining pins are inserted into holes A3, C1, and C5. Make sure that the jack is fully inserted into the board.
11. Flip the board and stereo jack upside-down again and place it on a flat surface. Bend the unsoldered lead from B4 to the stereo jack pin at C5. Snip the lead so that it’s just long enough to bend around the pin at C5.
12. Use needle-nose pliers to pinch the lead around the pin at C5, and use a small, flat
screwdriver blade to press the lead flat against the stripboard.
13. Solder the pins/leads at holes A3, B4, C1, and C5. Because the adapter is going to be inserted into a breadboard, it’s a good idea to snip the protruding pins of the jack as short as possible and file them smooth.
14. Use an old toothbrush and isopropyl alcohol to clean the flux from the bottom of the board, and allow it to dry.
15. Inspect the stripboard carefully for accidental solder connections and other problems.
Hello Again
Figure 2-8 is a photo of the completed USBS-PA3 adapter. In case you decide to paint the tops of the three header-pins, I have again indicated the colors that I used.
Figure 2-9 shows the USBS-PA3 installed on the “Hello World” breadboard circuit that we developed in Chapter 1. If you look closely at the photo, you will see a resistor tying the 08M2’s
Chapter 2 I Introduction to Stripboard Circuits 23
Completed USBS-PA3 adapter
serin pin to ground. What you can’t see in the grayscale photo is that its value is 100k. This small addition to the circuit is necessary because of how the Programming Editor initiates a program download to a PICAXE processor, but we need to back up a bit before explaining the details of the download process.
When an input pin is not connected to any part of a circuit, it’s said to be “floating,” which means that it isn’t tied either high or low and the voltage level on the pin can randomly fluctuate, or “float,” between high and low values. Theoretically, all unused input pins should always be tied either high or low, but in practice, this rule is often ignored. If you look at our “Hello World” circuit, you can see that input 3 (external pin 4) has been left floating. In spite of that omission, the circuit works fine. However, all inputs that areused in a circuit must
be tied high or low at all times, and the serin input line is always in use in every PICAXE circuit. This is because the processor is continually checking the state of its serin pin (in the background of the running program) to determine whether ProgEdit (or AXEpad) wants to initiate a new program download.
In other words, whenever a program is actively running on a PICAXE chip and you decide to download an edited (or entirely different) program, ProgEdit “interrupts” your running program to initiate the new download. It does this by pulling the serin pin high. Whenever the serin pin goes high (even for 1 microsecond), your program will stop running and the processor will start looking for the new download that it expects to receive. Since a floating pin can easily go high or low randomly, the serin pin must be held low at all times in order for your program to run reliably. That way, the only time the serin pin is high is when ProgEdit has deliberately raised it to initiate a new program download.
If you look back at the USBS-PA3 schematic presented in Figure 2-6, you can see that the 10k and 22k resistors in the standard programming circuit tie the serin pin to Ground. However, the USBS-PA3 is specifically designed to be easily movable from one project to another, and there definitely will be times when we will want to be able to run the program in a project that does not have the USBS-PA3 attached. The 100k resistor that ties the serin line to Ground is what enables us to do this. If we didn’t include it and then removed the USBS-PA3, the circuit would function
erratically or not at all.
To test this assertion, try the following
experiment. Set up the “Hello World” circuit with the USBS-PA3 installed but without the 100k resistor installed. Next, power the circuit; the LED should start blinking. Now, remove the USBS-PA3 from the breadboard two or three times; the LED may or may not stop blinking. If it stops blinking, reinsert the USBS-PA3 and it will start again. If it continues to blink without the USBS-PA3 in the circuit, touch the serin pin with your finger and the blinking will probably stop because your finger has changed the voltage level on the floating serin pin. Next, try the same procedure but this time with the 100k resistor tying the serin pin to
USBS-PA3 adapter installed on “Hello World” breadboard
Ground. In this case, the LED should continue blinking when the USBS-PA3 is removed and when you touch the serin pin with a finger. In other words, the serin line must always be tied to Ground in order for a program to function reliably.
At this point, I can almost hear you murmuring, “What’s the big deal—just leave the 10k and 22k resistors on the breadboard!” That may be the simpler approach, but it does have two disadvantages. First, it requires more board
space—for a breadboard circuit, this doesn’t matter very much, but for some very small PC boards, even an extra resistor can use up too much board
real estate. More importantly, putting both resistors in every circuit provides just one more opportunity to make a mistake. In my experience, it’s better to tie the serin pin to Ground with a 100k resistor and keep the PICAXE programming circuit separate, as we have done with the USBS-PA3. That’s the approach I will use throughout this book, but you can certainly modify any or all of the projects to include the programming circuit if you prefer. In Part Two of the book, we’ll construct additional programming adapters for specific purposes as the need arises, but the USBS-PA3 adapter is all we need to complete the projects in Part One.
Designing and Building a
+5V Regulated Power Supply
C H A P T E R 3
OUR SIMPLE4.5VBATTERY-POWEREDsupply was a
quick and easy way to get started with our “Hello World!” project. In fact, 4.5V is enough to power any current PICAXE processor, as you can see from the PICAXE supply ranges presented in Table 3-1. In addition, the M2-class chips, as well as the 20X2 and the low-voltage (3V) versions of the 28X2 and 40X2, can actually run on a 2-AA supply. However, with a supply voltage that low, the downloading process is not always reliable, so if you design a low-voltage project, you will still need at least a 4.5V supply for downloading your program to the processor.
When designing a project, it’s important to check the voltage requirements of each of the components that you may be using. For example, many LCD displays require a 5V supply to function correctly, so a 3-AA supply isn’t sufficient. There’s another problem with battery- powered projects that also must be taken into
consideration: Over time, the output voltage will gradually decrease and then drop rapidly as the battery pack becomes depleted. In projects as simple as “Hello World!” all that will happen is the LED will gradually grow dim and eventually not light at all. However, if a project involves any sort of critical timing functions and/or analog-to- digital conversion (ADC) voltage measurements, the accuracy of the program’s computations will suffer as the voltage decreases over time. Because of the problems associated with low-voltage battery supplies, it’s a good idea to also have a regulated 5V power supply available for projects that require it. In fact, it’s simpler to power all your PICAXE projects with a regulated 5V supply, at least during the development stage, and only switch to battery power in the final version of a project that requires it.
Of course, you could always purchase a commercial5V power supply for this purpose, but the fact that you’re reading this book suggests that you prefer building your own equipment, so that’s exactly what we’re going to do in this chapter. Also, we’re going to use our 5V regulated supply project as a “design study” for the process of using Microsoft Word to develop stripboard layouts.
27
PICAXE Processors Supply Range
08M2, 14M2, 18M2, 20M2 1.8V to 5.5V 20X2 1.8V to 5.5V 28X2, 40X2 (3V) 1.8V to 3.6V 28X2, 40X2 (5V) 4.2V to 5.5V
TABLE 3-1 Supply Range for Selected
Designing a +5V Regulated
Power Supply for
Breadboard Circuits
Figure 3-1 presents the schematic for our 5V regulated power supply. The circuit is a typical design that you have probably seen many times before. All of the parts are available on my website. Two of them require a brief explanation: the power connector and the switch.
There are several different sizes of power connectors on the market. The one I chose mates with a power plug that has a 2.1-mm ID (inner
diameter) and a 5.5-mm OD (outer diameter). That size plug is commonly available and easily
obtained from surplus vendors or obsolete
answering machines, modems, etc. If you decide to use a different size power connector, you may need to modify the layout slightly to accommodate it.
The pins of the switch I chose are spaced on 0.1-inch (2.54-mm) centers, which makes it easy to install in a stripboard circuit, but it’s only capable of switching currents up to a maximum of 300mA. The switch’s current limitation may seem a little too low, since the 7805 regulator is capable of sourcing a maximum of 1A. However, the 7805 requires a good heat sink to handle currents that large. Without one, it’s only capable of managing something in the vicinity of 300mA. Also, more robust switches tend to have pins that are too large and inconveniently spaced to be easily accommodated in a stripboard circuit. Those considerations, as well as the fact that 300mA is more than ample for all the projects we will be constructing, led me to choose the specific switch in the parts list. This switch has two rows of pins that attach it more solidly to the stripboard than the more usual single-row arrangement, but it’s still a single-pole, double-throw (SPDT) switch. If you would prefer maximum output from the power supply, I’m sure the layout could be modified to accommodate a heftier switch.
Schematic for +5V regulated power supply
Figure 3-1
Stripboard, large
Two bypass capacitors, 0.01F each Capacitor, electrolytic, 47F Capacitor, electrolytic, 100F Diode, 1N4001 LED, 3-mm, resistorized 7805 voltage regulator Power connector Switch, DPDT
Two headers, male, 10-pin, “reverse-mountable”
Using Templates for
Stripboard Layouts
Before we actually construct our circuit, let’s focus on the process of using the drawing features of Microsoft Word to develop the stripboard layout. Since we want our power supply to be convenient to insert into a breadboard, it needs to be as wide as a standard breadboard (i.e., 2.0 in., or 5.1 cm). In other words, our circuit will require 20 traces to span the two sets of power rails on a standard breadboard. Also, as we’ll soon see, the circuit is going to require nine holes in each trace to accommodate the necessary parts; that’s a total of 180 holes. Furthermore, a trace can’t be a single object because we need to be able to delete a section between any two holes to indicate that the trace is to be cut between those two holes. (We’ll delete a hole to signify a cut atthe hole.)
Consequently, each trace in our layout must be composed of nine holes and eight short segments, for a grand total of 340 objects (holes and trace
segments) in our layout—and that’s before we even begin to draw the components and connections for our layout!
Needless to say, that’s something you don’t want to do more than once, so it’s a good idea to make a template for a stripboard layout and save