Archive for the ‘hacking’Category

Arduino Auto-programmer part 1

I thought I’d try something new with this project. Write about it as I go along, revealing all the mistakes and false starts, etc. and not wait for it to be finished. Heck, it might never be finished!

This project was inspired by the various arduino-ISP shield tutorials out there.  Evilmadscientist.com has an excellent shield, and Adafruit has a do-it-yourself tutorial. These generally make the arduino into an STK500 compatible USB programmer, and you need a computer to burn the chip. I thought, why not make a shield that had a micro-sd card on it and push a button, and bang! chip programmed!

Not many people probably need this kind of production, but I thought I could learn a few things.

Now Adafruit has another cool project based on another project called Optiloader, where you can embed a program in the Arduino program and burn standalone, but the program has to fit on the Arduino along with the programming code.

Here’s my basic plan of attack:

  1. Decide what I want the project to do. Here I brainstorm a bunch of features and put it into a google doc. I then prioritize what I want for the first iteration.
    Here’s basically what I came up with:
  2. Project Overview:
    Create an Arduino Shield for standalone programming of atmega chips from files stored on a micro-sd card. First iteration will handle one program on the card (selection of files would require UI)
    Functions:
    • Program chip from files on SD card
    • Read chip to files on SD card
    • Maintain ArduinoISP functionality?
    • Log ArduinoISP session to card?
    • replay ArduinoISP session from card?UI
      • Read(read from chip to SD card) button
        • Green Light indicator
      • Write (program chip from SD card)
        • Red LED indicator during/flashing green at finish
      • Error indicated via flashing red
      • If USB is connected, information printed via serial
  3. Order any parts I need. In this case, I bought a micro-SD breakout board from Adafruit. This has a voltage shifter chip to protect the cards (which use 3.3 V from the 5 V Arduino signals. I already had a zif socket.
  4. Breadboard the project. As you can see above I did the minimum. For the “shield version” I’ll probably also add some buttons and indicator LED’s
    Here’s the wiring to the atmega/ziff socket (from the adafruit tutorial):

    1. Pin 1 to digital 10 – Blue
    2. Pin 7 to 5V – Red
    3. Pin 8 to Ground – Black
    4. Pin 9 to digital 9 – Gray
    5. Pin 17 to digital 11 – Brown
    6. Pin 18 to digital 12 – Orange
    7. Pin 19 to digital 13 – Yellow
    8. Pin 20 to +5V – Red
    9. Pin 22 to Ground – Black
      SD Breakout Wiring:
    10. GND to Ground
    11. 5V to 5V
    12. CLK to Arduino Pin 13
    13. DO to Arduino Pin 12
    14. DI to Arduino Pin 11
    15. and CS to pin 8 (important as this has to be different than the line used to select the 328!)
  5. Test the individual parts to make sure they don’t interfere with each other. I loaded the Arduino ISP code, and programmed an atmega328, and I loaded the SD library and read some files off the card. You’ll also need to change the code line in the SD example code to use the different chipSelect line.  I learned/realized a couple of things:
    1. I should probably include a crystal/oscillator so that you can burn fuses that require an external oscillator (like the Arduino itself)
    2. One of the SPI lines is tied directly to the SD card activity light. This means that that light will flicker when the chip is being programmed.

This is as far as I’ve gotten so far. Next:

  1. Write the code to read Intel Hex files from the card
  2. Define and write code for a file for fuses
  3. Adapt Optiloader code to write data read from the card
  4. Implement user interface

29

11 2011

Black Friday? No! F.A.T. Yes!

For the third year, our family entered in to the mad-crazy collaborative experiment that is  the Friday After Thanksgiving Chain Reaction at MIT in Cambridge. I think the main idea is to create, and not consume, and I love not only being there with my family creating, but also seeing the brilliant creations of everyone else.

As usual we weren’t super prepared (even th0ugh I spent most of the day on Thursday building) and spent almost till the last minute preparing and fixing, and our run wasn’t without the “Hand of God” helping it along, but it was fantastic!

I didn’t get very many pictures, but I’ll tell you about what we did.

The event is emceed by Arthur Ganson, artist in residence at MIT, and Mechanical genius. He has a whole room of his sculptures at the MIT museum, and it’s worth a trip just for that. He also generously helps people out, encouraging everyone, and builds the final link with some sort of theme. This year (the 14th) the theme was Sonnets, and his final piece dropped ostrich feathers one at a time with lines from a sonnet he wrote (it was beautiful!)

Each link is triggered either by a string pull or a golf ball entering your contraption. This year we decided to go for the additional challenge of the golf ball for the first time. We reused a ball run I made for last years event, and added an elevator for the ball made out of Knex.

Here’s the sequence:

  1. First the ball lands in a “chair” made out of Knex, and presses a Lego Mindstorms NXT touch sensor under it.
  2. This triggered the NXT to supply power to a short section of Lego 9V train.  The train steamed forward to…
  3. A brilliant Lego pneumatic switch mechanism design by our 11 year old neighbor and friend Jackson. This pneumatic contraption then fired his new high power laser pointer which….
  4. Popped a black balloon holding steel balls which
  5. Fell on a plate over a switch which triggered an Arduino controlled Silly String shooter. Getting to make this was some of the most fun. Before the event, I hooked it up to a motion sensor and surprised my kids with it. I got the idea while at Walgreens walking down the toy aisle. I thought, hey, I can probably rig a servo to spray that! Of course, googling it first, It’d been done! And cleverly too, so not one to reinvent the silly string shooter, I copied the design (though not the code…) Here’s the instructable that I used: http://www.instructables.com/id/Arduino-controlled-Silly-String-shooter/ by Instructables user Eric Kingston
  6. The silly string sprayed onto a paper plate (decorated as a target by Charlotte!) which pressed a microswitch that triggered another Arduino that used an Adafruit motorshield to run a KNex motor which I spliced into to run the winder to lift the golf ball. I use this shield a lot, for whenever I want to make some scavenged motor move something. For example I once built stuff from cd-rom drives for the kids to interact with in their classroom. Very handy.
    When the golf ball reached the top…
  7. The same Arduino started spelling out a message on the super bright 8×8 LED panel from Modern Device that I picked up at Maker Faire in Rhode Island. It scrolled FAT.. This board has a fabulous library, is super bright, and really easy to use.
  8. The golf ball rolled down several ramps to a makeshift ramp between tables and on to the next table.

Our neighbors contraptions put ours to shame, both in terms of mechanical cleverness and overall finish. The one before us was an elaborate mechanism that shuttled brightly colored golf balls along a track to fall into a bucket, the weight of which eventually powered a putter to put the travel ball on to our section.

I encourage everyone to come and to build! It happens every year, and it doesn’t take much to participate (some links are little more than domino runs) and it certainly gets you away from the shopping crowds into a much better crowd!

Afterwards, we hung out in the empty gym and flew our new Air Swimmer (which I highly recommend!)

27

11 2011

Woot! Free tool!

Instructables.com is one of my favorite sites, offering step by step instructions for all kinds of projects.

Instructables author Randofo created a cool Arduino shield for programming 8 pin attinys. In a brilliant move to get more instructables submitted, he offered one for free if you submitted an Arduino or AVR instructable. Well, that pushed me over the edge and I submitted my first one:

http://www.instructables.com/id/Turn-a-TV-B-Gone-into-a-super-camera-remote/

And this is what they sent me! Cool stickers and a badge! Now I just have to come up with a Nerd sash!As an added bonus, my instructable got featured on the home page and they rewarded me with a pro membership!

Now that’s the way to develop motivation to provide content!

Since getting the shield, I’ve already hacked it. It can’t program attinys with an external clock, so I added one, and put up this instructable:

http://www.instructables.com/id/Using-the-8Pin-ATTINY-programming-shield-with-an-e/

20

11 2011

More Noise: Sound sample

I’m a little reluctant to release this, as the police may use it on the occupy protestors. This is one annoying sound!

It was pretty hard to hear what the circuit sounded like in the video, so I modified it to have a line level output and recorded it on my computer. At first I was baffled, as the volume kept going up and down, and there were weird compression artifacts until I figured out the  sound card in my computer was doing all sorts of noise reduction and signal processing on the microphone input! I turned it off and here’s the raw sound:

17

11 2011

Making Noise, learning electronics!

I’d seen several projects on the net to make analog synthesizers, including the classic Atari Punk Console. I’m anxious to design something of my own, but I’m still learning, so I thought I’d start small. While this is not something that hasn’t been done before, I did it entirely from scratch. I read datasheets, and experimented with values for components.

Here’s a little video overview:

I did this project iteratively, first implementing a single oscillator controlled by a variable resistor or potentiometer. The capacitor I chose (220 pF) was somewhere in the middle of the range recommended by the data sheet, though I tried several other values. I have a cheap analog scope, and I could see the oscillation, but when I tried to attach a speaker, it went dead.  I hooked up a piezo element and it could drive that, but it wasn’t very loud. I stuck in a 2N2222 transistor, and used a pot to determine the optimal (loudest) bias resistor for the base, and replaced it with a fixed value.

Next, I replaced the pot with a photoresistor. This was fun, but the tone was pretty boring (plain square wave). I then hooked up another gate to drive an LED. Pointed at the photo resistor, but some distance away, it provides a cool beat, while the “average frequency is determined by the other light hitting the photoresistor. The frequency of the beat is controlled by a potentiometer like in the first circuit.

Here’s the schematic:

One tip: You’ll notice R3 in series with the potentiometer. This is because the pot goes all the way to zero, and at zero resistance the cap won’t charge and discharge properly setting up the oscillation. This sets some non-zero base value that you can set experimentally based on what you want that end of the frequency range to be.

13

11 2011

Super Camera Remote updates

I removed a delay in the 1.2 version of the supernikon code, so it should be more reliable now.
I also did an initial implementation of a canon remote, but I don’t have a Canon DSLR, so I haven’t tested it yet. Looks ok on the scope.

Here’s a link to the Canon code

and the Updated Nikon Zip

also available as a git repository: https://github.com/osbock/Baldwisdom

02

11 2011

Scary Robot Pumpkin Invasion

I left work a little early (around 4pm) to finish up the Cylon pumpkin.  The carving went pretty well, but it was starting to get dark by the time I put the electronics in.

If you want to do this project, please don’t do as I did with scratch building, and just buy the kit. When I put the electronics in the pumpkin, they didn’t work. I pushed my fingers around on the back of the board and I could get it to work sometime.

Back upstairs, I x-acto’ed between traces where there was already corrosion (I didn’t clean the flux very well) and resoldered a few things. Whew! Got it working 1 minute before the first trick or treater came!

And here’s the whole display. I hope you enjoyed it!

31

10 2011

Desperate Halloween Project: The Cylon Pumpkin aka Larson Scanner

We’ve been so busy this season, there’s been little time for extra things. I used to go all out for Halloween, but this year we decided we couldn’t do much more than help the kids with their costumes. Well, this bothered me, and I decided to at least try to do a cool jack-o-lantern.

I’ve mentioned my love affair with EvilMadScientist.com before. They have a ton of quirky, always fun projects. (I’m still trying to convince Joyce we need an eggbot!)

They have a very nice, inexpensive kit to do a “Larson Scanner” which is  a row of LED’s that scan back in forth, like in the Glenn Larson TV shows Knight Rider, and Battlestar Galactica. They also love Halloween, and published a list of their Halloween related projects. The first Cylon Pumpkin they did, was a simple slit in the pumpkin to show off the scanner, but more recently they did this awesome carving:

The project linked to this picture uses an older circuit, not the EMSL kit...

Now I haven’t carved mine yet, and I wasn’t thinking ahead. It would have been much easier to just order their kit ($13) but I had most of the parts lying around, and I stayed up late laying it out and soldering it (badly) to a proto-board. My local electronics store doesn’t have a very good selection of proto-boards, but they had a cheap (<$3) proto-board laid out like a solderless breadboard.

I’m sure this is old hat to most folks, but I realized that I could squeeze the IC in, not in the middle where it’s supposed to go, but toward one side by cutting the traces between the rows of pins for the socket.

I didn’t want wires on the front, so I tacked them from the back, and that was hard, and a little messy, as it’s very cramped especially in the middle of the attiny micro.

Once again, this whole project wouldn’t have been possible without my adafruit usbtiny ISP programmer. I used an Evil Mad Scientist minimal target board to program the chip.

EMSL’s code is a thing of beauty and a lot can be learned by studying it. Hopefully I’ll be back after tomorrow night with pictures of the finished Cylon-O-Lantern.

30

10 2011

Soul-B-Gone: A super camera remote

I’ve had a lot of fun with my TV-B-Gone, which I bought direct from Mitch Altman (the inventor) at Maker-Faire RI a couple of years ago. I particularly like turning off the plague of flatscreens at work, and every one I can see through the glass doors in my building!

I have a Nikon D90, and the little IR remote which has been very useful, but is pretty weak. It’s flakey past 5 feet, and you really have to point it right at the front of the camera. I thought, gosh, the TV-B-Gone is AWESOME, and open source, so I set about to make it into a super Nikon remote.

Here’s the 1.2 kit from Adafruit. It’s more powerful because it uses a better design of cascading transistors.

The actual hack took less than a half hour. I found someone else had done the reverse engineering of the timing on the web (http://www.alanmacek.com/nikon/)

The 1.1 software was super easy to translate the timings to. I recently bought a version 1.2 kit (the current version) and ported the software which involved mostly changing the polarity of on/off, and using a single pin instead of two.

The biggest part of this project was assembling all the bits to program. I built a usbtiny (Love it…) and used an extra TV-B-Gone pcb as a minimal target board.

The thing is Awesome! I haven’t tested how far it goes, but it hasn’t failed me yet, and it bounces around any room I’ve tried it in to be far less directional.

Thank you Mitch and Limor! Your code was great, and it was such a thrill to make something I wanted!

You can download the firmware from github. Now the only problem is switching the chips. The 1.2 version frees up a pin to use as region select, so it is possible to use it as a switch to select between camera remote and tv-b-gone.

20

10 2011

What Can You Learn From A Kit?

The family and I recently drove down to Providence, RI for the Mini-Maker Faire and Waterfire. It was really mini this year, but there were some good groups there including several hacker spaces and several of my favorite micro-businesses (mostly small electronic kit makers.) I’m usually inspired by something, but often too cheap to buy the really cool stuff. I bought two LED array kits from two different vendors, thinking it would be a good learning experience, both for myself and the kids. It’s also great to support local Makers! Also, I figure I’m contributing to open source by giving them feedback. John has already responded to the feedback I’ve given him and will be updating the site, and maybe even future designs (I thought he needed bigger solder pads…)

I bought two kits: a Charlieplexed 10×10 LED array from John Luciani (http://wiblocks.com) and an 8×8 LED driver based display from Modern Device. A charlieplexed display takes advantage of a quirk of microcontroller IO lines to control many LED’s with a smaller number of control lines. In the 10×10 display example, 11 IO lines are used. Since you only use the microcontroller and no additional chips, this design is much cheaper than the alternative. The disadvantage is that because it is multiplexed, the display will be dimmer and can’t really achieve full LED brightness when all the LEDs are lit.  The driver version uses special LED driver chips that communicate with a serial protocol to use only 3 or 4 lines to drive many LED’s. In the Modern Device unit, it uses 4 chips (which share the same serial “bus”) each controlling 16 LEDs. Not only does this allow full brightness, the boards can be daisy chained together to make bigger displays, using the same control lines and a single microcontroller driving them.

I haven’t built the Modern Devices display yet, but I’ll share what I learned from the Wiblocks kit.

Picture from John's site. Much nicer assembly than mine.

1. John is a really nice guy!

Ok, I already knew this as I’ve met him before at various maker events, but he was really generous as well, giving me a spare PCB for one of his drawdio remix boards (I have all sorts of EVIL plans for these! Stay tuned). He accidentally gave me the wrong board (an 8×8 board), so he promptly mailed me the right one and let me keep the other.

2. Read the instructions.

Ugh, could have avoided this!

I admit I’m one of those guys who thinks winging it is better. One really cool thing about John’s designs is that he wants you to use them as a starting point, and makes them very flexible.  The microcontroller board he includes with the kit is a mini version of the Arduino he calls the PICO1TR. He include instructions (and the appropriate components to build it to be compatible with 3.3V logic, or 5V logic.
Since most of my past experiments have interfaced with 5V electronics, I built the controller as 5V, and then started the LED board and found out that with 3.3V you don’t need ballast resistors (not included.) Well, not a big deal, except my stock of resistors is all 1/4 watt, and the board is quite compact and laid out for 1/8 watt resistors. This meant they stick up, and I had to add some ugly insulating material to make sure I didn’t short things out.

3. Debugging!

There were a lot of LEDs to solder, and it’s really hard to keep them all neat and straight. Fortunately I learned that flux is my friend and the soldering went very quickly, and looks pretty neat. Some of the LEDs point this way and that, but I was in a hurry. The proper way to do this is to drill holes in a piece of wood or plastic, stick the LEDs in there, and turn the board upside down and solder in place. Like I said, I was in a hurry….

I installed John’s libraries and tried to download his sample code but it wouldn’t compile. It turns out that in one of the Arduino releases since John built his library, they included an new WinAVR which has different pin names. I changed all the PB0 etc. to PORTB0 etc. I then downloaded the program to the board, and Viola it worked! Well, mostly. There was an extra LED coming on sometimes in the blank area and when that LED was supposed to be lit, it didn’t and several other LEDs lit dimly. I wrote some test code:

Turns out, the LED was in backwards, and because of the way the charlieplexed LEDs are hooked up, some current leaks into the rows and columns around it. (I haven’t completely thought this through, so that may not be entirely technically correct…) I reversed the LED and everything is cool!.

4. Let’s write some code!

One of the excuses I used to buy this, was that I thought it would be good to teach about arrays. Now I haven’t been brave enough to try it on a kid, I did write a bunch of bitmap manipulation routines to set and query x,y values in the array. Hmmm, what do do with that? Conway’s Life of course! I’d never written that before, but it was fun, and made me think a little! Right now I have it set to randomly re-seed after a certain number of generations, but I’ve laid the groundwork to detect static displays, and the next version will run until the current generation is just like two generations back. Another thing I wanted to learn, but is in the future, is to post code on github, and I have an account there, but haven’t gotten around to posting it yet. Until then, here is my modified library, and here is my life code. Drop the library folder in the arduino/libraries folder, and the life code is an arduino pde file (add the folder to sketchbook folder).

28

09 2011