Can you make the arduino do non miro controler things? - Page 1
Forum section: electronics / general

author: raspberrypi
author_rank: Frequent Contributor
timestamp: March 09, 2017, 08:33:38 pm
content: Since it reads C could you make it do something like process an image (compress a .jpg to lower quality or anything that a computer would do when you program it in C)? Not necessarily to output the image in any usable way but just make it perform calculations or do something other then look at inputs and turn on outputs.How complex is that chip; millions of transistors or is it pretty simple?

author: alsetalokin4017
author_rank: Super Contributor
timestamp: March 09, 2017, 08:48:08 pm
content: Well, the answer is basically "Yes". You can perform calculations, you can store/read digital data, you can synthesize music, you can do all kinds of things in c++ but these ARE "microcontroller things" after all. You can even have it store and serve an interactive web page wirelessly with the right "shield" plugin. A small webpage due to memory size limitations, of course.There is nothing magic about Arduino. It is basically just the microcontroller chip itself, a regulated power supply, and a convenient set of connectors for the power and the mcu inputs and outputs. The software IDE (integrated development environment) is just an easy way to get your c++ program into the chip, and other programs like "processing" make it easy to get whatever kind of input/output you need to display on your computer.Actually the chip itself doesn't "read c", the software IDE reads c and translates it into instructions that the chip can operate on. If you had the right IDE/compiler you could work in other high-level languages that would be translated into assembly language and fed to the chip.How many transistors in an ATmel mcu? I don't know but it's more than I can count on my fingers and toes, for sure. "Pretty simple" it's not, from my perspective. But from the perspective of a CPU designer it probably is "pretty simple".

author: Nusa
author_rank: Super Contributor
timestamp: March 09, 2017, 09:15:20 pm
content: As for video processing, here's an old project that actually produces VGA output with nothing more than a handful of resistors besides the Arduino itself.QuoteThe name Arduino refers to a family of devices, not a particular chip. Historically it uses one of the 8-bit Atmel AVR microcontrollers, but isn't restricted to those. If I had to guess what you bought to play with, you probably havehttp://www.microchip.com/wwwproducts/en/ATmega328p.

author: raspberrypi
author_rank: Frequent Contributor
timestamp: March 09, 2017, 09:20:09 pm
content: Quote from: Nusa on March 09, 2017, 09:15:20 pmI had the atmega but took it back as I was told for simplicity stick with the original arduino.

author: suicidaleggroll
author_rank: Super Contributor
timestamp: March 09, 2017, 09:20:43 pm
content: Quote from: raspberrypi on March 09, 2017, 08:33:38 pmYes of course, same with any other MCU. Your limitations are code size and RAM size, as long as you fit within those requirements it'll run almost anything, it just might be slow, especially if floating point calculations are involved.

author: Nusa
author_rank: Super Contributor
timestamp: March 09, 2017, 09:33:06 pm
content: Quote from: raspberrypi on March 09, 2017, 09:20:09 pmYou're confusing the chip designation and the product name. Look at the labeling on the CPU chip on your Aruduion. Odds are it says ATmega328. The Arduino Mega useshttp://www.microchip.com/wwwproducts/en/atmega2560, which has more i/o ports, timers and memory, but otherwise performs about the same.

author: pitagoras
author_rank: Regular Contributor
timestamp: March 09, 2017, 10:08:44 pm
content: http://www.gaudi.ch/OpenTheremin/

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2017, 12:01:16 am
content: An Arduino isTuring Complete, subject to the limitations of available memory, so given enough external storage, it can do *anything* that isn't time critical, as long as there's enough time to complete the task before the Arduino dies of old age. (e.g. from charge leaking away in FLASH memory cells, electromigration in the metallisation layer of the various chips, or the electrolytic caps drying up and failing)Here's an 8 bit ATmega emulating a PXA255 SoC (ARMv5TE. core) running Ubuntu Linux.http://dmitry.gr/index.php?r=05.Projects&proj=07.%20Linux%20on%208bitIts not actually an Arduino as such, but the Atmega1284P it uses in the same family of chips as the Atmel based Ardunos, and there are third party board packages for using a '1284P from the Arduino IDE.The emulator could be ported to run on an Arduino Mega 2560 + a protoshield for the SIMM and the SD card with a moderate amount of effort, but as its overclocking the '1284P at 24MHz and the Mega 2560 is only clocked at 16MHz with half the RAM of the '1284P, it would be a lot slower - approximately half the speed or maybe worse. Also it uses the 'raw' AVR GCC toolchain, not the novice-friendly Arduino IDE, (although the Arduino installation does install the AVR GCC toolchain) so it would be a steep learning curve if you only had previous 'Arduino-land' experience.

author: ataradov
author_rank: Super Contributor
timestamp: March 10, 2017, 03:40:33 am
content: Quote from: raspberrypi on March 09, 2017, 08:33:38 pmNumber of transistors means absolutely nothing as far as performed tasks go.

author: raspberrypi
author_rank: Frequent Contributor
timestamp: March 10, 2017, 03:54:44 am
content: So is this where most ICs are headed? I have a really cool clock that uses needle dial "VU" meters to show the hours, minutes, and seconds. The instructions say you can program it to do anything you want like changing out different dials or use different displays entirely. You can tell its "smart" by the way you set the time with a rotary encoder. So in the future or right now maybe, you get a micro controller whos only limits are speed and memory and you just program it to do what ever you want instead of purpose built ICs that only do one thing and only have one type of output that works? I'm noticing it in products that have USB connections...

author: ataradov
author_rank: Super Contributor
timestamp: March 10, 2017, 03:58:11 am
content: Quote from: raspberrypi on March 10, 2017, 03:54:44 amYou can do that right now. High end microcontrollers run at 300+ MHz and have 512 KB of RAM (and can use external SDRAM, if needed). This is plenty of computing power.And then your nickname is pretty powerful for its price.Quote from: raspberrypi on March 10, 2017, 03:54:44 amDepends on the "purpose". Some things are just impractical to do in software. Sometimes you care about the price and purpose-build ICs are cheaper.

author: raspberrypi
author_rank: Frequent Contributor
timestamp: March 10, 2017, 04:00:48 am
content: Quote from: ataradov on March 10, 2017, 03:40:33 amI often speak in generalizations. Such as I thought this power supply I was building (when I started it I had no idea what I was doing, or rather some knowledge but no working use of it) had some fancy MOSFET in it because it looked like one. It was an LM317 that doesn't have one transistor in it but probably 50. I had no idea that integrated circuits came in this package with only three pins. So when I say "number or transistors" I'm asking about general complexity of the device. Like a core I7 has ~10 billion transistors.

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2017, 04:05:14 am
content: If its digital, or mostly digital, is more than can be done with one off-the-shelf logic chip, and it doesn't need to be screamingly fast, the tendency is to use a MCU. If its pure digital and it does need to be screamingly fast, there's a tendency to use a FPGA.Many special purpose chips for more complex tasks are actually custom programmed MCUs - sometimes the only difference is the pre-loaded program and the part number, or it may be more 'hidden' e.g a MCU core on a multipurpose custom chip with extra peripherals and/or interfaces that can be factory programmed as a range of different chips for similar applications.

author: ataradov
author_rank: Super Contributor
timestamp: March 10, 2017, 04:09:06 am
content: Quote from: raspberrypi on March 10, 2017, 04:00:48 amThe reason such numbers are not readily publicized, is that they are pretty much useless for anything. Intel likes to brag about this stuff because there is not much else to say.I'd estimate that mega328 has 500K-1M transistors (excluding on-chip memories). But this says absolutely nothing about actual chip performance.

author: jonovid
author_rank: Super Contributor
timestamp: March 10, 2017, 04:10:38 am
content: be interested to know if this is possibledo like the old Arduino Atmel its the Z80 of our time.if someone can squeeze more out of it , then Good, let us know .

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2017, 04:28:09 am
content: Fromcomp.arch.embedded: Transistor count of common uCs? (11 May 2004)Quote

author: TNorthover
author_rank: Contributor
timestamp: March 10, 2017, 04:43:08 am
content: Quote from: Ian.MThis looks incongruous, I think he's mixing counts of different things (including the RAM for the ARM?). The Cortex-M0 apparently has about 12000 gates and while it's optimised for transistor count, I don't believe it's 50 times better than the earlier equivalents.

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2017, 04:52:12 am
content: Yes, it does look like Ulf mixed up the comparisons. However his numbers for the AVRs are probably good. - For those who don't know of him, he was well respected Atmel 'insider' who helped a lot of people with AVR queries on comp.arch.embedded and related technical USENET groups.

author: ataradov
author_rank: Super Contributor
timestamp: March 10, 2017, 04:52:23 am
content: Quote from: TNorthover on March 10, 2017, 04:43:08 amCortex-M0 from Design Start package in Cyclone V takes exactly 841 registers and ~4000 LUTs. This is just the core, no memories, no peripherals.

