Shop OBEX P1 Docs P2 Docs Learn Events
need help with program — Parallax Forums

need help with program

zainab1421zainab1421 Posts: 17
edited 2013-05-13 08:08 in BASIC Stamp
any one know we is the wrong in these codes ?

when i run it they said (label missing with ws = wst )
     ' {$STAMP BS2}
' {$PBASIC 2.5}
' COM Parameters
COM_RX              PIN   0   ' rx pin
COM_TX              PIN   2   ' tx pin
COM_SPEED           CON   84  ' baud 9600
COM_10MS            CON   10  ' 10ms unit

' Protocol Command
CMD_BREAK           CON         "b" ' abort recog or ping
CMD_SLEEP           CON         "s" ' go to power down
CMD_KNOB            CON         "k" ' set si knob <1>
CMD_LEVEL           CON         "v" ' set sd level <1>
CMD_LANGUAGE        CON         "l" ' set si language <1>
CMD_TIMEOUT         CON         "o" ' set timeout <1>
CMD_RECOG_SI        CON         "i" ' do si recog from ws <1>
CMD_RECOG_SD        CON         "d" ' do sd recog at group <1> (0 = trigger mixed si/sd)
' Protocol Status
STS_AWAKEN          CON         "w" ' back from power down mode
STS_ERROR           CON         "e" ' signal error code <1-2>
STS_INVALID         CON         "v" ' invalid command or argument
STS_TIMEOUT         CON         "t" ' timeout expired
STS_INTERR          CON         "i" ' back from aborted recognition (see 'break')
STS_SUCCESS         CON         "o" ' no errors status
STS_RESULT          CON         "r" ' recognised sd command <1> - training similar to sd <1>
STS_SIMILAR         CON         "s" ' recognised si <1> (in mixed si/sd) - training similar to si <1>
' Protocol arguments are in the range 0x40 (-1) TO 0x60 (+31) inclusive
ARG_MIN             CON         64 ' 0x40
ARG_MAX             CON         96 ' 0x60
ARG_ZERO            CON         65 ' 0x41
ARG_ACK             CON         32 ' 0x20    'TO READ more status arguments
'Groups and Commands
GROUP_1             CON   1    '(Command count: 2)
G1_FORWARD                          CON   0
G1_BACKWARD                         CON   1
GROUP_2             CON   2    '(Command count: 2)
G2_LEFT                             CON   0
G2_RIGHT                            CON   1
GROUP_3             CON   3    '(Command count: 2)
G3_TURN                             CON   0
G3_ZAINAB                           CON   1

WS_Timeout          CON   254
WS_Error            CON   255
RES_COMMFAIL        CON   253
RES_BUILTIN         CON   32
VAR_LANG            DATA 0
VAR_KNOB            DATA 2
VAR_LEVEL           DATA 2

'Robot Constant
VRLED               PIN   4
'Global Variable
VRA                 VAR   Byte
VRA1                VAR   Byte
VRGROUP             VAR   Byte
VRCOMMAND           VAR   Byte
' Main Start
  INPUT COM_RX
  HIGH COM_TX
' AUTOMATIC SWITCHING MODALITY
MSG = $22
SEROUT COM_IN_TX, COM_SPEED, [MSG]
SERIN COM_IN_RX, COM_SPEED, 1000, MAIN_CONTROL, [MSG]
IF MSG <> $55 THEN GOTO MAIN_CONTROL
GOSUB VR_Wakeup
GOSUB VR_SetLanguage
SEROUT COM_IN_TX, COM_SPEED, [MSG]
GOTO PROGRAMMING
MAIN_CONTROL:
DEBUG CR, "ROBOT CONTROL"
DEBUG CR, "Wake Up Voice Module"
GOSUB VR_Wakeup
DEBUG CR, "Voice Module Waked up"
GOSUB VR_SetLanguage
'VRA1 = 255
VRA1 = 5
GOSUB VR_SetTimeout
'start with trigger
WS = WST
MAIN_LOOP:
  LOW PIN_LED
  DEBUG CR, "Wait for "
  SELECT WS
  CASE 0
    DEBUG "TRIGGER"
  CASE 1
    DEBUG "G1"
    HIGH PIN_LED
  CASE 2
    DEBUG "G2"
    PAUSE 150
    HIGH PIN_LED
  CASE 3
    DEBUG "G3"
    PAUSE 150
    HIGH PIN_LED
  ENDSELECT
  'Wait for command
  VRA1 = WS
  GOSUB VR_Recognize
  RXC = VRA1
  LOW PIN_LED
  IF RXC < G1_Timeout THEN
    'Perform action and cycle
    GOSUB ACTION
    GOTO MAIN_LOOP
