Welcome! Log In Create A New Profile

Advanced

Analog Numbering

Posted by Reparator 
Analog Numbering
November 27, 2013 12:25PM
Hi,

Is there somebody who can explain to me, what analog numbering means?

If I look to pins.h there are lines like this:
        #define TEMP_0_PIN         13   // ANALOG NUMBERING
        #define TEMP_1_PIN         14   // ANALOG NUMBERING
        #define TEMP_2_PIN         15    
My TEMP_0_PIN is connected to A13 (pin 84 of the ATMega), but in pins.h there is only written "13". But what is the difference to D13 (pin 26 of the Mega) then?
The X_STEP_PIN is assigned to 54, which means A0. There it´s different (means not "0").
Why is it not neccessary to write "A13" in pins.h or "67", which is 54 (for the 54 digital Ports) + 13 (for analog Ports)?

Regards with a little bit of confusion...
Re: Analog Numbering
November 27, 2013 01:06PM
All pins can be used as digital in/output and some as Analog input. To distinguish what we mean, you see offen D54 with a D to emphasize that we mean the digital pin. But computers don't work good on chars, that's why we want only the number part.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: Analog Numbering
November 27, 2013 01:24PM
Yes good question.
All Dx (0-53) pins are "digital" which means it can be switched as output or logical Input 0/1t. These are named with "digital names" D# where # can be the same as pin number but not always
All Ax (0-15) pins are analog which means they can function as analog input for ADC, but they can also be programmed as digital output o/1.
some pins Dx can be used with PWM but are actual digital outputs only.
confusion oh yes....but it would be better if pins.h had used the analog numbering A13-x..etc for the mapping.
all numbers A0-15, D0-53 are mapped in the program headers to chip pin numbers depending on cpu used.

Edited 1 time(s). Last edit at 11/27/2013 01:25PM by justcurious.
Re: Analog Numbering
November 27, 2013 02:01PM
Yes that´s all clear! I know the difference between analog and digital pins.
But how does the Mega know that
#define TEMP_0_PIN         13
means the analog pin 67 and not the digital pin 13?
In pins.h is also written e.g.
#define X_DIR_PIN          55

Here it´s specific clear (and it is not written X_DIR_PIN 1).
Why the difference?

Regards
Re: Analog Numbering
November 27, 2013 02:07PM
Thats why you see the comment analog numbering. The routines take that value for analog methods always treat it as analog number and call analog methods not the digital ones.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: Analog Numbering
November 27, 2013 02:15PM
OK, I see!

If I look to pins_arduino.h in the folder \hardware\arduino\variants\mega of the arduino ide there are the definitions for A0 .. A15:

static const uint8_t A0 = 54;
..
static const uint8_t A13 = 67;
..
static const uint8_t A15 = 69;

So using
#define TEMP_0_PIN         A13
should also work?!?!

Thanks for that information!
Re: Analog Numbering
November 27, 2013 03:30PM
No, it does not work As you see A0 has number 54 which is the digital pin id and not 0 which is the analog channel used inside the avr to read the analog value.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Sorry, only registered users may post in this forum.

Click here to login