I'm trying to change the original SoftwareSerial library from VR3 Voice Recognition Module to a HardwareSerial one... I don't have any knowlodge of how libraries works... I Tried to make some these changes, but without sucess.

Eu estou tentando alterar a Library do módulo de reconhecimento de voz 'VR3' da qual originalmente foi criada para o uso em SoftwareSerial, gostaria de converte-lá para HardwareSerial... Como não tenho quase nenhum conhecimento na leitura e entendimento da linguagem de livrarias, estou tendo dificuldades...

Eu fiz algumas alterações, porém não deram certas,

Eu alterei o arquivo VoiceRecognitionV3.H desse modo


#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

#include "wiring_private.h"

//#include "SoftwareSerial.h"  ***** COMENTEI ESSA LINHA *****
#include <avr/pgmspace.h>

#define DEBUG

#ifdef DEBUG
#define DBGSTR(message)     Serial3.print(message) // ***** Alterei de Serial para Serial3 *****
#define DBGBUF(buf, len) Serial3.write(buf, len)
#define DBGLN(message) Serial3.println(message)
#define DBGFMT(msg, fmt) Serial3.print(msg, fmt)
#define DBGCHAR(c) Serial3.write(c)
#else
#define DBG(message)
#endif // DEBUG

Eu alterei o arquivo VoiceRecognitionV3.CPP desse modo

#include "VoiceRecognitionV3.h"
#include <string.h>

VR* VR::instance;

/** temp data buffer */
uint8_t vr_buf[32];
uint8_t hextab[17]="0123456789ABCDEF";

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

Meu código ino alterei apenas os valores dos pinos de 2,3 para 14,15 (HardwareSerial3 no mega)

#include "VoiceRecognitionV3.h"
VR myVR(15, 14); // (COMANDO DE VOZ) Hardware pins in Arduino MEGA Board

void Setup()
{
myVR.begin(9600); // Start module serial
  myVR.clear(); // Start the module
}

E estou recebendo os seguintes erros da IDE quando tento compilar o código

D:\...\VoiceRecognitionV3.cpp: In constructor 'VR::VR(uint8_t, uint8_t)':

D:\...\VoiceRecognitionV3.cpp:43:89: error: no matching function for call to 'HardwareSerial::HardwareSerial(uint8_t&, uint8_t&)'

 VR::VR(uint8_t receivePin, uint8_t transmitPin) : HardwareSerial(receivePin, transmitPin)

                                                                                         ^

D:\...\VoiceRecognitionV3.cpp:43:89: note: candidates are:

In file included from C:\.../Arduino.h:232:0,

                 from D:\...\VoiceRecognitionV3.h:31,

                 from D:\...\VoiceRecognitionV3.cpp:29:

