News for hackers. Stuff that matters.
Re:The ATtiny 2-Series by vardump on Monday November 28, 2022 @11:46AM (#33775871)
Is it just me, or are ATtinys surprisingly expensive chips? 55 cents for an ATtiny402 for instance. 4k Flash, 8 pins.

Something to do with the chip shortage?

Re:The ATtiny 2-Series by kevin_thibedeau on Monday November 28, 2022 @12:39PM (#33776646)
5V compatibility and 40mA per pin has associated costs. You won't get that in a cheap ARM device.
Re:The ATtiny 2-Series by szundi on Monday November 28, 2022 @04:48PM (#33780291)
That can save a dollar on other parts
Re:The ATtiny 2-Series by ilyt on Monday November 28, 2022 @05:43PM (#33780950)
That's mostly effect of production node. Smaller transistors get you better uA/MHz but lower currents (unless manufacturer just decides to spend more die space on output transistors) and lower running voltage
Re:The ATtiny 2-Series by TreeRingCounter on Monday November 28, 2022 @12:26PM (#33776451)
We've gotten to the point where a small 32-bit ARM core IC is cheaper than an 8-bit atmel core IC. I've stopped using 8-bit chips entirely in my designs.
Re:The ATtiny 2-Series by beardyw on Monday November 28, 2022 @12:41PM (#33776687)
> a small 32-bit ARM core IC is cheaper

Can you show an example.

Re:The ATtiny 2-Series by jamesmunns on Monday November 28, 2022 @01:13PM (#33777203)
stm32g0 parts (for example the stm32g030) can often be in the <$1 range, or <$0.50 at decent quantities. I think there is even an stm32c0 line planned at a lower price point.

There are likely lower cost parts, but the REALLY cheap 32 bit parts are moving to RISC-V, see WCH's recent releases.

Edit: as a specific example, the STM32G030F6P6TR is available at $0.74 for one, or $0.45/ea at qty 1000 over on JLCPCB's part list:

https://jlcpcb.com/partdetail/Stmicroelectronics-STM32G030F6...

I put some of these on a very recent project.

Re:The ATtiny 2-Series by LeifCarrotson on Monday November 28, 2022 @01:23PM (#33777372)
Here are ~200 examples from Digikey (sort by price->increasing at a reasonable quantity):

https://www.digikey.com/short/jjhtf0h8

These are Cortex-M0 and Cortex-M23 parts in manufacturer lines like Atmel SAMD10, Freescale KE04, Nuvoton Mini55, NXP LPC82x, Infineon PSOC4, STmicro STM32G0 and STM32F0, and others. And they often blow the 8-bit parts out of the water in features and performance, usually losing only in battery leakage current/active current consumption.

Technically they're often 16/32-bit ARM Thumb cores, not sure I'd call them 32-bit cores when 90% of the instructions you'll execute are 16 bits, even though the memory space and registers are 32 bits wide. I suppose they feel close enough to developers and users like 32 bit cores as opposed to something that's painfully, obviously, only 8 or 16 bits wide that you can just ignore that technicality...

Re:The ATtiny 2-Series by jamesmunns on Monday November 28, 2022 @01:33PM (#33777541)
fwiw: cortex-m parts would be pretty conclusively referred to as 32-bit parts (due to the 32-bit address space/pointers as well as 32-bits being the native word size of the platform).

Other 32 and 64 bit platforms support some kind of "compressed instruction" support, for example 32-bit ARMv7 microprocessors (think early android phones, original raspberry pi, etc.) also support the 16-bit Thumbv2 instruction mode, though thumbv2 support was removed in AArch64/ARMv8.

This is contrasted with a "true" 16-bit platform like msp430, which has 16-bit pointers and native 16-bit words.

RISC-V also has an optional compressed instruction set for both 32- and 64-bit platforms as well.

Re:The ATtiny 2-Series by girvo on Monday November 28, 2022 @06:32PM (#33781434)
And the Xtensa LX6/LX7 use a compressed 24-bit instruction set, but are referred to as 32-bit chips, just to add to your overall point.
Re:The ATtiny 2-Series by unwind on Tuesday November 29, 2022 @04:03AM (#33785255)
I agree, I think it's strange to make the instruction encoding influence whether or not a part is to be considered 32-bit.

Instead I think the programmer's model is what determines that (which would make these ARM cores firmly 32-bit like you say).

Re:The ATtiny 2-Series by LAC-Tech on Monday November 28, 2022 @05:30PM (#33780801)
I wonder if that's because the lower power consumption of an 8 bit Atmel is now in itself a premium feature consumers think is worth paying for? Definitely useful for remote IoT nodes at the very edge, where battery life really matters.
Re:The ATtiny 2-Series by matthews2 on Monday November 28, 2022 @12:00PM (#33776073)
The prices listed in the article are for buying a single chip. If you're buying in the thousands by the reel, many suppliers will sell you them for less than half the one-off price.
Re:The ATtiny 2-Series by twawaaay on Monday November 28, 2022 @12:08PM (#33776188)
Partly.

There is a lot of people who buy these in very small quantities, myself included.

Bulk purchasers pay much less. The ratio of cost of single unit when buying one and a huge amount varies wildly from chip to chip.

Re:The ATtiny 2-Series by ckocagil on Monday November 28, 2022 @12:11PM (#33776232)
Yes, they are expensive. This is what prompted a lot of people to switch to alternatives like Padauk. They had supply issues, though :/
Re:The ATtiny 2-Series by coupdejarnac on Monday November 28, 2022 @02:08PM (#33778053)
And most of the padauk chips hobbyists bought are collecting dust.
Re:The ATtiny 2-Series by LeifCarrotson on Monday November 28, 2022 @01:03PM (#33777059)
It depends on your volume and target price.

Are you trying to put a microcontroller, a battery, a couple switches, and some LEDs/speakers in an injection-molded, basically disposable, consumer good to sell through McDonalds Happy Meals, Walmart, or AliExpress, and you plan to build hundreds of thousands to hundreds of millions of units? Do you expect to program in assembly, or a custom subset of something C-like that obviously won't include the standard library but might not even include something as fundamental as any values on the call stack for arguments or returns, happily trading a couple weeks of developer frustration if it saves $0.01 per part? No, the ATTiny doesn't really make sense for you....find a Chinese 8051 or Paduk core you can epoxy down chip-on-board style, aiming for the absolute bare minimum of peripherals and costs.

Are you producing some high-value commercial good in small quantities? Do you place a high value on developer productivity, want a generous assortment of peripherals and interrupts including communication and reasonably performant DAC and ADC onboard, a comfortable C library, a UPDI online debug interface, vendor support and thorough documentation in English? The ATTiny may be for you, or maybe you want an MSP430 or Cortex-M0, or maybe you want to spend $1 more per unit (worth 200 man-weeks of developer frustration in the paragraph above!) and get something with 10x the Flash and pin count.

A good comparison of some similar microcontrollers (including the ATtiny 1-series) written in 2017 is here:

https://jaycarlson.net/microcontrollers/

Note that this article was specifically tailored to parts just under $1, and didn't focus on the very cheapest parts.

HN has hosted discussion of this article some 4 times in the past 5 years, originally here:

https://news.ycombinator.com/item?id=15633785

Re:The ATtiny 2-Series by aidenn0 on Monday November 28, 2022 @01:26PM (#33777426)
Re:The ATtiny 2-Series by zajio1am on Monday November 28, 2022 @03:02PM (#33778753)
Which (comparable) ones are cheaper?
Re:The ATtiny 2-Series by ilyt on Monday November 28, 2022 @05:42PM (#33780940)
Atmel were always bit pricy for the featureset
Re:The ATtiny 2-Series by Steltek on Monday November 28, 2022 @12:16PM (#33776308)
I love the ATtiny for hobby projects! The acceptable voltage range means it can run off lithium with no regulator and then the quiescent current is something like 5nA. The battery will practically self-discharge faster than the MC can wear it out. Of course the feature set is limited but for the battery powered "go to sleep until XYZ then do something" use case, it's awesome.
Re:The ATtiny 2-Series by scottwick on Monday November 28, 2022 @12:21PM (#33776386)
I totally agree, they're really great for simple hobby projects! I've mostly used the ATTiny85 and it's easy to understand the datasheet, easy to program, battery efficient and comes in a DIP-8 form factor for easy breadboarding. Compared with something like an STM32 I find it quite fun to work with!
Re:The ATtiny 2-Series by brokenmachine on Monday November 28, 2022 @06:55PM (#33781660)
I find the ATTiny85 difficult, since you have to connect a programmer to it.

I tried the Digispark clones but then you lose the low-power advantages.

I'm usually trying to work out problems with my crappy code so I need a connection all the time to iterate. So I prefer the ESPs or Arduino Pro Micro.

Re:The ATtiny 2-Series by snvzz on Monday November 28, 2022 @01:20PM (#33777319)
AIUI, Texas Instruments' MSP430 series[0] (which are 16-bit) is still king at low power.

0. https://embedded.fm/blog/ese101?format=amp

Re:The ATtiny 2-Series by zokier on Monday November 28, 2022 @01:44PM (#33777707)
While low-power has been the selling point for MSP430, in practice I understand the shitton of effort poured into making ARM power-efficient has allowed them to surpass MSP430, see e.g. https://www.eembc.org/ulpmark/ulp-cp/scores.php
Re:The ATtiny 2-Series by guenthert on Monday November 28, 2022 @01:45PM (#33777712)
True, but (some) ATtiny are still available in beginner-friendly tth DIP package.
Re:The ATtiny 2-Series by watchdogtimer on Monday November 28, 2022 @02:34PM (#33778418)
Unfortunately, judging from the article, this doesn't appear to be true for any of the new series.

Some of the new AVR series are, however. A few of these have some of the same features offered in these Tinys (e.g., 12-bit differential ADCs)

Re:The ATtiny 2-Series by puzzlingcaptcha on Monday November 28, 2022 @05:41PM (#33780932)
8-pin SOIC packages (like 412/212) are still very easy to handle as a hobbyist. I've used them in a variety of projects.
Re:The ATtiny 2-Series by BoorishBears on Monday November 28, 2022 @06:46PM (#33781584)
As a kid I remember ordering free MSP430 samples from TI (in DIP format)

SOIC would have been completely inaccessible for me as I mostly relied on breadboards and a radio shack soldering iron with a half-corroded tip that would probably be better suited for plumbing than placing SOICs

Re:The ATtiny 2-Series by unwind on Tuesday November 29, 2022 @03:52AM (#33785186)
This bears repeating every once in a while: surface-mount soldering is not very hard. It's perhaps harder than through-hole, since you don't get the benefit of having the component held mechanically, but not by a lot.

The actual soldering with surface-mount stuff does not mean you have to be like an industrial robot in your precision and gently apply heat to each tiny tiny leg, while also getting the solder in there just in time, all the while holding your breath so you don't blow things away. Not at all.

Surface-mount soldering can be done using way "uglier" techniques than through-hole, where you basically flood the component's legs with solder, heat it enough for it to melt and flow, and then remove the excess. Thanks to the magic of surface tension (and, if you have it, extra flux) the solder will flow to where you want it, all on its own. This kind of technique probably wouldn't cut it for production, where consistency and quality of course are important, but for hobby use it's fine!

There are plenty of YouTube videos showing this off, it can be really really easy. Please don't fear surface-mount soldering. Grab (the cool side of) your iron and join the fun!

Re:The ATtiny 2-Series by BoorishBears on Tuesday November 29, 2022 @01:39PM (#33791392)
As an adult with disposable income surface mount is easy, I have great soldering irons and I order PCBs all the time (used to make them too but it's gotten cheap enough that it's not worth the hassle)

But for a 15 year old with no budget and limited tooling (even flux would have been a luxury), being able to order off a sample form and get something that just worked was invaluable.

Re:The ATtiny 2-Series by snvzz on Monday November 28, 2022 @03:48PM (#33779383)
Several msp430 chips are still available in DIP too, and the new ATtiny's aren't either; it is not an ATtiny advantage.

On the bright side, some SMD packages are still reasonably workable with a soldering iron, like SOIC, and cheap devboards that do little else than breakout into a DIP package are commonplace.

Re:The ATtiny 2-Series by guenthert on Monday November 28, 2022 @06:31PM (#33781422)
Indeed. digikey even have some MSP430 in PDIP in stock for reasonable prices: https://www.digikey.com/en/products/filter/microcontrollers/...
Re:The ATtiny 2-Series by dragontamer on Monday November 28, 2022 @03:54PM (#33779471)
I did a brief search, and it seems that at 1MHz, all of the chips discussed in this discussion so far (ATTiny, MSP430, and STM32) are all 200 uA or less, while _fully active_.

Sleep modes bring that down below 50uA.

So on 2x AA batteries (~3000 mA-hours), it seems like these datasheets are telling me that all these chips can consistently hit 2.5 _YEARS_ of battery life? Or 6.5+ _YEARS_ of sleep-battery life?

I'm surprised at how low power modern microcontrollers are. The power-consumption metrics continue to get better-and-better year over year.

Re:The ATtiny 2-Series by ilyt on Monday November 28, 2022 @05:41PM (#33780935)
It's interesting tradeoff, because generally the bigger transistor the less quiescent current it has (=lower power when everything is off), but on the other side the bigger transistor the higher uA/MHz consumption
Re:The ATtiny 2-Series by squarefoot on Monday November 28, 2022 @06:39PM (#33781503)
A single ultra long life Li-SOCl2 D cell like the Tadiran TL5930/S could probably power one of these chips for no less than a decade.

https://www.mouser.com/ProductDetail/Tadiran-Batteries/TL593...

Re:The ATtiny 2-Series by snvzz on Wednesday November 30, 2022 @04:40AM (#33798716)
msp430 will get you into nA territory[0].

0. https://www.edn.com/ti-msp430-mcu-breaks-500-nano-amp-barrie...

Re:The ATtiny 2-Series by bragr on Monday November 28, 2022 @01:34PM (#33777550)
I made a little LED doodads with an ATtiny running off a simple coin cell. Good for several hours of fun!
Re:The ATtiny 2-Series by bitwrangler on Monday November 28, 2022 @12:27PM (#33776452)
I wonder if Arduino will support the ATtiny 2-series?

UPDATED:

Yes... it's at the bottom on the article.

"Spence Konde has updated his excellent megaTinyCore to add support for all the ATtiny 2-series parts"

The major differences that I can see:

- More flash/ram, now up to 32k / 3k

- This has two USART modules, not just one.

- This has no DAC module, it was removed

- The ADC is improved: was 10-bit 115 ksps, now 12-bit differential 375 ksps.

Re:The ATtiny 2-Series by snvzz on Monday November 28, 2022 @01:18PM (#33777297)
A missed opportunity to move to RISC-V.

At that price (and cheaper), WCH's new chips[0] are way more competitive.

0. https://www.hackster.io/news/wch-launches-a-sub-10-risc-v-mi...

Re:The ATtiny 2-Series by LeifCarrotson on Monday November 28, 2022 @01:35PM (#33777564)
Microchip/Atmel and the ATtiny - even on the launch of a new sub-series like this - are as safe and conservative a choice as IBM or SAP. The WCH RISC-V chip is very, very high risk. I can't buy them at any of the standard distributors, and your article and the linked CNX article say:

> The board is now available to order on Tindie for $6.90

> More information on the part ... is available in Chinese on the WCH website.

> I got pricing information from a tweet by Patrick Yang, Technical Director of WCH, who claims that the CH32V003 RISC-V microcontroller sells for less than 10 cents.*

I can't go to a customer with a quotation based on a tweet.

Obviously the bleeding edge of technology is more competitive in some ways, but not every product launch ought to be on that bleeding edge. I do hope that someday the big vendors launch RISC-V microcontrollers, but they all have a lot of IP in their preexisting ecosystems.

Re:The ATtiny 2-Series by 95014_refugee on Monday November 28, 2022 @01:46PM (#33777722)
RV32E seems dead in the water - no value, no movement, no uptake. RV32I* is ... a dumpster fire, and I say this as someone helping shepherd both silicon specification and reusable software components for it. Really basic things like "how interrupts should work" seem to be a matter of personal taste (and the specs are ... awful, like RFC-by-undergrad awful).

By contrast, and for all its faults, AVR is well-defined and stable. This removes a substantial amount of risk from a customer perspective. Once you have attained a basic level of competence in delivering something on AVR (and most major players did this 20 years ago) you can repeat this in a relatively predictable, consistent and low-risk fashion. The same cannot be said of RV32I*, where every new implementation has to be treated as a from-scratch bringup.

Consider the (relative non-)success of AVR32. Not a strict 1:1, but it brought very little to the table in terms of relevance to 8-bit AVR customers, and added a bunch of risk and overhead.

Obviously there are customers for which COGS is king, and they won't be buying AVR. Ditto those where engineering technofetishism is a consideration (gotta motivate your devs, and if new toys are what does it, then you have to factor it into your plans). But there are (clearly, since they keep making money with the product line) others for whom AVR's strengths make good sense.

Switching from AVR to RV32I* would destroy the product line from that perspective. Which is probably not the "opportunity" you were thinking of. 8)

[edit: fix use of *]

Re:The ATtiny 2-Series by sitkack on Monday November 28, 2022 @02:47PM (#33778568)
In one of these micro lines moving to RISCV they can provide a growth path that didn't previously exist. I haven't used a PIC in 10 years, but it seems like an ideal candidate to keep the same foot print and peripherals while moving to RV32IC.

The package and peripherals matter a whole lot more than the ISA in a lot of applications. The code is often a while(1) and some interrupt handlers.

Re:The ATtiny 2-Series by snvzz on Monday November 28, 2022 @03:43PM (#33779321)
It is just too new. Remember unprivileged ISA was 20191213 and privileged ISA was 20211203.

This is mere months ago.

We get some micro-controller families early, and the companies behind them do commit to some level of long term part availability.

Recent code density work (Zc etc) enables higher code density than Thumb2, finally making RISC-V the most dense in 32bit too. Furthermore, there's standardization going on for simpler and more complex interrupt controllers, for ISA profiles, and for platforms (e.g. profiles on hardware that's expected to be there), which will make long term part availability less important, by maximizing re-usability across hardware.

These early hiccups shouldn't discourage anyone with an ISA this new; Effort is being put into the right places.

Re:The ATtiny 2-Series by nerpderp82 on Monday November 28, 2022 @01:27PM (#33777446)
Metacomment, the information density and layout of this page is excellent!