author: TNorthover
author_rank: Contributor
timestamp: March 10, 2017, 05:09:39 am
content: Quote from: ataradov on March 10, 2017, 04:52:23 amYou don't happen to have the Cortex-M1 numbers handy too, do you? I'd heard that one was optimized for FPGAs but never actually saw the numbers and would be interested in what the difference is when tuning for different targets like that.

author: ataradov
author_rank: Super Contributor
timestamp: March 10, 2017, 05:14:06 am
content: Quote from: TNorthover on March 10, 2017, 05:09:39 amNope. But M1 numbers should be available from ARM. I think I saw some numbers on their site or in some promotional PDF.I'd expect them to be a bit more heavy on the register side. As far as number of registers goes, DS M0 is definitely optimized for that, at expense of a lot of logic. And that's no the best for FPGA.

author: Richard Crowley
author_rank: Super Contributor
timestamp: March 10, 2017, 05:16:43 am
content: Quote from: raspberrypi on March 09, 2017, 08:33:38 pmThere is a C compiler for the machine code. That is no indicator of capability.QuoteCould a lower-end Atmel microcontroller do the computations necessary to transform an image into a compressed codec? Yes, but for a couple of limitations which are likely show-stoppers:1) Speed. The amount of time it would take to process a large array of pixel data may be much longer than you expect.2) Memory. Unless you are talking about really tiny images, it seems quite possible that the Atmel microcontroller can't access enough memory to perform such a task.QuoteYou are vastly under-estimating the amount of "horsepower" it takes to do sophisticated image manipulation and/or analysis.QuoteComplexity of the CPU has no correlation with its ability to process a large amount of data quickly.

author: james_s
author_rank: Super Contributor
timestamp: March 10, 2017, 06:09:15 am
content: The only thing that "reads" C code is the compiler. C was developed in the early 70s and you can code in C for just about anything, even 8 bit microcomputers from the 80s. Technically there's no reason you couldn't do image processing or even transcode video with an AVR or even a 6502 if you were extremely patient. To put that into perspective, I remember when .jpg compression was first showing up I had a 40MHz 386 with a 640x480 VGA screen. It could open a jpg file for viewing but it took about 30 seconds to paint it on the screen. That had a lot more processing power and memory than an Arduino.

author: Rick Law
author_rank: Super Contributor
timestamp: March 10, 2017, 07:06:19 am
content: Quote from: jonovid on March 10, 2017, 04:10:38 amWikipedia has "As of 2016,10 nmdevices are still under commercial development. Commercial release is confirmed for 2017 by Samsung." and on the side bar,5nm in 2020.https://en.wikipedia.org/wiki/10_nanometer5nm is the width of about 50 atoms abreast. They are nearing/entering a domain where quantum mechanics starts to dominate. I am eager to see in 2020, if and how they begin to deal with that.I actually would not think 5nm is possible, but perhaps it is. Question remains is can it be commercially produced and with operational reliability. There is a floor >0.1nm. You can't have a node smaller than an atom.So, no matter what, the end of Moore's Law is in the near future.

author: westfw
author_rank: Super Contributor
timestamp: March 10, 2017, 09:35:48 am
content: See alsohttps://en.wikipedia.org/wiki/Transistor_count(alas, it does not include many microcontrollers.)

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: March 10, 2017, 04:21:03 pm
content: Quote from: Rick Law on March 10, 2017, 07:06:19 amI know what you are getting at, but transistors fundamentally depend on quantum effects to operate, so the domination has already occurredQuantum tunneling effects place a limit on the lowest practical feature size, I guess that is what you are thinking of.

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: March 10, 2017, 04:22:46 pm
content: Quote from: raspberrypi on March 09, 2017, 08:33:38 pmOf course, you could even run a power station* with an Arduino.*conditions apply

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2017, 05:14:48 pm
content: You could even compile Arduino sketches on an Arduino - though it might take the rest of your lifetime just to open the IDE!

author: james_s
author_rank: Super Contributor
timestamp: March 10, 2017, 07:03:23 pm
content: I suppose you could get around the memory limitations by using a serial interface to external RAM and mass storage. It might be kind of fun to see how far the concept could be pushed, maybe boot MS DOS in an x86 emulator? You might not live long enough to see it come up, then again the original PCs were not all that much more powerful than the AVR on an Arduino.

author: retrolefty
author_rank: Super Contributor
timestamp: March 10, 2017, 08:01:04 pm
content: A main point is that the 8-bit AVR used in arduino does not 'read' C code. Your PC does all the compiling (search cross compiler). If not for your PC working with an Arduino would not really be practical in anyway.

