Cheapest IC available?

I'm currently working on a project that needs:

2 x PWM
2 X Digital Pins
1 X I2C
1 X RX/TX, SCK, MISO/MOSI, RESET (to program the IC)

Currently I'm using Atmega328PB. Is there a cheaper alternative? I need to make these boards by the hundreds and any savings would help!

The ATTINY402 is available for $0.37 each. Might be available cheaper if you search around.

It might suit your purpose, although you would need to use the reset pin as a GPIO pin.

If you want to program it with the Arduino IDE, you would have to search around to see if it is supported.

I think you will find that the MCU is one of the cheapest components of a project. Enclosures, assembly, testing, switches and displays, ect. will all cost far more than the microcontroller.

Of course, if you want the cheapest thing ever, you could always get the $0.03 mcu from china.

Is 3 cents cheap enough ?

https://lcsc.com/products/PADAUK_11011.html

If you want to stick to the ATMEL chips, use their parametric search tool. Important other parameters that you forgot about include RAM and Flash storage, and maybe you need to use other peripherals like timers.

Note that the ATtiny402 and siblings are not programmed over ISP, it uses a different programmer.

How much Flash/SRAM/EEPROM does your current sketch use?

Hi Crossroads,

That is a good question, to which I unfortunately don't have the answer yet because I have yet to write the sketch.

Thank you all for the links to the cheap ICs! Since I am a beginner programmer, I am looking for something that works with Arduino IDE to make it easy to program for me. I should have probably mentioned this before, sorry! Anything else out there?

There are a series ot ATtiny chips that might do.
Looks like you need at least a 16 pin part:
PWM1
PWM2
D0
D1
SDA
SCL
SCK
MISO
MOSI
SS
Rx
Tx
Reset
VCC
Gnd

So perhaps Attiny2313?
SMD or DIP?
https://www.digikey.com/products/en/integrated-circuits-ics/embedded-microcontrollers/685?k=attiny2313
Doesn't have hardware for I2C, maybe fake it in software, or perhaps use the "Universal Serial Interface – USI" to fake it.

There are packages available to add it to the IDE as well

Or look at some of the other supported chips.

If you're after really small, some of the leadless packages are really small, and allow you to stay in the 328P for a uC.

John_S:
The ATTINY402 is available for $0.37 each. Might be available cheaper if you search around.

It might suit your purpose, although you would need to use the reset pin as a GPIO pin.

If you want to program it with the Arduino IDE, you would have to search around to see if it is supported.

I think you will find that the MCU is one of the cheapest components of a project. Enclosures, assembly, testing, switches and displays, ect. will all cost far more than the microcontroller.

Of course, if you want the cheapest thing ever, you could always get the $0.03 mcu from china.

It seems it is supported but how exactly do you go about using the reset pin also as a GPIO?

With just 6 IO pins, how would that be capable of all the IO listed?

Oops, you're right. Completely missed that! Still wondering if there's something cheaper than the Attiny2313 perhaps?

shai:
That is a good question, to which I unfortunately don’t have the answer yet because I have yet to write the sketch.

{facepalm}

Why don't you write your sketch first and see how much memory will be needed.

“I need to make these boards by the hundreds and any savings would help!“

Okay, let’s say you pay $3 per controller.

Let’s say you make 200 boards.

Let’s then say you find a controller for $2

Is $200 going to be a hardship, if so charge 1$ more for each board.

Forest verses trees.

BTW, there is usually a price break when you buy in bulk.

larryd:
Is $200 going to be a hardship, if so charge 1$ more for each board.

Forest verses trees.

+1

Small differences in price really only matter when the production runs into tens of thousands. Even then it may only affect the amount of profit and not the saleability.

Unfortunately, the other side of that coin is the possibility that it is only by spreading the development cost over tens of thousands of units that the price can be kept low enough to make a saleable product.

...R

The 816 is another option, has more I/O.

The 0 and 1 series are really nice ATtinies - 20 MHz on internal clock (I haven't found yet how that works at lower voltages), orders of magnitude better power in sleep, single pin programming, and really cheap. I have to admit it did take me about 1 1/2 hours to get an LED to blink using the timer... in part due to lack of documentation of the Arduino core, and a complete absence of examples to follow... those timers work very different.

Anyway, for OP, to pick the part you need: first of all get a complete overview of your requirements. That includes which I/O you want to use (SPI, UART, I2C, and regular digital I/O and analog I/O), how big the sketch will be (Flash, RAM usage), what other peripherals it needs (timers, PWM outputs), working voltage, processor clock speed requirements, and then use the parametric search tool to find out which one fits best. Instead of hardware UART you may replace this by software serial; at a cost of higher sketch size, use of a timer, higher processor overhead and lower maximum speed.

Before getting to wrapped up in costs. it would be a required step to make one work.
can you get your full project to work with a simple MINI ?
once you get it working, you can work on reducing parts counts and pin counts.
if you get an ATTINY85, an 8-pin chip, and a I2C expander and a shift register to deal will all your I/O but spend $1.50 for all the parts, but one microcontroller with 16 pins cost $0.75, you did not save any money?
like wise, if you could use a chip with the correct pin count, but needed to add memory, again, the support chips might cost more than a more expensive chip that does it all.

if you take a NANO or UNO, get all your things working, then figure out how much memory you require, the chips that fit your needs will be much easier to select.

As others have stated, when you have $4 worth of parts on a board, or more like $8 in sensors and $4 in other parts and $5 in enclosure and plugs, The difference between a $0.95 chip and paying $0.75 really do not have much effect in the grand scheme.

there are a lot of options for a microcontroller chip that is $1 USD or less.
figure out the costs of all the other parts, assembly, enclosure, sensors, etc and see if 25 cents savings on a chip has any real effect on your project. There is a real possibility to get a chip for $1. so work with that, figure all the other costs.

See attached diagram showing what I intend to do. This is for an SMT Feeder. I have yet to figure out the code, but perhaps someone who is more experienced here can take an educated guess how much memory space it may need?

The only features here is to move motor forward Xmm and back. Along with storing settings how many encoder clicks each Xmm is.

No idea without a clear picture of that mysterious "feeder ic" and what the thing is supposed to do - other than the optical sensors, which you apparently somehow expect to read over I2C, I don't see any inputs.

shai:
See attached diagram showing what I intend to do. This is for an SMT Feeder. I have yet to figure out the code,

Make a prototype with a regular Arduino and get it working. That will tell you how much code space is needed and probably will sort out a lot of other things you have not yet thought about.

You have been focusing on the "cheapest" IC. How about coming at it from the other end - what is the upper limit to the price at which you reckon you can sell your device?

...R

Normal workflow should indeed be:

  1. make it work
  2. optimise it: make it cheap/small/extra features/faster/etc

Lots of Arduino/ATmega328p code can run essentially unmodified on the ATtiny (after setting the correct pin numbers and so, of course). They're just that similar - been there done that quite a few times, develop code on a Nano for the ease of debugging over Serial, then move it onto an ATtiny. With some small modifications they may be able to run on totally different hardware - lots of Arduino sketches can run unmodified on the ESP8266 (been there done that quite a few times as well, both directions), though the compiled binary is of course totally different...