# Arduino Forum

## General Category => General Discussion => Topic started by: cmd1024 on Apr 24, 2013, 10:13 pm

Title: Does Arduino Uno have max 8-bit or more resolution?
Post by: cmd1024 on Apr 24, 2013, 10:13 pm
Hi,
Hi I've just read a tutorial about Arduino resolution and it says: "The analog to digital converters (ADC) in the Arduino are considered to have 10 bit resolution.  The bits of resolution is an obfuscation that means 2^10, or 1024 divisions (0 to 1023), of the reference voltage.." Doesn't "ATmega328" on Arduino Uno board have max 8-bit resolution? And doesn't that mean voltage is divided 256 steps? I'm a newbie and I thought I might be fundamentally wrong about these. Any input would be appreciated.
Thanx
Title: Does Arduino Uno have max 8-bit or more resolution?
Post by: cmd1024 on Apr 24, 2013, 10:15 pm
Hi,
Hi I've just read a tutorial about Arduino resolution and it says: "The analog to digital converters (ADC) in the Arduino are considered to have 10 bit resolution.  The bits of resolution is an obfuscation that means 2^10, or 1024 divisions (0 to 1023), of the reference voltage.." Doesn't "ATmega328" on Arduino Uno board have max 8-bit resolution? And doesn't that mean voltage is divided 256 steps? I'm a newbie and I thought I might be fundamentally wrong about these. Any input would be appreciated.
Thanx
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: spatula on Apr 24, 2013, 10:22 pm
If you look at the datasheet http://www.atmel.com/Images/doc8161.pdf (http://www.atmel.com/Images/doc8161.pdf), chapter 23, you can see that the ADC has a 10-bit resolution. I don't know why the tutorial calls this an "obfuscation", but the bottom line is that the range of values is from 0 to 1023, as the tutorial says. The part about ATmega's ADC having an 8-bit resolution is simply wrong.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: fungus on Apr 24, 2013, 10:28 pm

Hi,
Hi I've just read a tutorial about Arduino resolution and it says: "The analog to digital converters (ADC) in the Arduino are considered to have 10 bit resolution.  The bits of resolution is an obfuscation that means 2^10, or 1024 divisions (0 to 1023), of the reference voltage.."

Correct.

Doesn't "ATmega328" on Arduino Uno board have max 8-bit resolution? And doesn't that mean voltage is divided 256 steps?

No.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: cmd1024 on Apr 24, 2013, 10:29 pm
Hi spatula, it seems I didn't really understand what it means 8 bit micro-controller. I thought it is the resolution(bit depth).
What does 8-bit account for?
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: Erdin on Apr 24, 2013, 10:32 pm
The ATmega328 is a 8-bit chip. The code and calculations and register and memory is done in 8-bit.

The function analogRead() returns a value from 0 up to 1023.

To get the 10-bit accuracy, it depends on the 5V voltage and the noise. If a few samples are averaged, the accuracy is near 10-bit.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: AWOL on Apr 24, 2013, 10:32 pm
Memory and register width is eight bit.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: KirAsh4 on Apr 24, 2013, 10:33 pm

Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: Grumpy_Mike on Apr 24, 2013, 10:33 pm
Quote
And doesn't that mean voltage is divided 256 steps?

If it had then it would but it hasn't so it doesn't.

