Search This Blog

Friday, November 19, 2010

Arduino based XYZ CNC Pumpkin & Foam Carver

Project in progress....

I'd been looking for something cool to do with a numerical controlled milling machine and an Arduino.
Using a router bit or dremel, and stepper motor stage, very cool greyscale pumpkin art could be carved.
Carving to different depths yields different light intensity.   Compensating for the curve of the pumpkin sounds like a math tour de force that can't be resisted.

Previously when into miniature Wargaming,  I build some landscape elements out of carved foam blocks and paint mixed with sand.  Very nice looking and easy to make.  Using this machine really would take this to a whole new level.

A 3D printer is not far away, if I could find a material to squirt out.  But that is a pipe dream for now.

In college I worked in a machine shop, and let me tell you, once you have used a CNC to make something you are changed forever.

Couldn't resist starting some research and a prototype to get this off the ground.

XYZ stages of high precision are insanely expensive.  This was the cheapest/best I could find, but I'm not ready to shell out this kind of dough yet.  Maybe if this turns into something cool and I need something more precise and heavy duty:   This is $325 and has the stepper motors.

Zen Toolworks CNC Carving Machine DIY Kit 7x7

Zen Toolworks CNC Carving Machine DIY Kit 7x7


Since I'm not buying that to start, here is the plan.
We are going to stick to carving soft materials for now, so we don't need a heavy duty stage and large motors.  A Dremel will serve as the carving tool to start.

An arduino will serve as the controller, with H-bridge motor driver chips driving stepper motors.
Likely I will have some method to calibrate the machine, either pots, encoders, or limit switches.  That will be in phase 2.    Keeping the carver in a calibrated control loop will increase precision.

For the initial lash up, since I'm diving in with two feet, I'm going to blow some $ and buy some premade kits just so I can get something to work out the bugs.

Adafruit Motor/Stepper/Servo Shield for Arduino kit - v1.0  $19.50

Small stepper motor - PF35T-48  $6.00
http://www.adafruit.com/index.php?main_page=product_info&cPath=34&products_id=168
To use with the Motor Shield, connect green and red together to ground (middle), brown and black to one motor port (say M1) and orange and yellow to the other motor port (say M2). So in order, thats: brown - black - red&green - yellow - orange.

These motors are pretty small, so I'm going to start with a small machine on the first try.  They may not have the torque to move a big stage or fight against harder materials during carving.
I read on one blog that drawer slides from Home depot can be used to make a movable platform.

I need to find a source of gears, belts, etc that don't break the bank.  May go with the Lego collection on the lash up version, or rubber wheels moving the stage.

Down the road I will need bigger stepper motors and a higher voltage H bridge driver.
I have some of these chips around from automotive projects
L293NE

IC QUAD HALF-H DRVR 16-DIP


I also found bigger stepper motors at
But datasheets are sparse, color codes, voltages etc are hard to find.  Eventually i'll have to dive in and order something, but I'm starting with some little ones that I know will work until my code is running.

Motor control software is all over the place on Arduino pages.    
I may make the Arduino stand alone, or simply make it the interface between the computer and the motors.

One low budget idea is to add an sd card slot, and create windows bitmaps.  The arduino could run in raster mode.  In the past I did a lot of work with windows bitmaps.  They have a simple file structure with the first few bytes showing the picture size, a byte per pixel and a simple greyscale or color scale.    The greyscale could indicate depth.  It would be easy to use gimp to edit pictures to the size and color depth i want, and then just plot them out with the XYZ machine.  Or I may use more conventional vector software, and HPGL or some such.

------------update-------------
Built up one of the adafruit motor shields, hooked up two stepper motors and downloaded the adafruit motor library, according to the  http://www.ladyada.net/make/mshield/use.html  pages.  No problems.
Edited the code to control two steppers, like this:


#include <AFMotor.h>

AF_Stepper motorX(48, 1);
AF_Stepper motorY(48, 2);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");

  motorX.setSpeed(10);  // 10 rpm
  motorY.setSpeed(10);  // 10 rpm

  //step motors one step to power the coils
  motorX.step(1, FORWARD, DOUBLE);
  motorY.step(1, FORWARD, DOUBLE);
  motorX.step(1, BACKWARD, DOUBLE);
  motorY.step(1, BACKWARD, DOUBLE);
}

