pot command


Closed Thread
Results 1 to 6 of 6

Thread: pot command

  1. #1
    trying's Avatar
    trying Guest

    Default pot command

    Trying to learn to use the pot command
    I have a 50k pot and .1uf cap connect as per the PBP man.
    led should come if pot takes BO<125 off if BO> 125(starting point)
    I've tried changing the scale from 1 to 255 as well as BO <xxx
    do you see any problem with my code
    any help thanks


    @ DEVICE pic12F675
    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    @ DEVICE pic12F675, WDT_ON
    @ DEVICE pic12F675, MCLR_OFF
    @ DEVICE pic12F675, CPD_OFF
    @ DEVICE pic12F675, BOD_OFF
    @ DEVICE pic12F675, PWRT_ON
    @ DEVICE pic12F675, PROTECT_OFF
    DEFINE OSC 4
    Pause 10000 ' ALLOW PIC TO STABILIZE
    TRISIO = %00001100 ' MAKE GPIO.2/.3 INPUTS
    ANSEL = %00000100 'MAKE GPIO.2 ANALOG
    CMCON = 7


    SYMBOL LED = GPIO.5

    LED=0

    LED=1
    Pause 250 'POWER UP OK
    LED=0

    BO VAR WORD

    Pot GPIO.2,255,BO




    CHECKIT:
    LED=0
    IF BO>125 Then LED=1 'LED ON WHEN BO>125,OFF WHEN BO<125
    GoTo CHECKIT

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    How about doing it this way? Now, every time around the checkit will read the pot and take care of the LED

    Jerson



    CHECKIT:
    Pot GPIO.2,255,BO

    IF BO>125 Then
    LED=1 'LED ON WHEN BO>125,OFF WHEN BO<125
    else
    LED = 0
    endif
    GoTo CHECKIT

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    With the POT command PBP needs to control the I/O-pin. If you have the pin
    configured as an A/D input, the POT command can't toggle the pin to charge
    the capacitor.

    You could use ADCIN with the A/D configured for 8-bit or simply make the pin
    digital, then use the POT command.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    trying's Avatar
    trying Guest


    Did you find this post helpful? Yes | No

    Default

    Jerson that the 1st. way I wrote the code but for some reason it would not compile

    Bruce you a little over my head ( newbie) are you saying this is wrong?
    TRISIO = %00001100 ' MAKE GPIO.2/.3 INPUTS
    ANSEL = %00000100 'MAKE GPIO.2 ANALOG
    please explan more
    thanks

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you are using the POT command, then you do not want to make the pin
    an analog input. It needs to be configured for digital I/O.

    Change this: ANSEL = %00000100 ' MAKE GPIO.2 ANALOG
    To this: ANSEL = %00000000 ' MAKE GPIO.2 (and all other A/D pins) digital.

    Why?

    Because the POT command requires a pin it can control by flipping it from
    output, charging the cap, then flipping it back to an input. If you have the
    A/D feature for that pin enabled, then the pin no longer functions as a digital
    I/O-pin, and the POT command will fail.

    If you prefer not to use the POT command, then you could use the ADCIN
    command. In that case you would want to configure the pin as an analog
    input with ANSEL = %00000100 ' MAKE GPIO.2 ANALOG
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    trying's Avatar
    trying Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    thanks Bruce
    I will give it a try, with you and others I'm learning

Similar Threads

  1. Using the Pot command.
    By timseven in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 17th August 2009, 20:23
  2. PBP2.50b and POT command problem ?
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th October 2008, 17:14
  3. Replies: 4
    Last Post: - 24th January 2007, 22:20
  4. pot command
    By lerameur in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 25th November 2006, 04:12
  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