DFRobotShop Rover Voice controlled

I am working on an older DF Robot project. It is called

Carlitos’ Projects: Speech-Controlled Arduino Robot

My robot functions with other codes but I cannot get the microphone unit to communicate with my my robot. I pulled up the serial monitoring to see if I was outputting the right stuff but it keep throwing a “E” for error. I have everything put together just as the directions say except that I did not use the headset as i could not find the jack for the head set. I have just the “Easy VR 2.0” chip with microphone that it comes with. Any ideas on where I could messed up at that it keeps throwing the error? any help would be appreciated.

Also, I can’t seem to program the arduino if the Xbee Expansion shield is plugged into it. Is that normal?

Welcome to our forums! Can you upload some pictures of your setup so we can see what you’ve done?

For the Xbee shield, that is normal: the Xbee module is connected to the serial pins D0 and D1, which are the ones that are used to upload the code. You can use the switch on the Xbee shield to connect the Xbee module to pins 2 and 3 instead, but then you would need to use the SoftwareSerial library to communicate with the Xbee instead of using the built-in Serial object.

Looking forward to your reply,

Very useful What do you know?
I’m very curious at the right time.

Here are some pics of my project. I have been looking at my project and I am using an Xbee sheild that I got from Radio Shack. But i also have one i for from DFRobot(as it was unavailable on your website) that was supposed to be a replacement for the one I was supposed to use as it was discontinued. I have a picture of them included. The one of the right is the shield that i am trying to use (Radio Shack) because it had the female pin connections for me to put in the LED. The One on the left (DFrobot) only has male pins(not a big deal just inconveinant) but it has a run a program switch on it that the radio shack shield dose not. Dose this make a differance?






i have my voice recognition functioning (I had TX and RX pins wrong. I had them programed as pin 11 and 12 but soldered the board as 12 and 13. Updated the code and it started functioning) i can see the serial print in serial monitor now. But my Xbees do not seem to be communicating. Was there some kind of programing i had to do to these before hand or are they plug and play? I have been fighting this for 2 weeks and is my final project for the semester…which ends next week. Any advice on how to get these XBee’s to start talking to each other?

My XBee units are not equipped with USB ports so i am assuming that they are per-programmed to communicate. Is this a safe assumption?

I have posted pictures and have everything working except communication. I can use the Serial monitor and input the commands “w” “a” “s” “d” and so forth. the rover responds. I have the microphone functioning so that with Serial monitor I can see it print the commands in response to my voice. But Cannot for the life of me get the two to talk to each other. Is there something that i can check to see if they are communicating? The XBees do not have a usb port connection on them. So I haven’t done anything to program them assuming that they would already be programed to talk to each other. Can someone please give me some ideas?

To confirm, you have the half with the Arduino. voice recognition module, microphone working properly and outputting the correct commands?
You also have the half with the DFRobotShop Rover working properly and responding to commands?
Did you check the baud rate at which you are sending and receiving?

(In bold to separate my comments from the code That I am using)
The half with the Arduino Voice recognition module, microphone works. You can see the output of the commands in Serial monitor.
The Rover works, you can control it with the key board in Serial Monitor and send it the commands.
you know what when looking at the code I do not see the baud rate in the Robot code. Without that they will not communicate correct? I used the example code that was with the tutorial. I am not sure exactly how to include this into the robots code. This is what is in the Arduino half for Baud rate:

void VRbot_setup()
{
_baudRate = 9600;
_bitPeriod = 1000000 / _baudRate;
_receivePin = 12;
_transmitPin = 13;
digitalWrite(_transmitPin, HIGH);
delayMicroseconds( _bitPeriod); 
}

unsigned char VRbot_read(void)
{
uint8_t val = 0;
int bitDelay = _bitPeriod - clockCyclesToMicroseconds(100);

// one byte of serial data (LSB first)
// ...--\    /--\/--\/--\/--\/--\/--\/--\/--\/--...
// \--/\--/\--/\--/\--/\--/\--/\--/\--/
//    start  0   1   2   3   4   5   6   7 stop

while (digitalRead(_receivePin));

// confirm that this is a real start bit, not line noise
if (digitalRead(_receivePin) == LOW) {
  // frame start indicated by a falling edge and low start bit
  // jump to the middle of the low start bit
  delayMicroseconds(bitDelay / 2 - clockCyclesToMicroseconds(50));
  
  // offset of the bit in the byte: from 0 (LSB) to 7 (MSB)
  for (int offset = 0; offset < 8; offset++) {
  // jump to middle of next bit
  delayMicroseconds(bitDelay);
  
  // read bit
  val |= digitalRead(_receivePin) << offset;
  }
  
  delayMicroseconds(_bitPeriod);
  
  return val;
}

return -1;
}

