Avoid NCH Software Like the Plague!

I recently made the mistake of installing TwelveKeys by NCH Software on my computer.  Afterwards, I noticed strange new items the context menus that pop up when you right click a file in Window Explorer.  For instance, when I right clicked on a ZIP file, there was a new item, Extract with Express Zip.   Since TwelveKeys is a program for music transcription, it didn’t occur to me that this strange context menu item came from installing TwelveKeys.  Only after I googled Express Zip did I find out that it was installed by Twelvekeys.  It turns out that a number of other people were irritated by NCH Software adding extraneous context menu items to their systems.

I immediately uninstalled TwelveKeys, and much to my dismay, found out that the uninstaller leaves the context menu items behind.  Even worse, the context menu items all refer to software which gets uninstalled, so they point to a nonexistent file.  I used regedit to search for “NCH Software,” and found well over 100 junk context menu items in left in my registry!

Here is one of the 20+ entries it installed for VLC alone:

The items all attempt to launch TwelveKeys.exe with argument -extfind to automatically download more software into your system.

It took me over an hour to manually search for and delete the garbage with regedit.  This is a particularly insidious form of spam, and should not be tolerated. I will never again install any programs by NCH Software on any of my computers.

OpenSprinkler – An Open-source Internet-connected Sprinkler Controller with Web Interface

My house has a crazy amount of sprinklers.  In the front yard alone, there are 14 channels, which have been controlled by two very old Irri-Trol DewBee 7-channel units. I’m sure that they were fancy high-end stuff when they were purchased, but they look like they’re over 20 years old.  Not only were they a pain in the ass to program, but for the past year, they’ve been flaky, watering on the wrong days.  Another irritant is that they use a 9v battery backup which doesn’t last very long, so every time we have a long power outage, I’ve had to spend 1/2 hour reprogramming them.  It was high time for a replacement, but I couldn’t find anything that met my all of requirements at the hardware store:

  • easy to program
  • supports 14 channels
  • non-volatile program storage, so no reprogramming needed after long power outages
  • automatic clock setting after power outage
  • inexpensive

In addition, I thought it would be cool to be able to control it from the Internet, so I could change the settings if necessary, when away from the house.  I recently started playing with my Raspberry Pi, and was looking for a project to do with it, as a way to learn the ropes.  An Internet-connected sprinkler with a web browser interface immediately came to mind.  The RPi seemed perfect for the task, with its built in Internet connectivity, SD card, and tons of RAM.  One thing I’ve found with Arduino is that it’s easy to run low on memory when implementing web interfaces on it. No such problem with the RPi.  The RPi doesn’t have enough GPIO pins to handle my 14 channels + an LCD display, but I figured that I could cook something up with I2C.  The control aspect seemed  relatively easy to handle, but then I started thinking about how much work the web interface would entail.

Before starting on my own DIY sprinkler, I decided to search for existing open source sprinklers and happened upon Ray’s Hobby’s OpenSprinkler.  As soon as I saw it, I knew that I shouldn’t bother reinventing the wheel.  OpenSprinkler is an Arduino-compatible system with:

  • open source hardware and Arduino-compatible firmware
  • ATMega 328 MCU, 16×2 monochrome LCD, Ethernet, and onboard USBtinyISP
  • web-browser-based interface + direct HTTP interface for writing your own scripts
  • 8 channels, extensible in increments of 8 channels with extension boards
  • completely solid state, using 8 triacs instead of relays

Since I needed 14 channels, I ordered a DIY OpenSprinkler 1.4u kit ($89.99) and an extension board ($25.99).  Pre-assembled SMT boards are also available at higher cost. Shipping was very fast, and I received a box a few days after I placed the order.  The kit came nicely packaged, with bubble wrap protecting all of the delicate parts:

The components were also bagged in separate groups, which made finding the parts easier:

Ray’s Hobby has great documentation on their website.  The step-by-step assembly instructions are very clearly written, with lots of photos, and easy enough for even a noob to follow.  It took me about 3.5 hours to assemble both the main board and extension board, and one hour of that was spent undoing a careless error on my part.  I inadvertently soldered 4 of the triacs on the main controller board backwards, and had to clip the leads and solder them onto the top of the PCB in order to reverse the connections.  You can see in the photo below that the rightmost 4 triacs are all askew due to my messy rework:

The kit doesn’t come with a 24V transformer, so I salvaged one from one of my DewBees.  The firmware is completely open source Arduino code, and is hosted on github.  The controller has a built-in USBtinyISP, so you don’t need an FTDI cable or programmer to load the firmware.  It comes preloaded with the latest release, so I didn’t test uploading new firmware yet.

Ray takes the cautious approach, walking the user through inserting only the switching regulator and testing the power supply voltages before inserting the remaining IC’s.  After verifying the 5V and 3.3V supply voltages, I inserted the rest of the IC’s and to my delight, the unit powered up flawlessly on the first try:

The unit has a test mode that is entered by pressing and holding the top button while powering up.  In test mode, it cycles through the channels, turning each one on for 5 seconds.  I tested the triacs with a voltmeter, and was happy to find that I hadn’t fried any of them or messed up any PCB traces while doing my rework.

I mounted the units on top of my existing controllers by simply sticking them on with double-sided foam tape:

This way, I can revert to the old controllers when I sell my house.  I’m not sure if the new owners will be savvy enough to figure how to connect it up to the Internet, figure out the IP number mapping to the unit, and then pull it up on a web browser.

For Internet connectivity, I’m using an old Linksys WRT54G in running DD-WRT in wireless repeater bridge mode.  An added benefit is that I can now use my house’s WiFi from my driveway, where the signal was previously too weak.    I have my router set up to assign a fixed IP to the OpenSprinkler.  If you forget the IP number, pressing the 2nd button displays the current IP number and TCP port.

The web interface is a bit quirky, but it’s easy to use once you figure it out, and has  a terrific graphical preview screen.  The preview screen is actually one of the features that really sold me on OpenSprinkler, because it makes it very easy to check your programming for errors:

Ray cleverly gets around the limited memory of the ATMega328 MCU, and avoids having to have an onboard SD card by hosting a bunch of javascripts on his own webserver.  This means that in order for the web interface to function, the unit must have Internet connectivity.  You can host the scripts on your own LAN if you wish, but then you need to have a webserver running at all times.

I’ve only OpenSprinkler running for a couple of days, but so far, it’s running flawlessly.  I am very impressed with the quality of Ray’s Hobby’s products and detailed documentation, and would definitely recommend them to my friends.  Ray is actively working on improvements to the firmware, and since it’s open source, I’m able to hack it any way that I please.

How to use a WiFi Dongle with Raspberry Pi

My house isn’t wired for Ethernet, so I needed to get my Raspberry Pi networked via WiFi.  USB WiFi dongles are cheap, and can easily be found for less than $10.  I just happened to have an Airlink101 AWLL6075 laying around.  By coincidence, it uses the RTL8191SU chipset, and the official Raspbian distribution is preloaded with the appropriate driver (module r8712u).

USB WiFi dongles use quite a bit of current, and some web references said that they could only be used with the RPi via a powered USB hub.  However, some people reported success without the hub.  I couldn’t find a working powered USB hub in my house, so I tried connecting my dongle directly to my RPi.

While googling around for instructions on how to configure Raspbian for my WPA2-PSK network,  I found several different sets of instructions for configuration, and none of them worked.  After wasting a whole afternoon with no luck, I found out that early RPi boards had 140mA polyfuses to limit current draw on the USB ports. In addition to limiting the current too severely, the polyfuses lower the voltage below spec.  Therefore, later boards have 0 ohm resistors instead of the polyfuses.  Here is an official blog post which shows that the later boards don’t have the fuses:  http://www.raspberrypi.org/archives/1929

The fuses in question are F1 and F2.  The polyfuses are green, and have 14 written on them.  The 0 ohm resistors are black.  If your RPi has the resistors, then you don’t need to modify it. My board had the polyfuses, so I shunted them by soldering in jumper wires:

Bingo! The WiFi fired right up and connected to my AP on the first boot after the fix.

The easiest way to configure the SSID and password for your network is to edit the file /etc/network/interfaces:

$ sudo nano /etc/network/interfaces

Add the following lines to the file:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid “YOURSSID”
wpa-psk “YOURPASSWORD”

Substitute your network’s SSID and password in the quotes above.  If present, remove the 70-persistent-net.rules file:

$,sudo rm /etc/udev/rules.d/70-persistent-net.rules

Upon rebooting, your WiFi should connect up automatically.  If you want to start it without rebooting, type

