syntax error


Closed Thread
Results 1 to 19 of 19

Thread: syntax error

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

    Default syntax error

    Hi,

    I'm trying to use 4 pots to provide a range of values to set the temperature set point in the code featured http://www.picbasic.co.uk/forum/showthread.php?t=12712

    When I use the following code I get a bad expression syntax error on the SetPoint(ADchan) = POTS(ADchan) line

    Code:
        FOR ADchan = 0 to 3
            GOSUB GetADC
            POTS(ADchan) = ADvalue
            SetPoint(ADchan) = POTS(ADchan)
        NEXT ADchan
    My logic seems that it gets the adc value, places that in the POTS(0), POTS(1) etc, and then should give SetPoint(0) the same value as POTS(0)

    All I really need is a range between 100 and 500 for each SetPoint

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    Hi,

    I'm trying to use 4 pots to provide a range of values to set the temperature set point in the code featured http://www.picbasic.co.uk/forum/showthread.php?t=12712

    When I use the following code I get a bad expression syntax error on the SetPoint(ADchan) = POTS(ADchan) line

    Code:
        FOR ADchan = 0 to 3
            GOSUB GetADC
            POTS(ADchan) = ADvalue
            SetPoint(ADchan) = POTS(ADchan)
        NEXT ADchan
    My logic seems that it gets the adc value, places that in the POTS(0), POTS(1) etc, and then should give SetPoint(0) the same value as POTS(0)

    All I really need is a range between 100 and 500 for each SetPoint
    Have you tried [square] brackets ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Malc,

    Use ...

    Setpoints(ADchan)
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Hi Malc,

    Use ...

    Setpoints(ADchan)
    <br>
    Hmmm . . . so (ADchan) is a MATH operation ? I thought it was an array, if it is, then (brackets) are OK ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  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
    Hi Malc,

    Use ...

    Setpoints(ADchan)
    <br>

    How the hell did I miss that !

    Now just got to work out how to get the value with in the range !

    Thanks once again Darrel

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    How the hell did I miss that !

    Now just got to work out how to get the value with in the range !

    Thanks once again Darrel
    Hi Malc, I would say pretty darn easy, given the size of this program, I just un zipped it, nice work ! To all involved.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Thanks, but really the credit for the coding goes to Darrel.

    I'm still a rookie in PBP, and it's taking me hours to try and work this out and I'm still having trouble getting the value from the pot to change the set temperature

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


    Did you find this post helpful? Yes | No

    Default

    Still need help (Darrel ??)

    Code:
        FOR ADchan = 0 to 3
            GOSUB GetADC
            pots(ADchan) = ADvalue
            SetPoints(ADchan) = (Advalue / 100) 
            if SetPoints(ADchan) <200 then SetPoints(ADchan) = 200
            if SetPoints(ADchan) >500 then SetPoints(ADchan) = 500        
        NEXT ADchan
    and

    Code:
    LCDOUT $FE,$C0, DEC pots(0)>>1,"   "
    Gives a value on the LCD of between 1 and 8184 as the pot is turned from one extreme to the other

    however
    Code:
    LCDOUT $FE,$C0, DEC SetPoints(0)>>1,"   "
    Gives a static number, of 100 regardless of what position the pot is set to

    I would also like to know what to change to get the PC display to show the value of the setpoints - it still remains the same value (26 degrees) set by EE_setpoint value in the initial stages even though I've changed the setmode to manual

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


    Did you find this post helpful? Yes | No

    Default sorted !

    Managed to get this part to work.

    Code:
    FOR ADchan = 0 to 3
            GOSUB GetADC
            pots(ADchan) = ADvalue/10
            SetPoints(ADchan) = pots(ADchan) 
            if SetPoints(ADchan) <200 then SetPoints(ADchan) = 200
            if SetPoints(ADchan) >500 then SetPoints(ADchan) = 500 
            LCDOUT $FE,$C0, dec pots(0)>>1,"   "
    Now get a value between 0 and 818 when the pot is moved

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


    Did you find this post helpful? Yes | No

    Exclamation

    Uno Momento por favor ...

    Are you using 14-bit?
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Maybe I jumped to soon...

    strange thing is that whist the lcd is showing a value of 71, which I would assume would give a set point of 7.1 degree, the value on the PC is showing as 14.3

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

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

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

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

  16. #16
    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 !

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

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


    Did you find this post helpful? Yes | No

    Default

    Cheers DT !

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


    Did you find this post helpful? Yes | No

    Default Porting from 16F to 18F - strange A/D

    Guys,

    Is A/D handled different in an 18F4550 to a 16F877A ?

    The development of the 4ch PID thermostat with Darrel got as far as porting the original code to a 18F4550 (mainly as it has a lot more code space). I've copied over the A/D from the 16F code

    Code:
    ;----[Analog Settings]------------------------------------------------------
    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 350              ' 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
    ADCON1 = $0F
    And have the same routine for using the value to set the set point
    Code:
    GetSetpoint:
        FOR ADchan = 0 to 3
        GOSUB GetADC
        Result  = ADvalue*(MaxSetPoint - MinSetPoint)
       Result  = (DIV32 ADmax) + MinSetPoint
        Setpoints(ADchan) = Result 
        NEXT ADchan
    But when viewed on the PC via Hyperterminal the set point is either 10 or 110.

    I've tried changing the two values for minsetpoint and maxsetpoint to no avail.

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