void VRbot_write(uint8_t b)
{
if (_baudRate == 0)
  return;
  
int bitDelay = _bitPeriod - clockCyclesToMicroseconds(50); 
byte mask;

digitalWrite(_transmitPin, LOW);
delayMicroseconds(bitDelay);

for (mask = 0x01; mask; mask <<= 1) {
  if (b & mask){ // choose bit
digitalWrite(_transmitPin,HIGH); // send 1
  }
  else{
digitalWrite(_transmitPin,LOW); // send 1
  }
  delayMicroseconds(bitDelay);
}

digitalWrite(_transmitPin, HIGH);
delayMicroseconds(bitDelay);
}

/*******************************************************************************/

unsigned char VRbot_Detect(void) {
unsigned char i;
for (i = 0; i < 5; ++i) {
  delay(100);    
  VRbot_write(CMD_BREAK);    
  if ( VRbot_read() == STS_SUCCESS)
return 255;
}
return 0;
}

unsigned char VRbot_SetLanguage(unsigned char lang) {
  
VRbot_write(CMD_LANGUAGE);
delay(5);
VRbot_write(ARG_ZERO + lang);

if (VRbot_read() == STS_SUCCESS)
  return 255;
return 0;
}

void VRbot_RecognizeSD(unsigned char group) {
VRbot_write(CMD_RECOG_SD);
delay(5);
VRbot_write(ARG_ZERO + group);
}

void VRbot_RecognizeSI(unsigned char ws) {
VRbot_write(CMD_RECOG_SI);
delay(5);
VRbot_write(ARG_ZERO + ws);
}

void VRbot_SetTimeout(unsigned char s) {
VRbot_write(CMD_TIMEOUT);
delay(5);
VRbot_write(ARG_ZERO + s);
delay(5);
}

signed char VRbot_CheckResult(void) {

unsigned char rx;
rx = VRbot_read();
if (rx == STS_SIMILAR || rx == STS_RESULT) {
  delay(5);
  VRbot_write(ARG_ACK);
  return (VRbot_read() - ARG_ZERO);
}
if (rx == STS_TIMEOUT)
  return -1;
  
return -2;
}

How do take this to put it in the Robot side? I have never worked with these XBees before. Can I just take the section about baud rate and place in robot code?
Here is the Code for the Rover Robot. Where should I slide this baud rate in at? Sorry for all the Questions I am very new at this and this is my first Robot attempt.

int E1 = 6; //M1 Speed Control
int E2 = 5; //M2 Speed Control
int M1 = 8; //M1 Direction Control
int M2 = 7; //M2 Direction Control

int LED = 13;

void setup(void)
{
  int i;
  for(i=5;i<=8;i++)
  pinMode(i, OUTPUT);
  pinMode(13, OUTPUT);
  Serial.begin(9600);
}
void loop(void)
{
  while (Serial.available() < 1) {} // Wait until a character is received
  char val = Serial.read();
  int leftspeed = 255; //255 is maximum speed
  int rightspeed = 255;
  switch(val) // Perform an action depending on the command
  {
  case 'w'://Move Forward
  forward (leftspeed,rightspeed);
  break;
  case 's'://Move Backwards
  reverse (leftspeed,rightspeed);
  break;
  case 'a'://Turn Left
  left (leftspeed,rightspeed);
  break;
  case 'd'://Turn Right
  right (leftspeed,rightspeed);
  break;

  case 'l'://LED
  blink_LED();
  break;

  case 'f'://Stop
  stop();
  break;

  default:
  break;
  }
}

void stop(void) //Stop
{
  digitalWrite(E1,LOW);
  digitalWrite(E2,LOW);
}
void forward(char a,char b)
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);
  analogWrite (E2,b);
  digitalWrite(M2,LOW);
}
void reverse (char a,char b)
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);
  analogWrite (E2,b);
  digitalWrite(M2,HIGH);
}
void left (char a,char b)
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);
  analogWrite (E2,b);
  digitalWrite(M2,LOW);
}
void right (char a,char b)
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);
  analogWrite (E2,b);
  digitalWrite(M2,HIGH);
}

void blink_LED ()
{
  digitalWrite(LED, HIGH);
  delay(200);
  digitalWrite(LED, LOW);
  delay(100);
  digitalWrite(LED, HIGH);
  delay(200);
  digitalWrite(LED, LOW);
}

Your first block of code does adjust the baud rate, but that’s the baud rate for the EasyVR board, not the serial Xbee communication. If you see the voice commands in the serial monitor, than this baud rate is properly configured.

For the Xbee communication, you should have some code in your setup() function that does this:

  Serial.begin(9600);

If this is the case, then your serial is using 9600 baud, which is the right speed for the Xbees.

