Control Panel With Integrated Timer

by Electronics by Acronix in Circuits > Electronics

241 Views, 4 Favorites, 0 Comments

Control Panel With Integrated Timer

20241221_172239.jpg
Clipped_image_20241221_171833.png

I enjoy building control panels, and the idea of this one came after i decided i wanted to add something new to a project of mine. In this tutorial i will make a control panel with an adjustable timer, that is programmed to swicht a relay module on when the timer hits zero and with that being able to turn on anything (in this case as long as it uses 24V to run) connected to it.

Supplies

20241217_125920.jpg
20241217_130447.jpg

For materials you will need:

  1. 105x20cm MDF plate
  2. 50cm long M5 threaded rod
  3. 80cm long 18x18mm wood rod
  4. (16) M5 nuts
  5. (20) M5 washers
  6. (4) 20mm PZ1 long screws
  7. (4) rubber round legs
  8. 5cm DIN rail
  9. 7cm long wire duct
  10. a few small zip ties
  11. 2 small hinges
  12. 68mm long handle
  13. M16 cable gland and M20 cable gland
  14. black acrylic paint
  15. Hot glue sticks and a hot glue gun


For components you will need:

  1. 2 positions NO momentary lever switch
  2. 2 positions locking key switch
  3. Double push button switch with led (it needs to have 2xNO contacts and 1xNC contact)
  4. 2 positions locking toggle switch (small)
  5. 400 pin breadboard
  6. 24VDC relay
  7. 24VDC red, green and yellow lamps
  8. 4 digit 7 segment display
  9. 5V relay module
  10. Arduino nano
  11. (3) 10k resistors
  12. some wire ferrules
  13. male to male jumper wires
  14. male to female jumper wires
  15. 1mm² wire
  16. (1) wire connector with 4 pins
  17. 5V power supply module for the breadboard
  18. USB-a to USB-a cable
  19. 3D printed bracket for the 4 digit display (you can find the STL file for the bracket bellow)


For tools you will need:

  1. Crimping pliers
  2. Stripping pliers
  3. Cutting pliers
  4. Screwdrivers
  5. Wrench
  6. Soldering iron

Cutting the Materials

20241215_162538.jpg
20241216_184627.jpg

The first thing that you need to do is to cut the big MDF plate into 6 smaller plates. (drawings for the plates are linked bellow). Here i used a table saw.

Then you have to cut the big wood rod into 4 smaller pieces. (drawings for the support beams are linked bellow). For this step you could use a handsaw or a table saw.

And finally you will have to cut the threaded rod into 18 pieces, 16 each 22mm long and 2 pieces each 30mm long. For this i used a angle grinder.

Don't forget to sand down all sharp edges on the plates, beams and the metal rods with sand paper.

Drilling the Holes

20241216_184815.jpg
20241216_184715.jpg

Now that the plates and the support beams are cut to lenght, you need to start drilling the holes in them.( the positions where the holes need to be are shown on the drawings above). For this operation it will be best to use a table drill press so that the holes will be more accurate. You should also note that the holes in the wood rod need to be only 9mm deep and don't have to go all the way (18mm) across the rod!!!

Painting

20241217_123420.jpg

I decided to paint the MDF plates in black so i can give them a cleaner and a more professional look. A simple black acrylic paint and a big brush did the job just fine. Try to paint everywhere and don't leave any spots that show the brown colour of the plate. If the paint you are using isn't dark enough, just add an additional layer of paint when the previous one has dried.

3D Printing the Display Bracket

I wanted to make the display look nicer when attached to the front plate, so i 3D printed a mounting bracket for it. I then painted it in black using the same acrylic paint i used for painting the plates. You can find the STL file and the drawing for it bellow.

Assembling the Parts to Build the Enclosure

20241221_121904.jpg
20241221_123228.jpg

Now that the parts are cut to lenght, painted and ready to be assembled, you can start building the enclosure that is going to house all of the electronics inside. For this you will have to do the following things:

The support beams have a specific orientations that is non-reversible, so don't forget to mark down where each beam is supposed to go! After that use hot glue to put each of the (16) 22mm threaded rods into the holes of the already drilled wood beams.

