Choosing a microcontroller for mass production - Page 1
Forum section: electronics / general

author: Matienzo
author_rank: Newbie
timestamp: December 26, 2017, 04:12:28 pm
content: Hi y'allI'm working on a personal project that I prototyped using an Arduino uno. Now I'm paying a guy to make a more streamlined version (mine had several issues I didn't know how to solve) and I would like to make the prototype using the microcontroller that will be used on the final design.My question iswhat would be a good choice for mass production to replace the Atmega 328? The asumption here is that there might be cheaper optionsMy product has2 knobs to set temperature and time, 4 thermistors, and 4 PID loops(one for each heating element).Please let me know if I'm omitting information that would allow you to give me a proper answer.Thanks a lot!MatienzoPS: Someone suggested SMT32. Any thoughts?

author: janekm
author_rank: Unknown
timestamp: December 26, 2017, 04:34:47 pm
content: If you’re paying someone they will most likely give you advice on this point, at least I would hope so! And if you ask them to work with a micro controller they never worked with before, you’d have to pay them to learn about it, which may not be economical.Some important considerations you haven’t addressed are volume (100 pieces is very different from 10000 which is very different from 1000000 which is different from 10000000), and what accuracy requirements you have. And realistically it won’t be possible to give you good advice without knowing what the product is intended to do, as there may be other factors which are not obvious (e.g. automotive, Medical?).Look over the $1 microcontroller review, that will be a pretty good starting point.

author: Matienzo
author_rank: Newbie
timestamp: December 26, 2017, 04:55:20 pm
content: Thank you janekm.The product is a kitchen appliance intended to heat up food. As far as accuracy +- 5C is good enough. The minimum number of units would be over 10000

author: NorthGuy
author_rank: Super Contributor
timestamp: December 26, 2017, 04:58:22 pm
content: You only need very little from your MCU - 6 pins and analog features, so you can use practically anything. If your mass production is 10,000+, it's probably a good idea to choose by price.

author: Kalvin
author_rank: Super Contributor
timestamp: December 26, 2017, 05:01:25 pm
content: Any cheap microcontroller which has enough GPIO pins, has an on-chip A/D-converter, and which has enough Flash memory+RAM looks suitable for your application as a temperature controller typically doesn't require any fast real-time computations. However, you may also pay attention to the actual development time/cost as each hour spent for development will cost money, so pick a processor that you are familiar with and which has good set of tools (compilers, IDE etc.) available in order the reduce overall development time. For 10 000 units this may still be significant, but for 1000 000 units the actual development cost is less important and the price of the microcontroller is more important.

author: ebclr
author_rank: Super Contributor
timestamp: December 26, 2017, 05:12:49 pm
content: STM8 is a good candidate

author: Matienzo
author_rank: Newbie
timestamp: December 26, 2017, 05:25:56 pm
content: Kevin you have a really good points. The guy I'm working with is familiar with the stm32 and for what I read this MCU is a cheap option given the quantities I'm projecting.

author: Matienzo
author_rank: Newbie
timestamp: December 26, 2017, 05:31:47 pm
content: Quote from: ebclr on December 26, 2017, 05:12:49 pmlooking into it, thanks!

author: wraper
author_rank: Unknown
timestamp: December 26, 2017, 05:37:03 pm
content: Look into EFM8 from Silicon Labs. Their MCUs are very cheap and relatively advanced in analog part. Therefore likely will save money on other components as well.

author: NorthGuy
author_rank: Super Contributor
timestamp: December 26, 2017, 05:48:11 pm
content: Quote from: Matienzo on December 26, 2017, 05:25:56 pmLooks like a huge overkill to me. Go to some electronics site, such as digikey.com and do a parametric search.

author: DerekG
author_rank: Frequent Contributor
timestamp: December 26, 2017, 09:19:45 pm
content: Quote from: Matienzo on December 26, 2017, 04:12:28 pmAn 8 bit STM8S series micro like this one will easily do the job. They cost less than $US0.50 in low to average volumes:https://www.digikey.com.au/product-detail/en/stmicroelectronics/STM8S003F3P6TR/STM8S003F3P6TR-ND/4357536Microchip can't come close price wise for the memory & ADCs offered in this STM part.Your local STM distributor should be able to beat the Digikey price by 10% to 20%.However, if your programmer is not familiar with their programming, he will either charge you lots to learn (on your time) or convince you to use a part he is familiar with.If he programs in C then he can download the free Cosmic Compiler for STM8 & STM32 parts here:http://www.cosmic-software.com/download.phpFeatures:http://www.cosmic-software.com/stm8.phpDifferent C compilers are similar, but not the same. Your programmer may have a lot of library sequences which would speed his design work up a lot when using his preferred compiler.I use the Realizer programming software by Actum Solutions (The Netherlands) for these (& Microchip) parts, but it is unlikely that your programmer is familiar with it. It contains in inbuilt simulator so you can confirm all aspects of the code before downloading it into the actual micro. I'm sure you could learn this programming software (If I can master it, pretty much anyone else can too):http://www.actum.comThe one great benefit about doing your own programming is that when your product needs a slight change to the way it operates (or you want to add a new feature), you can do it yourself.Remember, no-one else knows how your product should operate better than you!

author: wraper
author_rank: Unknown
timestamp: December 26, 2017, 09:31:22 pm
content: Quote from: DerekG on December 26, 2017, 09:19:45 pmJust buy from Mouser, @ qty of 2500 it's 40% cheaper than digikey.

author: AndyC_772
author_rank: Super Contributor
timestamp: December 26, 2017, 09:40:13 pm
content: If you're paying someone to do a production-ready design for you, then you risk doing more harm than good by trying to be too prescriptive about what components should be used.Think carefully about what the prototype is actually for. It's useful to help you learn and understand what works, and what can be done. It might also be useful as a thing to show potential customers or investors.A professional engineer won't need to be shown how to connect a microcontroller to a few knobs, switches and relays, though - and it's likely that you'll get a much better solution, more quickly and at lower cost if you allow them to design it themselves.I'd certainly charge more to use an unfamiliar CPU in a way I've been "shown", than if I were free to do the design myself.

author: DerekG
author_rank: Frequent Contributor
timestamp: December 26, 2017, 09:44:40 pm
content: Quote from: wraper on December 26, 2017, 09:31:22 pmYes, lots of suppliers, however if the original poster contacts the official distributor in his country he is likely to be offered "special pricing". Definitely worth the cost of the phone call (or email).An Octopart search:https://octopart.com/search?q=STM8S003F3P6TR

author: Kjelt
author_rank: Super Contributor
timestamp: December 27, 2017, 12:42:05 am
content: For new designs and your colleague mentions stm32 then take a look at the STM32F0 series, they are Cortex M0 and not that more expensive than normal stm8S family which is also a good candidate.Two pointers: kitchen heating device, make sure the electronics stay cool <75C or buy the high temperature version of all ics and capacitors. Second, make sure you support firmware updates just in case.Good luck and succes with the startup.

author: saddle_au
author_rank: Newbie
timestamp: December 27, 2017, 07:02:18 am
content: Something that controls heat in a kitchen. I'd be looking for temperature and code stability and the robustness of the watchdog. Regardless of CPU selected, harshly test it for noise and static.2 more cents worth though.Will it be run unattended at all? Do you have methods of checking final output states against what the CPU asked for? That is for every control output there should be at least one or two ways the CPU (or a secondary one) checks what is actually happening, especially where people can be hurt by things going wrong. Will your design know if a wire from the control panel breaks (forcing the +heat button constantly on), an output fet or triac shorts or a power relay sticks off or on?All of the Arduino designs I've seen, almost none have feedback checking of inputs and outputs and any watchdog maintenance seems to be just a register write in the main loop.

