PDA

View Full Version : SayIt Module - Program Help



dehlen
03-03-2012, 11:50 AM
Hey, i have a SayIt Module and the downloadable standard program is working fine.
Anyway i want to have the following commands:
Move forward X feets (0-10)
Move backward X feets(0-10)
Move left X feets (0-10)
Move right X feets (0-10)
Turn left 90,180,270,360 degrees
Turn right 90,180,270,360 degrees
Spin around
Go in Detection Mode

Actually i am very new to PBASIC and i don't know how to program this. I always get an error that my eeprom is full, because my code is very dirty i think.

Could be someone so kind and tell me how to program this ?

Thanks so much.

dehlen
03-03-2012, 12:59 PM
I found this post here: http://forums.parallax.com/showthread.php?106561-Voice-Controlled-Boe-Bot which does pretty much what i want. But i want the boe bot not to drive 5 feeds for example but 5 meters. So how can i change that ? And how do i have to setup my say it module ? Could you please help me ? Thanks

dehlen
03-04-2012, 03:01 PM
Nobody ? Please i really need your help.

skylight
03-04-2012, 03:40 PM
You would need to structure your commands so that you end up with the correct portion of code running at the end of your voice commands
this will involve a lot of voice recording and code portions.written, as there will be so many options. Unfortunately you cannot load a variable with this unit as I assume from your post you wish to do.

dehlen
03-04-2012, 03:57 PM
You mean i can't use wordlists like :
Wordlist 1: Move, Turn
Wordlist 2: Forward, Backward, Left, Right
Wordlist 3: 1,2,3,4,5,6,7,8,9

I have to make i this way: ??
Move Forward 1
Move Forward 2
......
Move Backward 1
....

?

skylight
03-04-2012, 04:05 PM
You mean i can't use wordlists like :
Wordlist 1: Move, Turn
Wordlist 2: Forward, Backward, Left, Right
Wordlist 3: 1,2,3,4,5,6,7,8,9

? Yes you can like that but as you see it will end in several options, what I was saying is you cannot just have one command for example move forward x steps and have the say it module just fill in the variable x

you have to recvord and write all the necessary code and wordlists for all the options you feel you need and it maybe that's why you are running out of space?

dehlen
03-04-2012, 04:08 PM
Ah ok i see your point. Yes because of this number of options i get this "eeprom is full" error.
I don't know how to fix that. I mean look at the link i posted. There is a guy who succeeded with this, so there must be a way to get this working.

Duane Degn
03-04-2012, 04:14 PM
You mean i can't use wordlists like :
Wordlist 1: Move, Turn
Wordlist 2: Forward, Backward, Left, Right
Wordlist 3: 1,2,3,4,5,6,7,8,9

I have to make i this way: ??
Move Forward 1
Move Forward 2
......
Move Backward 1
....

?

You first group of wordlists if the way the SayIt works. You need to program the BS to switch wordlists though.

Usually you'd start with the SayIt listening for the trigger word "Robot". Once it hears "Robot" it knows to listen for more commands.

In you example, when "Robot" is heard, the BS would then switch the SayIt's wordlist to #1. While listening for words in wordlist #1, if the SayIt hears "Move", then your program would switch to wordlist #2 and listen for the direction. Once the direction is heard, the BS would switch the SayIt to wordlist #3 to determine how much to move.

The main thing about all this is the SayIt itself isn't very smart. It doesn't know when to switch to different wordlists on its own; it needs the BS to tell it which wordlist to use.

I see you're new to the forum. Welcome. Have you programmed your robot without the SayIt much? You want to make sure you know how to program the robot to do all these tasks without the SayIt before adding the complication of using the SayIt module as an input device.

You mentioned you're new to PBASIC. You might want to get a little more comfortable with programming before adding the SayIt.

It will also help us help you if you post the code you're working on. Phil made a little tutorial on how to use code tags. Here's the link.

http://forums.parallax.com/attachment.php?attachmentid=78421&d=1297987572 (http://forums.parallax.com/showthread.php?129690&p=978076&viewfull=1#post9780 76)