$ sudo ifup wlan0

Here are some useful commands related to your WiFi configuration:

$ iwlist wlan0 scan

scans for and displays available WiFi networks.

$ iwconfig

shows WiFi connection info, such as ESSID, bit rate, and frequency.

$ ifconfig

displays network information, such as IP number, MAC address, and packet errors.

How to Install Emacs on Raspberry Pi

I just got my Raspberry Pi up and running on Raspbian, and was finding nano, the pre-installed text editor a bit lacking.  I’ve been using Emacs since college, and decided to get it up and running on my Pi.  It turns out that it’s quite simple to install GNU Emacs:

$ sudo apt-get install emacs

If the above command fails and complains of missing packages, try

$ sudo apt-get upgrade

and then retry installing emacs (thanks to Tom Sargent for this tip).

Emacs users typically prefer their ctrl keys to reside where the Caps Lock key typically resides on most PC keyboards.  To swap the left Ctrl and Caps Lock keys, edit /etc/default/keyboard, and find the line XKBOPTIONS line.  If it’s currently empty, just replace it with

XKBOPTIONS=”ctrl:swapcaps”

if the line already has some other options in it, simply separate the options with a comma, e.g.:

XKBOPTIONS=”compose:rwin,ctrl:swapcaps”

To make the change effective, type:

$ sudo dpkg-reconfigure -phigh console-setup

They keyswap will persist across reboots, and works in both virtual text consoles, and X-windows.

Marlin Tuning

To get the most out of Marlin, here are a few simple tweaks.

1. EEPROM Settings

By default, Marlin forgets any configuration changes you make via the Mxxx G-codes whenever you reset or power cycle your controller. If you want to remember the settings, so you don’t have to set them every time you power up your controller, Marlin can store them in EEPROM. In Configuration.h, uncomment

#define EEPROM_SETTINGS

EEPROM_CHITCHAT is optional:

//to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
// please keep turned on if you can.
#define EEPROM_CHITCHAT

You will need to compile Marlin and then upload the modified firmware to your controller in order to take advantage of the changes.

After sending your Mxxx G-codes to Marlin, send M500 to save them to EEPROM.  You can also revert to default (“factory settings”) with M502.

One nice feature of Repetier-Host is that you can use it to set your EEPROM, rather than manually typing in Mxxx G-codes.  Simply go to Config->Firmware EEPROM Settings from the menu.

Personally, I prefer to just set all my Mxxx G-codes as start G-codes in Slic3r, rather than storing them in EEPROM, but most people will probably prefer to use EEPROM.

2. PID Auto Tune

When I first switched to Marlin, I was not at all happy with the temperature control of my extruder.  It was taking a long time for my hot end to heat up, and the temperature was still varying a lot. While the hot bed is controlled using bang-bang (traditional on/off temperature control), the extruder uses a more sophisticated algorithm, called PID, which should yield better temperature stability.

Initially, I tried turning off PID by commenting out

#define PIDTEMP

in Configuration.h.  My hot end heated up much faster, but the temperature was still fluctuating a lot.  I decided to try to get PID working better.  In order to get best performance out of PID, there are some parameters which need to be tuned: Kp,Ki, and Kd.  Configuration.h contains settings for Ultimaker, Makergear, and Mendel Parts hot ends, but I’m using a JHead.  I had no idea what values to use for After doing a bit of googling around, I found out that Marlin has a way for it to automatically calculate PID parameters, G-code M303 – PID relay autotune.  To automatically tune your hot end PID parameters, start with your hot end at room temperature, and using Pronterface, send it the M303 G-code as follows:

M303 S230

The parameter is the target temperature in celcius.  If your target temperature is different, substitute it for the 230.   Marlin will then heat up and cool down your hot end, while taking measurements.  This will take a while.  When it’s done, it will output a message similar to this one:

bias: 103 d: 103 min: 147.98 max: 152.02
Ku: 65.06 Tu: 30.67
Clasic PID
Kp: 39.04
Ki: 2.55
Kd: 149.66

Next, you need to tell Marlin to use the calculated Kp, Ki, Kd values.  If you don’t want to hassle with compiling/reloading Marlin, you can just use the M301 – Set PID parameters P I and D G-code.  Using the my values above, it looks like this:

M301 P39.04 I2.55 D149.66

