How to add a 7 segment display
This guide details how to add a display that has a 4 7-segment digits a mode changer to make it possible to cycle through the various values to be displayed and a frequency indicator that shows when the grid is under or above 50Hz.
The 4 7-segment digits are driven by a MAX7221 driver chip and the mode changer by a shift register as not to take up too many arduino digital pins although it still takes up 6. The value displayed is controlled by rotating a potentiometer.
There are already excellent guides on building the 7 segment display and the shift register for the mode changer independently of each other so I won't repeat them. This guide just details how to bring both of these parts together including some pictures of the circuits I built as a layout suggestion and the adapted Arduino code which is detailed below.
Here are the guides for the 7-segment display and shift register both in the Arduino playground:
Controlling a Led matrix or 7-segment displays with the MAX7219 or the MAX7221 - This is the main page that links to the two pages below.
The MAX7219 and MAX7221 Led drivers - details the 7- segment display hardware, including circuit diagrams and discussion of various factors that need to be taken in to account.
LedControl Library by Eberhard Fahle - details the Arduino library required to drive the display, including download.
Serial to Parallel Shifting-Out with a 74HC595 - Started by Carlyn Maw and Tom Igoe Nov, 06. Details how to build the shift register circuit that allows us to have effectively 8 digital output pins while only using 3. Ive used 6 of the outputs for the mode chooser and 2 for the frequency indicator.
Here are a selection of pictures of the boards I built, just in case they are useful when trying to work out how to place all the components. Let me know if there's any detail that isn't so clear. More pics can be found here.
Left: Whole display, including the 7segment bit, mode chooser, frequency indicator, potentiometer and socket. Right: Whole display with the 7 segments removed.
Back of the 7 segment display and mode chooser:
Pictures of installation on wall. Communication's wire goes through a hole in the wall to the main unit.
The arduino sketch here works with the display and an arduino independently of any of the other energy monitor hardware and code. The intention is to make it easier to see whats happening and to make it easier to use the code in other projects. For an example of how to add it to a full setup have a look here home energy monitor documentation page.
The main addition to the example code by Eberhard Fahle is the addition of code to make the decimal point work. The position of the decimal point depends on the number of significant figures.
- Download the sketch here: SAdisplay.tar.gz
- Compile and upload the Arduino sketch to the Arduino. For a guide on compiling and uploading the sketch to the Arduino have a look here.
- You should now see the display light up and be able to select through the values set in the sketch with the mode chooser.
Further detail on hardware
The display is made up of 3 independent parts:
1) The 7 segment display
To build this follow this link:
2) The mode chooser indicator LED's + the Large Red + Green Led's
The mode chooser LED's (the 6 small green LED's) and the 2 larger led's are all driven off the shift register. To build this part follow the following guide:
3) The mode chooser potentiometer
This potentiometer is connected directly to one of the arduino analog inputs, As you turn the potentiometer it provides a varying voltage from 0V to 5V which is read in the arduino using analogRead() The voltage is then used to select what mode is selected.
The only thing the 3 parts share in terms of hardware are the same 5V supply and ground.
- There are 3 control lines for the 7 segment to the arduino
- There are 3 control lines for the shift register
- One analog line from the potentiometer
If you wish to build the above I recommend building each section individually first as per linked guides. In terms of actual order of connection to the arduino this is how I have it organised but feel free to choose different pins if you require.