How to: FabTinyStar Programmer

actual boardThe FabTinyStar is a small ISP programmer for AVR chips started at FabLab Amsterdam. You can use it with AVRdude or even from within the Arduino IDE. It is a super cool little USB programmer for AVR chips. You will need something to program this programmer with, so if you happen to have an Arduino that uses the FTDI chip for serial communications, you’re in luck because you can use that as a programmer (just match up the pins on the connector headers) to get the  FabTinyStar up and running. Typically a FabLab has one or two “professional” AVR programmers, then each student builds their own FabISP or FabTinyStar.

The FabTinyStar has gone through multiple revisions, so I’m showing only what I have tested and got working. Zaerc has a good multipart tutorial on FabTinyStar version 12 as well.

Why would you want to use this over the regular FabISP?

  1. Fewer parts (no crystal)
  2. No need to desolder or break off any jumpers after you burn the FabTinyStar Firmware, simply burn the fuses and you are ready to go
  3. It has a switch to power the target board (no need to use external power for the target board)
  4. It has an LED to show that it is connected and powering the target board
  5. It has an LED to show it is programming correctly. This little bit of feedback is awesome for debugging!
  6. The neat-factor of having an 8-pin awesome custom AVR programmer.

To build this device, you can download all of the EagleCAD files and Firmware here. You can use a variety of PCB fabrication techniques to make your own boards. I’ll leave that part up to you. I milled my PCB but you can etch it just as well.

Below I’ve shown the header pinouts for the ISP pins. I recommend you leave off the bottom two pins of the header (USB D+ and USBD-) because if you solder them on there, you can’t use the regular 6-pin header for programming or connecting up circuits.
fabTinyStar-013_lay

Firmware:

In Windows machines, I install the Arduino IDE which will come with AVRDUDE. Search through the installation folders of the Arduino IDE to find the AVRDUDE executable program.  I then typically use AVRdudess or another AVRDUDE GUI to program it using the following settings:

 

FabTinyStar Drivers:

Before using the FabTinyStar, you must install the appropriate driver in Windows. There are a couple of good guides out there (namely the one on Adafruit) but the one that is closest to the FabISP you just built is here at Sparkfun. Following that guide will install the drivers. To check this driver is recognizing correctly, open the device manager in windows and confirm that “libusb-win32 devices–>USBTiny” appears (and disappears when you remove the device).

When using the FabTinyStar, you might need to flash the target chip multiple times, or you might get a “verification error.”

Installation was simple, but not being super familiar with windows, I hit a couple of stumbling blocks. Here are the steps I got to work on Windows 7.

  1. Download the Windows driver for USBTiny (which the FabISP is a type of)
  2. Unzip the folder to the desktop or somewhere accessible.
  3. Plug in the FabISP
  4. Start–> control panel–> hardware and sound –>Device Manager
  5. Once here, right click on the FabISP icon in the “unknown devices” tree
  6. Select “update driver”  or something to that effect
  7. Select the option to manually select the folder the driver lives in and locate the driver to install it.
  8. Also, install the ATtiny hardware files:  Download them here, and unzip them into your ~/My Documents/Arduno folder.
  9. I also manually added “FabISP” to my programmer.txt file.  You *could* just select “USBTiny” in the Arduino Tools–Programmer menu, but I wanted mine to say “FabISP”.
  10. So when you are ready to test this, open the Arduino IDE, select File–>Examples–> 01Basics–> Blink
  11. Change the pin number on line 10 to the one you LED is connected to (Arduino doesn’t use “PORTB.1” for instance, so look at the map at the bottom of this page to see what number your pins are.  You can use that type of addressing if you want, but most Arduino programs don’t).

 

Using this programmer with custom-built AtTiny circuits in Arduino.

The following is a quick summary of this page at HighLowTech to serve somewhat as a mirror, but mainly as a cheatsheet on how to setup and use AtTiny chips with the FabISP in theArduino IDE..

You can use these programmers in the Arduino IDE to program your boards directly, without using the Arduino bootloader on the target chips.To use Arduino IDE, you can install the AtTiny board library from HighLowTech. I don’t use the built-in function for add-on in Arduino’s IDE because it has never worked for me on any machine I’ve tried it on. Typically, I find it easiest to simply download the Arduino library for 1.6.x  (here’s my copy as a backup) and install it manually by copying the “attiny” folder in the zip file to my arduino’s hardware preferences folder. On my machine this is the path: C:\Users\ALaptop\Documents\Arduino\hardware. I had to create the “hardware” folder inside “Arduino”, but then I just restarted the Arduino IDE and could see the change had taken by finding Tools–>Boards–>AtTiny.)

On Mac or Linux, find the Arduino IDE installation and copy the library to the hardware folder.

How to use this new library:

Restart Arduino (or open it if you hadn’t already) and select “Tools–> Boards”  and now you should see a AtTiny entry.   I’m showing what it looks like in Arduino 1.6.4.  Different versions might look a little different, but you should be able to get the same results pretty easily.

board

Once you select “AtTiny” as the board, you will see different options under “processor”.  Select the chip you are using here.

Chip

 

After selecting the particular chip, you can select the clock frequency and whether it is internal or external. If your design uses a resonator or crystal, it is external.

clock

Also, when you select “Tools–> Programmer” you should see “USBTiny” listed.  Select that as well.

programmer

The first time you connect a particular AtTiny chip to this setup, you’ll need to burn the fuses.  The way to do that is plug your USBTiny into the computer, plug your target board (your custom design with an AtTiny) into the USB Tiny, Select the appropriate Chip, Board, and Crystal.  Then select Tools–>Burn Bootloader.”  After this is done, just the target board is ready to accept the arduino code you write.

bootloader

Not all functions of arduino are possible since the AtTiny series chips have fewer capabilities, but most stuff works fine. If you want to drive servos easily with the AtTiny chips, you can use the 8-bit servo library found here

Keep in mind the following pinouts for the AtTiny 44 and AtTiny45 (or 84/85) when writing your arduino code.

ATtiny45-85

ATtiny44-84

Photo Credit: All glory goes to High-Low Tech

Testing it out:

echoHelloWorldFlashy

You can build a simple multi-use board I made as an example.  Download the EagleCAD files and Arduino code for that project here. I originally made the PCB and the code for my FabAcademy page. Check those links for more detailed info.

