Remote controller with low quiescent current on the ATmega328P
According to the KDPV, it is clear that the author is not indifferent to Sony's vintage audio equipment. Here and MD Walkman, and the recent acquisition - a compact music center with a vertical CD- "transport". It was sold without a remote control, to the home-made analogue of which the author made a demand: the same low quiescent current as that of finished remotes on specialized microcircuits.
At first, the author wanted to write the firmware from scratch, since earlier he had already implemented the software protocol used in Sony remote controls. But then I decided to use the existing library . It supports various protocols, devices, and also has additional. features that facilitate development and debugging.
With this library, just connect the IR diode to the foot of the microcontroller and start searching for Sony remote control codes. They managed to earn a homemade remote control very quickly. But what's the point if the battery in it runs out in one to two days, even if you don’t use it at all?
In general, the task was to put the ATmega328P into sleep mode so that it practically did not consume current until a key was pressed. Libraries for hibernation control also exist, but the author decided that since he had taken a ready-made library for sending commands, let at least this part of the firmware be written independently. According to the datasheet, putting the microcontroller into sleep mode was a multi-step process.
Therefore, everything was commented in sufficient detail in the sketch, so that while reading the code and the dataset, you could understand what happens when each line is executed. The microcontroller “sleeps” almost all the time, and when the state of one of the inputs changes, it “wakes up”, determines which button is pressed, sends a command, and again “falls asleep”.
With 16 MHz quartz, the microcontroller, when it does not “sleep,” will consume more current than when using the built-in 8 MHz clock. To reconfigure the corresponding “fuses”, I had to use the in-circuit programmer. Sleep mode is selected so that everything is turned off except interrupts. The author did not immediately understand that it was necessary to turn off the ADC, for which he could not find the reason why the microcontroller consumed almost one milliamp in sleep mode. The watchdog timer also had to be turned off, and here is the result: about 2 μA in sleep mode and 3.5 mA when transmitting a command. This calculator showed that under ideal conditions, if you press the buttons 5 times per hour, the element in this mode will last for 4.82 years. Even one or two years is already great, and even more so.
The author developed the circuit board at Eagle. Files for repetition: sketch , diagram , gerbera , source board .
Video, where shown current measurement:
The process of improving the design continues, first of all, it is necessary to make a couple of buttons for which the codes found on the network turned out to be incorrect. Further, the author gives a simplified analogue of CC-BY from one phrase: “If you want, use the code and the board in other homemade products, just remember to indicate who developed all this for you.” Since the source library is not under the GPL, but under the LGPL, you can do this.