Don't mix it up with the 8 bit resolution of the PWM accessed through the badly named analogWrite call. It can only be considered an analog output once you filter it with and external circuit.
See this for information about PWM:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html (http://www.thebox.myzen.co.uk/Tutorial/PWM.html)

Quote
I don't know why the tutorial calls this an "obfuscation"

No nor do I, unless they are trying unsuccessfully to be friendly.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: cmd1024 on Apr 24, 2013, 10:35 pm
AWOL, another website says: "8 bit means that this controller can process only 8-bits of data at a time".
Does it mean each time Arduino sends a 8-bit chunk? But I thought serial protocol is one bit at a time always? How can one wire send 8 bits instantly? Another tutorial says: "The serial communications protocol sends data in 8-bit chunks, or 1-byte at a time." How can "at a time" a wire can carry 8 different states???
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: AWOL on Apr 24, 2013, 10:39 pm
You're confusing a whole load of concepts there.
Serial frames consist normally of ten bits - start bit, eight data bits and a stop bit, all transmitted one after the other.
Internally, the processor works on units of eight bits, fetched from memory in parallel along eight bit wide data paths.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: cmd1024 on Apr 24, 2013, 10:42 pm
So why do all tutorials say "at a time". Aren't the bits being sent one after another which means there is nothing as a chunk in real.
Or am I still wrong??

edit: So this "8 bit at a time" is about internal chips?? I thought it is about sending data from Arduino to PC for example(serial communication or usb).

Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: AWOL on Apr 24, 2013, 10:44 pm
Quote
So why do all tutorials say "at a time"

Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: Grumpy_Mike on Apr 24, 2013, 10:44 pm
Still wrong.
You are confusing serial data - one bit at a time. With the width of the data bus inside the processor 8 bits at a time.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: KirAsh4 on Apr 24, 2013, 10:46 pm
1 byte (at a time) = 8 bits (at a time).  Don't confuse byte versus bits.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: cmd1024 on Apr 24, 2013, 10:49 pm
Grumpy_Mike many thanks. I think now I started to understand a bit. So bit thing is as follows:

8-bit micro-controller means the chips inside sending 8-bits to each other at a time. Chunk is meaningful here.

Serial data is "1 bit" at a time.

10-bit is the resolution of the ADC converter.

8-bit also accounts for the resolution of the DAC converter.

Did I pass the exam now??:)
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: AWOL on Apr 24, 2013, 10:51 pm
Almost; there is no DAC.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: cmd1024 on Apr 24, 2013, 10:55 pm
Last question: Is that because analogWrite is not outputting continuous signal and should be smoothed ?
You should write a tutorial btw, your explanations are very clear. 8)
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: AWOL on Apr 24, 2013, 10:58 pm
The PWM signal output and modified by analogWrite is continuous.
You can smooth it with a low pass filter to produce a DC analogue voltage.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: Coding Badly on Apr 24, 2013, 10:59 pm

Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: Grumpy_Mike on Apr 24, 2013, 11:00 pm
Quote
You should write a tutorial btw,

Well I did write to one I linked to plus all the others on that site.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: AWOL on Apr 24, 2013, 11:14 pm
Quote

