Porting Elechouse VoiceRecognitionV3 library

Status
Not open for further replies.

mdauria

Member
Hi everyone,

I would like to use a Voice Recognition module from Elechouse with a Teensy 3.2 board :
http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=&products_id=2254

Here is the Github VoiceRecognitionV3 library source :
https://github.com/elechouse/VoiceRecognitionV3

I tested this example with an Arduino Uno :
https://github.com/elechouse/VoiceRecognitionV3/blob/master/examples/vr_sample_check_baud_rate/vr_sample_check_baud_rate.ino

Everything is fine.

But when I test with a teensy, the compilation was ok but I have this message (no connection):
Elechouse Voice Recognition V3 Module
Check Baud Rate sample
Check baud rate failed.
Please check the connection, and reset arduino

I checked pins, it's ok ... so I think there is a problem with library compatibility.
So I want to adapt this library for Teensy.
How can I start ?

Thanks a lot for your help !

Mike
 
Teensy doesn't support softSerial, since it's got multiple real serial ports, and there are other side effects to trying to emulate a serial port. Try moving the pinout to pin 0 (RX into Teensy) and 1 (TX from Teensy) and change the

VR(uint8_t receivePin, uint8_t transmitPin); line to match the new pinout. May also not like talking to a 3.3V board, but start using pins that can do serial coms first.
 
Which Arduino boards does this program support? I see it calls a "clear" function, which doesn't exist in any version of SoftwareSerial I can find.
 
GremlinWrangler : I try with pin 0 and pin 1 : it didn't work (I use pin 13 led to debbug because there is no more debug serial display with pin 1 and 0)
For the power, I use an external 5v power.
 
PaulStoffregen : It works well with a simple Arduino Uno.
I don't understand your reply regarding the "clear" function ... in the code, the "clear" function is not a "SoftwareSerial" function !?
 
The Teensy serial on pins 0 and 1 have nothing to do with USB serial for debug or programing (Serial1 vs Serial), which is why the Uno needs to use the somewhat problematic software serial to interface to the module. By way of example see the examples->Teensy-> echoboth of sending serial data to and fro.
 
Re clear, up the top of your example you have:
VR myVR(2,3);

which creates a myVR object and tries to use pins 2 and 3 which won't work.

Later there is

if(myVR.clear() == 0){

Which is looks to be dumping out the baud rate settings and starting over and you'd need to dig into the source to find out what it's up to there. When you moved pins, did you also update the first line to
VR myVR(0,1); ?
 
Sorry GremlinWrangler, I ment that when I used pins 0 and 1, I had no more access to printf function for the Serial monitor (for my debbug message).

Here is the code, I used :
/**
******************************************************************************
* @file vr_sample_control_led.ino
* @author JiapengLi
* @brief This file provides a demostration on
* checking the baud rate of VoiceRecognitionModule
******************************************************************************
* @note:
* check baud rate
******************************************************************************
* @section HISTORY
*
* 2013/07/10 Initial version.
*/
#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"
/**
* Connection
* Arduino VoiceRecognitionModule
* 2 -------> TX
* 3 -------> RX
*/
VR myVR(1,0); // 2:RX 3:TX, you can choose your favourite pins.

int br[]={
2400, 4800, 9600, 19200, 38400
};

void setup(void)
{

pinMode(13, OUTPUT);
/** initialize */

int i=0, a=0;
//Serial.begin(115200);
//Serial.println("Elechouse Voice Recognition V3 Module\r\nCheck Baud Rate sample");
for(i=0; i<5; i++){
myVR.begin(br);
if(myVR.clear() == 0){
digitalWrite(13, HIGH);
delay(5000);
digitalWrite(13, LOW);
//Serial.print("Baud rate: ");
//Serial.println(br, DEC);
break;
}
}
if(i==5){
//Serial.println("Check baud rate failed. \r\nPlease check the connection, and reset arduino");
for (a=0; a<8; a++) {
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
}
}
}

void loop(void)
{

}
 
It's definitely supposed to be VR myVR(0, 1).

0 is receive and 1 is transmit.

Try editing VoiceRecognitionV3.cpp. Look for this:

Code:
/**
        @brief VR class constructor.
        @param receivePin --> software serial RX
                   transmitPin --> software serial TX
*/
VR::VR(uint8_t receivePin, uint8_t transmitPin) : SoftwareSerial(receivePin, transmitPin)
{
        instance = this;
        SoftwareSerial::begin(38400);
}

Try commenting out the SoftwareSerial::begin(38400) line. Does that help?

This may be a static initialization order bug. SoftwareSerial's begin is calling Serial1's begin, but since this is done in the C++ static constructor, there's no guarantee Serial1 is initialized at that point. The code may be crashing if the constructors haven't initialized the Serial1 vtable. These are tough problems, but in this case the solution looks simple. There's no need to call begin() in the constructor, since you're calling it from the sketch code.
 
Last edited:
Status
Not open for further replies.
Back
Top