Go Down

### Topic: Significance of the numbers used in the manual. (Read 3097 times)previous topic - next topic

#### Kencephalon

##### May 24, 2014, 10:53 am
i just bought the starter kit and am currently working my way through the examples in the book when i came across some numbers used in the manual that seems a little too specific.

For example, in project #3,the love-o-meter, i had to divide the sensor value by 1024.0, and the explanation for it was never given in the manual.

Furthermore, in project #4(which i'm currently at), the book states that i have to convert sensor readings from 0 - 1023, to a value between 0 to 255.Is the number 1024/1023 simply an arbitrary number/limit set by the sensor's manufacturers? Also, is they any significance or reason that analogueWrite only accepts positive values up to 255?

Thanks!

#1
##### May 24, 2014, 11:03 am

Excellent questions.

For example, in project #3,the love-o-meter, i had to divide the sensor value by 1024.0, and the explanation for it was never given in the manual.

The analog-to-digital converter in an AVR processor works by comparing the input voltage to a reference voltage divided into 1024 steps.  It's called a "successive approximation analog to digital converter".

Quote
Furthermore, in project #4(which i'm currently at), the book states that i have to convert sensor readings from 0 - 1023, to a value between 0 to 255.Is the number 1024/1023 simply an arbitrary number/limit set by the sensor's manufacturers?

No.  The value 1024 is the number of steps in the analog-to-digital converter and is independent of the sensor.  1023 is simply the maximum possible value from the analog-to-digital converter.

Quote
Also, is they any significance or reason that analogueWrite only accepts positive values up to 255?

Yes.  The timers in an AVR processor can generate a pulse width modulation signal.  For the Arduino, the timers are configured to run in an eight bit mode.  The largest eight bit value is 255.

#### Grumpy_Mike

#2
##### May 25, 2014, 10:57 am
The point to bare in mind is that a computer works in terms of binary so you will see numbers like that all over the place. They are all powers of two minibus one.
So if a byte ( 8 binary bits ) has 256 diffrent combinations of zero and one that is the value of two to the power eight.
If you turn that into a number the lowest number is zero which leaves 255 other combinations for non zero numbers.

That is the same with the analog inputs they convert voltages from 0 to 5V into a ten bit binary number, so 1024 combinations with 1023 being the biggest number you can have from the maximum 5V input.

Go Up