go away spammer

Author Topic: Voice Controlled Robot not responding to commands  (Read 5530 times)

0 Members and 1 Guest are viewing this topic.

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Voice Controlled Robot not responding to commands
« on: November 10, 2011, 12:24:11 PM »
This project has been full of it's challenges. I guess I should have picked the $50 as my first robot lol.

Anyway, following the Voice Controlled Robot instructible posted by Admin on Instructibles.com, I was able to build the robot and program the Axon II (via demo hex file uploaded from AVR studio) with the Easy VR (via Commander software and FTDI breakout board).

As far as I can tell, AVR studio loaded the Axon through the hardware programmer fine. No errors. Lots of "Ok!"s. And in the Commander software, I was able to hook it up to the Easy VR and verbally test the voice commands (which tested perfectly). Once I disconnected the robot from my computer however, my voice commands do not seem to do anything to turn the servos of the robot.

I have my left and right servos connected into B5 and B7 of the Axon II...the UART from the EasyVR is connected into U2 (tx to rx, rx to tx)...battery is connected to BAT...

Any ideas why this thing isnt working?

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #1 on: November 11, 2011, 01:46:22 AM »
Set up an LED to flash with a voice command, and see what happens.

Also, see if anything comes out the USB port using Hyperterminal - both when the robot turns on and when commands are spoken.

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #2 on: November 11, 2011, 11:12:22 AM »
Ok, my hyperminal is a trial version. Not sure how to use it just yet. But I can do more research.

As far as setting up an LED to test the voice command, could you give me some instruction on how to do that?

Thank you for all your time! I am so close to finishing this thing...

Mike

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #3 on: November 11, 2011, 11:26:46 AM »
As far as setting up an LED to test the voice command, could you give me some instruction on how to do that?
Look at the source code, it'll be obvious after about 5 minutes of staring at it :P

(if you still aren't sure, post your best guess code here and I'll give you more hints)

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #4 on: November 11, 2011, 11:34:15 AM »
Are you trying to make me earn my grade?! HAHA! Ok cool man. Thanks!

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #5 on: November 26, 2011, 05:00:20 PM »
Ok, well I have taken a bit of time off from this to do other projects that were due. The robot is still unresponsive. This is how I programmed it:

I took the provided Axon II demo source code and loaded it to AVR Studio. I compiled it, making a hex file. After compiling with no errors, I loaded the hex file to the AVR Hardware Programmer. This is what I read:

Reading FLASH input file.. OK
Setting mode and device parameters.. OK!
Entering programming mode.. OK!
Erasing device.. OK!
Programming FLASH ..


then:

Getting isp parameter.. SD=0x06 .. OKOK
OK!
Reading FLASH ..      OK!
FLASH contents is equal to file.. OK
Leaving programming mode.. OK!   


I am guessing that my Axon is properly loaded now. Hyperterminal does not work on my computer, and according to the Instructible, this should suffice for programming my Axon to run the basic VR program (servo left, right, forward, etc).

Finally, I hooked the EasyVR up to my computer USB and programmed new commands using VR Commander. I followed the provided Axon source code and put each command to it's appropriate number. I tested the commands as it was all connected and everything worked. I didnt erase the stock default commands, but Commander does not allow you to. None of them correspond to the source code anyway.

Well, once I hooked the robot up, the robot was unresponsive. It doesnt respond to any of the commands, including "LED" as you had recommended. My battery is fully charged (as I had to buy a charger for the battery). The green status LED is on, as well as the red power lamp.

So, what can I do now?

Mike




Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #6 on: November 26, 2011, 10:47:43 PM »
You need to set up a means to debug the robot.

If it's "not working", you need to figure out what specific parts of the code are and aren't. To do this, you need to get HyperTerminal working on your computer, or at least program the code to flash an LED at each step of the code.

This will help you narrow down exactly what the problem is.

-----------

Slightly unrelated; when the VRbot is hooked up directly to your computer, you verified that it was responding properly to your voice commands, right? Can you upload a screenshot of it?

Did you make any modifications to my code?

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #7 on: November 27, 2011, 09:41:56 PM »
I dont know how to upload a screenshot here.

