Recommend an AVR for this...

Go To Last Post
33 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not so familiar with all the latest ones, but I've got a very small project I'm thinking about.

 

Probably going to run it off of a CR2032.

Timing/clock accuracy not important, whatever built in osc is probably fine.  Probably will run it slower to save power using CLKPR, etc.

Must be able to sample 5 buttons, any combination of buttons can be pressed at any given time.

Must be able to light 5 LED's (again any combination can be lit at any given time).

Needs to be able to sleep with as little power consumption as possible (but wake up if any of the 5 buttons are pressed).

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Sincere question: won't the current drawn by any of the LEDs swamp out any differences in sleep current between different families?  So does sleep current really need to be part of the choice matrix?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

They will be pretty low current, maybe 1mA or so and only lit when the user is interacting with the buttons.  Most of the time they will all be off.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alank2 wrote:
Probably going to run it off of a CR2032.
and 5 lit LEDs will be a relatively hefty load for that cell.

8 - Most Brown-Out Reset Circuits Don't Work | Designing Hardware/Firmware for Low Power MCUs (last two paragraphs)

 

edit : AVR Dx have a VLM in addition to BOD

What are the AVR28DA128 AVR32DA128 AVR48DA128 AVR64DA128 ?? | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Mon. Sep 21, 2020 - 11:21 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

you could have a look at the Tiny84 family. if you go plain simple you need 10 IO lines the tiny84 has 11( 12 with reset disabled, but you know the consequences of that).

No xtal, let it run on 1MHz. you need to check the wakeup capability as you will need to run PCINT interrupt and I am not sure if that can wake the processor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How clunky can this project be? I've been able to get 6 charlie plexed switches on 3 pins. Depending on additional hardware you will get "ghosting" if multiple switches are pressed at once. Also I had a project with a toggled LED for the indicator and a push button on the same pin. Any 8 or 14 pin low power device should be satisfactory. You can also run the tn84 (20 pin) on 128Khz internal osc IIRC (for power concerns) and still sleep it...maybe?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looking at it more, I'm on the fence of dropping the low current/sleep as a critical thing.  I was originally thinking of having no LED's on unless some buttons were pressed, but now I'm thinking I could run some dimly in certain conditions.  I'd still like to sleep and make it consume as little as possible though.

 

I think I've used tiny84'd before - how does the tiny804 compare?  I also saw a tiny841.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Alan, I only used the tiny84 on a little demo board. I do not have experience with the other 2 tiny's.