author: Matienzo
author_rank: Newbie
timestamp: December 27, 2017, 11:40:05 pm
content: So since my EE guy is familiar with the stm32 I'll let him design the prototype with that MCU. I assume it shouldn't be to complicated to downgrade the MCU once we have a prototype going and if I get to that stage I'll find someone that can do it based on the design we come up this time around.I'll make sure to have competent people helping me out with the testing as the points brought up by saddle_au are very important (and I didn't think about them). This is my first time around making a product from scratch and my knowledge of electronics is what I've acquired in about 5 years of arduino projects. Definitely a lot to learn from the pros.On a related note, I'm trying to find a good source to learn how to program the stm32f4 and I found a STM32 Programming Course for Beginners. Do you have any other suggestion? I know C and the Arduino programming language.Thanks a lot for all the great suggestions and advice!

author: Yansi
author_rank: Super Contributor
timestamp: December 27, 2017, 11:54:43 pm
content: Quote from: ebclr on December 26, 2017, 05:12:49 pmSTM8S003F3

author: DerekG
author_rank: Frequent Contributor
timestamp: December 28, 2017, 12:30:27 am
content: Quote from: Matienzo on December 27, 2017, 11:40:05 pmThe advantage of C is it is fairly device independent (you obviously have to know the special functions of the chip & the ports they connect to).As you know C, you can jump straight into the free C compiler from Cosmic Tools (or another C compiler) as it handles the STM32 series of micros:http://www.cosmic-software.com/download.phpThe compiler above along with the STM datasheet should be all you need.I personally hate C. It is very cryptic & non-intuitive.I would much rather use Realizer (supports STM & Microchip) or Basic (ie Great Cow Basic - supports Microchip & Altmel AVR but unfortunately not STM). Don't let the word "Basic" fool you. Great Cow Basic is very powerful, produces tight code & programs flow very logically. This makes it very easy to come back to 2 years down the track for a code tweak.Just my 2 cents worth.

author: wraper
author_rank: Unknown
timestamp: December 28, 2017, 01:23:55 am
content: Quote from: blueskull on December 28, 2017, 12:42:25 amThose are guaranteed to be available at least till 2025https://www.silabs.com/products/mcu/8-bit/longevity-commitment

author: janekm
author_rank: Unknown
timestamp: December 28, 2017, 08:16:30 am
content: Quote from: Matienzo on December 27, 2017, 11:40:05 pmST make version of STM32 in TSSOP-20 package (like STM32F030F4P6) which are designed for "white goods" applications like yours. These tend to the the cheapest versions and would make a lot of sense for your project.In the past STM8 was a lot cheaper because ST were trying to corner the market on low-cost MCUs, however they raised the price a lot in the last year and the price advantage compared to STM32 has all but disappeared. There's still some lower-cost options like Nuvoton but probably not worth it in your case (i.e. that's only worth it if your volume is > 100000).

author: AndyC_772
author_rank: Super Contributor
timestamp: December 28, 2017, 08:23:19 am
content: Quote from: Matienzo on December 27, 2017, 11:40:05 pmYou risk paying for the design twice if you go this route, it's not a good approach IMHO. Give ONE engineer a specification for the project, including a target build cost, and review the project together when the schematic is complete. Produce a costed BoM, sort it in descending order by price, and look through the top ten items together. You may learn a lot about where the real costs are in the design, and it's by no means certain that the microcontroller will be significant.Doing a prototype based on one processor, then doing another one with a different processor, is inefficient and will cost you in both time and money. This is especially true if you end up using two different design engineers.C is portable, apart from the hardware specific parts. Bear in mind that, in a device like this, a significant proportion of the code is likely to be hardware specific (eg. timers, GPIO pins, interrupts, watchdog...).Any engineer offering software development services will know C. That alone makes it a good choice.On the other hand, whatever the technical merits might be, you willneverfind another engineer already familiar with "Great Cow Basic", and should fully expect to have the software rewritten from scratch (in C, or maybe C++) if you ever need changes making.QuoteThere's quite a good thread on this subject here:https://www.eevblog.com/forum/beginners/how-does-a-hobbiest-go-about-getting-a-product-designed/QuoteI understand ST just bought Atollic, and will be releasing TrueSTUDIO for free for anyone using STM32 processors very soon if they haven't already. I'd start by downloading that, and having a play.Tip: I advise against using ST's hardware drivers. Poke the hardware registers yourself; it's faster, more compact, clearer, and no less portable.

author: brucehoult
author_rank: Super Contributor
timestamp: December 28, 2017, 12:30:40 pm
content: Quote from: ebclr on December 26, 2017, 05:12:49 pmI hadn't previously come across that one.Seems to be a mash-up of 6800, 6502, 6809 features. Single 8 bit accumulator like 6502, and two index registers and a stack pointer like the 6502 but they're 16 bits, and the PC is 24 bits. Compiler-friendly addressing modes with 8 or 16 bit offsets from X or Y, 8 bit from SP, 8 and 16 bit absolute addresses, and 6502-like indirect indexed with the base pointer in memory, but at an 8 or 16 bit address not only Zero Page. Some opcodes are two bytes, as with 6809, but it seems to be prefix bytes indicating addressing mode rather than post byte like 6809 Index byte or x86 ModRM. But it's not really like 6809 or x86 code page prefixes either, from a quick glance.I'd rather have a AVR8, but the STM8 should be far fewer transistors, if only because of the tiny register file. But slower, I would have thought.

