By KDPV can be seen that the author is not indifferent to the vintage audio equipment Sony. Here and MD Walkman, and the recent acquisition - small-sized music center with a vertical CD- "transport". It was sold without a remote control, to the self-made analogue of which the author presented a demand: the same small quiescent current as that of ready-made remote controls on specialized microcircuits.
At first, the author wanted to write the firmware from scratch, because 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, it is enough to connect the IR diode to the leg of the microcontroller and start searching for Sony remote control codes. Making homemade remote earn very quickly. But what's the point if the battery in it is discharged in one or 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 some key was pressed. Libraries for managing the sleep mode also exist, but the author decided that since he took a ready-made library for transmitting commands, then at least this part of the firmware will be written independently. According to the datasheet, putting the microcontroller into sleep mode turned out to be a multi-step process.
Therefore, in the sketch, everything is commented on in sufficient detail so that by reading the code and datasheet at the same time, you can understand what happens during the execution of each line. The microcontroller “sleeps” practically all the time, and when one of the inputs changes, it “wakes up”, determines which button is pressed, transmits a command, and “falls asleep” again.
With a 16 MHz quartz microcontroller, when it is not “sleeping”, will consume more current than when operating from an internal 8 MHz clock generator. To reconfigure the corresponding "fyyuz", I had to use an in-circuit programmer. Sleep mode is selected such that it disables everything except interrupts. The author did not immediately realize that it was necessary to turn off the ADC, which for a long time could not find the reason why the microcontroller consumed almost one milliamper 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 the command is transmitted. This calculator
showed that under ideal conditions, if you press the buttons 5 times per hour, the element in this mode is enough for 4.82 years. Even one or two years is already great, and even more so.
Pay author developed in Eagle. Files to be repeated: sketch
, source board
Video where it is shown incl. current measurement:
The process of improving the design continues, first of all it is necessary to make earn a couple of buttons for which the codes found on the network turned out to be wrong. Further, the author cites a simplified analogue of CC-BY from one phrase: “If you want, use the code and board in other homemade products, just do not forget to indicate who developed all this for you.” Since the source library is not under the GPL, but under the LGPL, you can do that.