Part of programming stand-alone ATmega chips is setting the fuse bytes, these are special settings that can be used to change how the ATmega chips operate.
Some of the things you can do by changing the value of the fuses include;
- select different clock sources and change how fast the chip runs,
- set the minimum voltage required before the chip works.
- set whether or not a boot loader is used,
- set how much memory is allocated to the boot loader,
- disable reset.
- disable serial programming
- stop eeprom data being erased when uploading a new sketch.
There are many articles online but I could not find a single source that brought all the information together and fully explain what the fuses actually do.
It is important to remember that some of the fuse bits can be used to lock certain aspects of the chip and can potentially brick it (make it unusable). However, with a bit of care it is fairly straight forward to understand and use the fuse settings.
Disclaimer, I am relatively new to programming fuses and these are notes I wrote to help me remember things. The information is based on the data sheet for the ATmega chip, internet searches, and questions I asked on forums (especially the Arduino forum).
05.12.2015 Updated the photos.
In a previous post I showed how to make your own Arduino on a breadboard. The next step is programming it.
Using an Arduino Nano to program a ATmega328P chip
There are many guides online on how to use an Arduino to program a ATmega chip, two goods ones are:
Using an Arduino as an AVR ISP (In-System Programmer)
Nick Gammon’s guide
If you google “using Arduino as a programmer” you will find most of the results are for using an UNO, very few are for the Nano. One Nano guide I did find is at Lets Make Robots This explains how to set up the Nano but it does not clearly show how to program a stand alone Atmega chip.
Breadboard Arduino / Stand Alone ATmega328P
Here is my Arduino on a breadboard. There are many online guides for creating a breadboard Arduino. All are basically the same and follow the same connections. Some use pre-programmed chips, others use blank chips. My intention was to use a new blank ATmega chip (no boot loader) and use an Arduino Nano as an ISP programmer.
I have never been happy that my first version of the drop controller had 2 different power supplies; a 12 volt supply for the solenoid valves and a second 5 volt supply for the Arduino, so I looked for a way to share the 12 volt supply. After a short search I came across Derek Molloy’s video on Youtube. This describes making a 5 volt power supply from a mains adaptor.
Full video after the break
Early water drop photos.Water, milk, coloured water and coloured milk.
The photos with black background done with the DropControl V1. Other photos done with V2.
Digial keypad on the left. Analogue keypad on the right.
When I first started building the dropController and the camController I could not find suitable navigation keypads, the ones I did find were expensive or not really suitable, so I built my own. These were simple keypads and follow the normal wiring for press button switches. This means each of the push button switches is wired to a separate pin on the Arduino. This obviously means you need 5 pins. This was fine until I wanted to add extra solenoid valves and realized I didn’t have enough spare pins.
I starting looking for pre-made keypads again and came across the Keyes Keypad on Taobao. These are cheap and smaller than the keypads I made. They also use a single pin. These are analogue keypads that use a single analogue pin on the Arduino.
I am now starting to built a version 2 solenoid breakout board. While the first one works I have learnt a bit more about controlling the valves.
Here is the diagram from Fritzing.
Added resistors in line with the diodes. The flyback diode may cause the the solenoid to release too slowly. Adding the resistor speeds up the current decay and causes the solenoid to release/close more quickly.
Using 12V 250mA solenoids with TIP121s, the resistor should not exceed 220 ohms.
Added a small bypass capacitor connected between the TIP121 emitters and the solenoid +ve terminals. The capacitor can be connected across the power in lines which is connected to the TIP121 emitters and the solenoid +V.
Here is my solenoid valve controller; version 0.1. It can control 3 solenoid valves and has 2 triggers.
It is designed to control the valves and then send a signal to another Arduino which controls the camera. However, it can be connected directly to a camera if required.
When building prototypes on breadboards I find it useful to have small pre-made components such as 3.5 stereo jack sockets configured to fit breadboards
The 3.5 stereo socket is attached to a small piece of board and the connectors from the socket attached to pins that fit in to a breadboard.
Red is VCC, black is ground, and white is the centre channel or data
I also create mini boards that have more than one component
These have female or male headers and can be connected using standard breadboard wires
In an early version of the camControl device (before the dropController) I used an interrupter/optoisolator to detect the water drops. The plan was to detect the water drop, wait a little bit and then activate the shutter.
There are various different kinds of photo interrupter, different shapes and different sizes but all do the same job.
A photo interrupter has a LED at one side (normally IR) and a photo transistor at the other. When the LED in emitting light the photo transistor allows a current to flow. Remove the light and the current stops.
I started creating a controller using a single Arduino Nano on a breadboard. Although it was very basic it worked fairly well. It allowed me to control a solenoid valve and trigger the camera shutter. I also added basic camera control and a timelapse function (intervalometer). This part worked well. I could set the frequency and the number of shots and the Arduino did the rest.
Initially had the Arduino controlling the solenoid and then triggering the shutter after a delay. I later added an interrupter sensor and a laser beam sensor to detect the water drop and activated the shutter based on a delay after the sensor was tripped. As the controller developed more the breadboard became very messy and this started to annoy me.
I separated the functions in to two units; a drop controller and a camera controller.
I wanted to try taking water drop photos and see what worked and what didn’t. Overall the results were better than I expected but not as good has I had hoped. Lighting is not good but I knew this from the beginning and concentrated on the drops and the timings. Working on the lighting can de done later once I have the other things sorted out.
I noticed that I got different results even when using the same timings. All the below had exactly the same settings.
The only difference was the time between shots. I suspect that as you wait water in the bottom nozzle moved towards the exit hole and you get a cleaner drop. Couldn’t really tell and I may be completely wrong.
Here are some of the better shots
Here is the camera and stand setup. The stand is a 80cm lab stand. I bought 2 of these with various clamps and supports. Another Taobao special.
There is now an updated and more detailed post. See Controlling a Solenoid Valve from an Arduino. Updated.
Using the Arduino to control the solenoid valve is simply a case of setting a pin high for the appropriate amount of time. There is, however, a caveat, the solenoid works at a different voltage to the Arduino and you cannot directly connect the two. In this case a TIP120 transistor is used as a bridge.
The TIP120 allows a small dc voltage (from the Arduino) to switch a larger dc voltage (12V to the solenoid). It can be thought of as a switch, applying a current to B allows current to flow between C to E.