' Handle errors
  ELSEIF RXC = WS_Timeout THEN
    DEBUG CR, "Timeout"
  ELSE'IF RXC = G1_Error THEN
    DEBUG CR, "Error"
  ENDIF
   WS = WST
  GOTO MAIN_LOOP
  END
' Main END

ACTION:
  SELECT WS
   CASE WST
      WS = G1
      IF RXC > 0 THEN
        DEBUG CR, "Custom Trigger"
      ENDIF
  CASE G1
    RXC_PREV = RXC
    WS = WST
    SELECT RXC
    CASE G1_FORWARD 'FORWARD
      DEBUG CR, "FORWARD"
      WS = G2
    CASE G1_BACKWARD 'BACKWARD
      DEBUG CR, "BACKWARD"
      WS = G2
    ENDSELECT
  CASE G2
    SELECT RXC
    CASE G2_Left 'LEFT
      DEBUG CR, "Left"
      IF RXC_PREV = G11_FORWARD THEN ' FORWARD
        GOSUB TURN_LEFT
      ELSEIF RXC_PREV = G1_BACKWARD  THEN 'BACKWARD
        GOSUB SPIN_LEFT
      ENDIF
  CASE G3
    DEBUG CR, "Number ", DEC RXC
        WS = WST
  ENDSELECT
  RETURN
 ' Wake up:
VR_Wakeup:
  TOGGLE VRLED
  VRA = CMD_BREAK
  SEROUT COM_TX, COM_SPEED, [VRA]
  SERIN COM_RX, COM_SPEED, 100*COM_10MS, VR_Wakeup, [VRA]
  IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
  LOW VRLED
  RETURN
 ' Inputs:
'   VRA1 = language index (0 = english, ...)
VR_SetLanguage:
  VRA = CMD_LANGUAGE
  SEROUT COM_TX, COM_SPEED, [VRA]
  VRA1 = VRA1 + ARG_ZERO
  SEROUT COM_TX, COM_SPEED, [VRA1]
  SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
  VRA1 = VRA1 - ARG_ZERO
  'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
  RETURN
   ' Inputs:
'   VRA1 = timeout (in ms, 0=forever, 255=default)
VR_SetTimeout:
  VRA = CMD_TIMEOUT
  SEROUT COM_TX, COM_SPEED, [VRA]
  VRA1 = VRA1 + ARG_ZERO
  SEROUT COM_TX, COM_SPEED, [VRA1]
  SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
  VRA1 = VRA1 - ARG_ZERO
  'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
  RETURN
 ' Inputs:
'   VRA1 = SI knob (0=loosest, 2=normal, 4=tightest)
VR_SetKnob:
  VRA = CMD_KNOB
  SEROUT COM_TX, COM_SPEED, [VRA]
  VRA1 = VRA1 + ARG_ZERO
  SEROUT COM_TX, COM_SPEED, [VRA1]
  SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
  VRA1 = VRA1 - ARG_ZERO
  'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
  RETURN
   ' Inputs:
