Searching \ for 'Reading a potentiometer without an ADC' 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/io/atod.htm?key=adc
Search entire site for: 'Reading a potentiometer without an ADC'.

Truncated match.
PICList Thread
'Reading a potentiometer without an ADC'
1998\11\29@154909 by gwaiche

picon face
Hi!

I need to read a pot with a 8Mhz 16C84 to drive
a motor with PWM.

Does anybody have an assembly language routine
to read a pot? Even a low resolution ( 4 or 5 bits)
will be enough.

Thank for your help!

Gael

1998\11\30@031136 by John Sanderson

flavicon
face
Bonjour Gael & PIC.ers,

I did this a while back. You might get some ideas from the code
below, this part of the project worked well.
..
Pity about the rest of the job....
..

Best regards, John


{Quote hidden}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;***************************************General subroutines
;pot_rc is defined as port pin rb2
;ASCII art, here goes:-
;
;
;                           220R                      Variable R, 10K
;      pot_rc pin ---/\/\/\/\/\---------0----------/\/\/\/\/\/---
;                                                   I                  ^       I
;                                                -----                I       I
;                                      0.1uF -----                ------I
;                                                   I
I
;                                                   I
I
;                                                   I
I
;                                              -----------             --------
;

readpot                 ;subroutine,read the pot position by cheap rc timer
               clrf    count4          ;sp routine counter forced to zero
               bsf     status,rp0
               bcf     trisb,pot_rc    ;make the pot pin an output
               bcf     status,rp0
                                       ;charge up cap. to +5v Vdd
               bsf     mirror_portb,pot_rc     ;r-m-w-
               movf    mirror_portb,w
               movwf   portb
               movlw   0x50
               movwf   count1
pumpup          decfsz  count1,same
               goto    pumpup          ;drop out only after cap charged full
               bsf     status,rp0
               bsf     trisb,pot_rc    ;make the pot pin an input
               bcf     status,rp0
decaycount
               movf    portb,w         ;r-m-w
               movwf   mirror_portb
               btfss   mirror_portb,pot_rc
               goto    exit_readpot
               incfsz  count4,same
               goto    decaycount
               movlw   0xFF
               movwf   count4          ;ensures pot_sp doesn't rollover >FF
exit_readpot
               movf    pot_sp,w        ;pot_sp is `old' pwmmark value
               subwf   count4,w        ;c set if pot_sp>count4=want more rpm
               btfsc   status,c
               goto    down_speed      ;=down_sp=pot_sp increase= less rpm
               decf    pot_sp,same     ;=up_sp=pot_sp reducing= more rpm
               goto    exit_readpot_1
down_speed                              ;NB ?? not sure about the logic of
               movf    count4,w        ;exit_readpot -> onwards, but it
               movwf   pot_sp          ;works properly.  ???!!!
exit_readpot_1
               bsf     status,rp0
               bcf     trisb,pot_rc    ;make the pot pin an output
               bcf     status,rp0
               bcf     mirror_portb,pot_rc     ;r-m-w-
               movf    mirror_portb,w          ;bash pin LO & keep it there
               movwf   portb
               return                  ;from readpot subroutine

********
..
email from John Sanderson at
JS Controls, PO Box 1887, Boksburg 1460, Rep. South Africa
Manufacturer & purveyor of laboratory force testing apparatus
and related products and services.
Tel/fax: Johannesburg 893 4154    Cellphone 082 453 4815

1998\11\30@033004 by Tjaart van der Walt

flavicon
face
John Sanderson wrote:
>
> Bonjour Gael & PIC.ers,
>
> I did this a while back. You might get some ideas from the code
> below, this part of the project worked well.
> ..
> Pity about the rest of the job....
> ..

Here is another easy way to do it :

1) Connect the pot from 5V to an input pin.
2) Connect a smallish cap (100nF) to the input pin.
3) Connect another pin (output) to the input pin via a resistor.

In your program, count the number of 0V pulses you have to hit
the output pin before the input pin becomes negative.

--
Friendly Regards          /"\
                         \ /
Tjaart van der Walt        X  ASCII RIBBON CAMPAIGN
.....tjaartKILLspamspam@spam@wasp.co.za  / \ AGAINST HTML MAIL

|--------------------------------------------------|
|                WASP International                |
|R&D Engineer : GSM peripheral services development|
|--------------------------------------------------|
|SMS tjaartspamKILLspamsms.wasp.co.za  (160 chars max)|
|     http://www.wasp.co.za/~tjaart/index.html     |
|Voice: +27-(0)11-622-8686  Fax: +27-(0)11-622-8973|
|          WGS-84 : 26¡10.52'S 28¡06.19'E          |
|--------------------------------------------------|

1998\11\30@040630 by Dr. Imre Bartfai

flavicon
face
Hi,
look at AN512 (or maybe AN513 - I mix this two up always). I realized it
and it worked very fine. However, it requires some calculations beforehand
;-).

Imre


On Sun, 29 Nov 1998, Gael Waiche wrote:

{Quote hidden}


'Reading a potentiometer without an ADC'
1998\12\01@121400 by lilel
flavicon
face
> Bonjour Gael & PIC.ers,
>
> I did this a while back. You might get some ideas from the code
> below, this part of the project worked well. .. Pity about the rest
> of the job.... ..
>

I've got a similar routine, and I've had some good luck with AN512
type A/D.  Gael, check it out and come back with questions about
specifics.  You'll find the biggest problem with AN512 is noise
immunity, and in a PWM motor app that might be a real big problem.

I'm currently moving a design from a PIC with A/D to a cheap
PIC16c54.  Should save almost $1.00 a board!  One a board that costs
less than $4.00 US that's a lot!

-- Lawrence Lile

"Nyquist was an optimist."

=> Median Filter Source Code
=> AutoCad blocks for electrical drafting

at:  http://home1.gte.net/llile/index.htm

1998\12\01@125211 by Peter L. Peres

picon face
On Tue, 1 Dec 1998, Lawrence Lile wrote:

> I've got a similar routine, and I've had some good luck with AN512
> type A/D.  Gael, check it out and come back with questions about
> specifics.  You'll find the biggest problem with AN512 is noise
> immunity, and in a PWM motor app that might be a real big problem.
>
> I'm currently moving a design from a PIC with A/D to a cheap
> PIC16c54.  Should save almost $1.00 a board!  One a board that costs
> less than $4.00 US that's a lot!

Just in case no-one mentions it:

There is a variation on the AN512 method that is actually a
self-calibrating converter. It uses 3 PIC pins (one input, 2 outputs). The
input has the cap to GND and one oputput drives a fixed R, while the other
drives the thermisor (or whatever), both into the cap. This gives
self-calibration (within reason).

Single large disadvantage: The sensor is not referenced to GND
Single large advantage: Can you picture multiplexing 7 thermistors like
this and still having 3 pins for serial IO on a PIC16C54 ;) ? I can
because I did that ;) ;)

Peter

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