If the holes in the plates are drilled correctly, they should line up pretty good with the rods in the support beams. When you have pushed the plate entirely to the back (showed in the first picture above), fasten the plate and the beam together using M5 washers and nuts. Do this for the front and right plate, so you can start the wiring. At this moment you can also attach the bottom plate using the screws, but before that make sure to put the round rubber legs (put the screw through the rubber leg), so the entire enclosure can stand on them.

When you are ready with that, put the lever, the key switch, the push button, the lamps, the display bracket and the toggle switch on the front plate and fasten them.

Wiring

20241217_215121 (1).jpg
20241218_153756.jpg
20241220_172851.jpg
20241220_172811.jpg

Now with the front, right and bottom plate attached, you can start the wiring. I first started with the 24VDC side, because it uses thicker wires, and when i was done with that i started with the 3V electronics such as the nano, the display and the relay module.

For wiring the 4 digit display i used some dupont jumper wires, but i removed their plastic covers to reveal their metal connectors (showed in the picture). Then i soldered the jumper wires to the legs of the display using a soldering iron.

Downloads

Writing the Code for the Arduino

The next step is to program the arduino nano. I already wrote the code, so you can find it bellow.

// Define pins for each segment (A-G)
const int segmentPins[] = {2, 3, 4, 5, 6, 7, 8}; // A, B, C, D, E, F, G

// Define pins for each digit (common-cathodes)
const int digitPins[] = {9, 10, 11, 12}; // Pins to control each digit

// Define pins for the start, increase, and decrease buttons
const int buttonPinStart = 13;
const int buttonPinIncrease = A0; // Pin for increase button
const int buttonPinDecrease = A1; // Pin for decrease button

// Define pin for the LED (using analog pin A2 as a digital output)
const int ledPin = A2; // LED connected to analog pin A2 (can be used as digital pin 14)

// Digit patterns for 0-9 (common-cathode)
const byte digitPatterns[] = {
0b00111111, // 0
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
0b01100110, // 4
0b01101101, // 5
0b01111101, // 6
0b00000111, // 7
0b01111111, // 8
0b01101111 // 9
};

// Initialize countdown time to 0 seconds
int countdownTime = 0;
unsigned long previousMillis = 0;
const long interval = 1000; // 1-second interval

// For smooth button handling
unsigned long lastButtonPress = 0; // Time of the last button press
const long debounceDelay = 50; // Minimum time between button presses (debounce delay)

// Countdown state variable
bool startCountdown = false;
bool pulseSent = false; // Track if the pulse was already sent
bool increasePressed = false; // Track if the increase button is pressed

void setup() {
// Initialize segment pins as outputs
for (int i = 0; i < 7; i++) {
pinMode(segmentPins[i], OUTPUT);
}
// Initialize digit pins as outputs
for (int i = 0; i < 4; i++) {
pinMode(digitPins[i], OUTPUT);
digitalWrite(digitPins[i], HIGH); // Turn off all digits initially
}

// Initialize button pins as inputs with pull-down resistors
pinMode(buttonPinStart, INPUT);
pinMode(buttonPinIncrease, INPUT);
pinMode(buttonPinDecrease, INPUT);

// Initialize the LED pin as output (using analog pin A2 as digital pin 14)
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // Initially turn off the LED
}

void loop() {
unsigned long currentMillis = millis();

// Check if the start button is pressed to start the countdown
if (digitalRead(buttonPinStart) == HIGH && !startCountdown) {
if (currentMillis - lastButtonPress > debounceDelay) {
lastButtonPress = currentMillis;
startCountdown = true; // Start countdown when button is pressed
}
}

// Handle smooth increase of countdown time
if (digitalRead(buttonPinIncrease) == HIGH) {
if (currentMillis - lastButtonPress > debounceDelay) {
lastButtonPress = currentMillis;
increasePressed = true; // Mark that the increase button is pressed
countdownTime++; // Increase countdown by 1 second
digitalWrite(ledPin, LOW); // Turn off the LED while increasing
}
}

// Handle smooth decrease of countdown time
if (digitalRead(buttonPinDecrease) == HIGH) {
if (currentMillis - lastButtonPress > debounceDelay) {
lastButtonPress = currentMillis;
countdownTime--; // Decrease countdown by 1 second
if (countdownTime < 0) {
countdownTime = 0; // Prevent countdown from going below 0
}
}
}

// Update countdown only if it has been started
if (startCountdown && countdownTime > 0) {
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
countdownTime--; // Decrease countdown by 1 second
}
}

