Searching \ for '[EE]:Potentiometer' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=potentiometer
Search entire site for: 'Potentiometer'.

Exact match. Not showing close matches.
PICList Thread
'[EE]:Potentiometer'
2001\01\10@231818 by Jinx

face picon face
part 1 4135 bytes content-type:text/plain; (decoded 7bit)

I suggested using a 4017 to select pots. Circuit and s/w attached
seem to work OK. Nitpicking welcomed

Tinkering I didn't have time for - using RC on 4017 Clock/Reset
to use one less PIC pin (R between Clock and Reset, C to 0V
from Reset, use long pulse to reset, short pulse to clock) and
fine tune routines/calls/delays to optimise speed. Data in the
EEPROM could be sent out serially

Components shown will give 8-bit resolution. Highest reading for a
10k pot was e9h (233d). There's a small overhead to remove from
this (about a 4-5 count). Bigger pots will need a correspondingly
smaller cap, eg 100k pot = 1n5 pot. Not decreasing the cap would
allow finer resolution, but it would take longer to go through the pots

The code for a 4051 MUX would be quite similar, even a little simpler.
The 4017 way can be expanded indefinitely using the same 2-wire
system, whereas a 4051 system would need extra chips to direct
the ABC selector lines

This should be useable in a robotics system as cheap or convenient
(possibly more so than encoders) position sensing for something
like a grasp or turntable

==================================================

rs      equ porta.0   ;o/p       4017 reset
pot     equ porta.1   ;i/p  o/p  measure/discharge cap
clk     equ porta.2   ;o/p       4017 clock
led     equ porta.3   ;o/p       finished
go      equ porta.4   ;i/p       start

orgdata ram

idx      rb    ;current position
ptn      rb    ;pot number to be done
count1   rb
count2   rb
count3   rb

entry    movlw  12h        ;...i ooio
        tris   porta
        bcf    clk
        bcf    rs
        bcf    led
        bsf    go
        movlw  00h        ;oooo oooo
        tris   portb
        clrf   portb
        movlw  80h
        option

        movlw  10h        ;store pot readings in RAM at address 10h up
        movwf  fsr
        clrf   idx
        movlw  01h        ;start with pot#1
        movwf  ptn
        bcf    led

wait     btfsc  go         ;wait for PB release on a.4
        goto   wait
        call   msdelay
waitl    btfss  go
        goto   waitl

setpot   call   reset     ;discharge cap, select pot

measure  btfsc  pot       ;bump measure while pot pin is low
        goto   store     ;else jump out and store count
        incf   count1,f
        goto   measure

store    call   cstore    ;store reading
        incf   ptn,f     ;next pot#
        movlw  04h       ;limit = (number of pots)+1
        xorwf  ptn,w
        btfss  zero
        goto   setpot    ;next pot
        goto   stop      ;all done

cstore   movf   count1,w  ;put count value in RAM
        movwf  indf
        call   stee      ;and/or EEPROM (also from 10h up)
        incf   fsr,f
        return

reset    bsf    rs        ;reset 4017, q0=1, no pot selected
        nop
        nop
        bcf    rs

        movlw  10h       ;a.2 = o/p, discharge cap
        tris   porta
        bcf    pot
        call   msdelay
        clrf   idx

nextpot  bsf    clk
        nop
        nop
        bcf    clk
        incf   idx,f     ;current 4017 position
        movf   ptn,w     ;pot to be measured
        xorwf  idx,w
        btfss  zero
        goto   nextpot   ;loop until 4017=pot#
        movlw  12h
        tris   porta
        clrf   count1
        return           ;to measure new pot

msdelay  movlw  0f6h      ;delay about 1 millisecond @ 10MHz
        movwf  count1
        clrf   count2
inc      incfsz count2,f
        goto   inc
        incfsz count1,f
        goto   inc
        return

stee     movf   fsr,w      ;store pot reading in EEPROM
        movwf  eeadr
        movf   count1,w
        movwf  eedata
        call   write
        return

write    bsf    rp0
        bsf    wren
        movlw  55h
        movwf  eecon2
        movlw  0aah
        movwf  eecon2
        bsf    wr

wrend    btfss  eeif
        goto   wrend
        bcf    eeif
        bcf    wren
        bcf    rp0
        return

stop     bsf    led        ;LED on, finished
wrst     goto   wrst       ;wait for RESET to go again


part 2 3205 bytes content-type:image/gif; (decode)


part 3 136 bytes
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\01\11@061257 by Jinx

face picon face
PS - missed out the 220R between the 15n and a1 (reduces
current into a1 during discharge)

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\01\11@064510 by Jinx

face picon face
One minor adjustment - if RAM for the 5 variables starts at 0ch
then the 10h used for storing the first pot value will be over-written
by count3. I didn't pick this up as I was only interested at the time
in the EEPROM

movlw  10h        ;store pot readings in RAM at address 10h up
movwf  fsr

should be changed to movlw 11h or more if RAM is used for
pot value storage (keep an eye on EEPROM endurance too)

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2001\01\11@125548 by Roman Black

flavicon
face
Cool! Thanks. Clever stuff. I have a couple
of 4017s around somewhere. :o)
-Roman




Jinx wrote:
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...