loading

If you store a car or motorcycle over the winter this timer will make sure that the battery stays charged. It uses an ATtiny85 to turn the charger on for half an hour every three days. The Attiny85 is programmed using the Arduino IDE. The program for the ATtiny85 is simple. It's just a blink program with longer delays.

You will need:

** If you want to use a different programmer, or build your own, that is okay too. There many alternatives, just search instructables for "attiny".

You can also use an Arduino as a programmer if you have one, all you need to do is put it on a breadboard and hook up six wires.

Step 1: Drilling the End Pieces

You need a 5/16" hole in one end piece and a 1/2" hole in the other. Drilling holes this big in thin sheet metal can be difficult. I used a 5/32" drill and enlarged the holes with a conical reamer like the one shown in the second picture.

Insert the rubber grommet into the 5/16" hole. It should be a tight fit, this will require some work.

Step 2: Re-size the PC Board

The board needs to fit into the grooves in the box, as shown in the first picture. Trouble is, the width across the grooves is 3.05 inches, and the board is 3.20 inches wide.

The second picture shows the original board compared to the re-sized board.

Carefully cut about .075 inches off of each side.

Go slowly, you want it to be a snug fit, not too loose.

I used a bench grinder to re-size the PC board.

Step 3: Assemble the Circuit

Assemble the circuit as shown in the diagram above.

The notch in the chip socket points to the left.

The wires at the bottom of the photo will go to the power supply. They should be about one inch long.

Use the 22 gauge hookup wire for all except the two output wires.

The top wires are the output. They are 18 gauge stranded wire. They should be at least six inches long.

Step 4: Mounting and Soldering the Barrel Jack

The photo of the barrel shows which terminals to connect.

Mount the barrel jack in the panel with the 1/2 inch hole. Make sure you have the countersinks facing out.

Solder the two wires to the barrel jack.

Step 5: Set Up the ATtiny85 Programming Environment

You will need to have the Arduino IDE installed on a computer to program the ATtiny85 chip. Go to https://www.arduino.cc/en/Main/Software to download the Arduino IDE. There are instructions here to install it on Linux, Windows, or Mac machines. If you are using Debian or Ubuntu it is in the repositories, just open a terminal and type:

sudo apt-get install arduino

Next you need to download the chip definition files for the ATtiny chip. They are available at:

https://github.com/damellis/attiny/

You will get a zip file named attiny-master.zip, unzip it and you will have a directory named attiny-master. Inside the attiny-master directory there is a directory called attiny, this is the one you are looking for.

The Arduino software stores your programs and some other stuff in a directory called sketchbook.

Open the sketchbook directory and look for a directory called hardware. If it does not exist create it.

Copy the attiny directory into the hardware directory.

Check to make sure the Arduino IDE is finding the chip definitions by opening the Arduino IDE and clicking on Tools and then click on Board. You should see three entries at the top of the list to run the Attiny85 chip at 1, 8, or 20 MHz.

Step 6: Programming the ATtiny85

In the picture of the programmer there is a six pin connector in the middle of the programmer that I added. The programmer comes with just the mounting holes.

Place your ATtiny85 chip in the programmer, the little dot on the chip goes in the same direction as the notch in the socket.

Open the Arduino IDE, click on Tools and select Board.

Click on ATtiny85 (internal 1 MHz clock).

Click on Tools again and select Programmer.

Click on USBtinyISP.

There is no reason to run the chip at a higher clock speed, all that will do is use more electricity. If you have changed the clock speed use the Tools=>Burn Bootloader option to reset the chip to 1 MHz. The burn bootloader option does not actually burn a bootloader on the ATtiny. It just changes the internal fuses to set the clock speed and a few other settings you don't need to worry about.

If you are using a new chip there is no need to burn the bootloader, the chip comes set the way you want it.

Copy this program into the Arduino IDE:

/*******************************************************
 * ChargerTimer.ino - Add a timer to a battery charger.
 *******************************************************/
/*******************************************************
 * setup() function
 *******************************************************/
void setup()
{
  pinMode(0, OUTPUT);
}

/*******************************************************
 * loop() function
 *******************************************************/
void loop()
{
  digitalWrite(0,HIGH);
  delay(1800000);
  digitalWrite(0,LOW);
  delay(257400000);
}

Plug the programmer into a USB port and then click on the upload button in the Arduino IDE. (The right arrow is the upload button.)

Remove the chip from the programmer and insert it in the socket on your board. Make sure the little dot is on the same side as the notch in the socket.

Step 7: Final Assembly

Slide the board into the grooves, make sure you slide it in far enough that it doesn't touch the terminals on the barrel jack. Use four of the screws that came with the box to secure the end panel.

The voltage regulator is a little bit taller than the top of the board. Let it bend the pins of the voltage regulator as you push it in. This will let the case help dissipate the heat. Heat dissipation should not be a problem, but more never hurts.

Pull the output wires through the grommet in the second end panel and use the screws to close the end.

Cut the output wires to the desired length, strip and tin the ends.

Attach the wires to the Powerswitch Tail. The positive (red) wire goes in the hole marked 1: +in, and the black wire goes in the hole marked 2: -in.

Use a small screw driver to tighten the set screws holding the wires.

Step 8: Connecting Everything Together

Connect the wires from the trickle charger to the to the battery. Make sure you have the polarity right.

Connect the 9 volt power adapter to the timer.

Plug the charger into the powerswitch tail.

Plug in the 9 volt adapter. The red LED in the powerswitch tail should come on.

Last plug in the powerswitch tail.

Step 9: Pictures

Just in case you were wondering:

The car is a 1946 Lincoln.

The bike is a 1974 Ducati 450 MK-3.

Nice useful project!<br>It would make more use of the Arduino if you used a voltage divider and one of the analogue inputs on the chip to monitor the battery voltage and trickle charge only when needed.
<p>Please check out my Attiny collection for more projects and tutorials on the Attiny chips. Located here: </p><p>https://www.instructables.com/id/Attiny85-and-84-projects-and-tutorials/</p><p>If you like this please vote for me in the Car &amp; Motorcycle contest.</p>

About This Instructable

4,072views

48favorites

License:

Bio: Most of my instructables will be tutorials for Atmel microcontrollers, Arduino, or Raspberrypi. I try to show concepts that you can use in your own ... More »
More by JRV31:MoonLight 7400 Quad Nand Gate Simulation RaspberryPi: set-up WIFI in Jessie-Lite 
Add instructable to: