If you were to clock arduino how fast is it? - Page 1
Forum section: electronics / general

author: Beamin
author_rank: Super Contributor
timestamp: September 10, 2017, 12:45:55 am
content: What is the realistic clock speed? If you gave it a program like the ones they give CPUs could you get a rough estimate of its speed? I read that the clock speed doesn't mean much because it goes in a round about way of doing things so that the compiler works on it. Like to turn a pin on isn't one operation its runs a little program that lives behind that command, or I could be full of shit reading the internet's lies and fake news.

author: IanB
author_rank: Super Contributor
timestamp: September 10, 2017, 12:52:04 am
content: You could look this up. It depends on what CPU the Arduino is based on. For instance, if it were built around the ATmega328 the clock speed would be 20 MHz. Given that this is also an 8-bit processor, the speed will be remarkably slow compared to a desktop PC. Thousands of time slower. But for the tasks the processor has to perform, it is fast enough.

author: westfw
author_rank: Super Contributor
timestamp: September 10, 2017, 02:08:53 am
content: The arduino Uno runs it microcontroller at 16MHz, and executes most of the CPU instructions in one clock cycle. So can can do UP TO 16 Million operations per second, or one operation every 62.5ns.Some people would call that 16 MIPS (MIPS = Millions of Instructions Per Second.) However, an "operation" is ill defined, and most of the time these days, people mean "Vax MIPS", based on the (now ancient) DEC Vax780 being rated as a 1 MIPS machine - a 16MIPS machine should run 16x faster than a Vax780. But the Vax was a 32bit machine with hardware floating point and a bunch of other fancy stuff, while the AVR is a simple 8bit CPU. It can add two 8bit numbers that are in registers in one cycle, but two 32bit numbers takes 4 times as long. If the numbers are in memory and you want the result in memory as well, you can add at least 24 more cycles for moving the bytes too and from memory.So what IS a good measure of microcontroller speed? One common metric is "how fast can I toggle an IO pin, or "bit bang" some sort of serial IO protocol?" A 16MHz AVR can do up to 8MHz is mostly-useless burst, and usefully output bits fast enough to implement the generation of video in software.The Arduino libraries slow things down a lot because they allow a bunch of values to be variables instead of constants, but you can still get around 100kHz. Basic math isn't slowed down by the Arduino-ness, however, and you can bypass as much of the arduino slowness a you want...This is "pretty damned fast." Prior "hobbyist" microcontroller things (Basic Stamp, 8052 BASIC) executed user code at a couple of thousand lines per second or so. Arduino is "about" 100x faster, or more. It might also be instructive to compare it to things like the original 8080/Z80 CP/M systems or Apple II (basically similar in capabilities the the AVR CPU, but at most 1M instructions/sec), or the 8088 in the original IBM PC (a more powerful CPU, but also in the realm of 1M instructions/s)All of this is VERY MUCH SLOWER than a modern desktop PC, which runs in excess of 1000 VaxMIPS, not include graphics accelerators. There are things that modern PC users take for granted that are well beyond the ability of an Arduino to do AT ALL. (video playback, for instance. I mentioned that you can generate Video in SW, but that means SW-created blobs on a low-resolution screen; not saved video or downloaded video.)For a better answer, we'd need a better description of what you're trying to do.

author: Ian.M
author_rank: Super Contributor
timestamp: September 10, 2017, 02:55:25 am
content: http://www.ecrostech.com/Other/Resources/Dhrystone.htmScaling that to 16MHz for an ATmega328P on an Arduino should theoretically give give 9209 Dhrystones/s or 5.24 VAX MIPS (assuming same C compiler and optimisation settings). For comparison its the Dhrystone C, v2.1 benchmark, and a results table for late 90's and earlier computers (not MCUs) can be found athttp://www.cs.csubak.edu/~marc/code/sde-6.06.01/examples/dhrystone/dhry.tblThere was a thread on running Dhrystone C v2.1 on MCUs a while back:https://www.eevblog.com/forum/microcontrollers/dhrystone-2-1-on-mcus/The results presented there are divided by the clock speed in MHz, so need scaling to compare with a 16MHz ATmega.Dhrystone is highly sensitive to the compiler used, so any comparisons with old results should be taken with a large pinch of salt.

author: IanB
author_rank: Super Contributor
timestamp: September 10, 2017, 03:03:09 am
content: CPU speed can't be everything. In the late 80's and early 90's we used to run big, number-crunching simulations on VAX mini/micro-computers, albeit with a whopping 16 MB of memory! I do not think that such big simulations could be run on an ATmega-based system. Not least because the lack of FP hardware and bus/IO transfer speeds would be severely limiting.

author: Ian.M
author_rank: Super Contributor
timestamp: September 10, 2017, 03:11:25 am
content: Could be run - Yes. Could be run in a practical amount of time - Hell No.Seehttps://www.eevblog.com/forum/microcontrollers/can-you-make-the-arduino-do-non-miro-controler-things/msg1156037/#msg1156037where I linked to an extremely clever but crazy guy's page on running Debian Linux on an ATmega1284P emulating an ARMv5TE core at 10KHz (yes that's KHz not MHz).

author: daybyter
author_rank: Frequent Contributor
timestamp: September 10, 2017, 03:16:22 am
content: Isn't stm32duino Arduino, too? I think you can clock a stm32f103 up to 160MHz, or so?

author: Ian.M
author_rank: Super Contributor
timestamp: September 10, 2017, 03:29:19 am
content: If its not an official Arduino board its not an Arduino its an clone or compatible.Seehttps://www.arduino.cc/en/Products/Comparefor a list of boards with MCU and clock speed. The fastest is probably theArduino Due: 84MHz ARM Cortex-M3

author: NiHaoMike
author_rank: Super Contributor
timestamp: September 10, 2017, 05:28:45 am
content: The Yun is the fastest with its 400MHz Qualcomm CPU running Linux. But even that is in a completely separate class from general purpose SBCs like Raspberry Pi.

author: cdev
author_rank: Super Contributor
timestamp: September 10, 2017, 05:39:10 am
content: Both Navspark boards and STM32 which both run Arduino code are 32 bit and >80 MHz. (and STM32 boards can be really cheap, like $3 for the Blue Pill.)

author: Ian.M
author_rank: Super Contributor
timestamp: September 10, 2017, 05:43:52 am
content: The way the Yun is set up with a 16 MHz, Atmega32U4 MCU handling all except the networking, SD card and USB host, your sketch runs no faster than it would on a Uno. Yes you can code for the Linux MCU, but there's not a lot of difference between that and coding for a Uno tethered to a Linux PC.

author: forrestc
author_rank: Unknown
timestamp: September 10, 2017, 06:19:07 am
content: As others have described, the arduinos most people think of when they think of an arduino ... I.E. the Uno and the mega2560... run an AVR processor at 16Mhz. That is definitely part of the equation.The other part of your question really has to do with how a C compiler and/or libraries work.When you write a sketch for the Arduino, you're really writing a C++ program. The C++ program (sketch) is converted to machine language by the arduino C++ compiler. Because machine language is a lot more simplistic than C++, generally (but not always) one C++ language statement will be translated into multiple statements.For example if you set a variable to zero, there is a good chance that the assembly would be a single instruction since there are 'set a memory location to zero' instructions in machine language which would permit this to be a single instruction. If you were adding two variables, this might be four instructions: One to retrieve the first memory location, one to retrieve the second memory location, one to add the two numbers, and one to put the result back in memory. The compiler's job is to try to turn the program into as efficient of a process as possible.Most sketches also use the arduino libraries. The arduino libraries are what makes it easy for people to use the ardinos. What a library is is a set of C++ language statements just like the ones in your sketch. These are called by sketches and possibly other libraries. When you do a digitalWrite() function call, the compiler knows to call the digitalWrite library - which is approximately 25 lines of C code. So a single digitalWrite() most likely dozens of lines of code.Adding all of this together means that a single digitalWrite() probably takes something like 25 instructions (totally guessing based on the C code). So on that 16Mhz part, you can do somewhere between 500,000 and 1 million of them in a second. This is fast enough that most things you'd do with an arduino seem rather instantaneous.But.... comparing this to say a desktop PC where you are running clocks in the Ghz instead of Mhz, and have multiple cores, then the arduino is rather slow. You're not going to be doing real time video processing on an arduino. But for many applications the arduino works well.

author: forrestc
author_rank: Unknown
timestamp: September 10, 2017, 06:25:52 am
content: Quote from: cdev on September 10, 2017, 05:39:10 amFastest ardino-compatible platforms I'm aware of are the chipKIT boards which have the PIC32MZ on it, such as the Wi-Fire. They run at 200Mhz.

author: hans
author_rank: Super Contributor
timestamp: September 10, 2017, 08:57:09 am
content: Quote from: forrestc on September 10, 2017, 06:19:07 amAnd.. is superscalar.. and cached.. and is CISC.. and has vector instruction set extensions for when you need it.Modern x86 chips execute north of half a dozen instructions per clock tick. This still puts them miles ahead of any microcontroller or even microprocessor, although the latter are catching up quite fast.The AVR architecture is quite a capable. According to Dhrystone scoring, it does not seem to outperform e.g. the Microchip PICs that much, or come close to an ARM Cortex chip. But nevertheless people have coded some amazing libraries for them.Just want to point; don't be fooled by comparing "MIPS" (i.e. MHz) and "DMIPS". DMIPS is a reference to the original VAX-11 computer which performed a baseline score of 1.0DMIPS at a 5MHz clock rate, achieving 0.2DMIPS/MHz. Actually this machine computed 1757 Dhrystone benchmarks per second. If you take the referenced Dhrystone forum thread then those scores look a little inflated, divide them by 1757 and you should get the DMIPS/MHz figure.Unfortunately AVRs were barely tested in that thread, because the AVR90USB seems to get an abyssmal result. Also all PIC32s seem a little quick.. Could be true in terms of raw CPU performance, but when it comes to I/O interaction in my experience the MIPS4K instruction set does not generate that efficient and small footprint code.

author: Ian.M
author_rank: Super Contributor
timestamp: September 10, 2017, 12:19:15 pm
content: Quote from: hans on September 10, 2017, 08:57:09 amQuoteYes, it gave the numbers in Dhrystones/sec/Mhz not DMIP/MHz.QuoteI like 'abyssmal', think bottom of theMarianas ocean Trench, which is miles worse than 'abysmal', (6.8 miles that is).From a quick skim of the rest of the thread the O.P. was using avr-gcc witout optimisation!The AVR result from the ecrostech.com Dhrystone Benchmark for MCUs page was 75% faster compiled with AVR-GCC 3.3.2, -g -Os.QuoteYes, but if we are using Dhrystone on a MCU, we are benchmarking the core, not the I/O.

author: brucehoult
author_rank: Super Contributor
timestamp: September 10, 2017, 03:54:46 pm
content: Quote from: forrestc on September 10, 2017, 06:25:52 amThe RISC-V FE310-G000 SoC based Hifive1 (Arduino Uno form factor, from the SoC maker, SiFive) and new LoFive (3rd party, similar to Arduino Pro Mini) are 32 bit CPUs with hardware multiply&divide (but no FP), 16 KB SRAM and 16 MB flash for the program. They run at standard speeds of 16 MHz, 256 MHz (16x PLL), or 320 MHz (20x PLL).They are both open-source hardware. You can now also buy the bare SoCs for $5 each ($25 for 5) from CrowdSupply and make your own board.Hifive1:https://www.crowdsupply.com/sifive/hifive1/https://www.sifive.com/products/hifive1/LoFive:https://groupgets.com/campaigns/353-lofive-risc-vhttps://github.com/mwelling/lofive

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: September 10, 2017, 06:55:24 pm
content: Quote from: forrestc on September 10, 2017, 06:19:07 amOTOH PC's suck at doing stuff in real time, and don't have I/O ports that can be manipulated directly.QuoteBut you can easily speed it up by simplywriting directly to the port.You can't do that on a PC. Everything has to go through drivers, which may take hundreds of instructions to get down to the hardware. Add in the overheard of a typical high level language such as Python or C#, and you may be looking atthousandsof instructions to do something simple like turning a LED on and off.

author: Ian.M
author_rank: Super Contributor
timestamp: September 10, 2017, 11:28:53 pm
content: Its worse than that. Due to the latencies of most non-legacy external peripheral busses, your typical PC CPU from the turn of the millennium onwards will grind through *Millions* of instructions between the point the function call was made to toggle the LED and when the hardware actually toggles it. That's if it doesn't go off into LaLa land executing higher priority system code and defer toggling the LED till several seconds later!

author: martinayotte
author_rank: Regular Contributor
timestamp: September 11, 2017, 05:06:02 pm
content: Quote from: daybyter on September 10, 2017, 03:16:22 amNo ! The F1xx are rated to 72Mhz ...The 160MHz you are thinking of is in fact the F4xx series rated at 168MHz.

author: stj
author_rank: Super Contributor
timestamp: September 11, 2017, 07:36:04 pm
content: i think stm32duino now supports the Nucleo F7 boards.those are something like 218MHz

author: thm_w
author_rank: Super Contributor
timestamp: September 12, 2017, 10:14:24 pm
content: Quote from: martinayotte on September 11, 2017, 05:06:02 pmNot that relevant, but, seems like overclocking works on the F10x to 128MHz+:http://www.stm32duino.com/viewtopic.php?f=17&t=432Downside is you lose USB.

author: macboy
author_rank: Super Contributor
timestamp: September 14, 2017, 12:24:06 am
content: Quote from: brucehoult on September 10, 2017, 03:54:46 pmESP32 is a 240 MHz dual core 32 bit CPU claiming 600 DMIPS, FWIW. It has far more memory with 520 KB SRAM, and 16 MB Flash. No hardware FPU here either. But it has cryptographic acceleration. Apparently supported by Arduino tools, but I've never tried (I have used Arduino with the ESP8266).

author: hamster_nz
author_rank: Super Contributor
timestamp: September 14, 2017, 12:37:04 am
content: I was playing with an ESP32 module last night... Far nicer than some ESP8266 modules I have due to the on board USB/Serial brigde.Was using 0.16A @ 5V when on WiFi, and jmy PSU read 0.00A when in deep sleep (I must remove the power LED). Want to meter it better....The Arduino IDE setup was painless on Ubuntu, but on Windows looked to be a bit of work needing Git Repo pulls and so on.A few corners of the hardware support is missing - e.g. the onchip temp sensor.I have got the board waking up every wee while to push data to a Pi, for house environmental monitoring.