Hello, I have some compatibility issues. Whenever I use emic related statements, the serial monitor stops printing out statements. It looks like emic halts the program. I was advised to use one of the HW serial ports on the Mega for EMIC2. I have been trying but no success. Could anybody tell me how to do it please?
Physically I connected tx1 (18) to SIN and rx1 (19) to SOUT. Then, I modified the code with the following:
#define RX_PIN 19 // connect to Emic2 SOUT
#define TX_PIN 18 // connect to Emic2 SIN
SoftwareSerial emicSerial = SoftwareSerial(RX_PIN, TX_PIN);
In setup(), I have:
// set up emic2 for new hardware serial
pinMode(RX_PIN, INPUT);
pinMode(TX_PIN, OUTPUT);
emicSerial.begin(115200);
emicSerial.print('\n'); // Send a CR in case the system is already up
while (emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it delay(10); // Short delay
emicSerial.flush();
emicSerial.print("Hello, this is EMIC2 \");
Thanks. Since I deleted the first snippet, should I also delete pinMode(RX_PIN, INPUT); and pinMode(TX_PIN, OUTPUT); in the second snippet? Even I deleted them, still nothing shows up on the serial monitor.
I connected the EMIC2 via hardware serial 1. In my program, I have a while loop within which there is a bunch of if statements for EMIC2 to talk different things depending on which condition is met during each iteration. I noticed that if I just issue a set of :
Serial1.print('S');
Serial1.print("A sentence depending on which if statement is chosen");
Serial1.print('\n');
without a delay after Serial1.print(\n'), EMIC2 does not talk each time it is supposed to. It seems like if the call for Serial1.print happens too quick, EMIC2 cannot catch up and as a result, it misses some Serial1.print statements. It also seems that by changing the parameter in delay, I can make the EMIC2 to talk more or less.
Could you please let me know what is going on and how to determine the proper delay parameter?