ADC Library
ADC (Analog to Digital Converter) module is available with a number of MCU modules. ADC is an electronic circuit that converts continuous signals to discrete digital numbers. ADC Library provides you a comfortable work with the module.
Library Routines
ADC_Init
Prototype |
sub procedure ADC_Init() |
---|---|
Description |
This routines configures ADC module. The internal ADC module is set to:
|
Parameters |
None. |
Returns |
Nothing. |
Requires |
|
Example |
ADC1_Init() Initialize ADC module with default settings |
Notes |
None. |
ADC_Init_Advanced
Prototype |
sub procedure ADC_Init_Advanced(dim mode as byte) |
||||||
---|---|---|---|---|---|---|---|
Description |
This routine configures the internal ADC module to work with user defined settings. |
||||||
Parameters |
|
||||||
Returns |
Nothing. |
||||||
Requires |
|
||||||
Example |
ADC_Init_Advanced(_ADC_MODE_CONTINUOUS) ' set continuous conversion mode |
||||||
Notes |
None. |
ADC_Set_Input_Channel
Prototype |
sub procedure ADC_Set_Input_Channel(dim input_mask as word) |
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
The function sets appropriate ADC channel as an analog input. |
||||||||||||||||||
Parameters |
|
||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||
Requires |
|
||||||||||||||||||
Example |
// sets ADC channels 0 and 1 as analog inputs ADC_Set_Input_Channel(_ADC_CHANNEL_0 or _ADC_CHANNEL_1); |
||||||||||||||||||
Notes |
|
ADC_Get_Sample
Prototype |
sub function ADC_Get_Sample(dim channel as word) as word |
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
The function enables ADC module and reads the specified analog channel input. |
||||||||||||||||||
Parameters |
|
||||||||||||||||||
Returns |
ADC value from the specified |
||||||||||||||||||
Requires |
|
||||||||||||||||||
Example |
dim adc_value as word ... ADC_Set_Input_Channel(_ADC_CHANNEL_1) ' Set ADC channel 1 as an analog input ADC_Init() ' Initialize ADC module adc_value = ADC_Get_Sample(_ADC_CHANNEL_1) ' read analog value from ADC module channel 1 |
||||||||||||||||||
Notes |
|
ADC_Read
Prototype |
sub function ADC_Read(dim channel as word) as word |
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
The function sets appropriate ADC channel as an analog input, enables ADC module, initializes ADC module and reads from the specified analog channel input. |
||||||||||||||||||
Parameters |
|
||||||||||||||||||
Returns |
ADC value from the specified |
||||||||||||||||||
Requires |
|
||||||||||||||||||
Example |
dim adc_value as word ... adc_value = ADC_Read(_ADC_CHANNEL_1) ' read analog value from ADC module channel 1 |
||||||||||||||||||
Notes |
|
What do you think about this topic ? Send us feedback!