'   VRA1 = SD level (1=easy, 2=default, 5=hard)
VR_SetLevel:
  VRA = CMD_LEVEL
  SEROUT COM_TX, COM_SPEED, [VRA]
  VRA1 = VRA1 + ARG_ZERO
  SEROUT COM_TX, COM_SPEED, [VRA1]
  SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
  VRA1 = VRA1 - ARG_ZERO
  'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
  RETURN
' Inputs:
'   VRA1 = wordset (0=trigger)
' Ouputs:
'   VRA1 = result (0-31=word, 32..=builtin, 253=comm err, 254=timeout, 255=error)
VR_RecognizeSI:
  VRA = CMD_RECOG_SI
  GOTO VR_Recognize0
VR_RecognizeSD:
  VRA = CMD_RECOG_SD
VR_Recognize0:
  SEROUT COM_TX, COM_SPEED, [VRA]
  ' send Group/WS
  VRA1 = VRA1 + ARG_ZERO
  SEROUT COM_TX, COM_SPEED, [VRA1]
  ' wait for answer
  SERIN COM_RX, COM_SPEED, 600*COM_10MS, VR_CommFailed, [VRA]
  IF VRA = STS_RESULT THEN
    ' send ack
    VRA = ARG_ACK
    SEROUT COM_TX, COM_SPEED, [VRA]
    ' wait for recognised command code
    SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA1]
    VRA1 = VRA1 - ARG_ZERO
  ELSEIF VRA = STS_SIMILAR THEN
    ' send ack
    VRA = ARG_ACK
    SEROUT COM_TX, COM_SPEED, [VRA]
    ' wait for recognised command code
    SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA1]
    VRA1 = VRA1 - ARG_ZERO + RES_BUILTIN
  ELSEIF VRA = STS_TIMEOUT THEN
    VRA1 = RES_TIMEOUT
  ELSE
    VRA1 = RES_ERROR
  ENDIF
  RETURN
VR_CommFailed:
  VRA1 = RES_COMMFAIL
  RETURN
FORWARD:
  'DEBUG CR, "Robot Forward"
  FOR counter = 1 TO 50
    PULSOUT LServo, 1000
    PULSOUT RServo, 500
    PAUSE 20
  NEXT
  RETURN
BACKWARD:
  'DEBUG CR, "Robot Backward"
  FOR counter = 1 TO 50
    PULSOUT LServo, 500
    PULSOUT RServo, 1000
    PAUSE 20
  NEXT
  RETURN
SPIN_RIGHT:
  'DEBUG CR, "Robot Spin right"
  FOR counter = 1 TO 50
    PULSOUT LServo, 1000
    PULSOUT RServo, 1000
    PAUSE 20
  NEXT
  RETURN
SPIN_LEFT:
  'DEBUG CR, "Robot Spin left"
  FOR counter = 1 TO 50
    PULSOUT LServo, 500
    PULSOUT RServo, 500
    PAUSE 20
  NEXT
  RETURN
TURN_LEFT:
  'DEBUG CR, "Robot Turn Left"
  FOR counter = 1 TO 85
    PULSOUT LServo, 750
    PULSOUT RServo, 500
    PAUSE 20
  NEXT
  RETURN
TURN_RIGHT:
  'DEBUG CR, "Robot Turn Right"
  FOR counter = 1 TO 85
    PULSOUT LServo, 1000
    PULSOUT RServo, 750
    PAUSE 20
  NEXT
  RETURN
PROGRAMMING:
  'DEBUG CR, "VOICE PROGRAMMING"
  ' COM IN Parameters  - PC serial port
  COM_IN_RX   CON   16   ' rx pin
  COM_IN_TX   CON   16   ' tx pin
  ' COM Parameters  - Voice Module port
  COM_OUT_RX  CON   COM_RX   ' rx pin
  COM_OUT_TX  CON   COM_TX   ' tx pin
  COM_TIMEOUT CON   5000
  ' Protocol Command
  CMD_SEND           CON   1 ' send request
  CMD_SEND_RECEIVE   CON   2 ' send and receive request
  CMD_RECEIVE        CON   3 ' receive request
  CMD_LED            CON   4 ' receive request
  CMD_SET_LANG       CON   5 ' receive request
  CMD_GET_LANG       CON   6 ' receive request

  CODE_ERROR         CON  48  ' 0x30
  CODE_ACK           CON  32  ' 0x20
  MSG VAR Byte
  LOW PIN_LED
  PROGRAMMING_MAIN_LOOP:
    ' wait for a byte on input COM
    SERIN COM_IN_RX, COM_SPEED, [MSG]
    ' send back Echo
    SEROUT COM_IN_TX, COM_SPEED, [MSG]
    SELECT MSG
      CASE CMD_SEND ' send request
        ' wait for the byte to send
        SERIN COM_IN_RX, COM_SPEED, COM_TIMEOUT, RX_ERROR, [MSG]
        ' send the byte to output COM
        SEROUT COM_OUT_TX, COM_SPEED, [MSG]
        ' send back Echo
        SEROUT COM_IN_TX, COM_SPEED, [MSG]
      CASE CMD_SEND_RECEIVE ' send and receive request
        ' wait for the byte to send
        SERIN COM_IN_RX, COM_SPEED, COM_TIMEOUT, RX_ERROR, [MSG]
        ' send back Echo
        SEROUT COM_IN_TX, COM_SPEED, [MSG]
        ' light?
        IF VRLED = 1 THEN HIGH PIN_LED
        ' send the byte to output COM
        SEROUT COM_OUT_TX, COM_SPEED, [MSG]
        ' wait for a byte on output COM
        SERIN COM_OUT_RX, COM_SPEED, [MSG]
        ' light?
        IF VRLED = 1 THEN LOW PIN_LED
        ' send the byte to input COM
        SEROUT COM_IN_TX, COM_SPEED, [MSG]
      CASE CMD_RECEIVE ' receive request
        MSG = CODE_ACK
        ' send a byte request to output COM
        SEROUT COM_OUT_TX, COM_SPEED, [MSG]
        ' wait for a byte on output COM
        SERIN COM_OUT_RX, COM_SPEED, COM_TIMEOUT, RX_ERROR, [MSG]
        ' send the byte to input COM
        SEROUT COM_IN_TX, COM_SPEED, [MSG]
      CASE CMD_LED ' LED request
       ' wait for the status byte
        SERIN COM_IN_RX, COM_SPEED, COM_TIMEOUT, RX_ERROR, [MSG]
        IF MSG = "0" THEN
         'LED OFF
          LOW PIN_LED
          VRLED = 0
        ELSE
          'LED ON
          'HIGH PIN_LED 'postpone to next cmd
          VRLED = 1
        ENDIF
        ' send back Echo
        SEROUT COM_IN_TX, COM_SPEED, [MSG]
     CASE CMD_SET_LANG ' set language on EEPROM
        ' wait for the byte to store
        SERIN COM_IN_RX, COM_SPEED, COM_TIMEOUT, RX_ERROR, [MSG]
        WRITE VAR_LANG, MSG
        ' send back Echo
        SEROUT COM_IN_TX, COM_SPEED, [MSG]
     CASE CMD_GET_LANG ' set language on EEPROM
        ' wait for the byte to store
        READ VAR_LANG, MSG
        ' send back Echo
        SEROUT COM_IN_TX, COM_SPEED, [MSG]
     CASE ELSE
        GOTO RX_ERROR
    ENDSELECT
    GOTO PROGRAMMING_MAIN_LOOP

