Software serial to control uMP3

Hi,

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:

bps: 9600
data bits: 8
parity: none
stop bits: 1
flow control: none

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");
  }
}

cheers!
/cj

Hi cj, the Arduino will only use flow control (if any) you implement yourself in your software so that's not the problem.

Your sketch will only send if digitalRead(8) is HIGH, are you sure it is?

Have you tried it to see if anything is sent if you comment out the line:
if (!waiting && in == HIGH)

That should continuously send (you may want to put a delay(100) in there ).

Hi mem,

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?

cheers
/cj

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...

/cj

Did you try it connecting the uMP3 RX/TX to pins 0 and 1 on the Arduino with hardware serial at 9600?

Oh, like i secretly suspected it was me who had done some foolish connection. This is how it's supposed to be, I had it the other way around.

Arduino RX goes to uMP3 TX
Arduino TX goes to uMP3 RX

But I also needed to do the

pinMode(UMP3_RX, INPUT);
pinMode(UMP3_TX, OUTPUT);

before i do the SoftwareSerial.begin(9600)

Complete and simplified code here:

#include <SoftwareSerial.h>

#define UMP3_RX 6
#define UMP3_TX 7

SoftwareSerial ump3serial = SoftwareSerial(UMP3_RX, UMP3_TX);

void setup()
{
  pinMode(UMP3_RX, INPUT);
  pinMode(UMP3_TX, OUTPUT);
  Serial.begin(9600);
  ump3serial.begin(9600);
}

void loop()
{  
  ump3serial.print("PC F /B0000.MP3");
  ump3serial.print(0x0D, BYTE);
  Serial.print("PC F /B0000.MP3");
  Serial.print(0x0D, BYTE);
  delay(5000);
}

Now both SoftwareSerial and hardware Serial works fine. Thanks for your help, mem!

cheers
/cj

Hi cj, good to hear you found the problem and have it working.

Have fun!