author: Yansi
author_rank: Super Contributor
timestamp: December 28, 2017, 02:28:57 pm
content: AVR8, especially those tiny/mega series are obsolete junk. Try comparing the peripherals too. Thats where the real fun begins.(And even more fun when the price is compared too)

author: John Heath
author_rank: Frequent Contributor
timestamp: December 31, 2017, 09:18:18 pm
content: Quote from: Matienzo on December 26, 2017, 04:55:20 pmI have the sense you are treating this like a hobby. You can not play with something that has the potential to burn someone's kitchen down. Think more along the lines of Murphy's law. just a few that come to mind.1] A voltage spike shorts the big triac that is driving the heater. Now the heat is on full blast with no way for the micro to stop it.2] Static discharge from the control knobs corrupts your EEPROM so the micro is running wild. Anything could happen.3] The food catches on fire no fault of yours. Think again as a kitchen that burns down starting from the location of your oven will point a finger at you.I do not mean to rain on your parade. I am just saying safety issues and legal venerability need to be considered. And secondly PID loops is not necessary for a 10 c target window. It will not require critical damping. The saved money can go into thermal fuses and such for Murphy's law.

author: John Heath
author_rank: Frequent Contributor
timestamp: December 31, 2017, 11:24:29 pm
content: Quote from: AndyC_772 on December 28, 2017, 08:23:19 amI find myself swimming against the current on the basic vs c language. A counter argument in favor of a basic compiler. If I say for I to = 1 to 10 a basic compiler will see this and take care of business. If I were to dare try this in c the sky would fall , alarm bells going off , emergency exit doors to the left and right. Why is a c compiler having a nervous break down over a simple for / next statement. The reason is "I" as a variable in the for / next statement is not declared in the start of the program. That is about as dumb as the bag of nails. Basic compiler knows a new variable not declared is given default properties and signed memory space. Why is a C compiler so inept that it has to stop the programmer from writing code to deal with a compiler issue of declaring a new variable "I". Why are C robotic crippleware compilers incapable of solving the simplest problems. Is it just me? If it were a special 4 byte variable yes but not the many default 1 byte variables. From my shoes a basic compiler will take care of business but a C compiler has to be babied alone with kit cloves as it can not think for itself. basic/ c.I will now get of my soap box.

author: DerekG
author_rank: Frequent Contributor
timestamp: January 01, 2018, 01:45:15 am
content: Quote from: John Heath on December 31, 2017, 11:24:29 pmI agree with you John. I LOVE BASIC & I can generally beat a C programmer to the post as BASIC is so logical & flows naturally. A C programmer spends so much of his/her time adding in comments so that when they come back to the code, they have some idea what is going on. Without their comments, they too are often very bamboozled.I have used a few different BASICs over the years, but when Chuck Hellebuyck moved over from the Micro Engineering Labs PicBasic Pro (Chuck wrote & published commercially printed books on how to program using PicBasic Pro) to Great Cow Basic (which is free), I thought he must be on to something.Chuck was right, Great Cow Basic is very easy to use, very logical, very powerful, very code efficient and ............. free.At the end of the day, it does not matter which platform you use to program a micro ............... just I would rather do it the easy way rather than the hard way. Each to their own thoughADDED:Take a look at:https://sourceforge.net/p/gcbasic/blog/2017/04/youtube-chuck-compares-arduino-and-great-cow-basic/andhttp://www.elproducts.com/chucks-blog/great-cow-basic-assembly-files

author: John Heath
author_rank: Frequent Contributor
timestamp: January 01, 2018, 02:43:21 pm
content: I just finish a project in GCBasic for a severo motor driver on a 16F627. Not a lot of memory in that chip 1K at 14 bits . The great cow managed to stuff 100 lines of compiled basic code into it with a little memory to spare. That is one line of basic code per 10 X 14 bits of flash. How did those kids at Great Cow manage to pull that one off? We need to form a Great Cow club to convert those sinners that are still using C , ha.

author: wraper
author_rank: Unknown
timestamp: January 01, 2018, 05:43:46 pm
content: Quote from: John Heath on January 01, 2018, 02:43:21 pmShhh blasphemer. But seriously it's a borderline retarded to use mad cow basic for mass production device. Especially considering you cannot hardware debug it. Also selecting MCU based on programming language with very limited hardware supportThis is nothing but off topic bullshit you are posting here.