I simply added the line to my start G-code in Slic3r.  Setting the PID parameters in G-code allows you to change them on the fly for different profiles, for instance, if you like to switch back and forth between PLA and ABS.

If you prefer to hardcode the values as defaults in the firmware, set them as follows in Configuration.h:

#define  DEFAULT_Kp  39.04
#define  DEFAULT_Ki 2.55
#define  DEFAULT_Kd 149.66

3. Acceleration and Jerk

If your printer vibrates a lot when printing at higher feedrates, causing wiggly prints, you can improve the quality without slowing down your prints too badly by lowering the acceleration and/or XY-jerk values. In Marlin, acceleration is specified in mm/s^2. The default is 3000. On my Printrbot, I slowed it down to 1000 with G-code as follows:

M201 X1000 Y1000; // max accel print
M202 X1000 Y1000; // max accel travel
M204 S1000; // default accel for normal moves

You can also change the value in Configuration.h, if you prefer:

#define DEFAULT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves

If you have a slow extruder, you can also slow down the retraction acceleration, but generally, there’s no reason do do this:

#define DEFAULT_RETRACT_ACCELERATION  3000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts

3000 is the default value.

The jerk value is also useful, and affects the speed at which Marlin joins two segments. The default XY-jerk value is 20 mm/s.  Lowering the value will slow down the transitions between segments.  This is especially helpful for smoothing out ringing waviness on 90 degree turns.  I found that 15mm/s is a good balance between speed an quality on my Printrbot.  G-code:

M205 X15; // max xyjerk mm/s

Configuration.h:

#define DEFAULT_XYJERK                20.0    // (mm/sec)

There are also values for the z-axis and extruder, but I didn’t need to change them:

#define DEFAULT_ZJERK                 0.4     // (mm/sec)
#define DEFAULT_EJERK                 5.0    // (mm/sec)

When tuning acceleration and jerk values, a handy way to test the effects of your new settings is the Dry Run feature of Repetier Host.  When Dry Run is enabled, the extruder is disabled while printing, so you can observe its motion without wasting filament.

After tuning the acceleration and jerk values my prints are better quality at higher feedrates, without sacrificing too much speed.  Note that depending on your print, the lower acceleration/jerk values will have more or less effect on the total time it takes to complete it.  Prints that have more short segments will be slowed down a bit more.

Even though my discussion was about slowing down the printer, you can also tune the acceleration/jerk parameters to speed things up, if you have a particularly well-tuned bot.

Bootloaders for AT90USB1286

While the AT90USB1286 MCU in the Teensylu/Printrboard can be programmed with an ICSP or JTAG programmer, you can also install a bootloader, which will allow you to program it via a USB connection alone. Besides the convenience of not having to attach a hardware programmer, uploading firmware via a USB bootloader is blazingly fast. Also, it allows you to write host software to do end user firmware upgrades without a hardware programmer.

I am currently aware of 3 bootloader options for the AT90USB128x MCU’s:

DFU – USB Device Firmware Upgrade Class

This is the bootloader officially supported by Atmel.

PRO: Works with Atmel FLIP tool.

CON: requires libusb device driver; no command line tool available for Windows.  For Linux, an open source host loader app is available; can’t integrate into Arduino IDE

CDC – USB Communication Device Class

PRO: can integrate into Arduino IDE; works with avrude via avr109 protocol.

CON: requires user to know which virtual serial port it’s associated with; in Windows, uses native Windows driver, but requires INF file install, needs upgrade of avrdude to newer version for Arduino < 1.0.

HID – USB Human Interface Device Class

PRO:  Trouble free – doesn’t require any device drivers – just plug and play

CON: doesn’t integrate into Arduino IDE

 

Fuse Settings

Before you can install a bootloader on your MCU, you must set the fuses correctly to allocate space for it.  We need 4K bytes (2K words) of space, so using the Engbedded Atmel Fuse Calculator, we see that we need Boot Flash Size BOOTSZ=01,  which is in the high fuse.  Here are the fuse settings that I use on mine:

avrdude -c usbtiny -p at90usb1286 -U lfuse:w:0xde:m -U hfuse:w:0xdb:m -U efuse:w:0xf0:m

BE CAREFUL IF YOU WANT TO FIDDLE WITH FUSE SETTINGS YOURSELF.  It’s not hard to “brick” your AVR with the wrong settings.  In fact, when I was first working with my Printrboard, I managed to brick it by messing up the CKSEL bits, thinking I was supposed to set it for an external oscillator.  Luckily, all I had to do was connect an external oscillator (I used the signal generator function of my DSO Quad mini scope) to XTAL1 and then use avrdude to fix the offending fuse.  If you do something worse, like disabling SPIEN by accident, you might have to resort to HV programming.  Here is some info on recovering a bricked AVR:  http://www.larsen-b.com/Article/260.html

Note that I have set hfuse = 0xdb, which disables the JTAG interface.  This makes more I/O pins available (in particular, some of the pins exposed on the I/O headers of Printrboard).  If you want to use a JTAG programmer, you should instead set hfuse = 0x9b.

Once your fuses are set correctly, use avrdude with your programmer to upload the bootloader.  After your bootloader is installed, you don’t need to use the programmer anymore – just a USB connection is enough.

Booting into Bootloader

Once a bootloader is installed (see instructions below), the bootloader must be activated when you want to upload firmware.  To boot the AVR into the bootloader instead of normal program code, you must tie the HWB pin to ground during a RESET pulse.  To to this on Teensylu or Printrboard, simply remove the 2-pin jumper that’s next to the AT90USB1286 chip, then press and release the reset button.  You can then replace the HWB jumper.

NOTE: If you have a Printrboard RevD, the jumper has been reversed, and needs to be INSTALLED to get into the bootloader, and REMOVED to run your firmware.

Below, I describe how to install and use each of the bootloaders.  For Arduino IDE integration, use BootloaderCDC.  I also like BootloaderHID, because it doesn’t need drivers, and doesn’t require selecting a virtual serial port.

DFU Bootloader

  1. Download and install FLIP. FLIP will also install the device driver.
  2. Download BootloaderDFU.zip. I built this one for AT90USB1286 from LUFA-120219.
  3. Install with avrdude: avrdude -c usbtiny -p at90usb1286 -U flash:w:BootloaderDFU.hex:i (note if using a usbtiny and avrdude complains of a verification error at byte 0x1f000, ignore it)
  4. To flash hex files to board, after Booting into Bootloader, use FLIP or dfu-programmer.

CDC Bootloader

  1. Download BootloaderCDC.zip.  I built this one for AT90USB1286 from LUFA-120219.
  2. Install with avrdude: avrdude -c usbtiny -p at90usb1286 -U flash:w:BootloaderCDC.hex:i (note if using a usbtiny and avrdude complains of a verification error at byte 0x1f000, ignore it)
  3. To flash hex files, you’ll need a newer version of avrdude than the one included with Arduino < v1.0.  The version I use is 5.10.  After Booting into Bootloader (the first time, Windows might want a driver … point it to the INF file that I included) , type:  avrdude -c avr109 -P port -p at90usb1286 -U flash:w:firmware.hex:i, substituting your Printrboard’s CDC serial port for port, and the name of your hex file for firmware.hex.
  4. If you want to flash directly from the Arduino IDE, follow my instructions for installing my at90usb1286txt.zip files into Arduino.  Then, after restarting Arduino and Booting into Bootloader, select [BootloaderCDC]Teensylu/Printrboard from the Arduino Tools->Board menu.  Then select the serial port associated with your board.  Hit the Upload button in the Arduino IDE to compile and upload your sketch.

HID Bootloader

  1. Download BootloaderHID.zip. I built this one for AT90USB1286 from LUFA-120219.
  2. Install with avrdude: avrdude -c usbtiny -p at90usb1286 -U flash:w:BootloaderHID.hex:i (note if using a usbtiny and avrdude complains of a verification error at byte 0x1f000, ignore it)
  3. To flash hex files, after Booting into Bootloader, type:  hid_bootloader_cli -mmcu=at90usb1286 -w -v firmware.hex, substituting the name of your hex file for firmware.hex.  I’ve included the Windows binary.  For Linux or OSX, you can build hid_bootloader_cli yourself from the LUFA sources.

NOTE: When uploading a bootloader to the AT90USB1286 using a USBtinyISP, you will get a verify error from avrdude.  You can safely ignore it.  The problem is that the USBtinyISP has a bug with reading flash memory above the 64K (10000h) boundary.  However, it can write it without problems.

grbl CNC Firmware Ported to Printrboard