C:\.../HardwareSerial.h:117:12: note: HardwareSerial::HardwareSerial(volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*, volatile uint8_t*)

     inline HardwareSerial(

            ^

C:\.../HardwareSerial.h:117:12: note:   candidate expects 6 arguments, 2 provided

C:\.../HardwareSerial.h:93:7: note: constexpr HardwareSerial::HardwareSerial(const HardwareSerial&)

 class HardwareSerial : public Stream

       ^

C:\.../HardwareSerial.h:93:7: note:   candidate expects 1 argument, 2 provided

C:\.../HardwareSerial.h:93:7: note: constexpr HardwareSerial::HardwareSerial(HardwareSerial&&)

C:\.../HardwareSerial.h:93:7: note:   candidate expects 1 argument, 2 provided

Voice Recognition Library Download

Arduino MEGA 2560

Exibições: 1629

Responder esta

Respostas a este tópico

Boa tarde HBS. (Good afternoon HBS).

Se for novo aqui no fórum , algumas recomendações:
    1. Leia http://labdegaragem.com/forum/topics/sugest-o-de-como-postar
    2. Remova seu sketch da área de texto do seu tópico;

    3. Comente as linhas do seu sketch. Fica Fica mais fácil entender o que vc quer fazer com cada linha.
    4. Clique em : " Deseja carregar arquivos? " e depois em " Escolher arquivo" e anexe o arquivo
        com o seu sketch.

E finalmente se seu problema for resolvido, divida conosco a solução e escreva "[Resolvido]"
no inicio do titulo do tópico.
Ficando assim: [Resolvido] + Titulo.

RV  Ranzinza velho

(  If you're new here in the forum, some recommendations:
   1. Read http://labdegaragem.com/forum/topics/sugest-of-how-to-post
   2. Remove your sketch from the text area of your topic;

   3. Comment out the lines in your sketch. It gets easier to understand what you want to do with each line.
   4. Click "Do you want to upload files?" And then "Choose file" and attach the file
       with your sketch.

    And finally, if your problem is solved, share the solution with us and write "[Solved]"
    at the beginning of the title of the topic.
   Show like this: [Resolved] + Title.)

   RV Old Crazy.   

Boa tarde Mineirin, em relação a organização do sketch... Os espaçamentos são inexistentes nos #define #if e etc, em relação a comentação do código, as linhas das quais reconheço a função, deixei comentada porém as que estão sem comentários são porque realmente não sei sua função. 

Abraços, Heitor.

   2. Remove your sketch from the text area of your topic;

 4. Click "Do you want to upload files?" And then "Choose file" and attach the file
       with your sketch.

Boa noite, 

Acho que você esta enganado. O recomendado é usar a serial normal do Arduino e não a Serial emulada (software serial)

https://github.com/elechouse/VoiceRecognitionV3

Connect your Voice Recognition V3 Module with Arduino, By Default:
connection

Boa noite José Gustavo, realmente, estou por isso estou tentando usar a HardwareSerial e não a SoftwareSerial, a questão é que a biblioteca vem apenas com suporte para a Software Serial.

Creio que a software serial é usada no VR3, pois deve ter mais flexibilidade na alteração dos parâmetros. 

Qual é o seu objetivo afinal?

O que é a tal de hardware serial que você chama ?

Explique com detalhes do que você precisa, qual será a sua montagem. Qual Arduino e quais pinos pretende usar ?

Na software serial, para mudar os pinos é só configura-los no Sketch (existem algumas restrições de pinos) .

Bom dia José Gustavo,

Então, eu estou usando o módulo de reconhecimento de voz para meu projeto de automação residencial. O hardware serial da qual me refiro são as 3 entradas que o Arduino MEGA (placa que atualmente uso) possui, andei pesquisando e realmente é mais vantajoso você usar um hardwareserial do que softwareserial, uma prova disso foi um de meus sensores que migrei para o hardware serial e obtive uma melhor fluidez no envio e recebimento de dados.

O módulo funciona, consigo liga-lo e faze-lo interagir com meus comandos, tenho pinos disponíveis para funcioná-lo em softwareserial, porém preciso de mais agilidade e principalmente de mais confiabilidade e para obter um pouco disso, por preciso migrar para o hardware serial.

Vi um pessoal falando muito bem do hardware serial, da uma olhada nas frases que retirei do fórum Arduino.cc

"If you must use a different baud rate, SoftwareSerial is the last choice. It blocks interrupts for long periods of time and can interfere with other libraries. It cannot transmit and receive at the same time."

"Don't use SoftwareSerial if you can avoid it. Don't expect to get more than one instance of SoftwareSerial to work on any Arduino."

"Four hardware UARTs can operate simultaneously, not so for software serial"

Aproveitando o embalo, gostaria de fazer uma pergunta... Existe alguma placa genérica do Arduino MEGA? Do qual contenha a mesma quantidade e funcionalidade de pinos ALÉM de um processador com clock maior que 16 MHz?

Heitor.

Boa tarde, 

Você já tentou usar a Softserial com os pinos definidos por HW no Arduino Mega?

Qual foi o resultado ?

https://www.arduino.cc/reference/en/language/functions/communicatio...

The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX).

https://www.arduino.cc/en/Main/ArduinoBoardMega

Arduino Mega = 4 UARTs (hardware serial ports)

  • Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and 16 (TX); Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and transmit (TX) TTL serial data. Pins 0 and 1 are also connected to the corresponding pins of the FTDI USB-to-TTL Serial chip.

SoftwareSerial library allows for serial communication on any of the Mega's digital pins.

Mais rápido do que o Arduino Mega é o Arduino Due. 

https://store.arduino.cc/usa/arduino-due

Tentei fazer este teste agora, não deu certo, usar os pinos do módulo nos pinos do hardware serial não funcionou.

Você não pode fazer isso :

//#include "SoftwareSerial.h"  ***** COMENTEI ESSA LINHA *****

A biblioteca Voice Recognition V3 (WIP) depende da biblioteca Software serial !

Sem isso, nunca funcionará.

Onde você encontrou esse comando ? Isso existe ?: 

VR::VR(uint8_t receivePin, uint8_t transmitPin) : HardwareSerial(receivePin, transmitPin) // ***** Alterei de SoftwareSerial para HardwareSerial *****

Eu voltei a biblioteca ao estado original dela... Reinstalei a biblioteca...

Então, em relação as alterações feitas na biblioteca antiga, eu não fazia muita idéia do que estava fazendo, por isso até deletei a biblioteca antiga e reinstalei a nova (original)

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço