Cheap small microcontroller to replace 555 and other simple logic? - Page 1
Forum section: electronics / projects

author: milow
author_rank: Contributor
timestamp: July 26, 2015, 04:55:26 pm
content: Hi,which cheap(est) small microcontroller do you use to replace simple logic and stuff which was done with a 555 in the past. I checked some prices:Attiny4 for $0.38For comparison:ne555 $0.15-0.20Are there any standard cheap microconctroller?Best regardsmilow

author: RogerRowland
author_rank: Regular Contributor
timestamp: July 26, 2015, 05:31:17 pm
content: In my not so experienced nor humble opinion, you can't beat the gigantic range of 8-bit PICs.http://www.microchip.com/ParamChartSearch/Chart.aspx?branchID=1012

author: mmagin
author_rank: Frequent Contributor
timestamp: July 26, 2015, 05:37:05 pm
content: Consider that with the microcontroller solution, assuming you're okay with the internal RC oscillator, you can probably get away with at least two less resistors and one less capacitor to do similar things.

author: splin
author_rank: Frequent Contributor
timestamp: July 26, 2015, 06:01:42 pm
content: STM8S003F3P6. 16 MHz 8-bit MCU, 8K Flash, 1K RAM, 128 bytes data EEPROM, 10-bit ADC, 3 timers, UART, SPI, I²C$.375 @ qty 20 including shipping:http://www.aliexpress.com/item/Free-shipping-20PCS-LOT-STM8S003F3P6-50PCS-STM8S003F3-STM8S003-New-and-original/32380791807.html$.27 @ qty 50:http://www.aliexpress.com/item/Free-shipping-STM8S003F3P6TR-STM8S003F3P6-TSSOP-20-NEW-ORIGINAL-IC-MCU-8BIT-8K-FLASH-20TSSOP-STM8S003F3-50pcs/32276649038.html$.23 @ qty 100http://www.aliexpress.com/item/New-Original-100PCS-LOT-STM8S003F3P6-STM8S003F3-TSSOP20-8KB-8-bit-microcontroller/32263970851.htmlYou can get good free compilers and development environment and a hardware one wire (+ ground!) debugging/programming interface, STLINK clone for $2.78. I don't think you can get a programmer for a PIC as cheap as that. It is a clone though - a more ethical, pukka STLINK is $21 from Digikey.http://www.aliexpress.com/item/FREE-SHIPPING-ST-Link-V2-stlink-mini-STM8STM32-STLINK-simulator-download-programming-With-Cover/1766455290.htmlThere is a reason that these seem to be fairly ubiquitous in cheap Chinese electronics such as $2 voltmeters, wireless modules etc.Development boards can be had for $1.2 apiece and even less for 10 or more:http://www.aliexpress.com/item/Free-shipping-1pcs-lot-STM8S103F3P6-system-board-STM8S-STM8-development-board-minimum-core-board/32401715387.htmlNote that I'm not recommending any of the above vendors but I've had no problems with the STLINK and development boards I've bought from other Aliexpress vendors. I found it really easy to get a timer interrupt program using I/O ports running - certainly easier than ARM 32-bit Cortex Mx microcontrollers which require a bit more setting up (but not too difficult - its mainly a problem of finding out where in the example code that the clocks and peripherals are configured and initialised).

author: milow
author_rank: Contributor
timestamp: July 27, 2015, 02:07:59 pm
content: Very interesting. I've researched different well known manufactures and it seems that about $.35 to $.45 @1000 is the cheapest you can get when buying from big distributors (and not from aliexpress). Nevertheless, what you get varies widely. One the one hand, there are lots of timers, adcs, spi, i2c, 1k ram (like the STM8S003F3P6). On the other hand, you get just a few bytes of ram, a timer or an adc (smallest Pics), which is still respectable.The question is, is it feasible to program these small controllers in C. If not, that would slow down development a lot.Right now, I have to practical application in sight. I just want to have a cheap one at hand and learn to to use it for future projects.Do you think there are sub $.20 micros? The cheapest available micro at octoparts is the PIC10F204T for $.35?

author: FrankBuss
author_rank: Unknown
timestamp: July 27, 2015, 02:27:00 pm
content: You can use C for it, 1k is sufficient for simple applications like a 555 replacement. I tried a very expensive microcontroller, $.50 if you buy 100and I wrote the program in assembly:http://www.frank-buss.de/PIC100/index.htmlThe factory calibrated RC oscillator is nice and for such simple applications, assembly doesn't slow down development time much. Replacing simple logic gates might even look simpler in assembly, because of the bit manipulation commands most CPU instruction sets provide, and unlike C, you know exactly what the CPU is doing. With these simple chips, there is no instruction cache or other difficult to predict timing uncertainties, so you can program cycle accurate programs, if you need it, like I did in my 100 Hz test project.