author: rstofer
author_rank: Super Contributor
timestamp: March 10, 2017, 08:31:43 pm
content: Quote from: james_s on March 10, 2017, 07:03:23 pmThe original 8080 ran at 2 MHz clock and about 4 clocks per instructions (IIRC) so about 500k instructions per second. Compare this to nearly 20M instructions per second on the AVR. I suppose it would be possible to get some kind of AVR to run CP/M and do it a LOT faster than my Altair 8800. I would probably have to forego the 8" floppies and go straight to SD cards.Even the Z80 only ran at 6 MHz or about 1.5M instructions per second and it was considered smokin' at the time. Arcade games used lots of Z80 chips!So, wimpy as they are, AVRs are pretty impressive!

author: james_s
author_rank: Super Contributor
timestamp: March 10, 2017, 10:26:16 pm
content: It's hard to compare clock cycles and instructions per second between different architectures. Especially when you're dealing with a microcontroller that has no exposed data and address buses. Yeah the Z80 and the 6502 were both very common in arcade games, Atari used a lot of 6502's. The games typically had custom graphics and sound hardware though, hardwired predecessors to the graphics accelerator.

author: timb
author_rank: Super Contributor
timestamp: March 11, 2017, 12:24:28 am
content: Quote from: james_s on March 10, 2017, 10:26:16 pmIt's also important to keep in mind that the same code can take different amounts of instructions, depending on the CPU architecture you're compiling for. Let's take this simple piece of code:Code:int square(int num) {return num * num;}Now, let's look at the ASM that outputs for different architectures (using the same version of GCC):AVR GCC 4.5.3Code:__SREG__ = 0x3f__SP_H__ = 0x3e__SP_L__ = 0x3d__CCP__ = 0x34__tmp_reg__ = 0__zero_reg__ = 1square(int):push r29push r28rcall .in r28,__SP_L__in r29,__SP_H__std Y+2,r25std Y+1,r24ldd r24,Y+1ldd r25,Y+2ldd r18,Y+1ldd r19,Y+2mov r22,r18mov r23,r19rcall __mulhi3pop __tmp_reg__pop __tmp_reg__pop r28pop r29retMSP430 GCC 4.5.3Code:square(int):push r10push r4mov r1, r4add #4, r4sub #2, r1mov r15, -6(r4)mov -6(r4), r10mov -6(r4), r12call #__mulhi3mov r14, r15add #2, r1pop r4pop r10retARM GCC 4.5.3Code:square(int):push {r7}sub sp, sp, #12add r7, sp, #0str r0, [r7, #4]ldr r3, [r7, #4]ldr r2, [r7, #4]mul r3, r2, r3mov r0, r3add r7, r7, #12mov sp, r7pop {r7}bx lrx86-64 GCC 4.5.3Code:square(int):push rbpmov rbp, rspmov DWORD PTR [rbp-4], edimov eax, DWORD PTR [rbp-4]imul eax, DWORD PTR [rbp-4]leaveretAlso keep in mind that each instructions could take anywhere from one to hundreds of clock cycles to execute, it all depends on the instruction in question, the architecture, your code, the compiler used, the current day of the week, humidity and alignment of the planets! Comparing one architecture to another is difficult; it's apples to weird space apples, really.That said, it *is* useful to checkout the sort of assembly your code is producing and compare it among compiler versions and architectures. I useCompiler Explorerto do that and it's awesome.

author: westfw
author_rank: Super Contributor
timestamp: March 11, 2017, 02:53:54 am
content: You also have to be careful about the Optimization settings of your compiler; sometimes they make a bigger difference than other times. For example, if I run "square" through avr-gcc with the -O3 setting, I get:Code:00000000 <square>:0: 88 9f mul r24, r242: 90 01 movw r18, r04: 89 9f mul r24, r256: 30 0d add r19, r08: 98 9f mul r25, r24a: 30 0d add r19, r0c: 11 24 eor r1, r1e: c9 01 movw r24, r1810: 08 95 ret(That's 4.3.3, rather than 4.5.3, but I get approximately the same improvement with 4.9.x.)(Also note that "int" on an AVR is 16bits, while "int" on the ARM and x86 is 32bits...)

author: Rick Law
author_rank: Super Contributor
timestamp: March 11, 2017, 05:08:40 am
content: On second thought, I removed the reply I just made to avoid hi-jacking the thread and tangent into other areas.