Tiny vs. Mega

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

I have a basic discrete digital design. Essentially, I need to monitor a couple of [potentially transient] digital signals and drive some constant lines (i.e., a pulse input results in a steady state change on the output).

I am currently looking at a circuit that is built from a comparator, several buffers, and some flip-flops. I think I could also build a circuit around a 555 timer to do the same thing. It occurred to me that a very small micro (i.e., a Tiny) could do the job with less cost and less space, with the added benefit of increased flexibility should the desired behavior change in the future.

If I were to use a micro, I would need a handful of digital I/O (say 6 to 8), and enough memory to be able to write a program (in C) to monitor the inputs, make some decisions, and change the outputs. A timer and/or an ADC would be great, but is not required. The chip would need to be programmable via ISP. Ideally, it would have an internal oscillator (no critical accurate timing required).

I have always used megas in my design because other constraints required me to do so (i.e., needed multiple UARTs, SPI/I2C, lots of I/o and/or lots of memory). I think a mega would be overkill here, and have started looking at Tiny's. I am looking for advice from Tiny users. How different are they to work with than Megas? I develop with avr-gcc, and use Megas with large memories. Am I going to be unpleasantly surprised by the severe lack of memory (again, I only need to monitor a few pins for rising/falling edges, debounce them, and set a corresponding output pin. At some point, may want to look at an analog input rather than a pulsed digital input).

My initial survey has led me to the ATtiny85. It appears to meet all of my requirements stated above. Is this a good option? Are there "better" Tiny devices? (I know that "better" is a subjective term. However, it is easy to tell a user that a 168/328 is "better" than an older mega variant).

Thoughts and suggestions please!

Science is not consensus. Science is numbers.

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

Quote:
How different are they to work with than Megas?
As far as the program itself, almost none (especially in C).

Regards,
Steve A.

The Board helps those that help themselves.

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

Quote:

I would need a handful of digital I/O (say 6 to 8) ...

Quote:

My initial survey has led me to the ATtiny85.

Without doing RSTDSBL, you only get 5 I/O from a Tiny85 family.

You mentioned 555 timer. If you have strict timing requirements, then you might want to use a crystal, and now the Tiny85 is down to three I/O.

You mentioned overkill, yet you mentioned Tiny85. Why not '25 or '45?

How many million are you going to make? What space requirements do you have? If only a few, and no particular space requirements, then what AVR model do you have on-hand? Use those.

Let's say you add the AVRs to an order from DigiKey or Mouser or whatever, so the overhead for shipping costs and the like is cancelled out. You are still buying at 1-off prices so for a few pieces the cost difference becomes negligible.

If you want to settle on a Tiny model and you do surface mount, then the '1634 packs a lot of features into a smallish pin count.

If there are no particular constraints on size, I'd use Mega48 family for "general" work. The only thing you might find missing in some apps is differential/gain on A/D.

Mega48A $2.04
Mega88A $2.24
Tiny1634 $1.81
Tiny85 $1.29
Tiny861A $1.94
Tiny261A $1.51
...
and so on.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Quote:

think a mega would be overkill here, and have started looking at Tiny's.

Tiny's or "really really Tiny's"? There are two class of Tiny. As others here have said your average Tiny (2313, 24/44/84, 25/45/85, etc.) are very similar to mega. About the only thing you might do battle with is when you are forced to use a USI for SPI or UART rather than the real thing. If programming in C you won't notice that the CPU doesn't have a MUL instruction (only that the code generate might be a bit bigger/slower for the same task).

But then there are the "brain dead" Tinys (4, 5, 9, 10, 20, 40). These are quite different. The most notable identifying feature is that registers R0..R15 are missing and they only have R16..R31. They also don't use ISP which could be a challenge if your programmer only does ISP. Dragon, AVRISPmkII and other Atmel devices (but not the STK500 as far as I know) have been upgraded to do TPI as well as ISP but if you have some other programmer you could be stuck.

