Introduction: Disk Usage and File Download Indicator
This is visual indicator circuit for RPI transmission server. (Hereinafter as torrent server)
As torrent server usually running as headless state without console and monitor, I’m always bothered on the disk quota remained now and curious about how many files are downloaded currently.
To address the issues of torrent server, this circuit is made to show used available disk space as 5 levels (e.g. 20%, 40%, 60%, 80%, 100%) and number of finished file downloads now.
By using shift register (74HC595) IC, making bar type LED level indicator and number showing numeric LEDs pattern indicator is designed for showing the information required.
For simplifying control of these indicator circuits, Arduino Uno is used with C program sketch. .
In the beginning of making this circuits, I planned RPI GPIO ports directly control the 74HC595 shift register IC.
But somehow I experienced many problems with RPI to interface with 74HC595 directly.
Therefore, Arduino Uno is used as connecting shift register IC directly.
By this way, hardware connection become very straight forward, easy and also I can utilize many referential Arduino project information from Internet.
The circuit shown in the picture above is intermediate result of overall RPI torrent server making project.
Another instructable will be written after this to introduce the completed RPI torrent server.
Step 1: Disk Usage Indicator Schematics
When LM555 timer IC circuit portion is removed, 74HC595 wirings with Arduino Uno is quite common LED chaser circuit using shift register IC. (Please refer web-pages explaining shift register interface with Arduino for more detail)
I will not explain operation details of 74HC595 such as applying Data with Clocking and subsequently turn on Latch for showing shifting action.
You can see many similar example circuits in the Internet.
But I’m using LM555 for blinking Red LED to give warning of disk full.
Actually 1N4148 diode will not necessary as Red LED itself is kind of diode which can prevent current flow from LM555 (when output of LM555 is ON state) to 74HC595 output port 5 (QE).
But as safety precaution of correct shifting operation by 74HC595, 1N4148 diode is added anyway.
This circuit is driven by C program sketch as follows.
***
- When disk usage is less than 20%, (Actually it is du –h command result of RPI and currently used disk space in the external 120GB SSD attached to RPI) the first Green LED will be turned on
- When disk usage is more than 20% and less than 40%, second Green LED will be turned on along with the first Green LED.
- When usage in range between 40% and 60%, third Green LED will be turned on along with other Green LEDs.
- But usage is exceeding 60% and still less than 80%, Yellow LED will be turned on to give warning for high disk usage level.
- Finally usage is exceeding 80%, Red LED will be blinking for imminent disk full error
***
As LM555 making 5 times of on/off clock per second with 1K and 12K resistors, Red LED will blink a little bit rapidly when disk usage is more than 80%.
Red LED will blink only when output pin 5 (QE) of 74HC595 is ON state regardless of continual clocking of LM555 as the LED wired to timer IC as reverse forward manner.
And as LM555 is sinking current (from 74HC595) while it’s off (0V) clocking cycle, Red LED is turned ON during the off period of the timer IC.
When LM555 output become ON state, Red LED will be off as there is no voltage difference between anode and cathode of Red LED. (That’s how Red LED is blinking)
By my mistake during soldering, I omitted wiring of 220 ohm resistors as red squared parts in the schematics above.
But still LEDs are turned on correctly. (I don’t know why… But anyway it works like that way)
Step 2: PCB Drawing
As I mentioned above, firstly I’m trying to connect this circuit directly to RPI with opto-coupler interface.
But LEDs are not turned ON altogether or wrongly turned ON regardless of re-checking soldered PCB boards and re-programming python codes several times.
Maybe opto-coupler can’t transfer DATA/CLOCK/LATCH signal correctly to 74HC595 seems main problem.
Without opto-coupler and direct interface with Arduino become quick and all-clear solution for correct driving the 74HC595.
Therefore, please don’t try wiring method shown in the left side of the PCB drawing above if you don’t have any correct solution for resolving problems I’d experienced.
Also 220ohm resistors are not used in my circuit as I told above.
Maybe 74HC595 chip I used have kind of current limiting capability inside. (It seems produced by China semiconductor manufacturer).
But don’t count the same result with your project.
Using 220ohm current limiting resistor seems norm when I’m looking similar project cases in Internet.
Step 3: Parts
Except 74HC595 shift register IC, no special parts are required.
The IC shown above is manufactured by TGS (it has marking on the IC chip) and somehow driving LED without current limiting resistor.
Other parts are listed below.
***
- 74HC595 8bit tri-state shift register IC
- LM555 timer IC
- 10uF (Clock period setting) x 1, 0.1uF capacitor (By passing) x 1
- Resistor 1K, 12K (LM555 timing setting)
- LED Green x 3, Yellow x 1, Red x 1
- Diode 1N4148
***
Step 4: Soldering and Wiring
As detail wiring methods are explained in Step 1 and Step 2 as drawings, I will not explain further to these subjects.
The daughterboard including 5 LEDs is attached to mother board with long pin head connector.
You can see vented and soldered pin head leads at the right side of the picture above.
Also Arduino Uno is mounted on the acrylic board and fixed with bolts and nuts under the indicator circuit PCB.
The black rectangular shape of component seen in the top side is 220V(input)/5V(output) 1.7A power supply module.
Using external hand-phone charger for power supply is not much elegant for self sufficiently operating torrent server without console and monitor.
Therefore, I’m using small switching power supply for Arduino and Indicator circuit boards to reduce number of power cables to torrent server.
Step 5: Operation
You can see video of the circuit operation at the following link.
*** <Video link>
https://drive.google.com/file/d/1kwdbxwF7OTHOvzOUQ...
***
The program used is for simulating LED chaser and will be changed when the circuit is connected with RPI.
Step 6: Arduino Sketch (Program)
Although this is RPI project, Arduino is used for several reasons.
Later Arduino will be connected with RPI via USB-serial.
Therefore, the program below is only used for demonstration of 5 LED blinking in sequence.
*** Program code start ***
int dataPin = 6; // Data pin of (14) 74HC595
int latchPin = 5; // Latch pin of (12) 74HC595
int clockPin = 4; // Clock pin (11) of 74HC595
byte leds = 0;
void setup()
{
// Set all the pins of 74HC595 as OUTPUT
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop()
{
leds = 0; // Initially turns all the LEDs off, by giving the variable 'leds' the value 0
updateShiftRegister();
delay(200);
for (int i = 0; i < 8; i++) // Turn all the LEDs ON one by one.
{
bitSet(leds, i); // Set the bit that controls that LED in the variable 'leds'
updateShiftRegister();
delay(200);
}
}
void updateShiftRegister()
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}
*** Program code end ***
One data bit will be stored to the 8 bit data register when “shiftOut(dataPin, clockPin, MSBFIRST, leds)” operation is executed.
Subsequent shifitOut will move new 1bit to 0th position of data register and shift all previous data to 1 bit left position (Shift).
Therefore rightmost 1 bit of data register (7th position value) value will be lost.
When each time “updateShiftRegister()” is called, 8 bit data register content will be shift left.
But only storing bits to data register does not change state of LEDs as shown in the picture above.
The 74HC595 has special storage called as 8bit latch register.
If latch is activated (clock change LOW to HIGH, so called as active LOW), data register values are copied to latch register.
According to latch register value LED is turn on if value is “1” or turned off when value is “0”.
With the above operational steps, LED is turned on sequent and incremental manner.
Step 7: File Download Count Displaying Indicator Schematics
This time I’ll introduce file download counter indicator which using the same operational scheme with 74HC595.
But visual indication is expressed as number by using two 7 segment LED display.
Somehow I have only common anode type of 7 segment LED displays in my inventory.
Although two common cathode type LEDs are available, they are too big to be used with the indicator circuit.
Therefore, I made numeric number pattern of LED display with 7 rectangular shaped red LEDs.
Overall operational scheme is the same with disk usage indicator.
When any files are downloaded by transmission process, number of completed files will be displayed by this indicator circuit.
This circuit also interfaced with Arduino Uno for correct number display.
Step 8: PCB Drawing
Comparing with other PCB drawings, this one seems a little bit complex and strange.
Actually 7 segment LED display is hardwired to CD4511 IC as you can see detail in the next step.
Use this drawing as just for reference for soldering and wiring.
All output pins of 74HC595 are used to display two digits number.
Each CD4511 receives 4 digit binary numbers to display number from 0 to 9 such as 0000->0, 0001->1, 0010->2. 0011->3 and 1001->9.
As two digit number should be displayed from 00 ~ 99, 4 digits x 2 outputs of 74HC595 fed to two CD4511 inputs such as 4 inputs x 2 IC chips.
Step 9: 7 Segment Display
This is example of two digits 7 segment LED display block made using universal PCB and female/male pin head connectors.
Actually CD4511 ICs are inserted inside PCB boards.
For mounting and fixing both PCBs, female pin head connector is used at backside PCB and male pin head connector is used to front-side PCB.
When insert male pin heads to female ones, all 7 segment LED inputs (a ~ g) are connected together and square box like display block is made as shown in the picture above.
Therefore 220ohm resistors shown in the PCB drawing are actually soldered inside the display block as shown in the right side of picture above.
Step 10: Operation
As PCB board details are introduced in Step 4, let’s see counting action of the file download circuit.
You can see video at the link below.
*** <Video link>
https://drive.google.com/file/d/1Z346HglU90wVkOGPa...
***
As disk usage sketch is deleted, 5 LEDs are all turned on as the initial state of the circuit is like that.
And you can see red LED is blinking continuously with operation of NE555.
Newly uploaded program is counting number from 00 to 99.
Due to the utilizing only 7 LEDs, very abstract numeric form of numbers are displayed.
But still you can differentiate numbers anyway when you see the video above.
Step 11: Arduino Sketch (Number Counting Program)
As 74HC595 shift register is used, initializing section is similar with disk usage indicator circuit’s code.
Because continual counting action is required, two numbers (i, j) are generate within two nested FOR loops.
Number stored in i is 10th position.
Number stored in j is 1st position.
If you want make number 53, digit10 (i=5) should be shift left 4 times.
Then OR operation is performed with digit1 (j=3) to make number 53.
Combined number (num=53) is sent to 74HC595 data register and subsequently to latch register.
When latch clock is activated, number is displayed on the 7 segment LED display.
Likewise all other numbers are generated and displayed
***
int DATA = 13; // Data pin of (14) 74HC595
int LATCH = 12; // Latch pin of (12) 74HC595
int CLOCK = 11; // Clock pin (11) of 74HC595
byte digit10 = 0;
byte digit1 = 0;
byte num = 0;
void setup()
{
// Set all the pins of 74HC595 as OUTPUT
pinMode(LATCH, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(CLOCK, OUTPUT);
Serial.begin(9600);
}
void loop()
{
for (int i=0; i<10; i++) {
digit10 = (char) i;
digit10 = digit10 << 4;
for (int j=0; j<10; j++) {
digit1 = (char) j;
num = digit10 | digit1;
printBit(num);
Serial.print ("\n");
ledDisplay();
delay(200);
}
}
}
// Prints out Binary value (1 or 0) of byte
void printBit(byte c) {
for (int bits = 7; bits > -1; bits--) {
// Compare bits 7-0 in byte
if (c & (1 << bits)) {
Serial.print ("1");
}
else {
Serial.print ("0");
}
}
}
void ledDisplay() {
for (int i = 0; i < 8; i++) // Turn on bit by bit
{
updateShiftRegister();
delay(20);
}
}
void updateShiftRegister()
{
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, LSBFIRST, num);
digitalWrite(LATCH, HIGH);
}
***
Step 12: Finishing
This is final outcome of disk usage and file download indicator.
It operating with own power supply and average current consumption is about 0.1A.
But more additions such as FAN controller circuit and other are required to support torrent server which is operated by RPI.
That further development will be subject of next instructable.