Monday, July 16, 2012

ZIF Socket Allows Programming of PICAXE Family

Lately I have been programming several PICAXEs for people due to my motorcycle gear position indicator project. It is a bit of a pain to insert and remove a PICAXE from my AXE091 dev board just to program a PICAXE. Plus, I often have a PICAXE already pushed into the dev board. Removing it with all the surrounding wires is not easy and depending on the state of the current project it could be harmful to the poor PICAXE I'm trying to program.  Basically, I needed a simple way to plug in a PICAXE and download code to it.  My solution: 
-----
You can see from the diagram in the picture, you plug the PICAXE microcontroller into the ZIF socket one way to program PICAXE-08/14 family devices. To program the PICAXE-18 family place the notch and pin 1 to the opposite side of the ZIF socket. The rig tests fine with all the PICAXE families mentioned.  
-----
I did solder female header rails adjacent to both sides of the ZIF to allow easy hook up of a servo, LED, etc.  However the point of the design was to create an small, tight, easy way to download code into a PICAXE and not create a development board.
-----
The cost was close to "free" since I already had a ZIF socket.  Labeled schematic follows (click to enlarge):
-----


Wednesday, July 11, 2012

Repurpose an Old Disk Drive as a Microcontroller Input Device

Every geek either has and old disk drive or soon will. Here is a way to repurpose that disk drive as an input device for a microcontroller project. This example just shows the disk drive blinking an LED. But you get the idea; with some creativity there are many applications. It's so easy it barely qualifies as a hack, but here are the details.
-----
The device that makes a disk drive spin is a DC spindle motor. If you spin the spindle motor a current is produced. Search youtube for LED Stepper flashlight, etc. and you will find many examples of this experiment.

We need to get two of the spindle motor wires on the disk drive ultimately into the microcontroller.  Take the drive apart and make connections to two of the spindle motor wires.  In the pic you see where we soldered small wires to middle spindle motor connection points.  The other end of these two wires are soldered to two of the drives header pins. This makes for a handy way to plug in a JST connector.

-----
Below is a 'scope shot of what the output signal looks like when you spin the spindle motor.  A purist might consider rectifying the output to keep the microcontroller from seeing a negative voltage.  Since the max output is maybe 500mV, I didn't worry about it.
-----
Here is the custom code for the microcontroller; a PICAXE-08M2.  An Analog to Digital Convertor (ADC) input is monitored.  If a signal is detected of the ADC from the spinning disk drive then flash an LED.  Short and simple.

#picaxe08m2
low 2                'LED on output 2.  Make certain it is off
main:                'Start of main program loop
readadc 1, b0   'Read value of ADC on input 1.  Store in b0
if b0 > 1 then   'If there is a signal on the ADC, the disk is spinning so LED on
toggle 2
pause 50
endif
goto main
----
Thanks for the visit!!!
-----
Link back: Hack A Day
-----

Friday, July 6, 2012

Using a MicroController to Train a Cat

Most of the time Kelso is a great cat.  A few examples of his awesomeness can be seen here, here, and here.  However, he still seems to squeeze in some mischief despite a rigorous schedule that includes sleeping 18 hours a day.

For example, we spotted some paw prints on the stove vent hood.  But wait... Kelso is strictly forbidden to even think about getting on the counters so it couldn't have come from him.  Impossible.  Up goes a security camera to gather more evidence:
-----
Busted!  We need a solution and it needs to be high tech.  

A quick search of the spare parts bin at "The Lab" yields a PICAXE 28X1 custom programmable microcontroller, a piezo speaker (that is really really loud!), a Sharp InfraRed Rangefinder, and a AA battery holder.
-----
All of that stuff in the picture is useless as a solution without some simple custom programming.  Basically, we coded the PICAXE 28X1 to continually monitor the Sharp InfraRed Rangefinder to see if Kelso is in front of it.  If he is, blast five LOUD chirps through the piezo speaker then rearm and wait.  The code was easy and straightforward; less that 20 lines.  The only thing special we did was turn off the PICAXE 28X1 brown out detection (disablebod) and slow the internal clock down from 4MHz to 31KHz in an effort to extend battery life.  Here is a pic of the finished rig that will keep Kelso from ever misbehaving again. ;)

-----
And here is demo of the rig in action:


-----
Does it work?  Hell yes it does!!!
Thanks for checking out the build.
-----
Link back: Hack A Day
Link back: Hatched Gadgets
-----