Computing stuff tied to the physical world

Picking an ATtiny

In AVR, Hardware on Oct 25, 2011 at 00:01

The reason I’m using an ATtiny for the AC current measurement setup, is their differential ADC + gain, and because it is fairly easy to develop for them using the same Arduino IDE as used by, eh, well, Arduino’s and JeeNodes. There are good installers for Windows, Mac OSX, and Linux.

There are several very interesting alternatives other than ATmega and ATtiny, such as the Microchip Technologies PIC and the Texas Instruments MSP430 series. But while they each are attractive for a number of reasons, they either have only a development environment for Windows, or they don’t support standard gcc, or they just don’t offer enough of an advantage over the Atmel AVR series to justify switching. So for something like the AC current node, which doesn’t even need to run off a battery, I’d rather stick to the Arduino IDE and carry over much of what is already available for it. In terms of cost, the differences are minimal.

The trouble with the ATtiny85 I’ve been using for the AC current sensor is that it only has at most 6 I/O pins, while the RFM12B needs 5 to operate (with polling instead of interrupts, this could be reduced to 4).

I’ve tried hard to find tricks to re-use pins, so that the differential ADC pins can be used during measurements while still supporting the RFM12B somehow. I even considered using a 1-pin OOK transmitter instead of the RFM12B. But in the end I gave up – the hassle of finding a solution, figuring out how to support this in software, and still have a decent way of debugging this (read: ISP) … it didn’t add up.

It’s much easier to pick a chip which is slightly less I/O-pin limited, such as the 14-pin ATtiny84:

Screen Shot 2011 10 17 at 14 10 11

One drawback w.r.t. to the ATtiny85, is that it has no 2.56V bandgap reference, only 1.1V – but it does have differential ADC inputs with optional 20x gain stage, which is what made AC current measurements possible.

It turns out that the ATtiny84 has enough I/O pins (a whopping 11!) to support an SPI interface to the RFM12B as well as 2 complete JeeNode-like ports. There is in fact enough I/O capability here to hook up a Room Board.

The 8 Kb flash rom size is sufficient for the RF12 driver plus a bit of application-specific functionality. The 512-byte RAM is not huge, but should also be sufficient for many purposes (two full RF12 buffers will use up less than a third of what’s available). And lastly, there are 512 bytes of EEPROM – more than enough.

To be honest, I’ve been fooling around with this chip for some time, since it could be used to create even smaller PCB’s than the JeeNode. But it has taken me quite a while to get the SPI working (both hardware- and software-based), which was essential to support the RFM12B wireless module. The good news is that it now does, so this is what I’m going to use for the rest of the AC current sensor experiments – wireless is on the way!

Stay tuned …

No, wait. One more factoid: this weblog was started exactly 3 years ago. Celebration time – cheers!

  1. Neat little chip. I have one on my breadboard too :-)

    Congratulations on three years of educational musings. Long may they continue.

  2. Congrats on three years. Whilst I have only been reading your stuff for less than 6 months, I have found all your articles really useful.

    Oh, and really looking forward to seeing an ATTINY84, PIR, and RFM12B all working. This would be much easier to stuff into a small solar garden light (my next project after my current two ;-).

  3. Champange? Great milestone – looking forward to years 4 and beyond.

    The third year is traditionally “leather”. Hmm… a handy Leatherman multitool for prising lids off reverse engineering boxes ?

  4. Congrats on the 3yr anniversary ! I too read your musings on a daily basis and find them informative and inspiring.


  5. Congrats on the 3yr anniversary! Hope you may enjoy many more years or writing, as we will surely enjoy reading it! :-)

  6. Congrats on the 3 years!

    Can’t wait for the new Nodes :)

    Keep going!

  7. Yee, time flies!

    I always read this blog in the morning with some coffee, and then go to work ;-)

    Wrt the ATtiny84: looks like a JeeTiny is coming, half the size of the current JeeNode… That would be really nice!

  8. Congrats on the 3 years! I have only been following for 4 months, but find this very interesting. These chips and sensors are a new endeavor for me and I find this information to be very helpful.

  9. Congratulations, JC!

    What a wonderful blog, fantastic hardware, incredibly useful ideas. I am certainly not the right person for ‘social networks’ á la facebook et al, but for me this is a real ‘social’ network with a real meaningful target (you may decide if this target is just communication between technically oriented people or ‘environmental electronics’)!

    Concerning choice of controllers, I have been using nearly every controller family that is (or has been) on the market in the last 20 years. Most of them have a ‘right of existence’ (otherwise they normally disappear within very short time). I have been using Atmel from the very beginning (At1200, 4414, 8515, etc. ), then switched to MSP430F139 for a high volume product, changed back to Atmel ATmega324 for the next generation of this product. Now the MSP430G2xxx series is again the controller with one of the best performance/price ratios on the market. But as you said, there are lots of other reasons for choosing a controller family for a certain purpose and the Atmel ATmega and ATtiny are still a very good choice. And for our ‘hobby’ projects, there is no real need to look for the last (€)ct, it is much more important to have a ‘convenient’ product.

    Keep on with your fantastic work,

    BR, Jörg.

    • Forgot to say that I emptied a bottle of champagne this evening (ok, this was only a ‘low cost’ spanish cava and my wife also had half of it), but nevertheless!

  10. Many thanks for all the kind words. I get the impression that we’re only scratching the surface in terms of what we can accomplish, especially with several people chipping in w.r.t. their respective fields of expertise!

    Kudos to Jörg for getting me to pour my wife and me a nice glass of port cq whisky right now!

  11. @Mars’ suggestion and your latest experiments on 220V power supply: a node that could be put in a (60 mm) deep drywall box, together with a relay. Current node is just a notch too big. Hotel switch circuit would allow both Jee and the physical switch to act. Jee can see light through translucent housing. The perfect intellihome appliance :-)

    • Ooh, that hotel switch trick is clever!

      Not there yet. For a relay I’ll need more power than the current 1 mA transformer-less setup. Either that or use a latching relay.

  12. JC, most latching relays are usually associated with signal switching; small form factor/230VAC contacts with adequate current capability are hard to find. A sensitive gate triac solution is possible & iff you know it is a resistive load, then triggering near the voltage zerocrossing makes the emi filtering much easier. Your X2 can be part of that filter. The trigger drive is a little demanding on the power supply – a few microseconds pulse is enough, but at 30-50mA.

    A pair can simulate a “hotel switch”. (That term is perhaps confusing – American electrician slang? – means a single pole, two way (A to B or A to C), equally confusingly called a ‘3way’ (sic))

    • Heh – the “hotel switch” comes from blindly translating how it’s called in Dutch. I do intend to experiment with triacs later – there’s a very nice app note from MicroChip with a PIC driving a triac from a very low-power transformer-less supply, I’ll dig it up when I get there.

  13. Hehe, it turns out it is American – for years, only hotels/motels had lights switchable from two locations. I didn’t think the Americans left the Dutch any heritage ;-)

    • I didn’t know what you were talking about when you called them hotel light switched, but now it sounds like the thing I have in my hallway (originally wired in the 1960s)!

      Do you mean a light switch on the stairs, with a switch at the top and the bottom. Switching either light switch changes the state of the lamp?

      You just need a double throw switch, i.e. one that has an output on both sides. You connect those to the two outputs of the other switch…

      Now if you want to get clever, you do it with 3 switches… I’ll leave you to mull on that one ;-)

Comments are closed.