author: janekm
author_rank: Unknown
timestamp: July 27, 2015, 02:31:57 pm
content: Quote from: milow on July 27, 2015, 02:07:59 pmThe STM8 is the sub $.20 micro. ST are really pushing for the very-low-cost market in China and are offering them at really ridiculously cheap prices in China (through local distributors only). You won't get those prices on any of the distributors on Octopart because ST don't want to mess up their not-in-China pricing. Oddly, locally produced micros, including 8051 clones, are more expensive than STM8.I think Pic and AVR just survive because they're well known and a lot of developers are familiar with them (good reasons to be sure). In terms of value for money, they're horrible (and their pricing through Chinese distributors in particular is terrible).

author: Zero999
author_rank: Super Contributor
timestamp: July 27, 2015, 02:44:50 pm
content: What exactly are you trying to do?If all you need is a short time delay or oscillator and stability isn't that important, often the most cost effective solution is a 555 timer. It has the advantage of being able to source/sink 200mA and run directly of voltages as high as 16V without an external voltage regulator.Other possibilities include logic gates such as the CD4011, CD4001, 74HC00 etc. or a flip-flop such as the CD4013 or 74HC74.

author: splin
author_rank: Frequent Contributor
timestamp: July 27, 2015, 05:47:13 pm
content: Quote from: milow on July 27, 2015, 02:07:59 pmI'd think that pretty much all microcontrollers have C compilers available apart from some very small or oddball devices - you'll probably have trouble finding one for the 16 instruction, 4 bit, Motorola MC14581 ALU for example!The STMS8 has at least two commercial compilers with code size limited free versions and a free GCC based compiler.QuoteDo let us know if you find one! Octopart isn't always reliable with pricing; Digikey is an excellent resource for this kind of problem - way better than Mouser, Farnell etc. Go to Embedded micronctrollers, put in your quantity and sort in price order. At 1000 the cheapest are:$.31361 Silicon labs EFM8BB10F2G-A-QFN20 2K bytes Flash 8051$.35 Microchip PIC10F200T-I/OT 384 bytes Flash$.378 Cypress CY8C4013SXI-400 8K byte, 32-bit 16MHz ARM Cortex M0You need to watch out for price breaks though which aren't always at obvious quantities. Changing the quantity to 2500 gives the top three as:$.31361 EFM8BB10F2G$.346 STM8S003F3P6$.348 Spansion MB95F272KPF-G-SNE. No idea what this is.The operating voltages vary a lot as well. The PIC10 is 2.2V to 5.5V, the STM8S is 2.95 to 5.5V but the EFM8BB10F2G is only 2.2 to 3.6V with 5V tolerant I/O.An important consideration when using microcontrollers is how reliable do you need it to be? There is a lot to be said for simple logic gates, if a microntroller isn't essential, when you have an application that you can't easily reset, power-cycle or is controlling something that could be a safety hazzard.Many micros have PWM peripherals for example which are marketed for motor control or switch mode PSU applications. But what if the processors locks up due to EMI, cosmic rays flipping RAM/register bits (really!) or ESD? If a MOSFET which is DC coupled to an I/O pin happens to be turned on at the time could the controller go up in flames?Additional circuitry or careful design may help but microcontrollers have so many possible internal states it can be very hard if not impossible to predict all the failure modes. At the very least you'll need a watchdog and brown-out detection will be good - I don't think the PIC10 has the latter.If the device is to be used commercially such as in a domestic appliance you're likely to have to comply with the safety standard IEC 60730 which would be a whole world of pain.

author: ralphd
author_rank: Frequent Contributor
timestamp: July 27, 2015, 10:22:22 pm
content: The ATtiny13a is around 34c qty 10 on aliexpress. Easy to program in C, and you can flash them with a USBasp that costs about $1.75.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 27, 2015, 10:33:50 pm
content: Something to consider if looking at the total price of manufacturing a product, As well as a decent (1%) RC OSC, MicrochipDirect can supply PICs pre-programmed and marked for a few pennies (in the case of the low-end parts), with low MOQ and setup costs.If you're making stuff in the 100s to 1000, this alone can be a deciding factor in overall cost, as it saves the cost of a production programming setup & processing time..

