# Will two 8-bit microcontrollers running in parallel perform similarly to a single 16-bit microcontroller?

Let's say I have multiple (8 bit) sensors which are sending signals to two microcontrollers simultaneously. In this case, I am looking to harness the parallel processing capability of the two microcontrollers to process the signals at the same time.

However, I am curious whether I can substitute the above setup by using only one 16-bit microcontroller? Then, would sending two 8-bit signals simultaneously be possible, using the 16-bit bus on the microcontroller?

Assuming in both cases above, they are running at the same clock speed (MHz).

Edited

Sorry, this is all still new to me.

One aspect that I'd like to understand is: Can we make two 8-bit signals from two different 8-bit sensors share the 16-bit bus at the same time?

• While trying to understand the question I thought You might want to give some more info on the higher level of architecture. Is there another interface to these micro controllers? Like actuators or another device? – Gürkan Çetin Jun 2 '17 at 20:27
• to Edited part - no simply way - the bus is like variable - how would you effectively share int for computing with two different bytes (both arriving at different time probably)? There are some ways, but usually not easy and not fast. You would understand better, if you try to write even easier program to manage two sensors at the same time in one variable - your result (if you would not drop it before) would be probably totally unreadable, long and prone to errors. And much slower, than doing it sequentially and independantly. Just try it with any non-totally-trivial task :) – gilhad Jun 4 '17 at 19:01

But if we assume the typical Arduino setup, than the sensors would not use 8 wires, but some serial protocol (Serial, I2C,...). Especially if you mentioned multiple of them.

Also usually processor asks sensor for data and sensor reply with values, not that sensor is spamming the processor on its own (or not more, than sends interrupt, when data are collected)

Also they would probably not send data to both processors simultaneously, as it would mean, that both processors would be blocked by reading one pice of data - better setup is to send half sensors to one processor, second half to other and synchronise only minimum of processed data between processors.

So the speed of the protocol would be one of very limiting facts here (400 kbit/s ~ 50 kbyte/sec for fast I2C on 16 MHz Arduino means, that while receiving one byte=8bits, your processor is able to do like 16.000.000/50.000 = 320 instructions, for asking sensor for value you address the sensor and send register number, so at least 3 bytes are transferred, also there are some kinds of handshaking - so we have more like 960 instructions per byte) and the transfers usually cannot go in parallel, as they are using the same wires.

• two processors would be able serve more data, as each of them can have its own data line and so two sensors can be questioned in paralel. 900 instructions may be enough to do some simple data manipulation over collected values.
• 16-bit processor cannot generally process two independent data in one instruction, even if it have 2x longer registers. So the there would not be gain from longer word in this way
• on the other hand 16-bit processor can make computations faster if it comes to bigger data types, like int/long/real (to contrast only bytes), many times more than 2x faster. But jumps, loops and so are not such faster, as well as 8-bit calculation. So it deeply depends on how you process the data (how much computation and what kind you do).
• if the sensors would send data only occasionally (as many sensors need a time to collect something) and you would do a lot of complicated computations over them, and those computations would need (nearly) raw data from all sensors (not just average over half second or so), then the 16-bit can win with sheer computing power and lack of need to synchronize data over more units
• if there would be too much data from sensors and such data could be computed independently and mainly in 8-bit logic (if (dist <128) near=true;), the 8-bits can win with two communication lines to sensors and two computing units (so 2x number of instruction/sec) - but in robotic it is not so simple usually (left half of robot is not independent from right).
• for many cases also the size of disposable RAM is factor
• complexity of programming differs in single-unit(16-bit) and two or more networked units (8-bit)
• Many Arduino libraries and examples are not very excellent, when it comes to parallel processing more inputs at the same time (first of all you must have forgot, that something like delay() exists, then lot of communications (like Wire for i2C) happily waits for the full request fulfilled (so waste a lot of instructions just waiting for communication be completed))
• so you can spend more time in inefficient library implementation than in the rest of program. This is not problem for simple scratches, for which Arduino is planned, but is serious limitation in more complex computations
• so you may use different approach to the same HW and use AVR rather then Arduino way (but it needs a lot more skills and knowledge).
• Lots of 16-bit processors have a faster clock, more RAM and more and more elaborated HW build in devices, so they can do even more work faster. Some have two or more I2C subsystems, so they can communicate with two buses at the same time and share the results inside without transferring them around
• so usually you have two different architectures which cannot be simply compared with just "it has the same clock, but 16-bits"

So your question cannot be answered simply, without knowing what sensors you are going to use, how many, which processors you are considering, how you want process your data and what peripherals you want to manipulate.

If you are all confused now, then simply start with the processor you currently have and just few sensors and try to solve only small part of final project. You will learn a lot along the way.

• If it works with one sensor but not two, you have problem in your programming and you have the simplest case to learn, how to solve it.
• If it works with four sensors but not five, you are probably hitting some limits
• try to measure, where you spend more time, if in the logic, or the communication
• if communication is the main problem, try other libraries or more independent processors
• if logic is the limit, use better algorithm or faster processor, or split it in net, if everything else fails
• if you hit RAM limit reconsider the algorithm, or use processor with more RAM or try to split it to two cooperating units, each with half of sensors

But first of all - start playing and having fun, usually it is much faster way to some results, then theorising over all possible details of the Death Star Project at one time before you manage even driving straight with two wheels.

• Also some sensors reuse their serial address for i2c making strict limit on number of sensors per i2c port of the same type. – marshal craft Jun 3 '17 at 12:01
• Thanks @gilhad for the extensive explanations. I would need some time to digest them all. I will edit my question for better clarification. – goddar Jun 4 '17 at 13:55
• If you refer to the edited question above, the second bullet point of your answer kinda answer my question, am I right? Is there no way at all to force them to share the 16bit bus? – goddar Jun 4 '17 at 14:12
• There is some way, but it is not common and is not easy. On the other hand if you do a lot of computations in more than 8 bits, the 16-bit processor may be a lot faster than two 8-bit processors anyway. (and that may include even such simple things as average) - see also answer from marshal craft – gilhad Jun 4 '17 at 18:54

It really depends on the problem, ideally two 8 bit processors work in parallel while one 16 bit processor works by itself. What if the problem is add three 3bit numbers (a+b+c). Can two 8 bit processors take advantage or maybe the single 16 bit? Now if we add three 8bit numbers the single 16 bit processor will be quicker. Alternatively if we ask to add four 3bit numbers (a+b+c+d) then the two 8 bit processors will be superior because one can compute x=a+b and another y=c+d in one instruction time then z=x+y in a second instruction requiring only two instruction time periods while the 16bit would need three.

Now consider the last problem but if there are allowed abcd to be 8bits then its not even clear, we need more information and the same is for your problem. Clearly there is no simple rule or way to answer your question as you naïvely hoped. So do some studying and figure it out for yourself. Or at least provide a coherent question.

• Also inter processor communication can easily be very costly and completely remove any advantage. You have to consider the capabilities of the processor. – marshal craft Jun 3 '17 at 11:58
• Thanks @marshal, I understood those aspects of the microcontroller that you described above. Sorry if the question was not clear. Please refer to the edited version above. – goddar Jun 4 '17 at 14:08
• Oh so you knew all that, funny then how you asked exactly something you already knew. I'll assume you know the answer two the second question as well. – marshal craft Jun 5 '17 at 6:24
• Sorry @marshal, I admit that the question was poorly pharased to convey my message. But I edited the question. Maybe I should rephrase the question as well. I am still new in this microcontroller thing. – goddar Jun 5 '17 at 6:40
• I would ask an entirely knew question once you've figured out what it is you are trying to ask. It should be something specific and that can be decided what the answer is given a specific technology like microcontroller, type of sensor, the type of bus (I'm not familar with too many 16 or 8 bit bus, usually the sensors are serial bus like spi or i2c). What is your goal here what are you trying to achieve in the case you dont know any of these things? – marshal craft Jun 5 '17 at 6:46