From your pictures, we see that the Xbee shield on your DFRobotShop Rover has its jumpers setup to use pins D2 and D3. I think that might be the problem. Can you try changing the jumpers to use pins D0 for XB_TX and D1 for XB_RX?

If this doesn’t work, we will have to do more testing of the Xbee communication by itself. Let us know how it goes!

Subscribed!

I switched the jumpers so that D0 is now jumpers to TX and D1 to RX. However it dose not seem to change anything. How can I verify that the XBee’s are talking to each other?

To test the Xbee communication, we recommend you upload the PhysicalPixel sample (from File -> Examples -> 04.Communication) on one of your boards, and then upload the following code to the other board:

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.print('H');
  delay(1000);
  Serial.print('L');
  delay(1000);
}

If the communication is working, the board with the PhysicalPixel code should have its pin 13 LED blinking on and off.

More information about using Xbees with Arduino is available here:

We also noticed in your pictures that you’re using the Xbee with U.FL connector but no antennas: that can be causing the problems with communications. We recommend either connecting external antennas or using the Xbee modules with trace antennas.

Hope this helps,

Do you know which communication example that i am supposed to use? there are several under example 04 on the arduino…

Nevermind you told me which one… I must have missed it but i see it now.

I did as recommended with the example communication. With the sender you can see it printing the “HLHLHLH” but nothing is coming to the Reciever. You said that it could be because the WBees did not have antennas? They one I ordered did not come with antennae so i figured they didn’t need them. I thought maybe they were for short range. I guess That i will have to track down a set with antenna…

I tried the suggested test to see if communication is happening and got nothing. I could see the sending unit printing “HLHLH” in the serial monitor but nothing happens on the receiver. I tried some other XBee units and communication still did not happen. These did not have antenna either but They are different…the others are Xbee S1 instead of the S2. They came in a Spark Fun kit. Did they need to be programmed seperatly or would my program already take care of that? I turned my project in today incomplete but still got full credit as each half worked perfectly separately I just can’t them to communicate. The Wireless communication was above and beyond the assignment I just wanted to challenge myself and it certainly has become that.

Do you recommend that i get new XBee units with antenna and see if i can get communication that way?
Thanks for all the help! I still want to get the wireless working just to prove I can now…Still plugging away…

Hey Chey

I also ordered V1 XBee’s for my (unrelated) project. If you still have the package they came sealed in (with a bar-code and a product number), you can tell what antenna style very easily.
WRL-11215 is also product code RB-Spa-772. This transceiver uses a Trace Antenna, and (if you didn’t cut the bag in half like I did, lol) it actually has the full text descriptor on the bag.
Interestingly, in the spec sheet, Trace or mini-monople antenna, regardless they state 100 meter range outside, 30 meters inside. If you look very carefully, and where the XBee module has the two angled edges (ie near Pin 1 & 20 end) you can actually see the 2 solder traces following the angled edge of the module - overcoated in the protective coating (Blue on mine).

I certainly can get reception across a residential basement with the Trace version. unless the distance between halves is significant (> 30 meters), I don’t think getting the monopole whip will solve this. At 2.4 GHz frequency, the antenna length is minuscule anyway.


UPDATE: Oh my bad :frowning:
upon looking at your pictures, you unfortunately have the U.FL version of XBee, which requires an External antenna to be plugged in… that would most likely explain why you have no connectivity. I see that Sparkfun, does state that external antenna is required when they sell the Xbee U.FL versions… too bad they don’t at least include a basic 1/4 wave monopole.
I think you need this: store.digi.com/index.cfm?fuseaction=product.display&Product_ID=2601 Of course if RobotShop has them they could give you the link. They are pretty inexpensive. 1/4 wave U.FL Female, 2.4 GHz monopole.
Since you are rocking the XBee Pro V2, with an antenna attached, you could be looking at some serious range… I’m sure this is overly optimistic, but it gets you anywhere you want to be from your rover:[highlight=#ffffff][font=Helvetica Neue, Helvetica, Arial, sans-serif]
][size=2]1 mile (1500m) range (from vendor’s datasheet)[/size]/:m][/font]
The female U.FL end you want, to get the RF energy off your module, looks like this:

[/highlight]
There seems to be a lot of U.FL cable to other format like SMA , etc which you then attach an antenna to. I wish Digi had a pic of their U.FL 1/4 wave to see if it will work for you.
Hope this helps.

Geoff

Great job Chey on the full points! :smiley:

If you’re looking to get new Xbee modules, we would recommend the same as Polaris did: this model has a trace antenna, so no external antenna is needed.

We unfortunately don’t currently have the Sparkfun-recommended u.FL to RP-SMA cable in our catalogue. We do have two version of u.FL to SMA cables, but we don’t have any SMA antennas for 2.4GHz.

Hope this helps,