Pages: [1]   Go Down
Author Topic: Significance of the numbers used in the manual.  (Read 599 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12779
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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".

https://www.google.com/search?q=successive+approximation+analog+to+digital+converter
http://en.wikipedia.org/wiki/Successive_approximation_ADC

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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33408
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: