Shop OBEX P1 Docs P2 Docs Learn Events
Error:148 - help with program to drive motors based on color sensed by camera — Parallax Forums

Error:148 - help with program to drive motors based on color sensed by camera

spathrwspathrw Posts: 6
edited 2010-04-21 15:04 in BASIC Stamp
The students are using a camera that senses colors.· They
have this working properly.· They also have the program
driving a motor.
The problem:· They can not get the motors to drive based on
the color sensed.
This is the error:· Error:148:Expected a Label
Program line is:·
Line IF (pRed<85) AND (pGREEN<42) AND· (bBLUE<26) THEN...

Comments

  • JDJD Posts: 570
    edited 2010-04-13 18:16
    Spathrw,

    If you post the program we can offer some suggestions, but the label missing is a subroutine, variable, or something similar that is used in the program that is not being declared somewhere. Can you post the entire program using the Attachment Manager?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • FranklinFranklin Posts: 4,747
    edited 2010-04-13 20:51
    Spathrw said...
    Program line is:
    Line IF (pRed<85) AND (pGREEN<42) AND (bBLUE<26) THEN...
    Perhaps pBLUE ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • spathrwspathrw Posts: 6
    edited 2010-04-14 13:51
    ' {$STAMP BS2}
    ' {$PBASIC 2.0}

    Out CON 7
    S3 CON 0
    S2 CON 1
    LED CON 5

    pRED CON 15
    pGREEN CON 12
    pBLUE CON 9

    RED VAR Word
    GREEN VAR Word
    BLUE VAR Word
    Counter VAR Word


    START:
    HIGH LED

    DO

    GOSUB Register
    GOSUB Seperator_move

    LOOP

    Register:
    GOSUB Color
    DEBUG "R", DEC3 RED
    DEBUG " G", DEC3 GREEN
    DEBUG " B", DEC3 BLUE
    DEBUG CR
    RETURN

    Color:
    LOW S2
    LOW S3
    COUNT Out, pRED, RED
    HIGH S3
    COUNT Out, pBLUE, BLUE
    HIGH S2
    COUNT Out, pGreen, GREEN
    RETURN

    Seperator_move:
    IF (pRed < 85) AND (pGREEN < 42) AND (pBLUE < 26) THEN SHIFT:
    FOR Counter = 1 TO 24
    PULSOUT 13, 750
    GOSUB Semi_seperator
    PAUSE 20
    NEXT
    FOR Counter = 1 TO 24
    PULSOUT 13, 850
    PAUSE 20
    NEXT
    ELSEIF (pRED < 55) AND (pGREEN < 76) AND (pBLUE < 43) THEN SHIFT:
    FOR Counter = 1 TO 64
    PULSOUT 13, 750
    GOSUB Semi_seperator
    PAUSE 20
    NEXT
    FOR Counter = 1 TO 64
    PULSOUT 13, 850
    GOSUB Semi_seperator
    PAUSE 20
    NEXT
    ELSEIF (pRED < 31) AND (pGreen < 37) AND (pBLUE < 43)THEN SHIFT:
    FOR Counter = 1 TO 104
    PULSOUT 13, 750
    GOSUB Semi_seperator
    PAUSE 20
    NEXT
    FOR counter = 1 TO 104
    PULSOUT 13, 850
    PAUSE 20
    NEXT
    ELSE SHIFT:
    FOR Counter = 1 TO 144
    PULSOUT 13, 750
    GOSUB Semi_seperator
    NEXT
    FOR counter = 1 TO 144
    PULSOUT 13, 850
    PAUSE 20
    NEXT
    ENDIF

    PAUSE 20

    RETURN

    Semi_seperator:
    FOR Counter = 1 TO 24
    PULSOUT 12, 750
    PAUSE 20
    NEXT

    RETURN
  • spathrwspathrw Posts: 6
    edited 2010-04-14 13:59
    Josh
    Program attached.
    Thanks for helping.
  • JDJD Posts: 570
    edited 2010-04-14 21:39
    Spathrw,

    Are you using the TAOS (TCS3200-DB Color Sensor) color sensor module? Or what camera are you using?

    I see the program is using ELSEIF, and that is a PBASIC 2.5 command. What you would want to do is use the 2.5 PBASIC directive to select the latest command set in PBASIC and try the run the program again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • spathrwspathrw Posts: 6
    edited 2010-04-15 13:49
    Ok so we have changed our basic stamp version to 2.5 and everything is looking like it is supposed to but for some reason the elseifs are not registering that there is an if at the beginning of the subprogram. Could this be a result of a program error and how it is written or is it another language barrier?
  • JDJD Posts: 570
    edited 2010-04-15 17:23
    Spathrw,

    ·I dont think you are running into a barrier but a formatting related issue. I see that you are using a SHIFT routine a number of times. Since each one is doing something different you would want to give unique names like you are using the Simi_seperator routine, so something like SHIFT_1, SHIFT_2, and so on.

    ·You can try something like the following; breaking the program up into easier to manage parts. Each IF...THEN statement has a specific place to jump to if the statement is true.

    Seperator_move:

    ·· IF (pRed < 85) AND (pGREEN < 42) AND (pBLUE < 26) THEN SHIFT_1

    ·· ELSEIF (pRED < 55) AND (pGREEN < 76) AND (pBLUE < 43) THEN SHIFT_2

    ·· *other IF...THEN statements continued here...

    '· Sub Routines Names

    SHIFT_1:
    ··· FOR Counter = 1 TO 24
    ······ PULSOUT 13, 750
    ······ GOSUB Semi_seperator
    ······ PAUSE 20
    ······ NEXT
    ··· FOR Counter = 1 TO 24
    ····· PULSOUT 13, 850
    ····· PAUSE 20
    ····· NEXT
    RETURN

    SHIFT_2:
    ···· FOR Counter = 1 TO 64
    ······· PULSOUT 13, 750
    ······· GOSUB Semi_seperator
    ······· PAUSE 20
    ······· NEXT
    ····· FOR Counter = 1 TO 64
    ······· PULSOUT 13, 850
    ······· GOSUB Semi_seperator
    ······· PAUSE 20
    ······· NEXT
    RETURN

    ** other Sub routines continued here

    Hope this helps,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • spathrwspathrw Posts: 6
    edited 2010-04-19 13:52
    Yes we are working with the TAOS color sensing module, sorry we didn't mention this earlier,·and everything is working on it based on our tests we done with it from the·program off of·the Parallax website.· OK so we have changed the·SHIFTS again·so that they are subroutine locations but we are still getting the·error that the ELSEIFs are not registering that there is an IF·before them, eventhough·we can see that the IF is active. Any help or other ideas?
  • JDJD Posts: 570
    edited 2010-04-20 16:50
    Can you upload the new program that has been changed for review?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • spathrwspathrw Posts: 6
    edited 2010-04-21 12:39
    Here is what the program is looking like now.
  • JDJD Posts: 570
    edited 2010-04-21 15:04
    Spathrw,

    ·There is a specific format that a IF...THEN statement must follow to properly compile. An IF...THEN statement can be completed on one line, which does not need an ENDIF, or multiple lines; the common practice when using ELSE and ELSEIF, followed by an ENDIF.

    ·I would suggest reviewing the IF...THEN statement in the BASIC Stamp Syntax & Reference Manual as there are some nice examples of using a ELSEIF with an IF...THEN command with some code snippets. Here is a link for your convenience.

    BASIC Stamp Syntax & Reference Manual:
    http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
Sign In or Register to comment.