Regarding your question, I never modified your code. All I did was make the proper changes to the VR Commander software commands to correspond with your source code; ie all commands under Group 2, 0 for English, 3 for left, 4 for right, 5 for forward, 11 for LED.

As far as hyperterminal, i had to get a trial version because I have windows 7 (which does not include hyperterminal). I have no idea how to get it to make a connection. It asks me for an address to dial but I'm clueless as to what that is.

As far as seeing what parts of the code are and are not working....wouldnt I figure that out from compiling the code in AVR studio? It compiles with 0 errors...and seems to upload to the Axon II when I make a connection to my hardware programmer. So what do I need hyperterminal for?


Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #8 on: November 27, 2011, 09:51:47 PM »
wow i'm a dummy...got hyperterminal working....ok, let me troubleshoot a bit...

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #9 on: November 27, 2011, 10:05:27 PM »
ok troubleshooting didnt do anything. My hyperterminal is a mystery to me. So maybe you can answer my questions instead, and we can go from there...I need to get this thing working without hyperterminal unless you have a great tutorial on how to use it with the Axon II...otherwise, I just gotta get it working before saturday (due date)...

Mike

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #10 on: November 27, 2011, 10:09:08 PM »
Here is what you do . . .

In your code, add rprintf statements to have it print to USB (and read by Hyperterminal).

For example:

code_that_does_something();
rprintf("something has been done")
code_that_does_something_else();
rprintf("something else has been done")
turn_left();
rprintf("turning left")
led_turned_on();
rprintf("led turned on")

If you don't see anything printed out, that means that code isn't running.

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #11 on: November 27, 2011, 10:31:23 PM »
First of all, I want to thank you for the help through the past 2 months on this.

To be honest though, when I first took on this project, it was made clear that no programming was required. We just upload your program to AVR Studio, then to the bot, and viola.

Can you please tell me if I programmed my Axon correctly? I specified what I did, yet was only given troubleshooting advice...I just need to know if uploading the compiled hex file from AVR Studio is a proper way to program the Axon II. I know for a fact I programmed my Easy VR module properly, because it tests fine when the software is connected. I know I conected it to the Axon correctly. I know my servos work (tested them with a function generator). Only problem seems to be when I hook the VR module up to the Axon....doesnt seem to be talking to it....

If you want me to do all this troubleshooting and playing around with code, thats fine. I will do that. But I need to know if my initial Axon/AVR programming procedure was correct. If it wasnt, then I can use a different procedure, and save myself more unnecessary hours of troubleshooting on this seemingly simple project...

Mike
« Last Edit: November 27, 2011, 10:37:53 PM by michealcollins »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #12 on: November 27, 2011, 10:45:31 PM »
Quote
I just need to know if uploading the compiled hex file from AVR Studio is a proper way to program the Axon II.
Yeap, that's all you need to do. However if it's not working, something was done wrong and debugging is the best way to narrow it down.

I was just staring at the code for a bit, and remembered that it has both Thai and English. Thai is for the first VR group 1 and English is for the second 2. The code by default sets English (group 2) as the default language. Did you program your VRbot voice commands in the 1st or the 2nd group?

If you put your English commands in the 1st, go to vr_library.h and change this:
uint8_t VR_group=2;//default Group
to this:
uint8_t VR_group=1;//default Group

Save and Rebuild All, and see what happens.

Quote
I dont know how to upload a screenshot here.
Below this text box, look for 'Additional Options...'. It will then have an Attach file button.

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #13 on: November 27, 2011, 10:59:48 PM »
yeah I programmed them in Group 2...

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #14 on: November 27, 2011, 11:04:11 PM »
although....you just brought up a good point in regards to the vr_library.h.....I probably should add that to the compiler huh? lol...lemme go do that....sheesh

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #15 on: November 27, 2011, 11:12:56 PM »
although I'm not sure why my program would have compiled fine without the vr_library.h file...

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #16 on: November 27, 2011, 11:13:24 PM »
hmmmm it wouldn't have compiled if vr_library.h wasn't already included.

