12

Excuse me if it is a silly question, but I couldn't find an answer.

I've been wondering for a while whether an Arduino (or generally any other micro-controller) gets happy if the code is light and it does not have to execute too much operations. Does a code that has too many ifs, too many loops and all sort of complicated calculations wear out an Arduino sooner than a code that just blinks an LED?

1

5 Answers 5

20

No, the code doesn't "wear out" the MCU. In general no matter what you are doing roughly the same level of activity is being performed. Even delay() does lots of work while it's "idling".

There are commands to make the CPU do less - place it in an IDLE or SLEEP mode - but these are used to save power rather than to reduce "wear" on the MCU.

Of course there are specific things that do have a limited lifetime and you can only use them a limited amount of times - things like writing to EEPROM and writing to the Flash memory - so you don't want to be doing those all the time. Other than that, no, no matter what you are doing it doesn't wear the MCU out.

7
  • 2
    But all semiconductos age, don't they? hot carrier injection and bias temperature instability are the mechanisms I remember. Of course it would take many many years.
    – MV.
    Commented May 20, 2017 at 18:50
  • 5
    @MV. Yes, but what you run on the microcontroller doesn't really affect it. Whatever you are doing you are running the CPU at (roughly) the same level. You're using all of it (pretty much) all of the time.
    – Majenko
    Commented May 20, 2017 at 22:48
  • 1
    Won't code indirectly influence generated heat? Hot components could wear down faster.
    – Mast
    Commented May 21, 2017 at 15:03
  • 3
    Only a very tiny tiny amount. Even when doing 'nothing' it is working hard and processing.
    – Majenko
    Commented May 21, 2017 at 15:04
  • Thank you for your reply. Now I can lean back and write codes as complex as I want and do not worry about life span of my Arduino! But is it also the case for constantly interacting with external components? Reading sensors, SPI communication and so on?
    – ahmadx87
    Commented May 22, 2017 at 8:10
6

It's not. Well, it might slowly wear out if you run it like 20 years....(like most other physical products)? At least it does not rely on code complexity but how many writing operation done in the same memory section. Moreover, when it wear out it will just get bricked and it won't become a simpler code like blinking the LED.

An Arduino (Uno) has three memory parts. SRAM, FLASH, and EEPROM. SRAM is more like a logical transistor gate. It won't wear out by storing variables. FLASH and EEPROM consist of floating gates. They slowly wear out when you write new data. From the datasheet of Ateml microcontroller, it states:

The Flash memory has an endurance of at least 10,000 write/erase cycles. (From Chapter 8.2)

The EEPROM has an endurance of at least 100,000 write/erase cycles. (From Chapter 8.4)

However, FLASH memory is a space for code execution. Writing operation is not be done while Arduino is running. You only write FLASH memory when you upload a new code. So it will wear out when you upload code at least 10,000 times.

If you really want you can make a special code to self-reprogram FLASH memory usually for the purpose of keeping variable data when Arduino is turned off. When you write this kind of program it will wear out slowly because FLASH memory doesn't have much writing endurance. That's why you will be suggested to use EEPROM which has much more life expectancy, if you want to keep data even when Arduino is turned off.

To sum up, it will wear out by re-writing FLASH or EEPROM memory, not by code execution.

6

For a hobbyist:

About the only life limiting software related issue might be writing to the FLASH memory as fast as you can from inside a program. But few programs make use of variables that need to survive events like changing batteries.

About the only life limiting hardware related issue is over loading the outputs with low resistance loads (incandescent light bulbs), inductive loads (like directly driving mechanical relays) to name just two. But the question is only about software.

5

... (or generally any other micro-controller) ...

The other answers are great, but there is one small exception.

Ferroelectric RAM (FRAM) is a form of memory that combines the non-volatility of flash and EEPROM, the writability of SRAM, and the density of DRAM.

However, read operations on FRAM are destructive to the data stored in the FRAM, and write operations are destructive to the FRAM construction itself (and since the data is destroyed by reading it, it must be written back each time). If your code is located in FRAM then running it will wear down the MCU in time. But given that FRAM has a write endurance in the millions of billions it is unlikely that the MCU will become inoperable due to FRAM in the lifetime of the device.

Examples of MCUs that use FRAM include TI's MSP430FRxx line.

1
  • 1
    In general if there is FRAM there is no other memory. Not even flash.
    – Majenko
    Commented May 20, 2017 at 17:32
3

Probably not ... The Atmel chip might get warmer over time (even a delay does not prevent this), however if it has a possibility to release its heat I don't see a problem. But mostly only overclocking can cause really serious problems, or using the Arduino in a fully closed box or in a hot environment.

In comparison: many computers are running for years without switching off, the Atmel (chip) is in that sense no difference, as long as generated heat can be relieved.

You can read more about a heat sensor in Atmels here: Internal Temperature Sensor

3
  • 2
    The way Arduino implements delay, is by constantly checking if enough time has passed. So running a program, or having a delay uses the same amount of processing power.
    – Gerben
    Commented May 20, 2017 at 13:17
  • I will update (remove) that part ... thanks! Commented May 20, 2017 at 13:18
  • There is a difference - most computers today have tons of power saving features; a lot of things power off when not needed, and this happens pretty much automatically. The Arduino also has ways to reduce power use, but you need to use them explicitly. If you need something that is powered-down most of the time, learn.sparkfun.com/tutorials/reducing-arduino-power-consumption is a great way to start. In particular, the lowpower sleep drops power consumption about a thousandfold - unlike delay, which just spins the CPU. This has its cost, of course :)
    – Luaan
    Commented May 22, 2017 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.