If you want to use your RepRap for CNC use, such as milling PCB’s, regular 3D printing firmwares might not be ideal. For instance, Marlin is not able to handle the slow step rates used for CNC work.

I have ported grbl, a firmware specifically for CNC use (from which Marlin derived its acceleration routines), to Printrboard and Teensylu. You can download it from my fork at: https://github.com/lincomatic/grbl.

Repetier Firmware Now Runs on Printrboard

I spent this past weekend porting Repetier-Firmware to Printrboard and Teensyduino. It took me a while to get it working properly, because the code intermixes calls to fastio and Arduino, and the pin definitions in fastio.h were different from the Teensyduino Arduino library. It is now working pretty well, so Printrboard and Teensylu users now have yet another option for RepRap firmware. I’ve already submitted my changes to Repetier, and he’s merged them into his code. Download it here: https://github.com/repetier/Repetier-Firmware.

In case you haven’t tried it, Repetier also has an interesting host program, Repetier-Host, which works with other firmwares as well as Repetier-Firmware.

How to Program an AT90USB1286/Teensylu/Printrboard with Arduino and USBtinyISP

My first step in loading Marlin RepRap firmware into the Printrboard is to get Arduino to play nicely with it.  The method I am going to describe in this article for programming a Printrboard with Arduino will work with the Teensylu or any other device that uses the AT90USB1286 and has an ICSP connector.   The programmer we are going to use is a USBtinyISP or compatible. Since the AT90USB1286 isn’t officially supported by Arduino, it takes a bit of setting up to get things working properly.

I first looked at the instructions on Teensylu’s page in the RepRap wiki, but found them very confusing, and I didn’t like the idea of having to send the HEX file to the MCU using an external utility instead of doing everything within the Arduino IDE. So, I set out to streamline the process and document it as I went.  If you follow my method below, you’ll be able to compile and download your firmware all within the Arduino IDE.

Step 1: Download and install Teensyduino

Teensyduino was created by PJRC for their Teensy line of boards.  Teensy is a great alternative to Arduino if you want an ultra compact board with built in USB.  The Teensy++ happens to also use the AT90USB1286, so it’s compatible w/ Printrboard/Teensylu.  Follow PJRC’s instructions for installation from the download link.

If you only plan to program for RepRap, you don’t need to install any of the libraries.  On Windows, you will be prompted to install the serial driver. Select yes.  You don’t have to worry when Windows complains that the driver is unsigned… it’s just an INF file to tell Windows to use one of its own built-in drivers.

Step 2: Modify Teensyduino Configuration for use with USBtinyISP

Download at90usb1286txt.zip.

Navigate to where your Arduino files are located.  On my computer, I have them in d:\arduino-0022.  We will call this <arduinofolder>.  Now, find the subfolder where the Teensyduino library was installed:

<arduinofolder>\hardware\teensy

If you are in the correct folder, you should already see a boards.txt and a subfolder called core in there.  Drop the files from at90usb1286txt.zip into that folder, overwriting the existing boards.txt.  You should see something like this:

If you don’t plan to develop with any of PJRC’s Teensy or Teensy++ boards, you can keep them from showing up in your Arduino menu by copying boards.txt.nopjrc over boards.txt.

Now, when you start Arduino, you should see some new configurations in the Tools->Board menu.  The important ones are:

[usbtinyisp]AT90USB1286
[usbtinyisp]Teensylu/Printrboard
[BootloaderCDC]AT90USB1286
[BootloaderCDC]Teensylu/Printrboard

To use a USBtinyISP programmer, select either [usbtinyisp]AT90USB1286 or [usbtinyisp]Teensylu/Printrboard. The only difference between the two configurations is that I took the extra useless options out to make things simpler when programming Teensylu/Printrboard.  The Teensylu/Printrboard option is the same as the AT90USB1286 option with USB Type = Serial and CPU Speed = 16MHz.

At this point, you can plug in your USBtinyISP and into your AT90USB1286/Teensylu/Printrboard and start programming!

So what are the [BootloaderCDC] configurations for?  They allow you to download sketches into your target board directly through a USB connection to your host, without the USBtinyISP programmer.  See my next article for details on how to do that.