Also, I just noticed/remembered that the code already has debugging statements in it. You just need to hook up to hyperterminal and see what it says - no need to add any code.

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #17 on: November 27, 2011, 11:38:42 PM »
Ok I printed a shot of the VR Commander screen and attached it here.

As far as hyperterminal....am I "hooking it up" to the Com port thats connected to my Axon via USB? I have done that...but from there nothing is projecting on the screen...I'm not sure what the heck to do there...

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #18 on: November 27, 2011, 11:42:48 PM »
also...here is a screenshot of the AVR compiler. Maybe you can see if I forgot to include any other *.h or *.c file or something...

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #19 on: November 27, 2011, 11:52:59 PM »
and finally here is all i have for my hyperterminal (screenshot)...I have the USB hooked up to my Axon and have the hyperterminal connected to it (Com3) and running....but not sure what I'm supposed to be seeing on the screen or what I'm supposed to command the hyperterminal to do to see if my Axon is working properly....

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #20 on: November 27, 2011, 11:55:04 PM »
Go here on how to use hyperterminal:
http://www.societyofrobots.com/programming_data_logging.shtml

to see which COM port you are on in XP:
start->settings->control panel->System icon->hardware tab->Device Manager button

Your baud rate is defined for UART1 in Project Designer.

AVR Studio looks fine when you compiled. Your commander stuff looks fine too.

Also, in addition to hyperterminal debugging, let's try out my somewhat improved version of the code. I basically simplified it a few days after I posted that Instructable. It was like 10 months ago so I don't remember, but maybe I even fixed a bug or two.

Use this for your main code. You will need to re-do your voice commands to match up the numbers.
Code: [Select]
//allows for printing with features, but uses more memory
#define RPRINTF_FLOAT
#define RPRINTF_COMPLEX

#include "hardware.h"

#include "VR_library.h" //voice recognition library


// Initialise the hardware
void appInitHardware(void) {
initHardware();


}
// Initialise the software
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){

servosDisconnect(&bank1);

delay_ms(1200);//Axon II bootup time

rprintf("\n\nAxon Initiated\n");

VR_Module_init();

return 0;
}
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

int8_t voice_command=-2;

//start voice recognition (note: it times out)
VR_Module_start_recognition(VR_group);//group B

while(voice_command == -2)
voice_command = VR_Module_get_result();

if(voice_command >= 0)
{
rprintf("\nvoice command is: ");

//turn on servos (I turn off to prevent noise interference)
act_setConnected(&wheel_left, TRUE);
act_setConnected(&wheel_right, TRUE);

//swap languages - not used in this example, as both languages are set to do the same
if(VR_group==1 && voice_command==0)
{
rprintf(" THAI");
VR_group=2;
}
else if(VR_group==2 && voice_command==0)
{
rprintf(" ENGLISH");
VR_group=1;
}

//other commands
else if(voice_command==1)
{
act_setSpeed(&wheel_left,127);
act_setSpeed(&wheel_right,-127);
rprintf(" LEFT");
delay_ms(500);
}
else if(voice_command==2)
{
act_setSpeed(&wheel_left,-127);
act_setSpeed(&wheel_right,127);
rprintf(" RIGHT");
delay_ms(500);
}
else if(voice_command==3)
{
act_setSpeed(&wheel_left,127);
act_setSpeed(&wheel_right,127);
rprintf(" FORWARD");
delay_ms(1500);
}
else if(voice_command==4)
{
rprintf(" DANCE");
//forward
act_setSpeed(&wheel_left,127);
act_setSpeed(&wheel_right,127);
delay_ms(600);
//reverse
act_setSpeed(&wheel_left,127);
act_setSpeed(&wheel_right,127);
delay_ms(600);
//spin right
act_setSpeed(&wheel_left,-127);
act_setSpeed(&wheel_right,127);
delay_ms(1200);
//spin left
act_setSpeed(&wheel_left,127);
act_setSpeed(&wheel_right,-127);
delay_ms(1200);
}
else if(voice_command==5)
rprintf(" WAI PRA");
else if(voice_command==6)
rprintf(" WORSHIP");
else if(voice_command==7)
rprintf(" ARM");
else if(voice_command==8)
rprintf(" ATTACK");
else if(voice_command==9)
{
rprintf(" SHUTDOWN");
servosDisconnect(&bank1);
}
else if(voice_command==10)
{
rprintf(" POWER_UP");
servosConnect(&bank1);
}
else if(voice_command==11)
{
LED_off(&statusLED);
rprintf(" LED");
delay_ms(2000);
LED_on(&statusLED);
}
else if(voice_command==12)
{
act_setSpeed(&elbow,80);
rprintf(" UP");
}
else if(voice_command==13)
{
act_setSpeed(&elbow,-80);
rprintf(" DOWN");
}
else if(voice_command==14)
{
act_setSpeed(&gripper,-50);
rprintf(" GRAB");
}
else if(voice_command==15)
{
act_setSpeed(&gripper,50);
rprintf(" RELEASE");
}

//stop further motion and turn off servos
act_setSpeed(&wheel_left,0);
act_setSpeed(&wheel_right,0);
act_setConnected(&wheel_left, FALSE);
act_setConnected(&wheel_right, FALSE);
}