author: MarkF
author_rank: Super Contributor
timestamp: July 27, 2015, 11:48:41 pm
content: I've been working with the PIC16F876A 8-bit PICs for a while now. With the Microchip XC8 C compiler I've been able to get a lot of functionality into 8 kB of memory. Although you would need a $50 PicKit 3 programmer, the PIC16F1829 with an internal 16 MHz clock in a 20 pin DIP package only costs $2.00. More than the MCUs you've quoted but would satisfy most small to medium sized projects written in C. Even driving small 1.27" 16-bit color OLED displays.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 28, 2015, 03:15:02 pm
content: also take a look at the Silego Greenpak devices - not MCUs but can be used in some similar applications as lowest-end MCUs

author: eneuro
author_rank: Super Contributor
timestamp: July 28, 2015, 03:50:03 pm
content: Quote from: FrankBuss on July 27, 2015, 02:27:00 pmOne can use C assembly listing and additional directives and I know what MPU is doing on assembly level too-no need to code everything in assembler, but critical part of code onlyThis is example part of custom ATTiny85 bootloader assembly code generated from C language with additional statements:Additionally all part of code is positioned at given flash program memory addresses.

author: tszaboo
author_rank: Super Contributor
timestamp: July 29, 2015, 07:47:13 am
content: Quote from: milow on July 26, 2015, 04:55:26 pmThat is strange way of doing things! If something can be done with simple logic, it is not size limited, why would you replace it with a microcontroller?74 series, 555, 4000 series will be in production for the next 30 years. They usually consume less energy than a micro, faster, more reliable, less problems with the production. Also less expensive as you saw, and you dont have a vendor lock-in. This is wrong thinking, it leads to stuff where you need an X86 galileo to measure a temperature wireless.

author: Kalvin
author_rank: Super Contributor
timestamp: July 29, 2015, 11:15:33 am
content: if you are fluent with microcontrollers, replacing discrete digital and analog circuits with a programmable solution is a very tempting approach: it is quite quick and easy to change or fix the functionality without modifying actual hardware when you are using small programmable devices. Also, adding new features is typically easier than modifying the existing hardware.Someone might argue that using MCU, CPLD or FPGA instead of discrete logic devices is not recommended because of vendor lock-in etc. The vendor lock-in may be a problem, agreed --- but the programmable device also provide many advantages. The programmable solution provides more opportunities for fast prototyping, incremental development and later product enhancements.Debugging these designs may be a nightmare, because you just cannot put your scope probe into a circuit and see what is going on. But that is an another story.

author: ralphd
author_rank: Frequent Contributor
timestamp: July 29, 2015, 03:04:35 pm
content: If you don't need ADC, the Cypress 4013sxi-400 is 38c/qty 10, and it looks like there's free shipping from the Cypress online store.http://www.cypress.com/part/cy8c4013sxi-400I think that ARM M0+ MCUs will undercut most of the 8-bit microcontrollers within a few years. Besides Cypress, ST has the STM32F030 line starting in the 30c range. I expect Holtek's 4K flash M0+ to sell in the 25 cent range.http://www.holtek.com.tw/English/products/mcu_126.htmIMHO, ARM M0 development still has (slightly) higher up-front costs and a steeper learning curve than AVR. An ST-Link V2 clone for ARM programming runs ~$5 vs < $2 for a USBasp. I have yet to see a M0+ mfr offering a official arm-eabi-none gcc build including header files for their peripherals, while Atmel offers binary downloads of avr-gcc with avr-libc for both Windows and Linux.I haven't dipped my toe in the ARM waters yet, but it is only a matter of when, not if. I'll probably start with the STM32F030, since it's cheap and includes a UART bootloader in ROM so I won't have to deal with SWD for programming. Although they aren't available in DIP, QFP32 is still easy to solder and I already have some QFP32-DIP adapter boards that I have used for AVRs.