author: Karel
author_rank: Super Contributor
timestamp: January 01, 2018, 07:10:03 pm
content: Quote from: DerekG on January 01, 2018, 01:45:15 amC language is for programmers who know what they are doing.They understand the concept of pointers to pointers.The reason we need C is because there's no good replacement for it.Saying that C should be avoided is like saying that a surgeon shouldn't use a scalpel because using a scalpel is difficult or dangerous...Thanks to the "modern" and "safe" languages, we are now flooded with bloated and slow software. And still buggy...

author: DerekG
author_rank: Frequent Contributor
timestamp: January 01, 2018, 11:48:00 pm
content: Quote from: Karel on January 01, 2018, 07:10:03 pmNope, most newly qualified surgeons have now found that using a cauterizing laser that stops the blood flow is a superior method for many surgeries over using a scalpel.There are of course many older surgeons that are getting near retirement that continue to perform surgery the only way they know how ........... with a scalpel.Perhaps you want to change your analogy?

author: saddle_au
author_rank: Newbie
timestamp: January 02, 2018, 01:45:51 pm
content: Off original topic, but my 2c seems to be growing, sorry for the following rant.I blame univeristies. They teach:1) the latest bling coding (because that's good on the cv)2) virtualised everything (no need for hands on, lets simulate the evironment cause it's cheap, giving us engineers who cannot fault find, debug and rectify, physical machinery)3) very little on design robustnessand4) Everyone can code (Like saying everyone can sing, everyone can play piano). Face it some can do it better than others. I know I'm nowhere near the top of that pile.When I went to uni, many many moons ago, my class had 250 people sitting in on the first day. The lecturers told everyone they expected to whittle this down to 12 by the end of 4 years. If you were doing the course without a real interest in it, you did not pass. Their rational was, do you want to drive over a bridge designed by someone who passed with 51% correct? If they did that type of culling now, I'm sure the uni would fire them. Mind you, of our 12, I know 10 are still doing engineering more than 30 years later.We are currently in a world where the client has been taught reliability for normal gear is not necessary, the only important things are speed, size, connectivity and cost. So that's what design houses churn out.(Honestly your honour, the patient died because of an exception caused by bad documentation. That library we purchased stated "word" in the doco, it really needed a "long". See, the case should be dismissed as it wasn't our fault.)I cringe everytime someone builds a critical system using things like serial to usb chips where there is an enormous amount of code in that one spot (chip) you have zero control over. Use Version XXX because it's more stable that XXT. Really? What is being sold here is convienence over reliability. It'd be nice if your heart bypass machine was able to data log to a flash drive, but should it stop doing it's job if the logging drive has a fault?I'm of the opinion the higher the complexity, the further it should be from doing harm. Any CPU that is able to talk to bluetooth, ethernet and the like should only be used in a supervisory role. Embedded CPUs are cheap, so distribute the work load. Years ago I was shown how to crash windows servers by malforming the data in a ping packet. Many people then were justfying putting them at the heart of major systems controlling machinery.The original VB doco gave examples on how to write the code to interface to a modem. One of the lines returned the data automatically after the sixth char was recieved. "What if it only sends 5?", I asked. Well the code froze at that point. This is what was shown to beginning programmers as how to code. Later they amended it to include a timeout value.Not the case for C# code I just pulled from the web (reputable site) dealing with binary data on the serial port, suggestions there tell people "You should never assume that data from a serial port is provided to you in one go (the same is true for network communication by the way). You need to make sure that your code accepts a message only if you have received everything."What? Knowing you're not receiving everything in a timely mannor is just as important as receiving everything, but this code will never know it. The thing talking to you could have gone to seventh heaven, or maybe it could simply be using the wrong baud rate. How can you rely on this?I'm also over badly thought out data protocols as well. If you define a start and stop sequence for a packet and the internal data passed in the packet could form either of these, you should be taken out and shot. "But you shouldn't be looking for these half way through" arguments don't take into account the asynchronous nature of comms, the user plugging in the power at any time shouldnt cause a race condition.

author: coppice
author_rank: Super Contributor
timestamp: January 03, 2018, 12:44:14 am
content: Quote from: saddle_au on January 02, 2018, 01:45:51 pmMaybe you just went to a bad university. Your first point is very odd, because the commonest complaint I hear about software courses is the exact opposite - that they haven't updated them for years, and they are teaching obsolete things.