Author | Stef Mientki, Copyright © 2002..2024, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling, Rob Jansen |
Compiler | 2.5r8 |
Library to handle ADC peripheral, supporting low (8-bits) and high (16-bits) resolution (whatever the PIC supports). Since the differences between the various ADC features are too different for various PICs, this library only provides some basic ADC features. The user has to do the following in the main program using the datasheet of the PIC that is being used: 1) Set the used ADC pin(s) as analog input 2) Set the refernce voltage for the ADC (default is often VDD) 3) Set the ADC clock according to the datasheet and the target clock being used by the main program (FRC is safe to use)
This is a heavy refactoring/rewriting of original library of Stef Mientki. Deprecated functions have been removed.
No dependency found
const bit _ADC_JUSTIFY_RIGHT = 1
constants
var byte adc_conversion_delay
Time to have the analog signal converted to a digital value. Value is calculated in _adc_init_acquisition_delay() and used in _adc_read().
const bit _ADC_JUSTIFY_LEFT = 0
constants for justification selection
adc_init()
Tilte: Initialise ADC module and default parameters Arguments: (none) Returns: nothing Initializes the PIC AD-converter, calculate aquisition time.
_adc_init_acquisition_delay()
Title: Calculation of acquisition delay Arguments: (none) Returns: nothing Notes: result is stored in global variable _adc_conversion_delay
adc_read_high_res(byte in adc_chan) return word
Title: Analog to digital conversion returning a 16-bits value Arguments: channel number Returns: 16-bits ADC value Notes: - Uses right justification Returns a 16-bits value of the result of ADC, of which the range is dependent of the supported ADC resolution of the PIC (can be a 8-, 10-, 12-bits value). When the PIC supports only 8-bits ADC resolution the result is the same as of adc_read_low_res().
adc_read_low_res(byte in adc_chan) return byte
Title: Analog to digital conversion returning an 8-bits value Arguments: Channel number Returns: 8-bits ADC value Notes: - Uses left justification. Returns the 8 most significant bits of the result of ADC
_adc_read(byte in adc_chan, bit in justify) return word
Title: Analog to Digital conversion of the selected channel. Arguments: - channel number (byte) justification (bit 0=left, 1=right) Returns: word with ADC value Notes: - When PIC supports high resolution (more than 8 bits) all bits of the ADC conversion are stored straight over from ADRESH and ADRESL. When PIC supports only 8-bits resolution only the contents of ADRES are stored. With right justification the result is immediately usable as binary value. Left justification allows easy selection of the 8 most significant bits of the result, regardless which resolution the PIC supports (can be 8-,10 or 12-bits).
12f675 | 12f675_12leds.jal |
12f683 | 12f683_pwm_adc.jal |
16f15325 | 16f15325_adc.jal |
16f1827 | 16f1827_adc.jal |
16f18323 | 16f18323_adc.jal |
16f18857 | 16f18857_adc.jal |
16f690 | 16f690_adc_lowres.jal |
16f723 | 16f723_adc_independent.jal |
16f73 | 16f73_adc_dependent.jal |
16f767 | 16f767_pwm_adc.jal |
16f77 | 16f77_adc_lowres.jal |
16f876a | 16f876a_adc.jal |
16f877 | 16f877_adc.jal |
16f877 | 16f877_adc_dependent.jal |
16f877a | 16f877a_adc_dependent.jal |
16f88 | 16f88_adc_lowres.jal |
16f88 | 16f88_adc_highres.jal |
16f88 | 16f88_adc_independent.jal |
16f886 | 16f886_pwm_adc_freq.jal |
16f886 | 16f886_pwm_adc_res.jal |
18f14k50 | 18f14k50_adc_independent.jal |
18f2450 | 18f2450_adc_dependent.jal |
18f2520 | 18f2520_adc_dependent.jal |
18f2550 | 18f2550_adc_dependent.jal |
18f25k22 | 18f25k22_adc.jal |
18f2620 | 18f2620_adc_dependent.jal |
18f452 | 18f452_adc_dependent.jal |
18f4550 | 18f4550_adc_dependent.jal |
18f4550 | 18f4550_dynamic_adc.jal |
18f4550 | 18f4550_adc.jal |
18f4620 | 18f4620_adc_dependent.jal |