syntax error


Closed Thread
Results 1 to 19 of 19

Thread: syntax error

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Uno Momento por favor ...

    Are you using 14-bit?
    <br>
    Sorry ?

    I'm using the code for the 16F877 we worked on, basically just wanting to sort the analogue pots and menus out.

    Code:
    DEFINE ADC_BITS 10                ' Set-up ADC for fastest 10-bit results
    DEFINE ADC_CLOCK 2
    DEFINE ADC_SAMPLEUS 5
    INCLUDE "DT_Analog.pbp"
    
    MaxSetPoint  CON 500              ' Pot fully clockwise
    MinSetPoint  CON 100              ' Pot fully counter clockwise 
    ADbits = 14                       ' set A/D resolution to 14-bits
    CMCON = 7                         ' disable Comparators
    ADCON1 = %10000010                ' AN0-4 Analog, Right justify

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I think this should do it.
    Set ADchan before GOSUBing ...
    Code:
    Result       VAR WORD
    
    GetSetpoint:
        GOSUB GetADC
        Result  = ADvalue*(MaxSetPoint - MinSetPoint)
        Result  = (DIV32 ADmax) + MinSetPoint
        Setpoints(ADchan) = Result
    RETURN
    hth,
    DT

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Darrel, I've tried you code, may not of put it in the right place

    Code:
    Main:
        FOR pid_Channel = 0 TO 3              ; cycle thru all sensors
            GOSUB SelectSensor
            GIE = 0                           ; disable interrupts before 1-wire
            @  DS1820_Convert                 ;   start a temperature conversion
            GIE = 1                           ; enable interrupts after 1-wire
        NEXT pid_Channel
        
    Result       VAR WORD
    
    GetSetpoint:
        FOR ADchan = 0 to 3
        GOSUB GetADC
        Result  = ADvalue*(MaxSetPoint - MinSetPoint)
        Result  = (DIV32 ADmax) + MinSetPoint
        Setpoints(ADchan) = Result 
        LCDOUT $FE,$C0, dec setpoints(0)>>1,"   " 
        NEXT ADchan
    but the set point displayed in hyper terminal is still twice the value shown on the lcd.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default With 1 decimal place

    Code:
    LCDOUT $FE,$C0, DEC setpoints(0)/10,".",DEC1 setpoints(0)//10
    DT

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Code:
    LCDOUT $FE,$C0, DEC setpoints(0)/10,".",DEC1 setpoints(0)//10
    Thanks.

    I tried changing the results value (dividing by 2 and then multiplying by 2) to no avail.

    How does dividing by 10 work out then ? If the result value was giving me a setpoints value of 100, but it was displaying 20.0 on the screen, dividing 100/10 gives 10 which would equate to 1.0 degree ??

    Just can't get my head round this... maybe I've been at it too long... or had too many glasses of wine !

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    value = 100
    value / 10 = 10
    value // 10 = 0

    DEC value /10,".",DEC1 value//10 = "10.0"<hr>
    value = 342
    value / 10 = 34
    value // 10 = 2

    DEC value /10,".",DEC1 value//10 = "34.2"
    <br>
    DT

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Cheers DT !

Similar Threads

  1. Compile error & syntax error on the word "loop:" as a label?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th March 2010, 04:14
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Optimizing DIV
    By skimask in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd September 2008, 04:58
  4. 16F88 Compile error
    By Toley00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd November 2005, 00:22
  5. Syntax error PIC16F684
    By milestag in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st September 2005, 18:54

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