Pages: 1 [2] 3   Go Down
Author Topic: Ethernet MP3 Player  (Read 8923 times)
0 Members and 1 Guest are viewing this topic.
Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Since you're using the Duemilanove, you won't be able to get much better than 57600 bps on a SoftwareSerial port.  Can you try setting the rMP3 to 38400 bps?  (Setting: "D2")

See if that works.  If it does, you'll have to:

1) use Serial for your communications with the rMP3 (you will have to add jumpers from pins 6 and 7 to pins 0 and 1 - and you will have to remove the rMP3 each time you upload a sketch).

2) use another board which has an extra hardware serial port (e.g. LEDHead, Arduino Mega, etc...
Logged


North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh I had forgotten about the Software Serial speed limitations - glad you came to the rescue with answers smiley-grin
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok, so 38400 works for the sync but the stream is corrupted. I suppose the write operation to the SD takes too long at that baudrate.
So I will try to do as bhagman says. I will see if I can go up to 57600 using the serial port. Will I still need the SerialSoftware library?
« Last Edit: April 25, 2011, 05:07:06 pm by LB01 » Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you use the hardware serial port, you won't need SoftwareSerial any more.

Just remember that you will have to remove the rMP3 (with power removed) each time you want to upload!  (This only applies when using the same hardware serial port that is used for uploading the sketch).

e.g.

Code:
#include "RogueMP3.h"

RogueMP3 rmp3(Serial);

void setup(void)
{
  Serial.begin(57600);
  rmp3.sync();

  ...
}

Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had some spare time to work on that issue.

I soldered a couple of pins to make it easier to connect/disconnect the rMP3. It works well, the only things is that it is confusing that the Tx/Rx pins on the solderable pads must be connected to the Rx/Tx of the arduino serial pins respectively (it must be a crossed cable). Apart from this point, I like this system, it is very flexible.

So I connected everything and modified a simple script to play a tune with the rMP3 using the serial port, and it works very well at 9600 but still fails at 57600. Basically, when I change the option D0 to D3 with the correct serial baudrate, the music does not start. Here is the setup function:

Code:
void setup()
{
  delay(2000);
  Serial.begin(9600);  // initialise the serial rMP3 connection
 
  rmp3.print("ST D0"); // if changed to D3, the module fails
  delay(100);
  Serial.begin(9600); // that would be changed to 57600
  delay(100);
 
  rmp3.sync();
  rmp3.stop();
  rmp3.setvolume(volume);
 
  filecommands.sync();

  // mix up our random number generator
  randomSeed(analogRead(0));

  updateSongList();
 
}

I suspect that the sync is still a problem. Any suggestion?
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Code:
  Serial.begin(9600);  // initialise the serial rMP3 connection
 
  rmp3.print("ST D0"); // if changed to D3, the module fails
  delay(100);
  Serial.begin(9600); // that would be changed to 57600
  delay(100);
You have two 'Serial.begin(####)' lines in there...
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes, I use that to set the baudrate to whatever I need. It is not nice, but with that I don't need to change the config file on the SD card everytime I change the baudrate. And it works when I use 9600. It also works when I set 57600 and then come back to 9600.
Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The only thing I can see is that you don't send the <CR> to complete the command.

Try this:
Code:
  rmp3.print("ST D3\r");
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot, it is now working! I did forget the \r to validate the changes, it seems like my shortcut to change the baudrate created more problems than it solved.

Anyway, I can now see the LEDS flashing on the ethernet shield, so the stream is coming. I can also see the indicator lit on the rMP3 and some data is written on the SD card but it cannot be read when the card is connected to my computer. The data is corrupted somewhere.

I suppose that the write operation is still too long for some reason (the 'Data in' LED of the  ethershield board does not flash very often). At the moment, I am using a byte-by-byte write operation because the stream buffer is a uint8_t and the write methods needs a char. Here is what I was doing:

Code:
char s;
  while (pos<plen) // write the remaining data to the buffer
  {
    s = char(buf[pos]);
    filecommands.write(filehandle,1,&s);
    pos++;
  }

I replaced it by the following:

Code:
char s[plen];
  while (pos<plen) // write the remaining data to the buffer
  {
    s[pos] = char(buf[pos]);
    pos++;
    sdpos++;
  }
  filecommands.write(filehandle,plen,s);

but now a red LED starts to flash on the rMP3 when the stream arrives. I suppose that means a buffer overflow because i pass on too much data in one go?



« Last Edit: May 02, 2011, 05:18:16 pm by LB01 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Still no luck, I have this red LED flashing on the rMP3 board whatever I try to do. What does this LED means? I can at best write 40 - 60 characters on to the SD card before it starts to flash.
« Last Edit: May 03, 2011, 04:45:15 pm by LB01 » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi LB01,

I've been quietly watching your project since it began.  It would be such a cool project for the Arduino and the rMP3!.

There's a writeup of a related project DIY MP3/OGG/FLAC music player using Arduino and VS1053 at http://kalum.posterous.com/private/sHqcofxooc that could be worth looking at. It's not strictly playing streaming radio, but the code could give you some ideas.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Novice,

Thanks for your enthousiasm, to be honest I left this project aside because I could not get any progress.

Using the arduino duemilanove, the rMP3 and an ethreshield, I managed to capture an icecast stream correctly but it could not copy it to the SD card (on the rMP3 board). If I redirect the stream to the USB serial port, it does work! I can listen to the radio, no problem. But as I said, the problem I have now is to copy this stream to the SD card on  the fly and there is a problem with the rMP3 card with that, the write function fails 90% of the time to copy the data. Apart from that, the rMP3 module seems to work fine so I feel like I am close to completion...

Ok, I will try and make it work again, but that will probably need some changes in the rMP3 firmware too.
Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey LB01,

I've been thinking this over, and I don't think that using the files will be the best way to go.  I've got a new idea (not really rocket science) to just add a direct serial stream to the decoder.  Should be pretty easy to do.  I'll update you when I get the coding done.

b
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh great ! I'll be waiting for it!

I just replied to your first email and I sent you the code that I wrote so far, but you may not need to look at it if you develop your idea. At the moment I can get a 128k/s icecast stream without a problem using a baudrate of 230400, but only if I redirect it to the USB port. Copying to the rMP3 SD card fails. If you can manage to make a direct protocol, then I think it will be very straightforward for me to finish.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm working on a project, that includes the tranferring of audio via ethernet and playback by Arduino.
Therefore I watch the thread with great interest and I hope that you guys might get it working.
Logged

Pages: 1 [2] 3   Go Up
Jump to: