Recently I've encountered an issue, that my laziness became tremendous problem for me at home. As soon as I go to bed, I like to put some nice LED powered light with some series playing on my PC. But... If I want to turn these things off I have to GET UP every time and turn them off by hand. Thus, I've decided to build a complete controller for the entire PC desktop, where I can turn monitors and light on and off, adjust speakers volume and LED strip lighting brightness by pressing a corresponding button on my remote.
The project is a PC desk / workbench controller box, that is operated by a IR remote. There are lots of types of IR remotes available these days, but that is not a problem. This controller is adjustable and can be paired with any type of IR remote that supports proper protocol for our used sensor (we'll cover this later).
The controlled computer desk feature desk are:
- AC Power Control: Switching power on/off the monitor that is plugged to 220VAC
- DC Power Control: Switching power on/off the monitor that is plugged to DC power (up to 48V)
- Audio Volume Control: Complete control of stereo volume that is passed to the speakers
- LED Strip Lighting Control: Complete control of LED strip lighting brightness
Device has a proper designed user interface and adjustable mechanical compartments, which make it easy to build and easy to use:
- Display: Real-time status of all the controlled systems are presented on the 16x4 LCD display
- RGB LED: For an additional feedback for the system, purpose of this is to acknowledge for the user that there is an accepted signal received from the IR remote
- Pairing system: Device contains single push-button, which has to be pressed for the pairing process. When the pairing process is initiated, we can pair any IR remote to our device by following the instructions shown on a display.
After we've covered the basics, let's build it!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Explanation
Device operation can be considered as a simple one, due to its lack of design complexity. As it can be seen in the block diagram, the "brain" is the AVR microcontroller, while all the other parts are controlled by this "brain". In order to organize the whole picture in our mind, let's describe the design block-by-block:
- Power Supply Unit: Power source for the device that was selected is the LED strip PSU, that is capable of providing 24VDC input to the system. Microcontroller, relays, digital potentiometers and audio amplifiers all operate at 5V, thus the DC-DC step-down converter was added to the design. The main reason for the DC-DC instead of linear regulator is the power dissipation and lack of efficiency. Assume that we use the classical LM7805 with 24V input and 5V output. When the current reaches significant values, the power that will dissipate in the form of heat on the linear regulator will be huge and may overheat, attaching humming noise to audio circuits:
Pout = Pin + Pdiss, so at 1A we achieve: Pdiss = Pin - Pout = 24*1 - 5*1 = 19W (of dissipated power).
- Microcontroller: In order to write the code as fast as I can, I've chosen the AVR based ATMEGA328P, which is widely used in Arduino UNO boards. According to the design requirements, we will use almost all of the peripheral support: Interrupts, timers, UART, SPI et cetera. As it is a main block in the system, it interconnects with all the parts in the device.
- User Interface: The front panel of the device contains all the parts that user should interact with:
- IR Sensor: Sensor for decoding the IR remote data.
- Push-Button: Is required for pairing the IR remote to the device
- RGB LED: Aesthetical attachment to provide feedback of receiving information by the system
- LCD: Graphic representation of what is going on inside the device
- Monitors Control: In order to make device capable of switching power at the PC monitors, there is a need to deal with great voltage values. For instance, my Samsung monitors don't share power configuration at all: One is supplied by 220VAC while other is powered by its own PSU of 19.8V. Thus the solution was to a relay circuit for each of the monitor power lines. These relays are controlled by MCU and are totally separated, which makes monitor power transmission independent for each monitor.
- Light Control: I have a LED strip, which comes with the attached power supply of 24VDC, which is used as a system power supply input. Since there is need to conduct a large current through the LED strip, its brightness mechanism involves a current limiter circuit based on a MOSFET, which operates in a linear region of active-zone.
- Volume Control: This system based on passing the audio signals on both LEFT and RIGHT channels through voltage dividers, where applied voltage is changed via digital potentiometer wiper movement. There are two LM386 basic circuits where at each input there is a single voltage divider (We'll cover that later). The input and output are 3.5mm stereo jacks.
It seems we've covered all the integral parts of the circuits. Let's proceed to electrical schematics...
Step 2: Parts and Instruments
Everything we need to build the project:
- Common Components:
- 6 x 10K
- 1 x 180R
- 2 x 100R
- 1 x 1K
- 2 x 1M
- 2 x 10R
- 1 x 68nF
- 2 x 10uF
- 4 x 100nF
- 2 x 50nF
- 3 x 47uF
- Diodes: 2 x 1N4007
- Trimmer: 1 x 10K
- BJT: 3 x 2N2222A
- P-MOSFET: ZVP4424
- MCU: 1 x ATMEGA328P
- Audio Amp: 2 x LM386
- Dual Digital Potentiometer: 1 x MCP4261
- Single Digital Potentiometer: 1 x X9C104P
- DC-DC: 1 x BCM25335 (Can be substituted by any DC-DC 5V friendly device)
- Op-Amp: 1 x LM358
- Relays: 5V Tolerant Dual SPDT
- External 24V Power Supply
- LCD: 1 x 1604A
- IR Sensor: 1 x CDS-IR
- Push-Button: 1 x SPST
- LED: 1 x RGB LED (4 contacts)
- Terminal Blocks: 7 x 2-Contact TB
- Board-to-Wire Connectors: 3 x 4 contact cable + housing connectors
- Audio: 2 x 3.5mm Female jack connectors\
- Outlet PSU: 2 x 220VAC power connectors (male)
- DC Jack: 2 x Male DC Jack Connectors
- LED Strip & External Power Supply: 1 x 4-contact Board-To-Wire Assembled Connectors + cable
- 3D Printer Filament - PLA+ of any color
- 4 Screws of 5mm Diameter
- At least 9 x 15 cm prototypings board
- Stock of unused wires
- 3D Printer (I've used Creality Ender 3 with attached glass-type bed)
- Hot Glue Gun
- External 24V Power Supply
- Oscilloscope (Optional)
- AVR ISP Programmer (For MCU Flashing)
- Electric Screwdriver
- Soldering Iron
- Function Generator (Optional)
Step 3: Electrical Schematics
The schematic diagram is divided into separated circuits, which can make it easier for us to understand its operation:
This is an AVR based ATMEGA328P, as it was described above. It uses internal oscillator and operates at 8MHz. J13 is programmer connector. There are a lot of programmers in the AVR world, in this project, I used an ISP Programmer V2.0 from eBay. J10 is UART TX line, and is primarily used for debugging purposes. When constructing a interrupt handling procedure, it is sometimes good to know what system has to tell us from the inside. D4 is RGB LED that is driven directly from MCU, due to its low current ratings. PD0 pin is attached to a push button of SPST type with an external pull-up.
IR sensor that is used in this project is a general-purpose three pin IR sensor that is available on eBay, at very friendly prices. The IR output signal pin is connected to the interrupt input pin (INT1) of MCU,
Display is a simple implementation of a 1604A display, with 4-bit data transmission. All the control/data pins are tied to the MCU. It is important to notice, that LCD is attached to the main board via two connectors J17, J18. In order to drive LCD module on/off, there is a single BJT switch, switching ground line for LCD.
All the internal circuits, excluding the LED strip operate at 5V. As it was mentioned before, 5V power source is a simple DC-DC module (Here eBay helped me find the solution), that converts 24V to 5V, without heating problem, that could occur on the linear regulator. Capacitors C[11..14] are used for bypassing, and are necessary for this design because of switching noise present on DC-DC power lines - both input and output.
Monitor control circuits are just a relay switching systems. Since I have two monitors, one is fed from 220VAC and the second is from 19.8V, there is different implementation required.: Each MCU output is connected to 2N2222 BJT, and a relay coil is attached as a load from 5V to BJT collector's pin. (Don't forget to attach a reverse diode for appropriate current discharge!). At a 220VAC, relay switches the LINE and NEUTRAL lines and at a 19.8V, relay switches the DC power line only - since it has its own power supply, the ground lines are shared for both of the circuits.
Audio Volume Control
I wanted to use LM386 audio amplifiers as the buffers for the voltage dividers, for careful audio signal transmission. Each channel - left and right comes from 3.5mm audio jack input. Since the LM386 implements at minimum parts configuration a standard gain of G = 20, there is a 1MOhm resistor for both channels. This way we can reduce the total amount of power for the input channels to the speaker system:
V(out-max) = R(max) * V(in) / (R(max) + 1MOhm) = V(in) * 100K / 1.1M.
And the total gain is: G = (Vout / Vin) * 20 = 20 / 11 ~ 1.9
The voltage divider is a simple digital potentiometer network, where the wiper passes the signal to the LM386 buffer (U2 is the IC). Device shares SPI for all the peripheral circuits, where only ENABLE lines are separated for each of them. MCP4261 is a 100K 8-bit linear digital potentiometer IC, thus each step in the volume increase is expressed: dR = 100,000 / 256 ~ 390Ohm.
Pins A and B for each LEFT and RIGHT channels are tied to GND and 5V. Thus at the wiper position at the bottom passes the whole audio signal to GND via 1MOhm resistor MUTING device volume.
LED Strip Brightness Control:
The idea of the brightness control is similar to the volume control, but here we have an issue: digital potentiometer may transmit only signals which amplitudes do not exceed 5V to GND. Thus the idea is to place a simple Op-Amp buffer (LM358) after the digital potentiometer voltage divider. and control voltage tied directly to a PMOS transistor.
X9C104P is a single 8-bit digital potentiometer of 100KOhm value. We can obtain a calculation for gate voltage following merely algebraic rules for current flow:
V(gate) = V(wiper) * (1 + R10/R11) = 2V(wiper) ~ 0 - 10V (which is sufficient to power on/off and control the brightness)
Step 4: Creating a 3D Enclosure
For device enclosure, I've used a FreeCAD v0.18 which is a great tool even for the novices like me.
I wanted to create a box where there is a single shell that will wold the soldered board. Front panel contains all the user interface parts and the back panel contain all the connectors to the desk electronics. These panels are inserted directly into a main shell with a 4-screw assembly at the top cover.
Probably the most important step in the sequence. There is need to take in account all the appropriate distances and cut-off regions. As it seen in the pictures, first of all the dimensions that were taken are on the front and back panels:
Front Panel: Cut-off regions for LCD, Switch, LED and IR sensor. All these dimensions are derived from the manufacturer datasheet per each part. (In the case you wish to use different part, there is need to reassure all the cut regions.
Back panel: Two holes for 3.5mm audio jacks, Two 220V 3-line power connectors, Two male jacks for DC power supply and additional holes for the LED strip and power to device
Top Shell: This shell is used only to attach all the parts together. Since the front and back panel are inserted into the bottom shell.
Bottom Shell: The base for device. It holds the panels, electronic soldered board and screws attached to the top cover.
Designing The Parts
After the panels are created, we can proceed to the bottom shell. It is recommended to ensure accommodation of the parts altogether after every step. The bottom shell is a simple rectangle-based extruded shape, with symmetrical pockets near the edges of the shell (See pic 4).
After pocketing step, there is need to create a 4-screw bases for the cover attachment. They were designed as a insertion of primitive cylinders of different radius, where cut out cylinder is available after XOR operation.
Now we have a complete bottom shell. In order to create a proper cover, there is need to make a sketch on the top of the shell, and create same cylinder points (I've only attached points to drill, but there is a possibility to create holes of fixed diameters).
After the whole device enclosure is complete, we can check it by assembling the parts together.
Step 5: 3D Printing
Finally, we are here, and can step forward to the printing.There are STL files available for this project, based on my design.There may be an issue with these files to print, because there are no tolerances taken in account. These tolerances can be adjusted in the slicer application (I've used a Ultimaker Cura) for the STL files.
The described parts were printed on Creality Ender 3, with glass bed. The conditions are not far from the standart ones, but should be taken in account:
- The nozzle diameter: 0.4mm
- Infill density: 50%
- Support: There is no need for support attachment at all
- Recommended velocity: 50mm/s for the project
As soon as the enclosure parts are printed, there is need to check them in real life. If there aren't any issues at attaching enclosure parts, we can proceed to the assembly and soldering step.
There is some issue with the STL viewer in the instructables, so I suggest to download it first :)
Step 6: Assembly and Soldering
Soldering process is a harsh one, but if we separate the sequence into different circuits, that will be much easier for us to finish it.
- MCU Circuit: Should be soldered first with its female programming connector. At that stage, we can actually test its operation and connectivity.
- Audio Circuit: The second one. Don't forget to attach terminal blocks on the soldered board. It is very important to isolate the return path of audio circuits from the digital ones - especially digital potentiometer ICs, because of their noisy nature.
- Monitor Circuits: Similar to audio circuit, don't forget to attach terminal block at the I/O ports.
- Connectors and UI Panel: The last things that should be connected. The user interface panel is connected to soldered board via Board-To-Wire connector, where wires are soldered directly into the external parts.
After the soldering process, there is a simple sequence of mechanical parts attachments. As it was noticed above, there is need to put 4 screws (I've used a 5mm diameter ones) at the corners, that present on the enclosure. After that, there is a need to attach UI parts and back panel connectors to the outside world. Preferred tool is a hot glue gun.
It will be very useful to check parts accommodation into the printed enclosure. If everything looks good, we can proceed to the programming step.
Step 7: Programming
This step is a fun one. Since there are a variety of things that have to operate, we will use a total of 5 services of the MCU: External interrupt, SPI peripherals, UART for logging, timers for precise counting and EEPROM for storing our IR remote codes.
The EEPROM is an essential tool for our stored data. In order to store IR remote codes, there is need to perform a sequence of pressing buttons. After each sequence system will remember the codes independent of state either device is powered or not.
You can find the whole Atmel Studio 7 Project archived as RAR at the bottom of this step.
The programming is done by AVR ISP Programmer V2,0, through simple application called ProgISP. It is a very friendly app, with complete user interface. Just select proper HEX file and download it to the MCU.
IMPORTANT: Before any programming of MCU, make sure that all the appropriate settings are defined according to the design requirements. Like the internal clock frequency - by default, it has its divider fuse active at factory setting, so it has to be programmed at logic HIGH.
Step 8: Pairing and Testing
We are finally here, after all the hard work that was done :)
In order to use the device properly, there is a need for pairing sequence, thus device will "remember" attached IR remote that would be used. The steps of the pairing are as follows:
- Turn device on, wait for main UI display initialization
- Press the button for the first time
- Before the counter reaches zero, press the button another time
- Press appropriate key which you want to have a specific function, according to device
- Restart the device, make sure that now it responds to the keys that were defined.
And that's it!
Hope, you'll find this instructable useful,
Thanks for Reading!