dehlen
03-04-2012, 04:18 PM
I did exactly what you are describing. My Robot is in the first Wordlist. I say Move and the Robot goes into Wordlist too, because in this VRACTION i change VRGROUP = 2
Then i say the direction and this works fine too and i set VRGROUP = 3 so he listens for the distance variable. But then i think i have to much cases and thats why my eeprom is full.
Wait a minute i will write the code again like i had it and will post it here.

Thanks again !

skylight
03-04-2012, 04:26 PM
look at the link i posted. There is a guy who succeeded with this, so there must be a way to get this working.He used his laptop to decode all the options and then just sent the appropriate command to the boe-bot.

The voice recognition unit talked direct to his laptop whereas the Sayit talks via the boe, you may be able to read the serial data from the sayit into your pc but you would have to write some pc code to utilise this and then send the appropriate command back to the boe-bot.

of course this could be achieved with a mic and voice recognition software also.

dehlen
03-04-2012, 04:26 PM
Here is my code:


' {$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_2 CON 2 '(Command count: 5)
G2_FORWARD CON 0
G2_BACKWARD CON 1
G2_LEFT CON 2
G2_RIGHT CON 3
GROUP_3 CON 3 '(Command count: 10)
G3_1 CON 0
G3_2 CON 1
G3_3 CON 2
G3_4 CON 3
G3_5 CON 4
G3_6 CON 5
G3_7 CON 6
G3_8 CON 7
G3_9 CON 8
G3_10 CON 9


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
VRVARIABLE VAR Byte


' Main Start
INPUT COM_RX
HIGH COM_TX


Restart:
LOW VRLED
VRGROUP = 2


DEBUG CR, "Setting up Robot... "
'Wake up or stop recognition
GOSUB VR_Wakeup
DEBUG "awake... "


'Set SI Language
VRA1 = 3
GOSUB VR_SetLanguage
DEBUG "language ", DEC VRA1, "... "


'Set 5 seconds timeout
VRA1 = 5
GOSUB VR_SetTimeout
DEBUG "timeout ", DEC VRA1, "... "


DEBUG CR, "Robot ready!"


VR_Loop:
DEBUG CR, "Robot 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 = 2 ' 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:
SELECT VRGROUP


CASE GROUP_2
SELECT VRCOMMAND
CASE G2_FORWARD
VRGROUP = 3
VRVARIABLE = 0
CASE G2_BACKWARD
VRGROUP = 3
VRVARIABLE = 1
CASE G2_LEFT
VRGROUP = 3
VRVARIABLE = 2
CASE G2_RIGHT
VRGROUP = 3
VRVARIABLE = 3

ENDSELECT
CASE GROUP_3
SELECT VRCOMMAND
CASE G3_1
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 1"
CASE 1
DEBUG "Move Backward 1"
CASE 2
DEBUG "Move Left 1"
CASE 3
DEBUG "Move Right 1"
ENDSELECT
CASE G3_2
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 2"
CASE 1
DEBUG "Move Backward 2"
CASE 2
DEBUG "Move Left 2"
CASE 3
DEBUG "Move Right 2"
ENDSELECT
CASE G3_3
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 3"
CASE 1
DEBUG "Move Backward 3"
CASE 2
DEBUG "Move Left 3"
CASE 3
DEBUG "Move Right 3"
ENDSELECT
CASE G3_4
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 4"
CASE 1
DEBUG "Move Backward 4"
CASE 2
DEBUG "Move Left 4"
CASE 3
DEBUG "Move Right 4"
ENDSELECT
CASE G3_5
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 5"
CASE 1
DEBUG "Move Backward 5"
CASE 2
DEBUG "Move Left 5"
CASE 3
DEBUG "Move Right 5"
ENDSELECT
CASE G3_6
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 6"
CASE 1
DEBUG "Move Backward 6"
CASE 2
DEBUG "Move Left 6"
CASE 3
DEBUG "Move Right 6"
ENDSELECT
CASE G3_7
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 7"
CASE 1
DEBUG "Move Backward 7"
CASE 2
DEBUG "Move Left 7"
CASE 3
DEBUG "Move Right 7"
ENDSELECT
CASE G3_8
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 8"
CASE 1
DEBUG "Move Backward 8"
CASE 2
DEBUG "Move Left 8"
CASE 3
DEBUG "Move Right 8"
ENDSELECT
CASE G3_9
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 9"
CASE 1
DEBUG "Move Backward 9"
CASE 2
DEBUG "Move Left 9"
CASE 3
DEBUG "Move Right 9"
ENDSELECT
CASE G3_10
SELECT VRVARIABLE
CASE 0
DEBUG "Move Forward 10"
CASE 1
DEBUG "Move Backward 10"
CASE 2
DEBUG "Move Left 10"
CASE 3
DEBUG "Move Right 10"
ENDSELECT
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


Of course instead of the DEBUG commands i would move the robot but for test purposes this is my code. Anyway i always get "eeprom is full" i think because of this high number of CASE commands.

Duane Degn
03-04-2012, 04:31 PM
I mean look at the link i posted. There is a guy who succeeded with this, so there must be a way to get this working.

I just looked at the post you linked to. He was using a computer for the speech recognition. The computer was only sending three variables to the robot. His setup doesn't put much of a burden on the BS2.

I do think the BS2 will be able to use the SayIt to control the BOE-Bot. It might take some careful programming not to use up all its EEPROM. I personally don't program Basic Stamps any more (I'm a Propeller fan) but there are lots of other forum members who could help you squeeze your code into a BS2. I'd suggest starting simple and then add more advanced features once you have the simple stuff working correctly.

skylight
03-04-2012, 04:34 PM
Think of the command structure like the branches of a tree, the more branches you have the more twigs you end up with, the eeprom hasn't the capacity like the hard drive on your pc so if you wish to have all those options then you have to look at storing the structure on your pc rather than using the sayit, otherwise you need to cut down on the command set.

dehlen
03-04-2012, 04:37 PM
ok so if i want all these options it only works when my pc is on ? i could only use the robot whit all these options at home ?
Anyway how could i complete this ?

Duane Degn
03-04-2012, 04:39 PM
Good to see your code.

One thing I noticed was all the strings. Strings take up a lot of memory.

Instead of


DEBUG "Move Forward 6"

use


DEBUG "MF6"

You could alternatively have the string


"Move Forward "

stored only a single time and reuse it in your debug statements and just add a unique ending as needed. I don't know how to do this with a BS2 but I bet others around here do.

I bet there are other memory saving tricks that would help reduce the size of your code. Hopefully other forum members will point them out.

Duane Degn
03-04-2012, 04:44 PM
ok so if i want all these options it only works when my pc is on ? i could only use the robot whit all these options at home ?
Anyway how could i complete this ?

I still think the BS2 can handle this project just fine (without needing a PC). Of course there will be a limit on how many tasks the BS2 can store, but I bet you could get your BOE-Bot to do a lot of stuff if you're careful with your programming.

skylight
03-04-2012, 04:44 PM
The problem I think you'll have is that the sayit module creates a BS2 template rater than talking to your pc via a serial gateway, it would mean that the onboard software on the sayit module would have to be hacked and that is probably something only the designer of the sayit would be able to help you with.
Otherwise it's a case of going down the route like in the link you posted.

Duane Degn
03-04-2012, 04:58 PM
the onboard software on the sayit module would have to be hacked

Do you mean hacking the SayIt's firmware?

The SayIt will work fine independent of the PC. You don't even need a PC to program in custom words. The PC software for the SayIt just sends serial commands to the SayIt module (via the bridge program). A microcontroller could also send these same commands. The PC software just make it more convient to program the custom words in the SayIt by letting the user interact with an easy to use GUI that takes care of sending the proper serial commands for you.

The PC software also generates a PBASIC template to help get you started with the programming process. The template isn't very smart. The user still needs to do a lot of work to make a useful PBASIC program from the template.

This is a great project. The BS2 can do this! It will only need the PC for editing and loading the program. It will not be dependent on the PC when it's roaming around listening for your commands. (Because of servo noise, the BOE-Bot might need to be standing still to hear commands.)

