Hi All,
I recently wired together 8x 10K pots to test some of my coding with Analogue inputs etc.
I'm using a 40X2 (pic 18F45k22), and i've chosen Port D as my analogue input port for all 8 pots under test.
Using the simplest code (below), i can clearly see the following occur in the Terminal window:
Pot on D.0 (ADC20) - works full range 0 to 255.
Pot on D.1 (ADC21) - works full range 0 to 255.
Pot on D.2 (ADC22) - works full range 0 to 255.
Pot on D.3 (ADC23) - works approx 1/2 way (or thereabouts) up to to 255, but will never go down to 0 when the pot is completely set to 0 position.
Pot on D.4 (ADC24) - works full range 0 to 255.
Pot on D.5 (ADC25) - works full range 0 to 255.
Pot on D.6 (ADC26) - seems to always be stuck on '0' no matter where the pot is turned.
Pot on D.7 (ADC27) - works approx 1/2 way (or thereabouts) up to to 255, but will never go down to 0 when the pot is completely set to 0 position.
ALL the pots have their ends bussed to each other, so there's a row of "+5v" pot-ends, and a row of "0v" pot-ends, then the 8 wipers wire into Port-D.0 to D.7.
I have measured the pot-ends to confirm there's definitely 0v-to-5v across each pot, with varying voltage on each wiper as expected.
Have i missed something with the ADC configuration that could be causing me this problem?
As the code shows, i haven't used any ADC config info because a lot of what i read about 40X2 and ADC config didn't seem applicable to my use.
(not needing different reference voltages and not needing CALIB to turn analogue pins back into digital pins etc).
The pots are all the same brand/type from good ol' ebay, so maybe i just have a mix of good/badly made pots giving me grief?
I'm yet to re-check each pot on my test panel when i get back to the workbench next week.
I recently wired together 8x 10K pots to test some of my coding with Analogue inputs etc.
I'm using a 40X2 (pic 18F45k22), and i've chosen Port D as my analogue input port for all 8 pots under test.
Using the simplest code (below), i can clearly see the following occur in the Terminal window:
Pot on D.0 (ADC20) - works full range 0 to 255.
Pot on D.1 (ADC21) - works full range 0 to 255.
Pot on D.2 (ADC22) - works full range 0 to 255.
Pot on D.3 (ADC23) - works approx 1/2 way (or thereabouts) up to to 255, but will never go down to 0 when the pot is completely set to 0 position.
Pot on D.4 (ADC24) - works full range 0 to 255.
Pot on D.5 (ADC25) - works full range 0 to 255.
Pot on D.6 (ADC26) - seems to always be stuck on '0' no matter where the pot is turned.
Pot on D.7 (ADC27) - works approx 1/2 way (or thereabouts) up to to 255, but will never go down to 0 when the pot is completely set to 0 position.
ALL the pots have their ends bussed to each other, so there's a row of "+5v" pot-ends, and a row of "0v" pot-ends, then the 8 wipers wire into Port-D.0 to D.7.
I have measured the pot-ends to confirm there's definitely 0v-to-5v across each pot, with varying voltage on each wiper as expected.
Have i missed something with the ADC configuration that could be causing me this problem?
As the code shows, i haven't used any ADC config info because a lot of what i read about 40X2 and ADC config didn't seem applicable to my use.
(not needing different reference voltages and not needing CALIB to turn analogue pins back into digital pins etc).
The pots are all the same brand/type from good ol' ebay, so maybe i just have a mix of good/badly made pots giving me grief?
I'm yet to re-check each pot on my test panel when i get back to the workbench next week.
Code:
#PICAXE 40X2 ; Define PICAXE 40X2 type
#NO_DATA ; Ignore EEPROM data - loads program faster
#NO_TABLE ; Ignore TABLE data - loads program faster
#Terminal 9600
Initialize: ' Initialise pins and set up variables
; Setup all the port bits to a clean state...
dirsA=%11111111 ; set ALL Port-A bits to OUTPUTS.
dirsB=%11111111 ; set ALL Port-B bits to OUTPUTS.
dirsC=%11111111 ; set ALL Port-C bits to OUTPUTS.
dirsD=%00000000 ; set ALL Port-D bits to INPUTS.
; Reference of which bits are assigned to which Analogue input names...
; ADC20 Analog input = port D.0
; ADC21 Analog input = port D.1
; ADC22 Analog input = port D.2
; ADC23 Analog input = port D.3
; ADC24 Analog input = port D.4
; ADC25 Analog input = port D.5
; ADC26 Analog input = port D.6
; ADC27 Analog input = port D.7
Do
readadc 20, b0 ;read pot value on pin C.5 (ADC17) to set the "pattern" value for the loader.
readadc 21, b1 ;read pot value on pin C.5 (ADC17) to set the "pattern" value for the loader.
readadc 22, b2 ;read pot value on pin C.5 (ADC17) to set the "pattern" value for the loader.
readadc 23, b3 ;read pot value on pin C.5 (ADC17) to set the "pattern" value for the loader.
readadc 24, b4 ;read pot value on pin C.5 (ADC17) to set the "pattern" value for the loader.
readadc 25, b5 ;read pot value on pin C.5 (ADC17) to set the "pattern" value for the loader.
readadc 26, b6 ;read pot value on pin C.5 (ADC17) to set the "pattern" value for the loader.
readadc 27, b7 ;read pot value on pin C.5 (ADC17) to set the "pattern" value for the loader.
SerTxd( " Pot1:", #b0, " Pot2:", #b1," Pot3:", #b2," Pot4:", #b3," Pot5:", #b4," Pot6:", #b5," Pot7:", #b6," Pot8:", #b7, CR )
Pause 1000 ;Display POT values in terminal window each second (or adjust for quicker updates).
Loop