Update 20140909: I have uploaded a copy of Arduino 1.0.5-r2 for Windows to github, which is already modified to work with the AT90usb1286, so you don’t have to modify it as above. Simply go to https://github.com/lincomatic/arduino-1.0.5-r2-at90usb1286 and click the Download Zip button, and then extract the contents to your PC. My distribution also supports the USBasp in addition to the USBtinyISP.

OpenEVSE – Open Source J1772 EVSE (“Charging Station”) for Electric Vehicles

Last year, I purchased a Nissan Leaf, which is an all electric vehicle (EV). Although the Leaf comes with an included L1 EVSE (“trickle charger”), which connects to a regular 120V wall outlet, it takes way too long to charge the car. The more practical solution is to purchase and install a J1772 L2 EVSE which is equivalent to the commercial charging stations you see in public parking lots. The problem is the cost. J1772 L2 EVSE’s cost a couple of thousand dollars; the quote I got from Aerovironment, Nissan’s chosen installer was about $4000 including installation. Considering that modern EV’s using the J1772 standard have the charger built-in to the car, and that a J1772 EVSE is no more than a smart safety interlock plug for connecting the car to the wall, I thought the cost was pretty outrageous.

I obtained a copy of the SAE J1772-2010 standard, and after a few hours of perusing it, realized that a J1772 EVSE could be implemented with an Arduino, a few parts, and a relay at the fraction of the cost of the commercial products.  Furthermore, that the circuitry is so simple and compact that it could be built into a small case that fits into your hand, and can easily be thrown into your trunk, rather than the giant monstrosities like GE’s WattStation.

I started to design my own EVSE around an AVR MCU, but soon discovered that Chris Howell had had exactly the same idea, and posted about his Weekend EVSE project on the MyNissanLeaf forums.  Chris had already made major progress on the project, so I thought, why reinvent the wheel?  I contacted Chris, and we decided to team up to develop an inexpensive, portable L1/L2 J1772 EVSE. Chris is a wizard with PCB layout, and has shrunken the board down to smaller than an Arduino over several revisions. It’s truly a sight to behold how tiny and simple it is after seeing the giant messy hackorama that’s being funded by the DOE, the $5000 Blink EVSE, which is just an amalgam of OFF THE SHELF DEVICES IN THEIR ORIGINAL CASES: http://www.mynissanleaf.com/viewtopic.php?f=26&t=5664 . One thing that I find annoying about commercial EVSE’s is that they often waste too much power in standby mode. Nissan’s included EVSE draws about 3W in standby, which doesn’t sound like much, but the question is WHY? Vampire power wastes about 10% of the energy used by a typical residential household. I’ve heard that the Blink wastes more than 50W when it’s doing nothing. Not only that, many of the commercial offerings (including Nissan’s included L1 EVSE) aren’t even 100% J1772 compliant!

After many hours of tweaking and testing, we designed a 100% J1772 compliant dual mode L1/L2 EVSE.
This DIY EVSE has worked flawlessly charging my Leaf ever since last summer:

The actual EVSE logic board is the tiny PCB at the top with the 3 LED’s attached to it.  The switching power supply is on the bottom right, and a 30A relay is on the bottom left.  A CT in the upper right is used to detect ground faults.

For a portable unit to throw in my trunk, I need adjustable current, so I’ve implemented a 1-button menu interface using a common HD44780-compatible 16×2 LCD, connected to an Adafruit LCD backpack, which greatly reduces the pin count required for interfacing to it. I’m currently using it in i2c mode.

Note how small the controller PCB is now … Chris is a PCB layout ninja … yes, that’s a complete implementation of a J1772 EVSE on that tiny board.  Now, go back to the Blink EVSE link I listed above, and see how huge and complex the circuits are in the commercial offerings THAT AREN’T EVEN 100% compliant to the standard!

This time, instead of going into the expensive box I bought for the first EVSE, it’s going to live in a $5 NEMA wiring box from my local hardware store. I think this box will be a lot more durable against getting dropped and thrown around than my fancy $18 NEMA box.

Hardware hackers, what are you waiting for?  Join in on the fun.  We’ve open sourced the design as OpenEVSE:  http://code.google.com/p/open-evse/. Now, you can build your own fully hackable, customizable EVSE!

DISCLAIMER:  Don’t jump into this project unless you have a thorough understanding of the precautions which must be taken when dealing with high voltages and currents.  It’s quite easy to electrocute yourself and DIE if you don’t know what you’re doing.