rprintf("\n");
delay_ms(100);

return 0;
}

/*
Group 1:
0 PASA_THAI
1 LEFT
2 RIGHT
3 FORWARD
4 DANCE
5 WAI PRA
6 WORSHIP
7 ARM
8 ATTACK
9 SHUTDOWN
10 POWER_UP
11 LED
12 UP
13 DOWN
14 GRAB
15 RELEASE

Group 2:
0 PASA_ANGRIT
1 LEO_SAI
2 LEO_KWA
3 DTRONG_BAI
4 DTEN LOY
5 WAI PRA
6 KOWROP BUUCHAA
7 KAEN
8 HAA REUNG
9 BID FAI
10 BERD FAI
11 LED
12 KEUN
13 LONG
14 JAB MAN
15 BLOY MAN
*/

And use this for vr_library.h:
Code: [Select]
//VR Recognition Module for Axon

#define DEFAULT_LANGUAGE 'A'//set to English

//when you program voice commands in the VRbot,
//make sure Thai (or whatever) is in the first group (1)
//and English is in the second group (2)
uint8_t VR_group=2;//default Group


MAKE_WRITER(writerVoice_Recognition)
{
return Voice_RecognitionSendByte(byte);
}


//set language for SI recognition
//Language (A = English, B = Italian, C = Japanese, D = German)
void VR_Module_change_language(char lang)
{
//transmit data to VR module, store previous UART setting
Writer old = rprintfInit(&writerVoice_Recognition);

rprintf("l");//change language
rprintf("%c",lang);

while(Voice_RecognitionGetByte() != 'o')//wait until language changed
delay_ms(20);

rprintfInit(old);//use default output method
}

//initialization, put in software init
void VR_Module_init(void)
{
//bufferFlush(&rx_Voice_Recognition_Buf);
//bufferFlush(&tx_Voice_Recognition_Buf);
uartFlushReceiveBuffer(Voice_Recognition);
uartFlushTransmitBuffer(Voice_Recognition);

rprintf("\nvoice recognition initializing ...");

delay_ms(1000);//required boot up delay

//transmit data to VR module, store previous UART setting
Writer old = rprintfInit(&writerVoice_Recognition);


//wake up
while(Voice_RecognitionGetByte() != 'o')
{
rprintf("b");
delay_ms(300);
}

rprintfInit(old);//use default output method
rprintf(" initialized");
//transmit data to VR module, store previous UART setting
rprintfInit(&writerVoice_Recognition);


//ask for firmware id (not required)
//rprintf("x");
//while(Voice_RecognitionGetByte() != 'x');

//set language
VR_Module_change_language(DEFAULT_LANGUAGE);

rprintfInit(old);//use default output method
rprintf("\nDefault language changed.");
//transmit data to VR module, store previous UART setting
rprintfInit(&writerVoice_Recognition);

//set timeout to 5 seconds
rprintf("o");
rprintf("F");
while(Voice_RecognitionGetByte() != 'o')//wait until changed
delay_ms(20);

rprintfInit(old);//use default output method
rprintf("\nTiming set.");
//transmit data to VR module, store previous UART setting
rprintfInit(&writerVoice_Recognition);

//change knob
rprintf("k");
rprintf("A");//A to E, E being fewer valid results
while(Voice_RecognitionGetByte() != 'o')//wait until changed
delay_ms(20);
//change level
rprintf("v");
rprintf("B");//B to F, F gives least false positives
while(Voice_RecognitionGetByte() != 'o')//wait until changed
delay_ms(20);

rprintfInit(old);//use default output method
rprintf("\nSensitivity set.");
//transmit data to VR module, store previous UART setting
rprintfInit(&writerVoice_Recognition);

rprintfInit(old);//use default output method

rprintf("\n.....initialized.");
}


