» Electronics » LEDs »Electronic candles on AVR and PIC

Electronic candles on AVR and PIC



Dear readers, before you again electronic candles, but this time unusual. The debate about which is better, AVR or PIC, did not have soil from 1976 to 1996 - all those 20 years when PIC was already and AVR was not there. And then it started, and continues to this day. The author, under the nickname Thierry, decided to participate in this dispute on both sides, making devices that were identical in purpose and close in characteristics to both. So regardless of the result, he won on his own, and quarreled on himself. Let's see how this happened.

The wizard begins by selecting microcontrollers for both options. homemade. So, from the Atmel side the ATTiny25 chip goes into the ring, and from the Microchip side - PIC12LF1822. Both of them are eight-pin, which do not require external timing circuits for the clock generator. Now it's time to think about the algorithm. The master stops at that. Having detected darkness, the electronic candle exits sleep mode and starts to flicker, the intensity of flicker changes every minute. After three hours, it goes back to sleep mode, and then, when it gets light and darkens again, the cycle repeats.

The difference in the pinouts of the microcontrollers did not allow to make the circuit of both options the same. Here are two diagrams in one figure:



The principle of operation for both schemes is as follows. LEDs can work as photodiodes. To switch between the LED and photodiode modes, no external reconnection is required, since both microcontrollers can programmatically switch their outputs to both input mode and output mode. Well, now the differences begin. The master could not get ATtiny to interact with the programmer at a frequency of less than 500 kHz, and I had to choose it. PIC managed to slow down to 31 kHz.

In sleep mode, the option on the AVR consumes 4 μA, on the PIC - less than 1 mA. "Waking up", but not being loaded on the LED - respectively, 190 and 5 μA - here the difference is huge. In operating mode and under load in the form of an LED - 2500 and 2300 μA, respectively. But the difference in the number of days that the battery lasts if the device leaves the sleep mode for three hours a day is small. AVR - 30 days, PIC - 33.If, in the AVR version, the average brightness is lowered by the PWM, you can “pull out” the same 33 days from it.

The master liked the ability of the PIC to consume only 5 μA, while NOT in sleep mode and doing some calculations. In AVR, even with a decrease in the clock frequency to 128 kHz, the current consumption remains quite large - 110 μA. But here you can apply this technique: wake the microcontroller from sleep mode, for example, every 100 milliseconds for only a few percent of the time.

For homemade products, any of the following types of microcontrollers is suitable: ATTiny25 / 45/85 or PIC12 (L) F1822 / 1840. The LED is yellow, such as LTL2T3YR6JS, its opening voltage is less than that of white. C code is presented in two files: and.

The back side of the board with the original battery holder is shown below:



As you can see, the master made one version of the board - double-sided, with pads for both types of microcontrollers. He doesn’t bring the motherboard of the board, but for the three-piece design, including the battery, it is not needed, you can get by with a piece of the breadboard like perfboard.

Now determine the winner. Without additional energy saving techniques, PIC wins. With them, you can get the same number of days of work from one element, so it's a draw. Both options outperform a real tea candle, which occupies even a slightly larger volume - it will not be able to shine for so long. But when used for its intended purpose - to maintain tea in a heated state - it wins already, since the electronic substitute is not capable of this.

It is good that the master is able to program both types of microcontrollers. Such people do not have time for holivars (except for such comic ones, of course), they quickly retrain on what they need to work with directly and straightforwardly. They make very valuable employees.
2
4
3

Add a comment

    • smilesmilesxaxaokdontknowyahoonea
      bossscratchfoolyesyes-yesaggressivesecret
      sorrydancedance2dance3pardonhelpdrinks
      stopfriendsgoodgoodgoodwhistleswoontongue
      smokeclappingcraydeclarederisivedon-t_mentiondownload
      heatirefullaugh1mdameetingmoskingnegative
      not_ipopcornpunishreadscarescaressearch
      tauntthank_youthisto_clueumnikacuteagree
      badbeeeblack_eyeblum3blushboastboredom
      censoredpleasantrysecret2threatenvictoryyusun_bespectacled
      shokrespektlolprevedwelcomekrutoyya_za
      ya_dobryihelperne_huliganne_othodifludbanclose
4 commentary
What is better PIC or AVR - a dispute from scratch. For example, I collect everything at the peaks. I just started reluctance to master AVR with them. I have friendships, so he climbs when I tell him about PIC16F84A.
Andrey A
Well, the comparison is not entirely correct. For example, Tiny441 consumes 150 NANOamps in power-down with wake-up by external interrupt. If you need a Watchdog to periodically wake up, it will consume 1.3 μA (at 1.8V). For low-power applications, the pico-power series needs to be considered. And by the way, the AVR has a Ttiny10 in the SOT23-6 package - one of the smallest MCUs in the world. Yes, with slow clocking, the AVR has an ambush - the programmer does not see it. But this is a programmer problem! The same Tiny441 works fine at 32 kHz.
Author
It's a typo. Less than 1 μA.
In sleep mode, the option on the AVR consumes 4 μA, on the PIC - less than 1 mA.
It, of course, is less than 1 mA.)) But how many times? )))

We advise you to read:

Hand it for the smartphone ...