130
Libraries
© 2008 Conrad Electronic
// 0x40 external input (-)AIN1 and the internal reference voltage are used
// 0x80 the Analog-Comparator is disabled
// In this example you can call AComp with parameter 0 (both inputs are used)
// or with 0x40 (internal reference voltage on (+) input, external Input PB3/PE3)
//------------------------------------------------------------------------------
// main program
//
void main(void)
{
while (true)
{
if (AComp(
0x40
)==
1
)
// Input (+) band gap reference 1,22V
{
Msg_WriteChar(
'1'
);
// Output: 1
}
else
{
Msg_WriteChar(
'0'
);
// Output: 0
}
// the comparator value is read all 500ms
AbsDelay(
500
);
}
}
6.4
Analog-Digital-Converter
The Micro Controller has an Analog Digital Converter with a resolution of 10 Bit. I. e. measured
voltages can be displayed as integral numbers from 0 through 1023. Reference voltage for the lower
limit is GND level (0V). The reference voltage for the upper limit can be selected at will.
·
External Reference Voltage
·
AVCC with capacitor on AREF
·
Internal Reference Voltage 2.56V with capacitor on AREF
Analog Inputs ADC0 ... ADC7, ADC_BG, ADC_GND
For the ADC the Inputs ADC0 ... ADC7 (Port A.0 to A.7 with Mega32, Port F.0 to F.7 with
Mega128), an internal Band Gap (1.22V) or GND (0V) are available. ADC_BG and ADC_GND can
be used for review of the ADC.
If x is a digital measuring value then the corresponding voltage value u is calculated as follows:
u = x * Reference Voltage / 1024
If the external reference voltage e. g. produced by a reference voltage IC is 4.096V, then the
Summary of Contents for C-Control Pro Mega Series
Page 1: ... 2008 Conrad Electronic C Control Pro Mega Series ...
Page 9: ...VIII Inhalt 2008 Conrad Electronic ...
Page 10: ...Part 1 ...
Page 17: ...Part 2 ...
Page 23: ...Part 3 ...
Page 41: ...32 Hardware 2008 Conrad Electronic 3 3 5 3 Component Parts Plan ...
Page 57: ...48 Hardware 2008 Conrad Electronic 3 4 5 3 Component Parts Plan ...
Page 58: ...Part 4 ...
Page 91: ...82 IDE 2008 Conrad Electronic ...
Page 92: ...Part 5 ...
Page 135: ...126 Compiler 2008 Conrad Electronic 31 1F US 63 3F 95 5F _ 127 7F DEL ...
Page 136: ...Part 6 ...
Page 231: ...Part 7 ...
Page 240: ......