skylight
03-04-2012, 05:03 PM
Do you mean hacking the SayIt's firmware?

The SayIt will work fine independent of the PC. You don't even need a PC to program in custom words. The PC software for the SayIt just sends serial commands to the SayIt module (via the bridge program). A microcontroller could also send these same commands. The PC software just make it more convient to program the custom words in the SayIt by letting the user interact with an easy to use GUI that takes care of sending the proper serial commands for you.

The PC software also generates a PBASIC template to help get you started with the programming process. The template isn't very smart. The user still needs to do a lot of work to make a useful PBASIC program from the template.

This is a great project. The BS2 can do this! It will only need the PC so you can type your program. It will not be dependent on the PC when it's roaming around listening for your commands.Not the way the OP wants to do it, with so many commands and options he is running out of memory, the debug commands he mentioned above I believe are not in his final program but were there to prove the structure was working ok.

The suggestion to hack the firmware was so that it could be used like the speech recognition unit he posted in his link, as it stands the Sayit would not be able to do what he wants unles he cuts back on his command list.

dehlen
03-04-2012, 05:11 PM
Ok i cut the commands to feet 1-5 not from 1-10 and now my eeprom isn't full anymore. Anyway how can i deliver the variable to my method ?
I check the cases and for example i am in the case forward 1 feet. So i write in this case GOSUB MForward

The MForward Method looks like this:

MForward: FOR counter = 1 TO ((var3-48) * 70)
GOSUB Forward
PAUSE 20
NEXT
RETURN


And the Forward method like this:


Forward:
PULSOUT 13, 850
PULSOUT 12, 650

RETURN

But how does the method MForward get the value for var3 ?

Thanks !

Duane Degn
03-04-2012, 05:14 PM
Not the way the OP wants to do it, with so many commands and options he is running out of memory,
<snip>
as it stands the Sayit would not be able to do what he wants unles he cuts back on his command list.

Really? You don't think a BS2 could handle these commands?


Anyway i want to have the following commands:
Move forward X feets (0-10)
Move backward X feets(0-10)
Move left X feets (0-10)
Move right X feets (0-10)
Turn left 90,180,270,360 degrees
Turn right 90,180,270,360 degrees
Spin around
Go in Detection Mode


I just find that hard to believe. As I mentioned, I don't use Basic Stamps anymore but I still think the BS2 could handle this project.

Any other BS2 users around that have an opinion about this? Chris, Mike, Tracy, erco, PJ?

skylight
03-04-2012, 05:16 PM
Anyway how can i deliver the variable to my method ?
The MForward Method looks like this:

MForward: FOR counter = 1 TO ((var3-48) * 70)
GOSUB Forward
PAUSE 20
NEXT
RETURN


And the Forward method like this:


Forward:
PULSOUT 13, 850
PULSOUT 12, 650

RETURN

But how does the method MForward get the value for var3 ?

Thanks !That's what I was saying beforehand you can't insert a value into the vaiable like that.
You will have to record a command for each value of var 3 to do something for each option you would fill in the program code in the template, it's laborius but i'm afraid it's the only way

So to summarize you would have forward code for 1 foot, 2 foot, 3 foot etc.......

you could get the relevant code to say that var 3 is this value but it would still probably have the same amount of commands and code snippets to achieve the same result.

dehlen
03-04-2012, 05:21 PM
i know that the calculations for the FOR Loop is wrong .... i will correct that, but i really need how to deliver var3 to the function.

skylight
03-04-2012, 05:25 PM
Really? You don't think a BS2 could handle these commands?



I just find that hard to believe. As I mentioned, I don't use Basic Stamps anymore but I still think the BS2 could handle this project.

Any other BS2 users around that have an opinion about this? Chris, Mike, Tracy, erco, PJ?I'm not saying the BS2 cannot handle the commands it's more a case of how many commands.

dehlen
03-04-2012, 05:28 PM
oh sorry i got it.... now everything works just fine. Thanks a lot for your help !

skylight
03-04-2012, 05:43 PM
Glad you got it to work.