Shop OBEX P1 Docs P2 Docs Learn Events
Boe-bot with sayit module — Parallax Forums

Boe-bot with sayit module

RL600RL600 Posts: 40
edited 2012-02-17 10:48 in Robotics
Hi all,

Recently I have bought a sayit module, but he isn't working well at the moment.
The day he came in,I have directly connect it to the Boe-bot, for control. It doesn't care what I say, he always turn to the left!!!!
For better control (I thought) I use the servopal, so the sayit can wait for another command while the boe-bot is driving ( maybe I use the pal in the wrong way).
beneath is the code ( I live in the Netherlands, so some of the DEBUG words are in dutch )

I look forward for a reaction.


' {$STAMP BS2px}
' {$PBASIC 2.5}
' COM Parameters
COM_RX PIN 0 ' rx pin
COM_TX PIN 2 ' tx pin
COM_SPEED CON 396 ' baud 9600
COM_10MS CON 25 ' 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>

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_LINKS CON 0
G1_RECKTS CON 1
G1_VOORUIT CON 2
G1_ACHTERUIT CON 3
G1_STA_STIL CON 4
RES_ERROR CON 255
RES_TIMEOUT CON 254
RES_COMMFAIL CON 253
RES_BUILTIN CON 32

'Robot Constant
VRLED PIN 4
nInp PIN 14
Alarm PIN 15
'Global Variable
VRA VAR Byte
VRA1 VAR Byte
VRGROUP VAR Byte
VRCOMMAND VAR Byte

INPUT COM_RX
HIGH COM_TX
Restart:
LOW VRLED
VRGROUP = 1
GOSUB VR_Wakeup
VRA1 = 0
GOSUB VR_SetLanguage
VRA1 = 5
GOSUB VR_SetTimeout
GOSUB SERVOPAL
DEBUG "BOE-BOT is ready!",CR,CR
DEBUG "Group="
VR_Loop:
DEBUG CRSRXY,6,2, DEC VRGROUP
DEBUG CRSRXY ,0,4, "Waiting for command... "
LOW VRLED
PAUSE 150
IF VRGROUP =1 THEN
VRA1 = VRGROUP
GOSUB VR_RecognizeSD
ENDIF
IF VRA1 = RES_ERROR THEN
DEBUG "error "
GOTO VR_Loop
ENDIF
IF VRA1 = RES_TIMEOUT THEN
DEBUG "timed out "
VRGROUP = 1
GOTO VR_Loop
ENDIF
IF VRA1 = RES_COMMFAIL THEN
DEBUG "comm failed "
GOSUB VR_Wakeup
GOTO VR_Loop
ENDIF
VRCOMMAND = VRA1
IF VRCOMMAND <= RES_BUILTIN THEN GOSUB VR_Action
GOTO VR_Loop
VR_Action:
DEBUG CRSRXY,0,5,"RICHTING: "
SELECT VRCOMMAND
CASE 0
DEBUG CRSRXY,14,5," LINKS "
PULSOUT 14,650
PULSOUT 14,650
CASE 1
GOSUB SERVOPAL
DEBUG CRSRXY,14,5," RECHTS "
PULSOUT 14,850
PULSOUT 14,850
CASE 2
GOSUB SERVOPAL
DEBUG CRSRXY,14,5," VOORUIT "
PULSOUT 14,650
PULSOUT 14,850
CASE 3
GOSUB SERVOPAL
DEBUG CRSRXY,14,5," ACHTERUIT "
PULSOUT 14,850
PULSOUT 14,650
CASE 4
GOSUB SERVOPAL
DEBUG CRSRXY,14,5," STAAT STIL "
PULSOUT 14,750
PULSOUT 14,750
ENDSELECT
RETURN
'GOED
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

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

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
SERVOPAL:
INPUT nInp
DO UNTIL nInp=1
LOOP
LOW nInp
PAUSE 100
HIGH nInp
RETURN

VR_RecognizeSD:
VRA = CMD_RECOG_SD
VR_Recognize0:
SEROUT COM_TX, COM_SPEED, [VRA]
VRA1 = VRA1 + ARG_ZERO
SEROUT COM_TX, COM_SPEED, [VRA1]
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





RL600

Comments

  • RL600RL600 Posts: 40
    edited 2012-02-12 10:05
    OOH yes I forgot.
    My question is what chance must be insert so he go the way I say and not go to the left if I don't say that.

    RL600
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2012-02-14 06:39
    Can you describe how you have the Say-It module wired up to your BASIC Stamp? Attaching a picture of your setup may help.

    In order to determine exactly what is going on you'll need to do some more troubleshooting. Can you verify that your BASIC Stamp program can correctly respond to the Say-It module? I would temporarily disconnect the SERVO's and then have your program use the debug command to echo out the responses from the Say-It module. You can try with with the code for the SERVO's left in place and also with it commented out. At least this will tell if the BASIC Stamp is getting what you expect from the module. If the motors aren't running to and it isn't properly then you aren't getting the response you expect from the Say-It module or there is a bug in your code that is always defaulting to left.

    You may want to consider changing 0 to mean 'do nothing' and then any other non zero value to mean that some command was received and act upon that.

    If you aren't getting the proper response when the robot is moving I would ask how close if the Say-It module to the servo's? When a servo is running is can make a lot of noise so that could interfere with the recognition.

    Robert
  • RL600RL600 Posts: 40
    edited 2012-02-17 10:48
    Sorry for the late reaction ( the last week I was on trip, BUT THERE WAS NO INTERNET CONNECTION),

    My connection: the say it module is connected to the black adapter, with the Vss, Vdd,0,2,4,6,8,10,12,14
    the servo's are connected to 14 and 15 with a servopal between (14 is the servopin and 15 is the alarm pin). There are no further connections.
    I have insert a CASE in the code with "do nothing" , but he still go to the left.
    The noise hasn't any influence, because when I run the program you can see where he currently is (in the case) and when I say a command he go to the right case, but go to the left.
    I have filtered the "Robot" command which is the start command, maybe that is the problem!!!!
    I hope the info is good enough.

    RL600
Sign In or Register to comment.