The one saving feature of the brain dead models is that they are built down to a cost. If your issue here is about making a million units of something and you want to save 20 cents per unit then see if you can get the solution into a brain dead tiny. There's also the 6 pin one that is physically smaller than any other AVR. Otherwise only a masochist would choose to use these chips.

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

Thanks for the feedback.

@Theusch: I did mention the 555, but only because it can be configured to create a steady state output from an input pulse (i.e., bi-stable multivibrator). As I said, I do NOT have any critical timing requirements.

Good suggestion re: the 1634 family - I had looked at them too. Size is very important to me for this application, so I really like the 85. I would NOT use RSTDISBL, so you are correct -- I would be limited to 5 pins (no external crystal needed). I think I can shoehorn the circuit into 5 pins if required.

@Clawson: I do not need the really really tiny chip. While size is important, so is relative ease of development. I'm willing to sacrifice the increased size to use an SOIC-8 and have development be easier.

W/ regards to programming, I have an AVRISPmkii - so I could do this "TPI", but again, I'd rather stick w/ a non-"brain-dead" tiny.

Science is not consensus. Science is numbers.

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

You did not mention the duration of pulses you wish to watch for.

If you are sequentially polling the input bits then you must be aware of your loop time to make sure you can "capture" the pulse.

If you use interrupts on a pin transition and set a flag then you might get a faster response, BUT there is still a minimum time duraton for the pulse to successfully trigger the interrupt.

Using the ADC requires a significantly longer pulse, as the ADC samples the input and then processes it.

One can, of course, sometimes add an RC to the input to stretch the pulse a bit, if needed.

JC

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

Excellent points. The input pulses have not been specified. I could stretch it w/ a monostable, but that's not really necessary. This is the back end of a current measurement circuit. I merely want to be able to latch over current warnings, even if the over current condition goes away. I do not see the possibility of an over current condition (at least one that I care about) lasting less than 10ms. Since all the loop will be doing is looking at the input pins, that should be plenty long to detect.

Science is not consensus. Science is numbers.

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

Look at the tiny24/44 series too, only 14 pins compared to '1634's 20 pins.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

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

The tiny24/44 look good too.

I think for this prototype, I will likely use the 85. An added complication to this design is that others on the team do not want to use a microcontroller at all, because they feel it will unnecessarily complicate the board. I want to show that an SOIC8 with a decoupling capacitor can replace 4 flip-flops/buffers. A larger 14 or 20 pin component in this particular application, while not significantly larger or more expensive, would "appear" to be more complicated.

I realize this is a strictly non-engineering based reason to make an engineering decision. However, as I believe this is the best route to get a microcontroller used in this design (which, in my opinion is the best solution), I will go with what I have to.

Science is not consensus. Science is numbers.

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

If the cost is the same I'd always put in as much intelligence as possible so you keep your options open (and you never know - if you have an unused pin it might be the solution to some completely different problem you haven't encountered yet).

On the other hand if it's just combinational logic I wonder if a CPLD might make a happy half way house (both in terms of cost and complexity) between discrete gates and a full CPU?

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

The 'x5s are a nice series, but I would also lean toward the attiny24/44/84 series. I find the added few pins quite useful in many cases over something like the 'x5 series with its five available pins. They still has many of the same size and ease of use advantages.

If people are convinced that something like an attiny is going to be more complicated than discrete logic, I can't see that 8-pins or 14-pins is going to make that much of a difference. I would assume that the "programmable" aspect will have a large effect on their view of the complexity. Show how simple the program is, the circuity is, and the update is, and they'll either accept it or not.

Martin Jay McKee

As with most things in engineering, the answer is an unabashed, "It depends."

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

Having a few more pins with the tinyx4 also helps to have the ISP pins separate. While it is often possible to use the ISP Pins for other purpose, this may require extra resistors. In the smallest (MLF) version both the tiny85 and 84 come in the same 20 pin package and even a mega168 is not larger.

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

Depending of small in 3D space, it could be that a design with a DIP 85 chip could end up smaller, because there can be components under it, and it can be removed from the board for programming.(so no space for extra resistors and connector only used for the programming).