best thing is compare the first 2 pages of the datasheets and perhaps the electrical characteristics( specially as you are looking for low current.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks like the tiny804 has very little EEPROM - this leaves me with the tiny84A and tiny841

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alank2 wrote:

It looks like the tiny804 has very little EEPROM - this leaves me with the tiny84A and tiny841

The tiny804 is from the tinyAVR 0-series. The 0-series has lots of new features, but the EEPROM is rather small compared to the older AVR cpus. You can use the tiny1604 with 2x more EEPROM/flash/SRAM instead of the tiny804, this will still be cheaper than the tiny84a or the tiny841. Both have the UPDI 1-wire programming interface. If the EEPROM is still to small, you can use a part of the flash as APPDATA section, and use this much like the EEPROM.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Needs to be able to sleep with as little power consumption as possible (but wake up if any of the 5 buttons are pressed).

Can you actually have it off when not needed?  Use some cmos gates to detect a button is pushed, then fire a one-shot or something to actaully power things up.  Or "wire or" the buttons with some diodes to a fet to "kick" it into power up mode when a button is pressed (the AVR then keep the power on til it's done).   A little power slide switch is also cheap & effective!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks - I agree - I think I'm going to give up on any sort of soft off and just put a power switch in.  I still want to reduce power consumption when it is idle, etc., just to make the battery last longer, so I'll see what I can do.  I'm going to give the tiny84a a try and see what I can do with it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 I think I'm going to give up on any sort of soft off and just put a power switch in

Well that does have the win for lowest possible current...any monitor circuit will draw some fA, pA, nA or maybe uA.

If you monitor using galtes, old metal gate cmos is about the lowest quiescent current, cheap, devices (whne no t blazing hot). 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got some tiny84a's in today and some testing has been good:

 

power down mode = 0.16 uA (wow) - I can use a pin change on any of my 5 buttons to wake it back up (not limited to just INT0).

 

This is awesome because it means I don't have to mess with a real power switch at all.  CR2032 capacity of 225 mA / .00016 would yield 160 years so the cell will die of old age certainly before that.

 

idle mode = 140 uA and active mode = 442 uA.

 

All of this tested at 3V and 1 MHz clock speed.

 

I have another question asking about disabling the BOD in power down mode - but I then thought - do I need to use BOD ever at all since I am using a CR2032 battery.  If voltage gets too low, the LEDs won't light before the AVR will give out anyway.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alank2 wrote:
I got some tiny84a's in today and some testing has been good:

The tiny44/84 family is one of my go-tos.  Glad to hear it is a good fit.  Your approach sounds right, good luck!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How many of these units are you making?   One, One for now,  ten, a thousand?...

 

If less than ten, then I recommend the Arduino UNO or Nano.  It is based on the ATmega328P.  This common Arduino has 13 input/output pins  (5 outputs for the LEDs, and 5 inputs for the push switches).   It only costs a few dollars for the standardized development break-out board with a USB-serial bootloader pre-installed.

 

  I recommend the Button.h  library v1.1 by Alexander Brevig.  This code sets up an object for each button that keeps track of how long the button is pressed, how long since the last press, and what to do when each button is pressed.

 

  This Arduino can be put into various levels of low-power modes by using any of the various downloadable Sleep libraries.  Waking up on a button press is monitored by using pin-change interrupts on input pins, using pin-change library code.  With Arduino all these basic libraries integrate well together and you are less likely to get the unforeseen bugs and side effects that happen when coding for five buttons and sleep modes.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
then I recommend the Arduino UNO or Nano.  It is based on the ATmega328P.
A board that is not designed for power consumption?!? Get real.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I prefer to write in gcc with the datasheet.

 

I'm using idle mode now as well to reduce consumption while it is waiting on any buttons to be pressed:

 

uint8_t inputget()
  {
    static uint8_t lastkey;
    uint8_t c1;

    for(;;)
      {
        if (inputcount)
          {
            c1=inputbuffer[inputout];
            inputout++;
            if (inputout==KEYBOARD_BUFFER_SIZE)
              inputout=0;
            ATOMIC_BLOCK(ATOMIC_FORCEON)
              {
                inputcount--;
              }

            if (c1)
              {
                lastkey=c1;
                return c1;
              }
            else return lastkey | _BV(7);
          }

        //sleep until interrupt (reduces power from 440 uA to 150 uA for a 66% power reduction)
        set_sleep_mode(SLEEP_MODE_IDLE);
        sleep_mode();
      }
  }

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do you guys recommend more for reverse battery polarity protection?  I've used a schottky diode before but I don't like the loss from the voltage drop on it (although with a decent one it usually isn't too bad).  Another approach is a TVS which offers generation protection and if the battery is reversed it will conduct.  I'm not sure one is really a replacement for the other so that is why I am asking.  Battery = CR2032

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the battery holder contacts the positive terminal of the CR2032 on the edge and the negative terminal in the center of the face, then problem solved, battery inserted backward does nothing.

David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

P-channel MOSFET. Plenty of examples around. I usually add a zener for over-voltage, and sometimes a polyfuse for over-current, neither of which seem necessary in your case.

 

More generally, I have used keyed connectors in the past, but you can still wire these incorrectly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

There are a fair number of chips that turn a mosfet into an ideal diode.  However, don't know whether these chips are power misers  themselves.  I ran into some on Digikey looking for "gate driver"...well they are gate drivers.

Here is an example (not exactly what I had in mind)

https://www.diodes.com/assets/Da...

 

Your best bet is probably to drive your circuit through, maybe 2 or 5 ohms (> 1/4 or 1/2 W) and put a TVS across to gnd.  So normally, there is a small ohm loss, but at  20 ma, that's only 20 or 40 mv drop.

If the batt is reversed the TVS kicks in & the resistor just serves to limit the "short circuit" on the the coin cell (which will fade pretty quick).  You can do similar with a polyswitch instead of a resistor for somewhat larger cells, like D cells. 

 

We did similar with larger currents (amps) and using a 5KP33A...those are fairly hard to blow out on a pulse basis.  They will ge hot if you sit there & drop 5 watt steady on 'em

 https://www.vishay.com/docs/8830...         

I like the KW units! 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Sep 24, 2020 - 01:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

more

Gliders Coin Cell Holders | Batteryholders.com | MPD | Batteryholders.com | MPD

...

... while the built-in polarity protection ensures that the coin cell will not make contact when improperly inserted.

...

BA2032 | Batteryholders.com | MPD | Batteryholders.com | MPD

...

... and reverse polarity protection

...

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Lots of great links - thanks all!

 

This is the type I'm thinking of using because I want it to be as low profile as possible.

Power usage will be low probably <5mA so a Schottky may be a workable plan.

 

I still wonder though, will a TVS provide enough protection to short a cr2032 into not having any voltages high enough to damage the microcontroller - long enough for the person to figure out they have it backwards and correct it.

 

I suppose I could do both, but I'm really trying to be as minimal on parts as possible.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alank2 wrote:
Power usage will be low probably <5mA so a Schottky may be a workable plan.

I would use the p-fet reverse polarity circuit, rather then the diode, as it has a lower Vf loss and possibly smaller pcb footprint, for this type of battery powered circuit.

But either solution will work.

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I still wonder though, will a TVS provide enough protection to short a cr2032 into not having any voltages high enough to damage the microcontroller 

The unidirectional TVS just looks like a diode drop when reversed, no high voltage.  here is an example 8V TVS, giving the standard 0.7V drop....if you are only drawing  10's of ma, 1-2 ohms will be almost no voltage drop & costs one penny.  If the TVS is beefy enough you could even just apply it directly to a coin cell (but I like to have some resistance, since i hate to divide by zero).

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Sep 24, 2020 - 05:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That is what I'm asking avrcandies - if I put a unidirectional TVS in there designed for 3V so that it conducts over 4V, then it can provide some static protection and at the same time if they reverse the cell by accident, it will be a short on the cell and possibly keep voltages from doing any damage.  I suppose shorting the cell really isn't much protection though, but the question is could it be the difference between someone seeing the mistake and flipping over the cell to a working thing vs. not a working thing.

 

EDIT: Then there is also the TVS + a small PTC.  Reversing the battery would cause large current and the PTC could trip.  What is the power efficiency of a PTC vs. MOSFET vs. Schottky?

Last Edited: Thu. Sep 24, 2020 - 05:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PTC by itself is no good, it has to work against a TVS or someting...you don't want it working against your AVR or opamp to open up under reversal.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That is what I am thinking, it could work against a unidirectional TVS.  Most PTC's are not so small on current, I found 0ZCM0001FF2G which says that it is 15 ohms Rmin.  If AVR load is 1mA @ 3V that would be a 3000 ohm load and a 15 ohm PTC wouldn't be so bad, right?  It allows 10mA, but trips at 30mA.  If someone put the battery in backwards the TVS would conduct and the PTC would then trip and cut off the current.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Use an N-fet in the negative connection.

A P-FEt will have a reverse diode that will make sure it will not work, so there you would need 2.

We are using this already for over 15 years, works like a charm. All you need to do is make sure the N-FET threshold level is well below 2V as else the fet will become impedant whilst you still would not want it as this causes extra drop.

 something like this:

now as you only have 1 connection you can remove the resistors. Here we have a SMPS attached that makes 5V so when the device is on the FET is getting 5V Vgs when off it gets whatever the battery voltage is. IIRC this fet has a threshold level of 0,5V and is wide open with 2V.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meslomp wrote:

 

 

Use an N-fet in the negative connection.

A P-FEt will have a reverse diode that will make sure it will not work, so there you would need 2.

 

 

A P-Fet will work in the same way when it is in the + Path of the battery. N-Fets are better here because of the usually lower on-resistance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Compact Multi-Purpose Coin Cell Power Pack (Keystone Electronics)

...

  • Polarized to protect circuitry from improper battery installation

...

1067 (Keystone Electronics)

...

Polarized to Assure Proper Continuity and Circuit Protection

...

 

"Dare to be naïve." - Buckminster Fuller