author: Chris C
author_rank: Frequent Contributor
timestamp: July 29, 2015, 04:48:21 pm
content: The regular 555 can provide up to 200mA on its output. This is a blessing if you need it, but a curse otherwise. Because when switching output states, it exhibits something called "shoot-through". It briefly turns on both its source and sink transistors, causing 200mA to flow straight from power to ground. That's a significant amount of current, and it causes glitches on the power rails. The recommended bypass capacitors do help tame this, but do not eliminate it.Some years back, I was working on a circuit with two independently adjustable 555's. I found that the switching noise from one could prematurely trigger the other, if they were set to similar frequencies; causing them to lock on to each other and run at exactly the same frequency, when they were not supposed to. I was able to reduce this by adding additional filtering, using heavier wires, and routing supply rails carefully using star topology. The kind of stuff one would normally only have to bother with for high-current circuits, even though mine was not, except for this one quirk of the 555's. But even this still didn't fully eliminate the issue.I ended up switching to a CMOS 555 version, which does not shoot-through, and that finally solved it. But one CMOS 555 costs more than a cheap MCU! Whereas a cheap MCU could take the place of both CMOS 555's, and more. I'd been intending to learn to use MCUs for a while at this point. This ordeal was what finally made me take the leap, and I'm very glad I did.There's a lot of focus on cost in this thread. Also vendor lock-in, and questioning why one would under-utilize an MCU merely to replace a simpler and cheaper 555. All of which are important concerns if producing a product, but maybe not so important if  is a hobbyist. If something makes experimentation easier, it's often worth the extra pennies. For me, paying $0.25 extra for an MCU is well worth never having to deal with the noise from a 555 again. And while first learning to use an MCU, paying much more is worth it if it makes that easier; one can branch out into the smaller and larger varieties later as needs dictate.Quote from: NANDBlog on July 29, 2015, 07:47:13 amThough this may be of concern, even for a hobbyist. If your 555 goes out in a decade, you'll still be able to get a direct replacement. But what about an MCU? This is one of the reasons I use Microchip. Though they're admittedly not the most attractive in all aspects, they've promised that replacements will always be available. Every MCU they've ever made, and every package style, is still available and readily purchasable from multiple vendors in quantity one. As far as I know, no other vendor has made a similar promise. Browsing what's available from them, I often find chips just a few years old phased out entirely. Fewer vendors. Chips regardless of age out of stock for months at a time. Kind of scary.

author: technix
author_rank: Super Contributor
timestamp: July 29, 2015, 05:15:48 pm
content: I got a bunch of PIC16F72's for less than 20 US cents (on Taobao though, big distributors are not readily accessible in China) and those puppies run good enough with C code.Also if you want to eliminate as much parts as possible you can use ATtiny series AVR, like the lowest end ATtiny13 (or higher end ATtiny85 if you like so, just personal preference using AVR over PIC for smaller projects)

author: kripton2035
author_rank: Super Contributor
timestamp: July 29, 2015, 05:26:58 pm
content: what about this replacement for a ne555 ?http://www.datasheetarchive.com/dl/Datasheet-081/DASF0030511.pdf

author: Fungus
author_rank: Super Contributor
timestamp: July 29, 2015, 07:02:38 pm
content: Quote from: milow on July 26, 2015, 04:55:26 pmWith the NE555 you often need more external components. That will bring the prices a bit closer, but, yeah, micros are going to be more expensive.OTOH you usually gain a LOT of functionality.

author: MarkF
author_rank: Super Contributor
timestamp: July 29, 2015, 08:18:16 pm
content: Quote from: milow on July 26, 2015, 04:55:26 pmMilow,It depends on what you're trying to do. Sometimes the simple logic chips are just the best to use.However if you want to use a MCU to replace the standard logic chips and start learning how to program and use MCUs, I would recommend just picking one of the more popular MCUs that you can get a lot of support and examples for. Say one of the Arduinos or one of the Microchip PICs. I would select one with average capabilities (with a hardware SPI for driving small displays, D/A convertors and etc.) and stick with it for several projects until you comfortable. Then branch out from there.I would NOT pick the cheapest because you will quickly out grow it.I started with one of the PICs several years ago because I didn't need a programmer for it. However, it cost as much as the programmer. But for a one-of, it served me well for many years as a learning tool. You can use theMicrochip Advanced Part Selectorto narrow down a selection if you wish to use a PIC.

author: Kleinstein
author_rank: Super Contributor
timestamp: July 30, 2015, 09:03:24 am
content: If you need a slow clock, the µC is a real alternative to a NE555 style timer:- no external components except decoupling- usually rather accurate internal RC clock (e.g. 1 - 5 %)- low power (possibly even lower than CMOS Versions of 555)However you still need programming. So it's only half the solution if you get a blank µC in 20 years if you a re lucky.

author: technix
author_rank: Super Contributor
timestamp: July 30, 2015, 09:35:26 am
content: If you re really conscious about avoiding the vendor lock-in you can design your system into interchangeable modules, and stick to that interface you defined using whatever part you can find.Here is an example, M121, a battery backed I2C RTC module. Here is the standard pinout I chose:+5VVddAD0INT#SQWSDASCLGNDThere are always two devices on this I2C bus: the RTC chip and a 24C02 EEPROM chip at 0x50/0x51 (based on AD0 pin.) The EEPROM have three bytes of critical information within: RTC address with AD0=0, RTC address with AD0=1 and RTC chip model.If any chip used in one version of the module is out of production, I can always replace it with another compatible module.