Open the Arduino IDE and start a new project. Paste the following code in it and set it up to program an AtTiny44 with a 20MHz external clock. PLug in your FabTinyStar, connect the example board and compile and download the code.:

 

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(7, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(7, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(7, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

Book Review: “Hot Seat” by Dan Shapiro

Since we placed an order for the GlowForge laser cutter (more on this in another post), we got a pre-released copy of the Dan Shapiro’s upcoming book on Startups and Entrepreneurship “Hot Seat  The Startup CEO Guidebook” Dan is the CEO of Glowforge and has a string of successful startups behind him such as Ontela (now Photobucket), Sparkbuy which he sold to Google, and Robot Turtles which is a board game designed to teach children as young as 4 years old about programming and logical thinking which he did as a kickstarter and which is now available in Target stores.

“Hot Seat” is basically a cheatsheet on startups broken into 5 parts. Founding, Funding, Leadership, Management, and Endgame. Dan explains his history and cites specific people and examples of practices that will help you navigate the dark waters of a startup.  The first section of the book is all about Founding. There are some great tips here I wish I used in my previous business ventures. Founding is a dirty and scary thing for every startup. You want to think about contingencies from the start. Dan recommends to do this before you even incorporate.

In the first section of the book, Dan gives advice on everything from who should be a cofounder to even providing a template for a decision matrix on what projects your startup should focus on. He also gives great examples of how shares might be calculated for different types of cofounders, answering the question of “How much is each cofounder really worth?”.  These kinds of things are what make this book awesome. Dan also freely gives advice that I’m sure he learned the hard way. Some of this advice is common sense, but there are plenty of gems you’d only learn from a good mentor.

Each section has several chapters in it. Again, the information comes straight from Dan’s personal experience. For the Funding section, there are slides directly from the pitch deck of some of Dan’s successful ventures.  He breaks down what to put on each slide, and how to best present it. Arguably, this could be considered style more than anything else, but with a record such as his, and the fact that he now is an investor in other startups I’m going to go out on a limb and say it’s more than just style. There ae several other chapters in the funding section that explain the differences between different types of investors and what each of their motivations are, which is what you need to keep in mind if you are pitching ideas to them.

In the Leadership section, he discusses the different duties of a CEO, and how to cultivate a good company culture. I think anyone applying for a new job or even considering changing jobs would find this section interesting because you can tell a lot about how day-to-day interactions reflect the culture. The CEO is the taproot of the company’s culture and is the archetype all the other management will follow. It says a lot about a company if everyone is constantly gossiping…

While I’m not a CEO right now, I am in a newer management position at my full-time gig. I found the management section of this book very helpful. I’ve memorized some of it as one-liners that I can repeat to myself to help me learn this new set of skills. My favorite and most obviously useful advice in this section was on “playing the CEO ‘Inspire’ card”. This section also gives great general tips on hiring, whether you should buy or lease furniture, how to deal with a board of directors.

The final part of this book discusses the Endgame. What are the different types of acquisitions? Who do you negotiate with?  It stresses how important it is to have done things correctly and thoroughly from the beginning of the startup.  Technically, the entire goal of any startup is to either be bought or to reach critical mass and go “Google” on the market and end up buying other startups. Either way it is important to know what to expect. Dan gives the example from his previous company Sparkbuy’s acquisition by Google and breaks down the different parties involved and somewhat what to expect in negotiations.

Overall, I really enjoyed Dan’s book. It gave more gritty details than any of the other books on buiness and startups I’ve read. The devil is in the details and while this book stops short of giving you legal advice, you get insights on how things are supposed to work.  Personally, it reaffirmed my intuitions on getting a business started correctly and having contracts in place for the “big day”; be it an exit, acquisition, or other huge event for you or the company. The book will be available in paperback May 2015 and

Playing with Google Apps Scripts

OCRcoverGoogle Apps Scripts (GAS) is an interesting tool that you can use to automate tasks using functions built into Google’s powerful APIs.  Personally, I couldn’t find a ton of info on the syntax and what-not for the language, but it seems to be javascript with some caveats. (It doesn’t like linebreaks in the code, you use only a single quote for Strings, and it will ignore newline characters in strings “\n”).  Oddly though you can’t use the javascript examples from Google’s developer API examples directly (or at least I didn’t have any luck).

As an example project, something I’m working on required me to read the text out of an image then highlight keywords. I broke this down into three steps.

  1. Acquire an image
  2. Use Optical Character Recognition (OCR) to read text
  3. Search and highlight keywords

Background:

I’ll start with giving you access to the finished project code. To run it,  you will have to “File–>Make A Copy” of the project. Then follow the steps on this webpage word-for-word to Activate the DriveAPI and developers console and you’ll be fine.  Sometimes the developers console site doesn’t want to load, just keep trying it until it works. When you want to run the code, you click on “Publish–>Deploy as web app”. The first time you’ll have to set who you will allow to have access to the app. They will also have access to your google drive if you allow them to execute as your account so be careful. Once you’ve set this, click “Deploy”.  Then you’ll get the link to the web app.  The first time you run it you will have to give it access rights to your google drive.

The Guts and Explanation:

OcrTestForm

Luckily while searching, I stumbled across the blog of Amit Agarwal which if full of great example code.  For step one, the simplest solution I could find was his code example that uses a custom HTML form upload an image to your google drive account.   This might seem like overkill. Why didn’t I just use the fileID of something already in my google Drive?   Well, in this particular application, the user might be uploading multiple files from a camera on a mobile device. This form setup seemed to be a simple web-based uploader which gives me complete access to the guts of what’s going on.  This will help me get the fileIDs easily for different files.

For the second step, the OCR, I had attempted multiple times and methods for getting an Android native OCR library to work. Every tutorial I found was highly dependant on the version of Android SDK or Eclipse I had, or I would just hit a dead end when I tried to compile. Plus, those would only work on Android, not every device. I really wanted a web app. That’s actually how I stumbled upon Google Apps Scripts again.  I had played with it a bit in the past, but this time, after finding some great example OCR code from Amit’s website, I found GAS much more accessible. I added this code to the HTML form example from Step 1 above and tweaked it a bit.

In the original OCR code snippet the script reads an image, then creates a Google Doc with the image followed by the text that it recognized. This file is saved this into the root folder of google drive.  Since the uploader code (from Step 1) saved its picture into a subfolder, I made the OCR code save into that same folder.  The way to do this is to add a “parents” ID tag to the properties of the OCR file.  Since I already had the folderID from the uploader code, that was pretty easy to sort out. This was not super easy to figure out. As I said, I couldn’t find a lot of info on GAS language and this was one of the things that took me a while to find. By looking at how Google’s other services save a file into a subfolder, I was able to do the same thing in GAS.  You can see the results below.

OceTestDriveFolder

I tweaked the form code to print out the URL of the newly created Doc file with the searchable text.  I couldn’t figure out how to get logging to work in GAS at all.  Every time I tried to run something that should print to the console, a console would briefly appear, but disappear before I could read anything. So I just stuck with having the form print the URLs. Then I could copy and paste them into the address bar to visit the document.

The third step was searching for keywords within the text.  Again, someone else had done the hard work for me.  I simply tweaked the code and pasted it as a function into my script.

To test the code I printed a page of public domain POE-etry and took a picture of the page with my cellphone to simulate how a user might do.  To make sure that I’d get a lot of hits on my text search, I hardcoded the keywords for the search to be the rhyming sounds in the poem.  In this case –oor and –ore.  Then I uploaded the image to my Google Drive using the HTML form. After a couple of seconds (it takes a couple of seconds to upload) all I needed to do was open the newly created OCR DOC file and see how well the OCR worked.

As I said before, the Google Drive’s OCR process pasts the image into the file, then translates the image to text. Even in normal room lighting at night time it was really good at translating the text and easily searchedand highlighted the keywords I hardcoded. Here’s the resulting file.

Guiding Telescope with a Webcam Setup

I’ve finally gotten jealous enough for the astrophotography subreddit to get back to work on this project. Jess bought me a Meade LX10 8″ diameter telescope several years ago for my birthday. I’ve used it quite a bit to view planets and try to take deep sky astrophotography pictures. This telescope isn’t one of those fancy ones you can type in whatever cool thing you want to see and it’ll drive itself to point right to it, that’s called a “GO TO”. Rather it has a simple “barn door” tracker motor. Basically, if you align to perfect true north, and set the wedge (the thing that mounts the telescope to the tripod) to your latitude, whatever you point the scope it will stay in view for hours in the eyepiece. If I know where to look, I can attach a camera to the scope and leave the shutter open and get some amazing pictures of nebulae and galaxies.

Being that I’m no good at polar alignment, I decided a few years ago to build an arduino interface that will connect my scope to my computer.  The way this works is that I attach a webcam to the spotter scope (the small telescope that helps you find stuff) which looks at a particular star.  The webcam pipe data into a program that sends signals out to the arduino to move the scope to keep the star in the same part of the webcam’s view.  This way, I don’t have to be perfectly polar aligned, the software will help adjust the position of the scope for me.

I went on the hunt for a webcam that would work well with Windows and linux.  This is because a lot of people are buying Raspberry Pi boards,connecting a webcam to them and attaching the whole setup to the telescope. Right now I’m testing on a windows machine so I need a webcam that’ll play well with both.  I looked up the Linux Universal video Class (UVC) drive list to find a good modern camera. This list shows a good number of webcam models and brands that are known to work natively in recent linux distros.

The camera I landed on is the Logitec HD Webcam C270.  It is a very cheap 720p 3 megapixel webcam. That’s overkill for the telescope, but it’s a good general use webcam and we can use it for video chats and such as well.  This means my solution to attaching the camera to the scope can’t be permanent.

I keep a bunch of 3/4″ PVC pipes and connectors in the garage for prototyping, so I grabbed a 3/4-inch T connector.  This connector can easily accommodate my 1″ outer diameter sighting scope.

webcamTele

The scope doesn’t fit perfectly, so I added some 2mm sticky-backed craft foam for a snug pressfit. (On a side note, I can’t tell you how useful it is having this kind of foam in the toolbox for all sorts of random purposes. I use it all the time)  To accommodate the webcam, I used a hacksaw to cut a portion of the PCV connector off as shown.  Then I wrapped a 3/8″ piece of foam on each of the cut edges of the PVC where it will touch the camera. This will help the camera seat well and stay in place when I attach it to the scope.

3webcamTele  4webcamTele

Finally, I used a smooth “ouchless” hair tie to hold the camera to the PVC tightly and aligned the camera with the hole in the PVC T-joint. Again, believe it or not, these hair ties are pretty useful for random jobs.  In fact, I use a 8-inch smooth headband made of the same material to hold on my cheapo dew shield (more on this in another post.)

5webcamTele  6webcamTele

7webcamTele

 

The final product is easy to use and quite robust. I think it’ll work quite well with my the rest of my setup.  Since I’m still working that all out, I’ll post more as I learn more.8webcamTele

Audible and My Reading Life

I started last year out strong by reading 5 books just in January.  That is where my documentation ended, so I had to resort to the virtual trail left behind on my Kindle and in Audible for my yearly stats.

I read 15 books on my kindle. I read at least two books in print. I’m sure this number is higher, but I didn’t put any effort in determining what other books I may have read. I listened to 6 books through Audible.

This puts my last year total at 23+ books. I don’t have a numerical goal for this year. I simply want to get into a more regular habit of reading and documenting my reading progress.

Jessica-of-SheekGeek

P.S. My reading stats would have been 6 books less without Audible. It is a happy part of my work/home commute. (It feels so productive to “read” while you drive.) If you are interested, you can try Audible out for free; or dive right into a Gold membership (which is what I have).