// Check if countdown reached 0
if (countdownTime == 0 && startCountdown && !pulseSent) {
startCountdown = false; // Stop the countdown
sendPulse(); // Send pulse when countdown hits 0
digitalWrite(ledPin, HIGH); // Turn on LED to signal countdown reached 0
pulseSent = true; // Ensure pulse is only sent once
}

// If the increase button was released, reset pulseSent flag
if (increasePressed && digitalRead(buttonPinIncrease) == LOW) {
increasePressed = false; // Reset the flag
pulseSent = false; // Reset pulseSent so the pulse can be triggered again next time countdown reaches 0
}

// Display the current countdown time
displayTime(countdownTime);

// Small delay to reduce flickering
delay(5);
}

void displayTime(int time) {
// Just use the full time as seconds, no need for minutes/seconds division anymore
int digit0 = (time / 1000) % 10; // Thousands place
int digit1 = (time / 100) % 10; // Hundreds place
int digit2 = (time / 10) % 10; // Tens place
int digit3 = time % 10; // Ones place

// Display each digit
displayDigit(digit0, 0);
displayDigit(digit1, 1);
displayDigit(digit2, 2);
displayDigit(digit3, 3);
}

// Function to display a single digit at a specific position
void displayDigit(int number, int position) {
// Turn off all digits
for (int i = 0; i < 4; i++) {
digitalWrite(digitPins[i], HIGH);
}

// Set segment pattern for the current number
byte pattern = digitPatterns[number];
for (int i = 0; i < 7; i++) {
digitalWrite(segmentPins[i], (pattern >> i) & 0x01);
}

// Turn on the current digit
digitalWrite(digitPins[position], LOW);

// Short delay to allow display persistence
delay(2);

// Turn off the digit to prepare for the next
digitalWrite(digitPins[position], HIGH);
}

// Function to send a pulse on the LED pin when countdown reaches 0
void sendPulse() {
digitalWrite(ledPin, HIGH); // Send a pulse by turning the LED ON
delay(100); // Keep it on for 100ms (pulse duration)
digitalWrite(ledPin, LOW); // Turn the LED off again
}

Finalizing the Project

20241221_140314.jpg
20241221_174201.jpg

After you have wired all of the electronics and the rest of the control circuit, it is time to close the enclosure. Put the back and left plates and fasten them together to the rest of the enclosure by using the same M5 washers and nuts.

When all of the plates exept the top one are in place, put the handle on the top plate and glue the 2 hinges to the left plate, so the top one can open and you could see what's inside (shown in picture). You could also screw the hinges, but i found the space between the panels too small, so that's why i used hot glue to put them in place.

If you are ready with the circuit, here is how it needs to work:

By turning the key switch the yellow lamp H1 (power on) should light up together with the red lamp H3 (off) indicating that there is power running across the circuit and that the relay module is turned off. By flipping the toggle switch S4 the 4 digit display should turn on. By pressing the lever S3 down, the timer should increase and by pulling it up, the timer should decrease. When you have chosen the time you want, press on the green pushbutton S2.1, S2.2 (2 NO contacts stacked on eachother) and its own green light H2 should turn on, and the timer will start counting down. When the timer hits zero, the red lamp H3 will turn off and the green one H4 will turn on, indicating that the relay module is on. With that you can control different outputs that are connected to the same output as the green lamp H4. (24VDC)


If there is something wrong with the circuit, or if it doesn't work properly or even if you have any other questions regarding the project, feel absolutely free to message me and ask me anything about it.


Thank you for reading this tutorial. Please let me know if you enjeyed it! :)