pot command


Closed Thread
Results 1 to 23 of 23

Thread: pot command

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default pot command

    Hi,

    Little problem trying to switch POrt on my pot command.
    I am geting good result using the default port . The port command only goes to port B. I want to use portA, so I would like to use this command but it do not work: PortA.02,175,B0

    The follwoing is my working code:

    B0 var byte
    Start:
    Pot 2,175,B0 ' would like PortA.2,175,B0
    Lcdout $fe, 1 'Clear screen
    Lcdout "Pot: ", Dec B0 'Display the decimal value
    Pause 300

    k

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Once again, we can't guess wich PIC you're using so try one or all of the following lines

    CMCON=7
    ADCON1=7
    ADCON1=$0F
    ANSEL=0
    ANSELH=0

    if any of ADCON or ANSEL setting work... you may discover something interesting and NEVER EVER use POT command
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    sorry pic16F88

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Now you have to forget POT but use ADCIN instead. Just your POT on your PORTA, no capacitor in serie.

    Your PIC have ADCs AND analog comparator on PORTA... it's useless to use POT.

    Datasheet section 12.0 and 13.0.

    You need to disable the comparator first.. something is right in my previous thread about that.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    well the adcon1 I used before doing some A/d conversion.
    I also tried setting the port to output using the Tris command. NOthing works.
    Also, I guess when you say I donthave to use the Pot command you are refering to making A/D conversion ??

    k

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Probably you have disable the ADCs but not the comparator? Both have to be disable.

    And yes i'm talking about doing a A/D conversion... that's already built-in, free and far better than POT
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    by just using a pot on that pin, wont I have to use a voltage divider. If I just put a pot, then it will the same voltage and the convertion will be the same.
    Right now with this I am getting weird characters on the lcd.
    I did not touch portB..
    To disable I guess by using the ADCON1 = 0 it is disable (bit 2 and 3)

    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    B0 var byte
    Start:
    TRISA = 3 ' Set PORTA to all input
    ADCON1 = 0 ' PORTA is analog
    ADCIN 0, B0 ' Read channel 0 to B0

    Lcdout $fe, 1 'Clear screen
    Lcdout "Pot: ", Dec B0 'Display the decimal value
    Pause 300

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Look at mister_e's question

    Quote Originally Posted by mister_e
    Once again, we can't guess wich PIC you're using so try one or all of the following lines

    <h4>CMCON=7</h4>
    <h4>ADCON1=7</h4>
    ADCON1=$0F
    <h4>ANSEL=0</h4>
    ANSELH=0

    if any of ADCON or ANSEL setting work... you may discover something interesting and NEVER EVER use POT command
    Hi Lerameur,
    I think we gave mister_e a headache tonight, The data sheet chap. 5, 12, 13 makes mention of these. Get it here if you do not have.
    Cheers
    JS
    http://www.microchip.com/stellent/id...cName=en010243
    Last edited by Archangel; - 24th November 2006 at 07:29.

  9. #9
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yes I am printing them out and carefully reading them now.
    But, i am curious, if I wanted to use the POT command, what do i have to do to read from port A?

    k

  10. #10
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default I think...

    Quote Originally Posted by lerameur
    yes I am printing them out and carefully reading them now.
    But, i am curious, if I wanted to use the POT command, what do i have to do to read from port A?

    k
    lerameur,
    without actually doing it to verify it works . . .as I do not have a 16F88
    put the three BOLD commands into your code to make the PortA pins digital and turn off the analog comparators
    Code:
    CMCON=7              ' Disable comparators
    ANSEL=0               ' Set port as digital I/O
    ADCON1=7
    TrisA = %11111111  'sets all port a as input
    TrisB = %00000000  ' sets all port b as output
    B0 var byte            ' establishes a variable called B
    Start:
    Pot PortA.2,255,B0           ' would like PortA.2,175,B0 use number to suit you
    Lcdout $fe, 1                   'Clear screen
    Lcdout $FE,$80,"Pot: ", #B0       'Display the numerical value
    Pause 300 
    goto start
    end
    This should work.
    JS
    Last edited by Archangel; - 24th November 2006 at 07:29.

  11. #11


    Did you find this post helpful? Yes | No

    Default

    Hi Lerameur. I have an 'F88 and this program works. The 'F88 has 5 ADC's which are better than using the pot command. I connected pin 17 (ana 0) to the center terminal of a 1 meg pot. The CCW terminal to ground, CW terminal to B+.

    OSCCON = $60 'SET INT OSC TO 4MHZ
    ANSEL = 0 'SELECT ANALOG INPUTS 0 = NONE AND ALL DIGITAL
    ADCON0 = 0 'AD MODULE OFF & CONSUMES NO CURRENT
    CMCON = 7 'COMPARATORS OFF
    TRISA = %11111111 'PORTA INPUTS
    TRISB = %00000000 'PORTB OUTPUTS
    X VAR BYTE 'VARIABLE TO PUT POT VALUE
    PORTB = 0 'ALL OUTPUTS LOW

    START:
    ADCIN 0, X 'READ VALUE ON ANA 0
    IF X > 0 AND X <= 50 THEN LED1
    IF X > 50 AND X <= 100 THEN LED2
    IF X > 100 AND X <= 200 THEN LED3
    IF X > 200 THEN LED4
    GOTO START

    LED1:
    HIGH PORTB.0
    PAUSE 1000
    LOW PORTB.0
    GOTO START

    LED2:
    HIGH PORTB.1
    PAUSE 1000
    LOW PORTB.1
    GOTO START

    LED3:
    HIGH PORTB.2
    PAUSE 1000
    LOW PORTB.2
    GOTO START

    LED4:
    HIGH PORTB.3
    PAUSE 1000
    LOW PORTB.3
    GOTO START

Similar Threads

  1. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  2. Using the Pot command.
    By timseven in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 17th August 2009, 20:23
  3. PBP2.50b and POT command problem ?
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th October 2008, 17:14
  4. Replies: 4
    Last Post: - 24th January 2007, 22:20
  5. Can I do this???
    By noobie in forum mel PIC BASIC
    Replies: 2
    Last Post: - 10th June 2006, 18:57

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts