need help with program
zainab1421
Posts: 17
any one know we is the wrong in these codes ?
when i run it they said (label missing with ws = wst )
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
Could it be something to do with neither ws nor wst ever getting declared as a VAR or a CON ?
It's wordset and word set trigger
I define
without having declared A as a VAR beforehand.
Likewise, B has to be declared a VAR (or a CONST).
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.
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.
Ws mean wordset
Wst mean wordset trigger
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; Although not required, a following comment to describe how the variable is used is very important. The apostrophe ( ' ) begins a comment.
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.
if you need to help start first to know
how to speak with people !
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.
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
Good luck with your project.
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 ?
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
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.