I have a problem with communication from an Arduino Diecimila to a RogueRobotics uMP3 card. It seems like it has something to do with the "flow control" or "echo" of the serial protocol. When I control the uMP3 (using a number of serial commands) through the Hyper Terminal on WindowsXP with these settings, it works:
If i try to send the same commands using a SoftwareSerial, the hardware serial or with another setting of the flow control, the uMP3
doesn't respond. So I believe the problem is that Arduino uses some kind of flow control. Am I right? How can i change that? Can i change it in the SoftwareSerial.h/cpp?
Here is the code i have on my board:
#include <SoftwareSerial.h>
boolean waiting = true;
#define UMP3_RX 6
#define UMP3_TX 7
SoftwareSerial ump3serial = SoftwareSerial(UMP3_RX, UMP3_TX);
void setup()
{
Serial.begin(9600);
ump3serial.begin(9600);
pinMode(8, INPUT);
Serial.println("BEGIN");
}
void loop()
{
int in = digitalRead(8);
if (waiting && in == LOW)
{
waiting = false;
}
if (!waiting && in == HIGH)
{
waiting = true;
// send command
ump3serial.print("PC F /B0000.MP3");
// send new line to end command
ump3serial.print(0x0D, BYTE);
Serial.println("PC F /B0000.MP3");
}
}
Yea, i put the digitalRead(8) in to be able to control the sending through a button. I can see the (hardware) serial response in the Arduino serial monitor when i press the button, so totally sure that the software serial print is sent, but i'm also sure the command doesn't interpret correctly on the uMP3 (i hear no song playing).
It good to know that the Arduino doesn't have any flow control, then i can leave that... Could it be a timing problem then? The SoftwareSerial does some kind of fixed wait for 50 loops when sending, to compensate for digitalWrite(). Could it be that this time is too long/short and the sending speed (which should be 9600) becomes something else?
I don't think it's a baud rate problem if you have a standard Arduino board and have tried it with the hardware serial set to 9600.
And you code seems to be what the board expects. Hmmm?
What is the physical connection between the board and hyperterminal (how do you convert to the TTL input the board expects) and how did you connect to the Arduino when you tested the hardware serial? I wonder if it could be a wiring problem (bad ground perhaps?)
I connect a USB Mini adapter RX/TX to the uMP3 RX/TX over a bred board. Then it works from Hyper Terminal, but not from the Arduino Serial Monitor. Then i just connect the uMP3 RX/TX to the digital pin 6/7 instead and send software serial data from the Arduino. No more changes...
I see now that i don't do a pinMode(6, INPUT) call for the ports i use for the SoftwareSerial, but maybe thats taken care of inside SoftwareSerial. That could be a problem, i'll try that in a bit...