void loop() {
//  Serial.println("Single coil steps");
//  motor.step(100, FORWARD, SINGLE);
//  motor.step(100, BACKWARD, SINGLE);

  Serial.println("Double coil steps");
  motorX.step(48, FORWARD, DOUBLE);
  delay(5000);
  motorY.step(48, FORWARD, DOUBLE);
  delay(5000);
  motorX.step(48, BACKWARD, DOUBLE);
  delay(5000);
  motorY.step(48, BACKWARD, DOUBLE);
  delay(5000);

}



Talked to a friend today and it was depressing.  He told me my steppers would need high torque, that gears are hard to buy, lead screw designs are really inefficient, and it is hard to couple to a shaft.  He said steppers can slip and get off, so relying on counting steps was bad.  He suggested using drill motors and optical encoders instead of steppers.  All possible, but I'm looking for a build that uses components that anyone can get cheap.

Pressing forward with the basic prototype, I'm an EE not an ME so this may fail horribly.

Found a cheap XY table, making note.  Looks like it has very small (like <2") range in one direction, so probably not big enough

Proxxon 27100 Micro Compound Table KT 70



Found some cheapo rotary encoders, bought a few just in case.  May be too flimsy to hold up but good for getting the software going.
http://www.sparkfun.com/products/9117
I may just use the encoders for calibration, or monitoring.  A feedback loop solution may be overkill.  It depends on the torque and backlash of the motors.  TBD.

Looks like the best system may be to use multiple arduinos to control the motors, since one arduino can't really handle more than 2 steppers.  A PC interface will be needed to control the arduinos.  This is probably the most sane solution, since the Arduino has such limited memory, downloading a big drawing to an Arduino that is also controlling steppers, reading encoders and talking to another Arduino will likely be too much.
Depending on my initial results with the encoders, I think the plan will be one Arduino per motor/encoder pair and a simple communication with the PC.  The PC will do all the work.   One Arduino might be able to handle both X and Y motors which might make some of the timing between motors easier.  I have to decide if I will pixelate the instructions, raster or vector.
Friend suggested Java or Elcipse on the PC to run the whole thing.  Looks like I will be learning how to code for the PC next!

Starting a new post now that I have some direction on this project....
Look for the story to continue in the later post


Sunday, October 31, 2010

Check Engine Light Came On

Before I could try out my home brew OBDII interface, the check engine light came on for my 1997 Honda Accord.  It has 180,000 miles on it.  It is my extra car that I only drive a couple times a week.

I read code PO135, the book says the sensor heater error.   Makes no sense. Went online and found this.

http://www.obd-codes.com/p0135

Looks like I need a new oxygen sensor.  I reset the code to see if it comes back.  No sense in moving too fast, if it is really broken it will set the code again!  Might be a fluke.

Currently waiting to see if the code appears again.....
2 days and counting and it hasn't come back.  Maybe it was a false alarm

Nope.  A day later the check engine light is back.  Off to find an oxygen sensor!

Sorry to say i paid my mechanic friend to fix this for me.  Work was crazy and i just didn't have time. $300.  I am ashamed.  ;-)

Friday, October 22, 2010

Research on the Arduino OBD II interface for reading codes, auto MPG, etc.

This post is just a place to keep some notes and links while I develop this project.
Why do this?  Monitor live engine, MPG, etc.  Diagnose check engine lights, log data on the car.
I'm also thinking the car modders would love to have lights that respond to what the vehicle is doing, flames that brighten when the engine revs etc.

I ordered an OBD II interface cable from Amazon.  No way around this one for $10.95+ship

OBDII Cable, J1962M to Open End, 10ft (144505)


There are some adapter cables to RS232, but why add money buying different connectors.  I suppose I could have scrounged a 9 pin from an old motherboard.  Too much work.   Here is the pinout.  This cable has an open wire end i can just solder in.  

You can also use a OBDII to DB9 cable, seems like the pinout is standard
http://www.elec-intro.com/obd-connector
obd connector


Sparkfun has this cable
http://www.sparkfun.com/commerce/product_info.php?products_id=10087








OBDII to DB9 Cable

sku: CBL-10087
Here is the basic pinout (OBDII > DB9 Female)
Pin DescriptionOBDIIDB9
J1850 BUS+27
Chassis Ground42
Signal Ground51
CAN High J-228463
ISO 9141-2 K Line74
J1850 BUS-106
CAN Low J-2284145
ISO 9141-2 L Line158
Battery Power169


SAE J1962 defines the pinout of the connector as:
  1. Manufacturer discretion. GM: J2411 GMLAN/SWC/Single-Wire CAN.
  2. Bus positive Line of SAE-J1850 PWM and SAE-1850 VPW
  3. Ford DCL(+) Argentina, Brazil (pre OBD-II) 1997-2000, Usa, Europe, etc. Chrysler CCD Bus(+)
  4. Chassis ground
  5. Signal ground
  6. CAN high (ISO 15765-4 and SAE-J2284)
  7. K line of ISO 9141-2 and ISO 14230-4
  8. -
  9. -
  10. Bus negative Line of SAE-J1850 PWM only (not SAE-1850 VPW)
  11. Ford DCL(-) Argentina, Brazil (pre OBD-II) 1997-2000, Usa, Europe, etc. Chrysler CCD Bus(-)
  12. -
  13. -
  14. CAN low (ISO 15765-4 and SAE-J2284)
  15. L line of ISO 9141-2 and ISO 14230-4
  16. Battery voltage


On 1996 and later vehicles, you can tell which protocol is used by examining the OBD II connector:
J1850 VPW--The connector should have metallic contacts in pins 2, 4, 5, and 16, but not 10.
ISO 9141-2--The connector should have metallic contacts in pins 4, 5, 7, 15, and 16.
J1850 PWM--The connector should have metallic contacts in pins 2, 4, 5, 10, and 16.




The project involves interfacing the car's computer, which runs at 12V.  Arduino runs at 5V.  After that, it is all software.

The OBD II has a line called ISO K line, which is a bidirectional serial bus.  

It seems there are a couple routes people have gone.
  • Using an ELM 323 or 327 OBD to RS232 adapter IC.  These are $14 on scantool.net, in clearance.  Otherwise they are $30 and seem to be hard to buy right now.
  • Connecting direct to OBD protocol, using a level shifter.
    • Using a MC33290 or MCZ33290EF level translator IC.  Found these are hard to get, end of life'd.  There may be replacements, but this is not worth the effort.
    • Just use some transistors to build one!  I have some 2N3904 that cost 33 cents lying around.  This guy did it this way.  I think this circuit is missing a resistor for the 12 to 5V division, and the first stage should be to 5V to keep the Arduino safe.  But it shows the concept.  Easy.  Cheap.  You can see where this is going.  Don't be scared of a couple of transistors!

http://prj.perquin.com/obdii/obdii_avr.gif

OK, the ratios of his resistors THEORETICALLY keep the Arduino from seeing 12V, but being a consumer device circuit designer this circuit is not safe.  If the K line ever touches 12V, or if one side or the other of this circuit is not powered, RXD will float to 12V and cook the Arduino.


Here is my circuit to replace the MC33290 with a few cheap discrete transistors


NOTE/UPDATE - RX comes from the collector not the grounded emitter on Q4.  Schematic is wrong but I no longer have the orginal to edit.  This is the way it should be.  Somebody pointed this out years ago but for some reason I couldn't see the obvious.



Wikipedia is always my friend.  OBDII is a bit more complicated.  Different cars use different protocols.  Dang.  I have Hondas, a 1997 and a 2007.  So I'm guessing i can still use the K-line.

This seems pretty straight forward.  And i think others have already written the code for the Arduino to emulate this

  • ISO 9141-2. This protocol has an asynchronous serial data rate of 10.4 kBaud. It is somewhat similar to RS-232, but that the signal levels are different, and that communications happens on a single, bidirectional line without extra handshake signals. ISO 9141-2 is primarily used in Chrysler, European, and Asian vehicles.
    • pin 7: K-line
    • pin 15: L-line (optional)
    • UART signaling (though not RS-232 voltage levels)
    • K-line idles high
    • High voltage is Vbatt
    • Message length is restricted to 12 bytes, including CRC

This guy has some good info on the codes, but I think his circuits have issues and may send 12V back to the Arduino under certain cases.  Ouch.  I'll fix that.  http://prj.perquin.com/obdii/

Still looking at protocols.  Found a nice document at
http://www.esatinc.ca/News_Letters/OBD_II_Specifications_and_Connections.pdf
It looks like CAN bus will be required on all new vehicles by 2008.  I probably have a K wire interface on my older car, but it would be nice to build something that has more generic usage.   Also diagnostics may only be on CAN in some vehicles.  From this doc
A simple check to see if the CAN bus is in use in a vehicle, and accessible via the OBD socket, is to connect a resistance meter across pin 6 and pin 14. Due to the combined resistance of the two termination resistors at 120 Ohms each the overall resistance should be read as 60 Ohms. (refer to vehicle specifications)








The CAN bus speed may be as fast as 1 MHz, although the OBD-II ISO 15765 specification specifies two speeds which may be used for on-board diagnostics, 250 KHz and 500 KHz.
So it looks like I should support K wire and CAN both.

Cool -  a high paydirt google hit give me this.  All the electrical stuff is here!
http://www.interfacebus.com/Design_Connector_CAN.html
CANbus interface Circuit
CAN Bus Interface IC Logic Levels


Most of the CAN IC's have a uController built in, and cost $20+.  Yuck.  I could handwire a circuit.
Found these parts that might help. for <$5
http://search.digikey.com/scripts/DkSearch/dksus.dll?Cat=2556697&k=MCP2510

This part is probably worth the $5.  The CAN bus was going to max out the Arduino and make it hard for it to do anything else.  I would have spent $5 on the devices to interface.
http://ww1.microchip.com/downloads/en/DeviceDoc/21291F.pdf

Uh oh!  Looks like I need another part to actually interface to the bus.  Boo!
http://archive.electronicdesign.com/files/29/4057/figure_01.gif
http://electronicdesign.com/article/communications/build-a-simple-and-inexpensive-controller-area-net.aspx

This guy has already done it, wants to sell for 30GBP.  Yikes.  I'm thinking a $10 shield will make a nice project.
http://www.skpang.co.uk/catalog/product_info.php?cPath=140_142&products_id=706

Not so bad, the CAN interface chip is only $1.12!
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=MCP2551-I/P-ND


And there is a cheaper version of the controller:  MCP2515-I/P-ND for $1.98!   This might be a <$10 board yet!

OK, ordered the MCP2515 and MCP2551 and got them almost immediatly from Digikey.  I put together a quick lash up.  Then I finally got around to taking the OBDII cable out to the car and checking if I have a CAN bus.  I have a 2007 Accord, and some older cars.  I was sure the 2007 would have a CAN bus, since they are required in 2008.  But you can guess.  Nope, open circuit between 6 and 14.  Doh!  Major setback and I"m going to go back and build the K line version first now.

A thread with info on another person's project
http://ecomodder.com/forum/showthread.php/obd-mpguino-gauge-2702-27.html

So I have my interface circuit together, using 4 transistors, some resistors, diode and a cap.  Made a version for less than $5, not including the prototype board.  I will write it up once I'm sure it's really working.  Need to get some basic code going to begin talking.

Looks like the obduino32K has some good code.  These guys have gone way over the top on the code.
http://opengauge.googlecode.com/svn/trunk/obduino32K/obduino32K.pde

Decided to put my OBDII K line interface circuit together with an LCD and load the obduino32K code.
The code compiled without much trouble, and the LCD comes on, and the K line gets wiggled.  Today I will plug it into my car and see what happens.  See the circuit diagram above.  Basically I am building the circuit from http://code.google.com/p/opengauge/wiki/OBDuinoDiagram but I am not using the MC33290, since I couldn't find one.  I put together a level translator with a handful of cheap transistors, similar to the diagrams I quoted above.  Functionally equivalent to this picture:   Also odd that there are no pull up resistors on the switches.


OK - debug time.  The board comes up, the K line wiggles.  I tried this in two Honda's and a Toyota and never get past the initial sync.    I need to strip down this code to a basic sync and a dump of the response to see if the car is responding and I'm missing or mangling it, or if there is no response.   I looked at the data sheet of the MC33290 and I'm pretty sure my circuit should work.  I have an LED on the K line (not directly) so I can see there is activity.

Still stuck.  I can't get the car to respond to the Init.  May be i'm using the wrong protocol, my interface circuit may have problems, or my code is no good.   I'm going to begin to deconstruct things and start with some basic bit banging the control lines to see what is up.

I posted my tweaked openguage code so i can pick it up from my laptop, and try debugging in the car...

Wednesday, October 20, 2010

Arduino Shield List

A note of a neat website.  I will try to get some of my stuff listed.

http://shieldlist.org/

Monday, October 18, 2010

GE GSS25TGPEWW Refrigerator broke

Doh!

My GE GSS25TGPEWW side by side refrigerator is having a problem.  It's new as far as things go, maybe 5 years old.  I'm not ready to buy a new one.

Ice made by the icemaker, periodically all melts, drips down and refreezes as huge icicles.
This happens randomly, maybe every couple days or a week.  All the food near the top gets really warm,
but the bottom is always cold enough that the water doesn't leak out the bottom, it freezes.

Some google searches to appliance repair quickly led me to the diagnosis that the main board was bad.
Another search led me to what main board my refrigerator used.   Sorry I missed making note of that website.
Bought this on amazon WR55X10942.  For good luck I bought a new thermistor WR55X10026, the sensor that reads the temp, in case that is really the problem.

This is an example of the web logs i found that described the issue.
http://www.applianceblog.com/mainforums/ge-hotpoint/17856-ge-side-side-temp-flucutations-ice-melting.html




This board did set me back over $100.  But it was cheaper than a new refrigerator, and I'm sure a repairman would have been several times that.




This was <$10, and shipping was free.

When the parts come I'll let you know what happened...... time passes.....so the parts came and I'm updating......

Turns out it was really easy to install the new main board.  Anybody could do this.  It came with some instructions.   Pulled out the fridge, and on the back panel near the bottom is a cover, maybe 8 inches by a 1 foot.  I did not unload the food, just kept the door shut and unplugged it. The panel has 8 or so hex nut screws all around the edges.  You just unscrew them with a socket wrench, and open the cover.  The board sits in a little space right there, all by itself, very easy to access.   I used a pair of needle nose pliers to squeeze wings on the four white posts that clip the board down.  Once they are squeezed the board pops right out.  I simply unplugged the connectors around the edges, and transferred the plug to the new board one by one so that i wouldn't get anything mixed up.  I don't think you could hook it up wrong, but it is always good practice to do it one at a time.   I popped the board back in over the white posts and put the cover back on.  All in all it took about 15 minutes plus 10 minutes cleaning up the mess and dirt under and behind the fridge. Yuck. Only tools were needle nose pliers and a small socket wrench set.

I decided to wait to swap in the new thermistor, lets see if the board did the trick since I don't know yet where the thermistor even goes!

Plugged it back in, and the fridge was up and running immediately.   Now we will see if the ice melts again.

A week and the refrigerator is still working great.  I'm calling this one fixed!  Victory!

-Another update, fridge has been working flawlessly for nearly a year now.  Badabing!

Friday, October 15, 2010

Arduino project list and some ideas

Projects I've built with Arduino covered in my blog,

  • Ethernet stock/time fetcher (need to write it up)
  • GPS logger- in the field and working great
  • IR TV sleep timer setter. - in the field and working great!
  • RFID tag reader - have a motor controller I want to add.  Otherwise the RFID is working fine
  • SD card reader, built from scratch before i found others had a kit.  (should write it up anyway)

Projects in progress
  • TV B Gone.  Got the transistors and LEDs, now have to put it together
  • Nintendo DS game cartridge save file reader.   Worked but was flaky.  Need to get back to debug it and write it up.
  • BatchPCB: Getting PCB making up and running, may just build a LCD shield to get started.
  • OBD reader.  Started with CAN bus, switched to K line due to my car.  Testing stalled because my car won't respond.
  • XYZ CNC arduino based machine.  Got some parts, building it up.

Some things I might build next
  • TV Video output for Arduino.   I'm thinking I will set up a video output board, to display text to a TV screen.  Maybe as an overlay.  Just sounds like fun.  Found this similar thing http://lowvoltagelabs.com/products/videooverlayshield/
  • VGA Output for Arduino.  Totally useless but it's gotta be fun!
  • Mag Stripe reader  The readers are all over ebay.  However I'm not sure the point of doing this, just curious about what is encoded on all those cards in my wallet.
  • Wireless hot spot SSID finder.  Found some pages on signal strength
  • Car Compass  My car doesn't have one of those displays that tell you the direction you are driving.  Could I build one?  The GPS seems overkill for this function, but it works fairly well if you are moving.  There must be a compass module that can be bought.  On Ebay they are crazy expensive, like $100.  Might as well buy a GPS module and an arduino for that price.
  • GPS Warmer Colder  Program in a location, and it tells you how far away and in what direction it is.   Uses GPS.  GPS I already built will do that with a few lines of code.
  • Arduino iPod or iPhone interface,  Looks like well worn ground
http://www.rosiedaniel.com/2007/09/ipod-arduino-love.html



To do list:

  • Get photos of the IR sleep timer in the box taken and uploaded
  • Finish putting to together the TVBGone now that i have all the parts
  • Get the LCD mounted in the case of the GPS
  • Add the Hbridge to the RFID lock, now that i have the solenoid part and Hbridge
  • Debug the oscillator on the CAN bus interface shield.  Maybe I have the wrong caps.  On hold due to lack of CAN bus automobile to test with.
  • Test the K line interface box, and build up a more permanent version.


    Thursday, October 14, 2010

    Research on the Arduino TV output

    As always, somebody has already done the thing I thought of and made a web page.
    However I'm sure I can think of a new twist.

    http://www.batsocks.co.uk/readme/art_SerialVideo_1.htm
    http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=74067

    Maybe I will look into transmitting as DVI in one of the lower res modes, or just VGA.  Now that sounds like fun!

    http://lslwww.epfl.ch/pages/teaching/cours_lsl/ca_es/VGA.pdf
    http://www.linusakesson.net/scene/craft/

    http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230286016/30
    May need an add on, i don't think i can produce waveforms this fast, 25MHz

    Sunday, October 10, 2010

    Arduino RFID tag reader cleaned up

    I made a more permanent version of the RFID tag reader:


    It took some staring at the cryptic documentation and the web site below to figure out the circuit, so I drew it up, since the drawings elsewhere were awful and had errors.


    • Rewrote the code so that it keeps a list of tags to be granted access.  
    • Upgraded to arduino-0021, and replaced the add on NewSoftSerial library with the built in SoftwareSerial libarary.  The built in library is not as good as the add on, but it makes it easier for others to get my code running.
    • Used a prototype shield and made a permanent hardware version with some LEDs
    Photo of the Arduino with the proto shield stacked on top.  The RFID module is soldered to a breakout board which is in turn soldered to the prototype shield.  Indicator LEDs are installed sticking up high so they will poke out of the box when done.

    The unit placed inside the bottom half of the Sparkfun project box. This box fits an Arduino perfectly.  If I had the project to do over again, I'd have put the RFID module on the other end of the prototype board so it was centered in the box.  I built the unit while i was waiting for the box to come, and didn't plan this ahead properly.  I was thinking I might put a small LCD readout on the end of the prototype board, that is why I did it this way.  In the end the LCD wasn't really useful and I deleted it.


    All buttoned up with the holes for the red and green LEDs drilled.


    I'm going to repeat information in the previous post on the prototype version, so the writeup is all in one place.







    The RFID module reads out serial ASCII data, and all you have to do is connect that output to a pin on the Arduino.  You use the SoftwareSerial library to be able to define any pin as a serial input.  Otherwise you have to use the TX/RX pins, and that interferes with serial communication to the computer.  Set the RFID reader serial speed to 9600 baud.  Other speeds i found spewed garbage.

    The sketch looks for codes and compares them to a valid list.  I can't imagine anyone could pull the compiled code off the microcontroller to see the list of valid tags.  Plus the RFID reader has a good 5 inches of range, so you can put the reader INSIDE the door if you want.  It even reads from the back of the RFID module.

    I found the reader only reads the tags from Sparkfun.  It does not read HID tags (at least the ones I have), it does not read pet chips, or Metro smartcards.  I was disappointed as a hacker, but the project still works great.

    You could add a data logger or an ethernet shield if you want to save a record of what tags were read or send that information across the internet.

    Parts List:
    • Used the RFID Reader ID-20 from Sparkfun:
                http://www.sparkfun.com/commerce/product_info.php?products_id=8628
               The datasheet is here:
               http://www.sparkfun.com/datasheets/Sensors/ID-12-Datasheet.pdf
               The ID-12 is functionally identical, with a smaller range and uses less power.  Pick that one for a battery operated project, or if range isn't important.
    • This little breakout board for the RFID module is worth the $0.95 to make the pins plug into the breadboard.
               http://www.sparkfun.com/commerce/product_info.php?products_id=8423

    • I got a couple of these tags for $1.95 each.  RFID Tag - 125kHz.  Even if you have your own tags, i'd get one to be sure the reader is working when you build it.

              http://www.sparkfun.com/commerce/product_info.php?products_id=8310
              http://www.adafruit.com/index.php?main_page=product_info&cPath=17_21&products_id=55
    • stacking headers $1.50
              http://www.adafruit.com/index.php?main_page=product_info&cPath=17_21&products_id=85
    • A red LED, a green LED, 2 1kohm resistors and a switch for reset.  If you don't have the miscellaneous stuff, you can get all this with the protoboard from Adafruit if you buy the proto kit for $12.50.
    • A project box.  This box is made for the Arduino and is easy to drill.  Kinda pricey at 11.95 but I needed something I wouldn't be embarrassed to see hanging on my wall.   Arduino and shield drop right in.  http://www.sparkfun.com/commerce/product_info.php?products_id=10088

    These electric door locks look like they should work, I haven't tried yet.  Likely it will need a relay or transistor to boost the current to activate the lock, like an LM293
    Electric Door Strike - Mortise Type

    This was much cheaper, so i ended up getting this instead.  It is really for autos but worked fine.



    The sketch code follows the break...

    Thursday, October 7, 2010

    Arduino RFID tag reader prototype







     Put together the basic Arduino RFID reader in about an hour!  It was way easier than I expected and worked the first time!  


    <Note: See the final version in this post>
    http://siliconfishtech.blogspot.com/2010/10/arduino-rfid-tag-reader-cleaned-up.html


    Here is the prototype breadboard version I just whipped up:



    The RFID module reads out serial ASCII data, and all you have to do is connect that output to a pin on the Arduino.  The serial library called in the code (the link is in the code) lets you put a serial input on any pin.
    Thats all there is to it.  

    You can read your tags, and put if statements in the loop to activate a pin on the arduino to make a lock, or whatever you want to happen when a card is read.   

    • Used the RFID Reader ID-20 from Sparkfun:
                http://www.sparkfun.com/commerce/product_info.php?products_id=8628
               The datasheet is here:
               http://www.sparkfun.com/datasheets/Sensors/ID-12-Datasheet.pdf
               The ID-12 is functionally identical, with a smaller range and uses less power.  Pick that one for a battery operated project.
    • This little breakout board for the RFID module is worth the $0.95 to make the pins plug into the breadboard.
               http://www.sparkfun.com/commerce/product_info.php?products_id=8423

    • I got a couple of these tags for $1.95 each.  RFID Tag - 125kHz.  Even if you have your own tags, i'd get one to be sure the reader is working when you build it.

              http://www.sparkfun.com/commerce/product_info.php?products_id=8310
    It took some staring at the cryptic documentation and the web site below to figure out the circuit, so I drew it up since the drawings elsewhere were awful and had errors.




    The sketch code follows the break...

    Tuesday, October 5, 2010

    Arduino RFID reader started

    I've started putting together an RFID reader, using an ID-20 module from Sparkfun and an Arduino.
    This post is just a place to note a couple links to information I'll need.  This is what I got so far.  The RFID is pretty pricey!  Sparkfun is a good website, the only place I could find the RFID reader.  However, the stuff took a week and a half to come from Colorado.  Hacktronics and Adafruit are 3 days (for me on the east coast).


    RFID Reader Breakout$0.951$0.95
    RFID Tag - 125kHz$1.951$1.95
    RFID Reader ID-20$34.951$34.95

    And of course, and Arduino Duemilanove, now selling for $25.  I got a new Uno version  to try out as well, either will work.  I learned my lesson buying the Chinese knockoff boards from Ebay.  Save money but no workie.

    It appears that i connect the output pin to the serial pin on the arduino and then just let her rip.  We will see if it is that easy.


    Data sheets and info were here:

    http://www.sparkfun.com/datasheets/Sensors/ID-12-Datasheet.pdf

    http://hcgilje.wordpress.com/resources/rfid_id12_tagreader/

    Although this is a different tag, maybe the concepts are the same:
    http://www.arduino.cc/playground/Learning/PRFID

    Another tag reader i didn't try is here:

    http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/rfid/List/1/ProductID/114/Default.aspx?SortField=ProductName,ProductName

    Saturday, October 2, 2010

    Arduino IR remote TV sleep timer setter

    Now that this project is finally up and running in field trials, I'm finally going to write it up.

    The purpose of this project is automatically turn on the sleep timer of the television.

    Story: My wife is an insomniac and stays up late every night watching TV.  She eventually falls asleep and leaves the TV on.  She NEVER remembers to set the sleep timer, plus the TiVo remote doesn't allow setting the TV sleep timer, and who knows where the original TV remote is most of the time.   We have DirecTV, and about 3 or 4 in the morning they do a download.  The TV goes black and quiet for a while, then comes back to life when the download is done.  This wakes me up every night and i have to get out of bed and turn off the TV because my wife as fallen asleep and lost the remote in the bed somewhere.   Arrrgh!

    How it works:  Based on an Arduino board, it has an IR receiver ripped from an old broken TV, and an IR diode from a remote from a TV we don't have anymore.  The device sits on the TV stand, directly in front of the TV. When it detects IR traffic from the remote, it keeps resetting a timer.  If the timer expires, it assumes that the user has fallen asleep and is no longer controlling the TV.  The device then sends a remote control to the TV to set the sleep timer.   If the user doesn't notice (they are likely asleep), the sleep timer counts down and shuts off the TV.  You might ask why don't I just send a power command?  Problem is I can't really be sure the TV is on or off.  What if she actually turned the TV off before falling asleep.  It would be a disaster to have the device turn ON the TV.  Using the sleep timer is the perfect fail safe.  If the TV is off, the sleep command does nothing .  If the TV is on, it will count down and turn off.  Just takes a little longer than turning it off directly.

    We have a SONY Bravia TV and use a DirecTV TiVo box primarily.  This works for those devices.  You will have to modify for your devices.

    Arduino TV IR sleeper

    The project is constructed of:
    Connections:
    The IR receivers have three pins.  Signal, Gnd, 5V.  I attached it to pin 9
    int RECV_PIN = 9;                //IR detector module attached here
    int led_green = 11; //led to indicate TV on & IR activity flickers green.  Connect the same way as the IR diode, but use a 2.2K resistor in series instead
    int led_yellow = 13;          //led to indicated TV user is drowsy.  Same as led_green.

    IR wiring
    thanks to http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html for this drawing

    I used the prototype shield, which is probably overkill but made a nice compact unit.  I bent the receiver and yellow/green LEDs so they pointed towards the user.  The IR tx diode is mounted on the back edge and points towards the TV.  I put on a reset switch because it is always nice to have a wave to recover.

    This project proved way more difficult than i expected.  The device is both a reciever and a transmitter, and needed to detect IR transmission as an interrupt because I was running a timer from last activity.  Combining these three functions was tricky.  There was an IR library on Arduino playground http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1176098434 ,  that was based on delay(),.  The receiver worked just fine, but the transmitter failed to control the TV.  I experimented for hours and finally discovered that the timing of the bits in the Arduino were off.  I had to set the times much shorter than the spec, because the Arduino was timer and interrupts were slowing things down.  In the process of debugging and googling help, the http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html library bubbled up through google and i downloaded it.  This is much more solid and uses the PWM as the timing reference for transmit, so the TV liked it.  Luckily it supports the same devices that I had in my home, so I used it almost unmodified.   I had further troubles with the sending routine stopping the receiving routine, which the author admits to in his blog comments.  All you have to do is restart the receiver after you have transmitted.  I had further troubles with ambient IR triggering the receiver, and had to add a code filter to ignore anything that doesn't match a valid IR code from either the TiVo (NEC codes) or Sony.

    So here is the code I ended up with.  you need to download the IR library and put it in your libraries folder.
    This code has debugging to the serial monitor included, which helps you understand what is happening.

    Code follows....

    Links to Arduino based TV-B-Gone

    Just making note of this link to an Arduino TV-B-Gone, since i have the hardware built already i'll probably have to try this.  I've used his IR library and it works very well.  Some of the other code out there relies on delays and breaks when the Arduino is busy.
    http://www.arcfn.com/2009/12/tv-b-gone-for-arduino.html

    Adafruit posted a kit, which of course i could just build, but what fun is that?
    http://www.ladyada.net/make/tvbgone/design.html
    They have a nice schematic drawn of the fanout to multiple IRLEDs.  I'm going to check up on the current, surprised there is no series resistor on the output LEDs

    Wednesday, September 29, 2010

    RFID reader

    Found some info on RFID readers that i'm making note of

    http://www.instructables.com/id/Weather-proof-Bluetooth-capable-RFID-reader/

    makes use of
    http://www.sparkfun.com/commerce/product_info.php?products_id=8419
    http://www.sparkfun.com/datasheets/Sensors/ID-12-Datasheet.pdf

    Also found this on Ebay.   A little too much to spend at $59, but it has some info on how they work.
    Still thinking about building a fun project to detect who is in my office by reading their badges.

    Datasheet at
    http://www.rfidshop.com.hk/datasheet/T5567/HI-R-W26-W2%20Datasheet.pdf







    HI-R-W26-W2

    125Khz HID compatible RFID Reader
    with wiegand 26 bit output Interface






    Features  (Datasheet download here)





    • Frequency : 125Khz




    • support protocol : HID compatible protocol  




    • power : +9V to +12V DC




    • read card serial No only




    • wall mount version




    • embedded antenna




    • effective distance up to 3-5 cm




    • Less than 100ms decoding time




    • Low power dissipation with single power supply




    • Built-in LED and buzzer




    • output interface : wiegand 26 bit




    • (42x80x15) mm

    Interface Description  

    Wire color
    Wiegand
    Red
    +9V To 12V DC
    Black
    Ground
    Green
    Data 0
    White
    Data 1
    Drain
    Shield Ground
    Brown
    Red LED (active low)
    Orange
    Green LED (active low)
    Yellow
    Buzzer (active low)
    Blue
    Hold
    Violet
    Card Present