| View previous topic :: View next topic |
| Author |
Message |
Woody
Joined: 11 Sep 2003 Posts: 85 Location: Warmenhuizen - NL
|
| Quick question about ADC in a PIC18F04Q41 |
Posted: Fri Dec 05, 2025 9:13 am |
|
|
I am either experiencing a senior moment or I never understood how channel switching for the AD converter works.
Before I elaborate on what the problem is, can I ask: do you need to issue a | Code: | | set_adc_channel(sAN2); | before every read of an ADC value? Also if I am only interested in on input channel? |
|
 |
Woody
Joined: 11 Sep 2003 Posts: 85 Location: Warmenhuizen - NL
|
|
Posted: Fri Dec 05, 2025 9:44 am |
|
|
Yep, senior moment.
Reading my own question back I noticed the 'sAN2' and thought, that cannot be right....
And indeed, changing this to | Code: | | set_adc_channel(2); | solved my problem.
My excuses for the stupid question. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9600 Location: Greensville,Ontario
|
|
Posted: Fri Dec 05, 2025 1:43 pm |
|
|
| don't feel bad.... at 72 ALL my moments are 'senior' ! |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19995
|
|
Posted: Sat Dec 06, 2025 12:34 pm |
|
|
It is also a very common one.
The sANx designations are used for the setup, to specify which channels
are to be connected to the multiplexer. The set_adc_channel command
then just selects the numbered channel from the multiplexer you want
to read.
I suspect many of us have made that mistake at least once.....  |
|
 |
|