pot command


Closed Thread
Results 1 to 23 of 23

Thread: pot command

Hybrid View

  1. #1
    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

  2. #2
    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.

  3. #3


    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

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I am going to try this today thanks.
    I am following John Iovine,s book, he usesa F84a pic. He always uses the portB by default, I wanted to try using port A , but on a F88.
    Also I was reading the command CMCON=7 meaning th three first bit are set to one. When I read the legend it says 1 is for Setting th bit, I would of first thought setting would be for setting for comparator mode.

    k

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


    Did you find this post helpful? Yes | No

    Default His Book

    Quote Originally Posted by lerameur
    I am going to try this today thanks.
    I am following John Iovine,s book, he usesa F84a pic. He always uses the portB by default, I wanted to try using port A , but on a F88.
    Also I was reading the command CMCON=7 meaning th three first bit are set to one. When I read the legend it says 1 is for Setting th bit, I would of first thought setting would be for setting for comparator mode.

    k
    Hi Lerameur,
    I have his book too, I thought that was where you got that code. He , in my opinion, left too many loose ends in his code as he neglected to put in all the needed little setup routines, like the trisa and trisb etc. he relies on pbp defaults
    and that sorta leaves beginners out in the cold, if you do not rely on defaults and write in everything your code will always be usable and only require minor tweaking to port to other PICs
    Cheers
    JS

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yes thats what I am beginning to realize too , lots of stuff missing in the book, then when you use another chip, I'm screwed.
    Abou tthe A/D, doesn't that read a voltage ? whereas the Pot read a resistance ?

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    both cde works,
    i am trying to figure out one thing now.

    I am replacing this command line:
    HIGH PORTB.0
    PAUSE 1000
    LOW PORTB.0

    by this one:
    serout 2,n9600,(2)

    i am getting errors:
    C:\PBP\POT_TRY.BAS ERROR Line 39: Bad expression.
    C:\PBP\POT_TRY.BAS ERROR Line 33: ID LED2 is not a LABEL.
    C:\PBP\POT_TRY.BAS ERROR Line 34: ID LED3 is not a LABEL.
    C:\PBP\POT_TRY.BAS ERROR Line 35: ID LED4 is not a LABEL.

    suddenly my labels are not labels ??

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