Newbee how to run pval back if if b0 < b1


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006
    Posts
    35

    Default Newbee how to run pval back if if b0 < b1

    I don't have the next to the last line right but I've tried quite a few things with no avail. Thanks much!

    DEFINE OSC 4
    PVAL VAR WORD
    pval2 var word
    b0 var word
    b1 var word
    DUTY VAR BYTE
    DEFINE ADC_BITS 8 ' Set number of bits in result
    DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds

    Begin:

    PVAL = 1000 ' Start with 1kHz
    For duty = 64 To 250
    hpwm 1, duty, pval
    pause 1000
    Next duty

    duty = 60 ' 30% Duty-cycle
    For pval = 1000 To 10000 Step 100 'Increments of 100. Change as needed
    hpwm 1, duty, pval
    pause 1000
    Next pval

    TRISA = 255 ' Set PORTA to all input
    ADCON1 = 2 ' PORTA is analog
    ADCIN 0, B0 ' Read channel 0 to B0
    pause 2000
    TRISB = 255 ' Set PORTB to all input
    ADCON1 = 2 ' PORTB is analog
    ADCIN 1, B1 ' Read channel 1 to B1

    if b0 < b1 then pval -1 'run pval backwards
    if b0 >= b1 then begin

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Hi emmett brown
    Try:

    Code:
    IF b0 < b1 THEN
     pval = pval -1   'run pval backwards 
    EndIF
    "Data sheets? I ain't got no data sheets. I don't need no data sheets. I don't have to read any stinking data sheets!"

  3. #3
    Join Date
    Jun 2006
    Posts
    35


    Did you find this post helpful? Yes | No

    Default

    Excellent! I was trying to make it extremely complicated as I always do. Thank You So Much for your response and time. (tried to post this yesterday but it didn't show up). Emmett

Similar Threads

  1. Help with a draft of a robóvia rf
    By cesar35 in forum mel PIC BASIC
    Replies: 39
    Last Post: - 1st May 2009, 16:11

Members who have read this thread : 1

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