Don't we just hate time-wasting cross-posters?
(Don't bother to answer that, it was a rhetorical question)
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: Erdin on Apr 24, 2013, 11:21 pm
Exam number two:

The ATmega328 is a 8-bit chip.
Draw a big rectangular on a paper, that is the ATmega328.
Draw an 8-bit data bus inside.
Draw all the parts inside with the number of bits.
Serial port (8-bit register access), serial data going in or out can be 8 or 7 bits.
Three timers, two of 8-bit, one of 16-bit.
EEPROM, 8-bit.
I2C (wire), 8-bit. Serial data going in or out is a number of 8-bit data.
TWI, 8-bit. Serial data going in or out is 8-bit (not always).

Question 1: If the ATmega328 chip is internal 8-bit, how can it do calculations with 16-bit or 32-bit integers, and how with 32-bit floating point numbers ?

Question 2: What is the best way to send the 10-bit ADC value via an serial port ? How many bytes would probably be needed ?
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: cmd1024 on Apr 25, 2013, 12:00 am
Erdin, I think I have answer to your 2nd question. I believe that 10 bits will be stored in two 8 bits in computers(16 bits in total for each sample). It seems like 6 bits will be wasted for each sample. 16 bit ADC would be more efficient but more expensive(also slower?). What do u think? My answer is 2 byte. Is that true?

Also regarding 8 bit topic; can we say that 8 pins of ATMEGA chip is sending 8 bits at a time?? If so which pins are they?

Your first question is beyond my knowledge.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: KeithRB on Apr 25, 2013, 01:19 am
Don't confuse what the compiler does with what the underlying chip instructions can do! The compiler works in 2-byte ints. It combines multiple bytes as necessary to make it transparent to you. That is why using bytes can sometimes be faster than using ints on these machines.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: Erdin on Apr 25, 2013, 01:46 am
For the SPI, I2C (called TWI), and Serial pins, see the page about the Uno, http://arduino.cc/en/Main/arduinoBoardUno

Everything beyond 8 bit is done in software. The microcontroller shifts/adds/shuffles the 8-bit data until it finally gets the result. The compiler generates that code.

Yes, 10 bits are stored in two bytes (that is 16 bit).
But....  With the serial port (also called UART), often readable text is used.
So the text "0" or "1023" could be transmitted.
It is easier to use a character to start and to stop. Let's use '<' to start, and '>' indicates a stop. So the text becomes "<0>" or "<1023>".
That is often followed by CarriageReturn and LineFeed.
The result is 5 to 8 byte.
Assuming one startbit and one stopbit per byte for the serial protocol, makes the total is 50 to 80 bits.
The 10 bit of the ADC are transmitted over the serial line as 50 to 80 bits.
And it is perfectly normal.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: cmd1024 on Apr 25, 2013, 02:09 am
Does "32-bit operating system computer" mean that the communication between the ICs inside the computer is actualized with '32-bit information at a time'?  For example:

Let's say we have a computer and its micro-processor's clock rate is 1GHz. What I understand is that: In 1/1000.000.000 of a second (in a billionth of a second) an IC sends out 32-bit information(with its 8 pins) "at a time" to other ICs.

Did I get the big picture?
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: AWOL on Apr 25, 2013, 08:37 am
Quote
What I understand is that: In 1/1000.000.000 of a second (in a billionth of a second) an IC sends out 32-bit information(with its 8 pins) "at a time" to other ICs.

No, a 32 bit computer will have datapaths at least 32 bits wide, as well as multilevel caches.

I'm moving this to "General Discussion"
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: Grumpy_Mike on Apr 25, 2013, 10:50 am
Quote
Let's say we have a computer and its micro-processor's clock rate is 1GHz.

It depends on the processor, some processors need lots of clock pulses to move stuff about, others can do it in one clock. That is why the simple clock speed is not enough to measure the power of a processor.
Title: Re: Does Arduino Uno have max 8-bit or more resolution?
Post by: MichaelMeissner on Apr 25, 2013, 02:23 pm
A simplification that I think is useful to describe how a computer is 8-bit, 16-bit, 32-bit, or 64-bit is as follows:

Remember when you were in grade school and were told to add 23 + 49?  Unless you are a calculation savant, you don't add 23 and 49 in one step.  Instead, you add 3 + 9, which gives you 12.  You put '2' down as the last digit, and then carry the '1'.  You then do 1 + 2 + 4 to give '7', and you put those together as '73'.

Now, an 8-bit computer like the AVR inside of Arduinos (except for the Due) does things in terms of 8-bit buckets.  So a 'short' on the AVR is 16-bits, that means it has two 8-bit parts (called bytes).  When the computer does an add, it loads the bottom byte from each side, and does an add operation that returns the bottom byte of the resultant add, and the 1 bit carry operation.  It stores the bottom byte, and then loads the top bytes, and does an add with carry operation that combines the carry from the previous add along with the two bytes.  If you are adding a long which is a 32-bit data type, it would do 1 normal add, and 3 add with carry operations.  On the AVR, 'int' is 16 bits (like 'short'), but on an ARM, it is 32 bits.

A 32-bit processor like the ARM in the Arduino Due, would be able to do an add of two longs (or ints) in one instruction.  However, in doing two adds of two short values and storing the result in a short value, the ARM would need 3 instructions, because the ARM chip does not have a 16-bit add instruction.  Instead the compiler does the calculation in 32-bits, and then needs to convert the 32-bit long to 16-bit short via shift left 16-bits, and shift right 16-bits with sign extension.

Some chips can be 32-bit or 64-bit like modern x86's.  There is a mode within the hardware that says whether internally things are done in 32-bits or 64-bits.  If you have a new workstation but are running Windows XP on it, you likely are running in 32-bit mode.  If you were running Windows 8, most programs would be run in 64-bit mode, but the operating system can recognize when it is asked to run a 32-bit binary, and arranges when that binary is run, the process is run in 32-bit mode (the operating system still runs in 64-bit mode, and when the control goes back to the OS, it switches mode to 64-bit).