RX_ERROR:
  MSG = CODE_ERROR
  SEROUT COM_IN_TX, COM_SPEED, [MSG]
  GOTO PROGRAMMING_MAIN_LOOP

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-04-26 18:42
    zainab1421 wrote: »
    any one know we is the wrong in these codes ?
    when i run it they said (label missing with ws = wst )

    Could it be something to do with neither ws nor wst ever getting declared as a VAR or a CON ?
  • Hal AlbachHal Albach Posts: 747
    edited 2013-04-26 18:49
    It appears that you have not defined what WS and WST are. You are treating them like variables so you need to define them as such. Probably a few others further down, too.
  • zainab1421zainab1421 Posts: 17
    edited 2013-04-26 23:54
    How I can to define it ?
  • zainab1421zainab1421 Posts: 17
    edited 2013-04-26 23:56
    Ws and wst

    It's wordset and word set trigger
    I define
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-04-27 05:07
    A program cannot have a line like: A = B
    without having declared A as a VAR beforehand.
    Likewise, B has to be declared a VAR (or a CONST).
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-27 06:48
    "How I can to define it?"

    These are basic concepts. If you don't understand, then you need to spend some time learning basic concepts. "What's a Microcontroller?" and "BASIC Stamp Syntax and Reference Manual" are generally the starting points for this.
  • PublisonPublison Posts: 12,366
    edited 2013-04-27 16:25
    I counted at least seven variables that were not declared.

    WS
    WST
    RXC
    G1_Timeout
    G1
    RXC_PREV
    G2

    Are they Byte or Words?

    As in :

    WS VAR Byte

    I stopped counting. There are many.
  • zainab1421zainab1421 Posts: 17
    edited 2013-04-29 04:36
    G1 mean group 1

    Ws mean wordset

    Wst mean wordset trigger
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-04-29 05:39
    Stop reacting, Read Reply #2, #6.
  • Hal AlbachHal Albach Posts: 747
    edited 2013-04-29 06:39
    G1 mean group 1

    Ws mean wordset

    Wst mean wordset trigger

    Really?????

    This is NOT defining a variable!
    As Mike Green has told you, this is a basic programming concept. You really need to study up on how to program. Throwing words at a Basic Stamp is not programming. Just so you know, to define a variable means the following:

    1) a variable name, followed by...
    2) the term VAR, followed by...
    3) the type of variable (bit, nibble, byte, word)

    Putting 1,2,3 together;
    
    WS     VAR     Byte
    
    Although not required, a following comment to describe how the variable is used is very important. The apostrophe ( ' ) begins a comment.
    WS      VAR      Byte           ' WordSet used for blah blah blah
    

    Now the compiler knows what WS is and sets aside a byte of memory called WS. This defining process is required for ALL variables you use in your program. The variable type is determined by the largest number the variable will hold.
  • zainab1421zainab1421 Posts: 17
    edited 2013-04-29 06:40
    pj allen very rude

    if you need to help start first to know
    how to speak with people !
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-29 06:59
    PJ is not at all rude. He's annoyed that you've already been given advice and, based on your replies, you don't seem to have taken it.

    Please keep in mind that this is a message forum, not a school, not a lecture, etc. You ask questions. Various other people, out of the goodness of their hearts, give advice, most of it good, occasionally not. You are expected to pay attention to it, follow it for the most part ... since it's usually been found to be helpful. Mostly, you are expected to do some work, whether that's the reading of reference books and articles, the working out of examples in some of the texts, etc. We will not / cannot do the work for you. If you're unwilling to do the work, and, by your answers, show that it's so, you'll find that we stop providing suggestions and answers. PJ has less tolerance than some of us for this sort of thing.
  • zainab1421zainab1421 Posts: 17
    edited 2013-04-29 09:27
    Relax mike the words not for you
    And pj can answer what I told him
    I don't talk to you

    And your help not clear by the way just you give us what the same what we have in the manual
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-29 09:38
    Unfortunately, from your questions, it appears that you have not understood what is taught in the manuals, particularly the ones I've mentioned already. It's not our job to teach you the fundamentals of how to use a Stamp and how to program using Parallax Stamp Basic. Parallax has already spent lots of time and energy in writing these manuals and there's no point in duplicating the effort. For some people with other programming experience, it may be enough to read the manuals. For others, you really have to work through the examples provided. That's why they're there.

    Good luck with your project.
  • zainab1421zainab1421 Posts: 17
    edited 2013-04-30 07:49
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' COM Parameters
    COM_RX              PIN   0   ' rx pin
    COM_TX              PIN   2   ' tx pin
    COM_SPEED           CON   84  ' baud 9600
    COM_10MS            CON   10  ' 10ms unit
    ' Protocol Command
    CMD_BREAK           CON   "b" ' abort recog or ping
    CMD_SLEEP           CON   "s" ' go to power down
    CMD_KNOB            CON   "k" ' set si knob <1>
    CMD_LEVEL           CON   "v" ' set sd level <1>
    CMD_LANGUAGE        CON   "l" ' set si language <1>
    CMD_TIMEOUT         CON   "o" ' set timeout <1>
    CMD_RECOG_SI        CON   "i" ' do si recog from ws <1>
    CMD_RECOG_SD        CON   "d" ' do sd recog at group <1> (0 = trigger mixed si/sd)
    ' Protocol Status
    STS_AWAKEN          CON   "w" ' back from power down mode
    STS_ERROR           CON   "e" ' signal error code <1-2>
    STS_INVALID         CON   "v" ' invalid command or argument
    STS_TIMEOUT         CON   "t" ' timeout expired
    STS_INTERR          CON   "i" ' back from aborted recognition (see 'break')
    STS_SUCCESS         CON   "o" ' no errors status
    STS_RESULT          CON   "r" ' recognised sd command <1> - training similar to sd <1>
    STS_SIMILAR         CON   "s" ' recognised si <1> (in mixed si/sd) - training similar to si <1>
    ' Protocol arguments are in the range 0x40 (-1) TO 0x60 (+31) inclusive
    ARG_MIN             CON   64 ' 0x40
    ARG_MAX             CON   96 ' 0x60
    ARG_ZERO            CON   65 ' 0x41
    ARG_ACK             CON   32 ' 0x20    'TO READ more status arguments
    'Groups and Commands
    GROUP_1             CON   1    '(Command count: 5)
    G1_FORWARD                          CON   0
    G1_BACKWARD                         CON   1
    G1_LEFT                             CON   2
    G1_RIGHT                            CON   3
    G1_ROTATE_RIGHT                     CON   4
    RES_ERROR           CON 255
    RES_TIMEOUT         CON 254
    RES_COMMFAIL        CON 253
    RES_BUILTIN         CON 32
    
    'Robot Constant
    VRLED               PIN   4
    'Global Variable
    VRA                 VAR   Byte
    VRA1                VAR   Byte
    VRGROUP             VAR   Byte
    VRCOMMAND           VAR   Byte
    ' Main Start
      INPUT COM_RX
      HIGH COM_TX
    Restart:
      LOW VRLED
      VRGROUP = 0
      DEBUG CR, "Setting up VRbot... "
      'Wake up or stop recognition
      GOSUB VR_Wakeup
      DEBUG "awake... "
      'Set SI Language
      VRA1 = 0
      GOSUB VR_SetLanguage
      DEBUG "language ", DEC VRA1, "... "
      'Set 5 seconds timeout
      VRA1 = 5
      GOSUB VR_SetTimeout
      DEBUG "timeout ", DEC VRA1, "... "
      DEBUG CR, "VRbot ready!"
    VR_Loop:
      DEBUG CR, "VRbot in group ", DEC VRGROUP, " waiting for command... "
      LOW VRLED
      PAUSE 150
      IF VRGROUP > 0 THEN HIGH VRLED
      VRA1 = VRGROUP
      GOSUB VR_RecognizeSD
      '-- handle errors or timeout
      IF VRA1 = RES_ERROR THEN
        DEBUG "error"
        'try again in the same group
        GOTO VR_Loop
      ENDIF
      IF VRA1 = RES_TIMEOUT THEN
        DEBUG "timed out"
        VRGROUP = 0 ' back to trigger
        GOTO VR_Loop
      ENDIF
      IF VRA1 = RES_COMMFAIL THEN
        DEBUG "comm failed"
        'resync and try again
        GOSUB VR_Wakeup
        GOTO VR_Loop
      ENDIF
      '-- got a command
      VRCOMMAND = VRA1
      IF VRCOMMAND <= RES_BUILTIN THEN GOSUB VR_Action
      GOTO VR_Loop
    VR_Action:
      DEBUG "got ", DEC VRCOMMAND
      SELECT VRGROUP
        CASE GROUP_1
          SELECT VRCOMMAND
            CASE G1_FORWARD
             PAUSE 0 '-- write your code here
            CASE G1_BACKWARD
             PAUSE 0 '-- write your code here
            CASE G1_LEFT
             PAUSE 0 '-- write your code here
            CASE G1_RIGHT
             PAUSE 0 '-- write your code here
            CASE G1_ROTATE_RIGHT
             PAUSE 0 '-- write your code here
          ENDSELECT
      ENDSELECT
      RETURN
    '=== VR Routines ===
    ' Wake up:
    VR_Wakeup:
      TOGGLE VRLED
      VRA = CMD_BREAK
      SEROUT COM_TX, COM_SPEED, [VRA]
      SERIN COM_RX, COM_SPEED, 100*COM_10MS, VR_Wakeup, [VRA]
      IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      LOW VRLED
      RETURN
    ' Inputs:
    '   VRA1 = language index (0 = english, ...)
    VR_SetLanguage:
      VRA = CMD_LANGUAGE
      SEROUT COM_TX, COM_SPEED, [VRA]
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
      VRA1 = VRA1 - ARG_ZERO
      'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      RETURN
    ' Inputs:
    '   VRA1 = timeout (in ms, 0=forever, 255=default)
    VR_SetTimeout:
      VRA = CMD_TIMEOUT
      SEROUT COM_TX, COM_SPEED, [VRA]
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
      VRA1 = VRA1 - ARG_ZERO
      'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      RETURN
    ' Inputs:
    '   VRA1 = SI knob (0=loosest, 2=normal, 4=tightest)
    VR_SetKnob:
      VRA = CMD_KNOB
      SEROUT COM_TX, COM_SPEED, [VRA]
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
      VRA1 = VRA1 - ARG_ZERO
      'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      RETURN
    ' Inputs:
    '   VRA1 = SD level (1=easy, 2=default, 5=hard)
    VR_SetLevel:
      VRA = CMD_LEVEL
      SEROUT COM_TX, COM_SPEED, [VRA]
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA]
      VRA1 = VRA1 - ARG_ZERO
      'IF (VRA <> STS_SUCCESS) THEN GOTO VR_Wakeup
      RETURN
    ' Inputs:
    '   VRA1 = wordset (0=trigger)
    ' Ouputs:
    '   VRA1 = result (0-31=word, 32..=builtin, 253=comm err, 254=timeout, 255=error)
    VR_RecognizeSI:
      VRA = CMD_RECOG_SI
      GOTO VR_Recognize0
    VR_RecognizeSD:
      VRA = CMD_RECOG_SD
    VR_Recognize0:
      SEROUT COM_TX, COM_SPEED, [VRA]
      ' send Group/WS
      VRA1 = VRA1 + ARG_ZERO
      SEROUT COM_TX, COM_SPEED, [VRA1]
      ' wait for answer
      SERIN COM_RX, COM_SPEED, 600*COM_10MS, VR_CommFailed, [VRA]
      IF VRA = STS_RESULT THEN
        ' send ack
        VRA = ARG_ACK
        SEROUT COM_TX, COM_SPEED, [VRA]
        ' wait for recognised command code
        SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA1]
        VRA1 = VRA1 - ARG_ZERO
      ELSEIF VRA = STS_SIMILAR THEN
        ' send ack
        VRA = ARG_ACK
        SEROUT COM_TX, COM_SPEED, [VRA]
        ' wait for recognised command code
        SERIN COM_RX, COM_SPEED, 20*COM_10MS, VR_CommFailed, [VRA1]
        VRA1 = VRA1 - ARG_ZERO + RES_BUILTIN
      ELSEIF VRA = STS_TIMEOUT THEN
        VRA1 = RES_TIMEOUT
      ELSE
        VRA1 = RES_ERROR
      ENDIF
      RETURN
    VR_CommFailed:
      VRA1 = RES_COMMFAIL
      RETURN
    
    '--------------------------------
    'Sub Routines
    '--------------------------------
    pulseCount VAR Byte
    ' robot move forward
    forward :
      FOR pulseCount = 0 TO 100
        PULSOUT 13,850
        PULSOUT 12,650
        PAUSE 20
      NEXT
    RETURN
    
    ' robot move backward
    backward :
      FOR pulseCount = 0 TO 100
        PULSOUT 13,650
        PULSOUT 12,850
        PAUSE 20
      NEXT
    RETURN
    ' robot turn left
    left :
      FOR pulseCount = 0 TO 100
        PULSOUT 13,650
        PULSOUT 12,650
        PAUSE 20
      NEXT
    RETURN
    ' robot turn right
    right  :
      FOR pulseCount = 0 TO 100
        PULSOUT 13,850
        PULSOUT 12,850
        PAUSE 20
      NEXT
    RETURN
    
     ' robot turn rotate right
    rotate_right :
      FOR pulseCount = 0 TO 100
        PULSOUT 13,750
        PULSOUT 12,750
        PAUSE 20
      NEXT
    RETURN
    



    this is my code and everythings right
    when i run it its run

    but when i talk to the robot to move forward its not moving

    say it module

    any help ?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-04-30 19:41
    I HIGHLY suggest taking both Mike and PJ's advice. PJ is not rude, he is stating the obvious. There are MANY people on this forum that will literally bend over backwards to help you out but you must be willing to help yourself and do some of the leg work. As you can see, no one has chimed back in to help out. Both PJ and Mike have been around a long time and I must say I agree with what they have told you.
  • ajwardajward Posts: 1,130
    edited 2013-05-01 07:48
    zainab1421 wrote: »
    any one know we is the wrong in these codes ?

    when i run it they said (label missing with ws = wst )

    Hi zainab1421,

    To answer your first question...

    I compared your version of the Maker Shed BS2 demo code to the original. You are, most likely, getting the error "label missing with ws = wst" because you removed the lines
    "WS VAR Byte"
    and
    "WST CON 0 ' wordset trigger" from the program. Additionally, you removed quite a number of other CON assignments from the demo code. Just curious as to why?

    Some observations:

    Did you try to run the unmodified demo code on a Boe Bot before you made all those changes? If so and it didn't work then, perhaps you should have directed your questions to Maker Shed.
    If you didn't, I suggest you try that. Also recheck the wiring... it can look correct many times before you spot an error.

    Next, spend some quality time with the Say It documentation. Also reviewing "Robotics with the Boe Bot", "What's a Microcontroller" and "Basic Stamp Syntax and Reference Manual" certainly can't hurt. (All available online)

    Lastly, after looking at all the changes you made, I should remind you of one the primary considerations in computer programming, "Computers do what you tell them to do, not what you want them to do".

    Good luck!

    Amanda
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-05-13 08:08
    Hello,

    I have removed 1 of 2 duplicate threads on this subject (another moderator already got the other one). Please keep your posts about the same subject within the same thread. Also, you should use a descriptive subject line in your posts. A subject like, "Help" doesn't really indicate what you need help with.
Sign In or Register to comment.