Saturday, April 9, 2016

@MAKE: Electronics Experiment 34 started

As I mentioned in this post, I became discouraged by the need for a $20 cable to program a $3 microcontroller, particularly since Charles did not mention it it the parts list or supplies.  Also, Charles dismissed the less expensive option of using a computer's serial port.  I submitted an erratum to the publishers on this--since the book's subtitle is "Learning by Discovery" and it's a +Make: book, I though it would be more in the spirit of the book to lead the reader to discover and make. I love the book and it has provided me with great deal of learning and satisfaction, but I found this irritating.  I got over it, and now I'm on to the project.

Also, I have not found any posts or videos of these experiments, so I might as well do it.

But first, I needed a serial port. Most late-model computers do not have the old-fashioned 9-pin RS232 ports for what is normally called a DB9 connector but really is DE9. Fortunately, I hoard old computers and have a 14-year old Windows XP computer with serial ports on the motherboard.  If there had been on a PCI card rather than the motherboard, I could have swapped that out  into my regular desktop.  That left me with 2 choices:  fire up the XP machine and use that to program the PICAXE, or buy a PCI card for my desktop. Since I doing this because I'm cheap, I chose the former. PCI cards cost US$7 and up from Amazon, Newegg, and the like, and as low as $4 on eBay. If I decide to use the PICAXE for more than this project, that's an option.

The XP machine started up fine, and I was able to download and install the PICAXE software according to the book instructions (or see the PICAXE web site).  I still needed a cable.  Here again, I had two options:
1. find a serial to something cable, cut it, figure out which wires go to which pin, and connect the 3 wires I need to the PICAXE
2. make my own
Again, this is a makers' book, so I decided to make one.  A quick Google yielded this set of instructions. I bought a DB9F (as in female) connector from Amazon. Following the aforementioned instructions, I soldered 24" solid core wires to the pins I needed:
red wire to pin 2       (Rx--receive--computer in)
green wire to pin 3   (Tx--transmit--computer out) I didn't have white solid core wire
black wire to pin 5   (Ground)
I heatshrinked the connections for insulation.
I then cut a servo wire in half and kept the half with the end that I could connect to a 3-pin header on the breadboard and:

  1. slid small heatshrink on each lead
  2. slid larger heatshrink over the 3 wires to the DB9
  3. spliced the servo wires to the connector wires with solder, matching the wires by color (red/red/ black/ black, white/green) 
  4. heatshrinked the splices
  5. heatshrinked the cable
  6. snapped the cover on the serial connector end
Viola, I had a cable.  Here are some photos of the process.
Tools and supplies ready 
to make the PICAXE cable
DB9F ready to solder

soldered wires ready for heatshrink
finished cable


Next step:  configure the breadboard:
  1. add a 2.1mm barrel jack to bring unregulated 9V to the breadboard via wall wart or 9V battery
  2. add a voltage regulator circuit to deliver clean 5V to the power rails on each side of the breadboard
    .  the circuit consists of 2 100uf capacitors, 2 .1uf capacitors, and an LM7805 voltage regulator
    .  Charles' instructions are good, see schematic
  3. add the PICAXE to the breadboard and connect it to power and to the computer serial output
    .  I have a PICAXE 08M2, pin 2 is serial in and pin 7 is serial out, so the red wire (computer out) goes to pin 2 (see next bullet), and the white wire (computer in) goes to pin 7 (i,e, computer in to PICAXE out, computer our to PICAXE in)
    .  actually the red wire goes to a breadboard hole in a row between a 10K resistor that goes to a breadboard ground rail and a 22K resistor that goes to PICAXE pin 2--keeping pin 2 pulled to GND when it's not receiving
    .  PICAXE pin 1 goes to a breadboard 5V rail, and pin 8 goes to a breadboard ground rail
  4. Add an LED for testing--connected to PICAXE pin 6 and on to GND through a 330Ohm resistor
Fritzing diagram of circuit--the business on the left is the voltage regulator circuit



I had a heck of a time with the voltage circuit.  I kept getting ~9V out. I tried multiple units, and checked ny wiring.  Finally I set up a circuit like the L7805 datasheet, and it worked--exactly 5V out. I was going to submit another erratum on the book, but as I wrote ti it didn't make sense that I would get 9V out, so I rewired it in a different spot on the breadboard: 4.98V out.  I moved it back to the original location: 9V out.  I'm doing something stupid, but I'm ready to move on to the PICAXE and test my cable, so I'll put it back where it works and declare victory.

breadboarded circuit with messy wires

Now, we're ready to test the cable and circuit.

Oops.  I cannot get the XP machine to recognize the PICAXE./  I have a problem with my cable (although I don't think so, but I'll check), the circuit, my computer, or something else. It could be the breadboard--I suspect that's the problem with the voltage regulator circuit--see above.  I've done some preliminary checking, but I'm not there yet.  The book is absolutely no help on this since Charles went the non-Maker route, I'll do another post if/when I get something working.






No comments:

Post a Comment