//start voice recognition (0-3)
void VR_Module_start_recognition(uint8_t group)
{
char number='B';

rprintf("\nvoice recognition activating...");

//transmit data to VR module, store previous UART setting
Writer old = rprintfInit(&writerVoice_Recognition);

if(group==0)//trigger
number='A';
else if(group==1)//1-15, generic
number='B';
else if(group==2)
number='C';
else if(group==3)
number='D';
else if(group==16)//16, password
number='Q';


rprintf("d");
rprintf("%c",number);

rprintfInit(old);//use default output method

rprintf("\n..... group %d activated.",group);
}


//gets result of voice recognition
// -1 = timed out, no word detected
// -2 = no word detected yet within time limit
// any other value represents detect word
//note: may take several seconds before result is returned
int8_t VR_Module_get_result(void)
{
char data = Voice_RecognitionGetByte();

//no data received
if ((uint8_t)data == -1)
return -2;

//if positive result
else if (data == 'r')
{
rprintf("\ngot positive result");

//transmit data to VR module, store previous UART setting
Writer old = rprintfInit(&writerVoice_Recognition);
rprintf(" ");
rprintfInit(old);//use default output method

//wait for returned result
data = Voice_RecognitionGetByte();
while((int8_t)data == -1)
data = Voice_RecognitionGetByte();

return data - 'A';
}

//timed out
else if (data == 't')
{
rprintf("\nvoice detection timed out");
return -1;
}

else if (data == 'e')
{
char error_code=0;

data=-1;//reset value

Writer old = rprintfInit(&writerVoice_Recognition);

//get error code
rprintf(" ");
while((int8_t)data == -1)
data = Voice_RecognitionGetByte();
error_code = (data - 'A') * 16;
rprintf(" ");
while((int8_t)data == -1)
data = Voice_RecognitionGetByte();
error_code = error_code + (data - 'A');


rprintfInit(old);//use default output method

//note that manual actually specifies error codes
rprintf("\nvoice error detected: %c", error_code);
return -1;
}
return -2;
}

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #21 on: November 27, 2011, 11:59:36 PM »
I just remembered you were directly using the .hex file . . . he is the code/.hex file.

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #22 on: November 28, 2011, 12:31:39 AM »
roger that...transmission commencing lol...I will let you know here in a few mins...

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #23 on: November 28, 2011, 12:42:42 AM »
WOOOOHOOOOOO!!!!! Son of a gun. She's alive!!! Thanks man!! Finally...

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #24 on: November 28, 2011, 12:45:57 AM »
Just the new code made it work?

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #25 on: November 28, 2011, 01:03:33 AM »
Yup!

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #26 on: November 28, 2011, 01:04:55 AM »
Not sure if the old code was 'wrong', but all I did was load the new hex you gave me, then reprogram the vr software to match, and viola!

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Voice Controlled Robot not responding to commands
« Reply #27 on: November 28, 2011, 02:34:29 AM »
When you get it to do some neat stuff, be sure to post a video of it working ;D

Offline michealcollinsTopic starter

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 0
Re: Voice Controlled Robot not responding to commands
« Reply #28 on: November 28, 2011, 03:30:28 PM »
Sure thing! Thank you for all your help! Was a great project =)

 


Get Your Ad Here