author: Zero999
author_rank: Super Contributor
timestamp: July 30, 2015, 09:55:13 am
content: Quote from: Chris C on July 29, 2015, 04:48:21 pmYes, I've heard about this issue but never experienced it myself.Another possible solution could've been to use logic gates or flip-flops such as the 74HC14, CD4011, 74HC74 CD4013. They're often much cheaper than CMOS 555 times and microcontrollers, use less power and don't suffer from the same power glitches.

author: technix
author_rank: Super Contributor
timestamp: July 30, 2015, 12:41:53 pm
content: Two cents on the MCU side of things, some freakishly accurate but still cheap enough solution are available if you use a MCU, like using the single chip DTCXO/RTC DS3231 as your time reference. You can write what is effectively a digital PLL using code tracking the DS3231's 2ppm 32768Hz oscillator. This is treading on time nut territory but some tasks may need this kind of accuracy. (BTW, if your product needs an RTC anyway this can be a cost saver since you can fold both the adjustable frequency standard and RTC into one two-chip-maybe-one-crystal solution, cutting a bit of board size and part count. DS3231 uses internal crystal and most MCU can either run on DS3231's 32768Hz square wave output or have internal RC oscillator)

author: tszaboo
author_rank: Super Contributor
timestamp: July 30, 2015, 12:57:26 pm
content: Quote from: Chris C on July 29, 2015, 04:48:21 pmFairchild has a no-obsolescence policy. So all the logic gates.MCU vendors, at least the big ones are OK. There are those horrible vendors like Maxim, who makes components obsolate before they enter mass production. Because someone didnt order. I also like when intel and AMD talks about the embedded market. 2-3 years of product support and production. Like by the time your product is designed, you are almost already screwed. I wouldnt touch galileo, geode and all these x86 chips, if they would show me pictures of billions of chips on stock and engineers with a red phone direct support line.

author: janekm
author_rank: Unknown
timestamp: August 04, 2015, 09:12:36 am
content: I forgot to give a price reference RE the STM8 being the 20c microcontroller, here's a distributor on taobao selling STM8 for <20c:http://world.taobao.com/item/10606202689.htm?spm=a312a.7700714.0.0.IaaN3D#detail(RMB1.17 is $0.19 currently). That's for small quantities and "spot supply" i.e. tail-ends etc. For reference, the same vendor does sell a PIC10 for $0.2 (but you kinda get a bit less for your money).Generally speaking the spot supply pricing in Shenzhen follows the large-volume pricing fairly closely. You don't get as big a discount from 1 to 10000 units as you would on digikey (etc) as the distributors in Shenzhen basically treat small orders as sample order loss-leaders, expecting that some proportion will lead to large orders in the future.I think it's obvious that ST are trying to use STM8 to break into the really low-cost market, and the STM32F0 for the "value-add" low-cost market. They're undercutting literally everyone else currently, including the Chinese makers of 8051 clones (which do make a living by integrating specific low-cost features like LCD controllers and 24-bit ADCs for weigh scales etc).As an aside, I've seen a humorous MCU out of China before, 4-bit MCU with 24-bit ADC, obviously for "precision" weigh scale applications

author: Kalvin
author_rank: Super Contributor
timestamp: August 04, 2015, 03:36:29 pm
content: Quote from: DiligentMinds.com on August 04, 2015, 03:27:11 pmI have to disagree here. As far as I know, the 8051 core is synthesized from the VHDL or Verilog description and that has nothing to do with the Intel's 8051 mask, layout or any other on-chip stuff like ESD. And yes, 8051 is very old design, but somehow it is still popular despite the fact that its architecture is quite painful and inefficient for the C compilers.

author: Kalvin
author_rank: Super Contributor
timestamp: August 04, 2015, 04:30:27 pm
content: Quote from: DiligentMinds.com on August 04, 2015, 04:18:19 pmI am not going to argue this further eitherAnd I do agree that old 8051 cores licensed from Intel may have some weaknesses as you stated. The new derivates and SoC devices are synthesized from VHDL or Verilog, so there is nothing in common with original Intel 8051, except the fact that the MCU behaves functionally as the original 8051.Edit: If you are referring to the [CMOS*] latch-up, it was a common problem in 80's and maybe still in 90's. Even the standard  logic devices suffered from the latch-up. Today the  latch-up is understood better and it should not be a problem in modern chips.The latch-up was more common in CMOS than NMOS/PMOS.