Author Topic: uMP3 and the Axon  (Read 4635 times)

0 Members and 1 Guest are viewing this topic.

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
uMP3 and the Axon
« on: October 10, 2008, 09:51:31 PM »
Hello, and welcome to another installment of noob messing with things he knows nothing about. In todays episode we throw a curve ball at him by trying to get him to have two separate devices communicate with each other and to play audio files. We also ask for him to program said said ensemble into a working animatron. Lets watch,

So yes, I decided to open my post with a background story. For my project, and future ones, I have decided to use <a href='http://www.roguerobotics.com/products/electronics/ump3">uMP3[/url] to play audio and manage an SD card, thank you Admin for the great find. But to do so I need to one power it, and two send it serial commands. I would like to have a second( or third) opinion on my work to be sure that my procedure would work.

The powering of the device would come from the ADC0 pins with the signal wire removed, so as to avoid one of my stupid moments, and then the device should be running off of regulated 5 VDC and should begin doing its stuff.

After said power up I would have the axon initiate the UART, uartInit(); , then establish the bitrate, uartSetBaudRate(2, 38400); , then establish the channel to print to, rprintfInit(uart2SendByte);
 , after that is done i get confused. On the site it says that the uMP3 can take a few seconds to initialize, and I am assuming that I should not send it commands during that time. So should i do a loop checking to see if a letter was sent? temp=uart3GetByte(); if (temp!=" " & temp!="")
Then when my brain wants to play a noise, would i simply do, rprintf("PC F /MP3_Voice/Curse.mp3");
The command there was found in the uMP3 documentation page 23.

Thanks for the help, I seem to have trouble wrapping my mind around programming micro-controllers and controlling subsystems.

Since this post deals with more then one category please bare with me.
« Last Edit: October 13, 2008, 06:13:31 PM by gamefreak »
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: uMP3 and the Axon
« Reply #1 on: October 10, 2008, 11:00:50 PM »
you need to wait for something until a pin goes high or low?

check sfr_defs.h

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: uMP3 and the Axon
« Reply #2 on: October 11, 2008, 06:03:17 AM »
I dont think im waiting for a pin, I am trying to do serial communication, so i am waiting for data not just (insert name of something that isnt data here, I couldnt...)

I believe i need to wait for the uMP3 to tell me that it is ready, which means it will send me a line and somewhere along that line, at the end supposedly, is a greater than(>) sign. After I receive that then I should be able to safely send the serial commands.

Im curious to know if my approach is correct before I make the investment.
« Last Edit: October 12, 2008, 02:32:11 PM by gamefreak »
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: uMP3 and the Axon
« Reply #3 on: October 13, 2008, 07:50:39 PM »
Any thoughts? I liked to know if I know what im doing before I spend 100 $
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,663
  • Helpful? 169
    • Society of Robots
Re: uMP3 and the Axon
« Reply #4 on: October 14, 2008, 04:02:30 AM »
Hmmm I'm looking at the uMP3 sourecode . . . no C, just assembly and BASIC:
http://www.roguerobotics.com/node/20
http://www.roguerobotics.com/node/22

This manual, right?
http://www.roguerobotics.com/files/ummc/documentation/ummc-100-a3-103.pdf

Quote
Then when my brain wants to play a noise, would i simply do, rprintf("PC F /MP3_Voice/Curse.mp3");

Looking at page 22, I see this:
Quote
Example Session
This example session opens a log file, writes data, and then retrieves it.
>O 1 W /LOGS/JANUARY/JAN03.LOG{cr}
>W 1 18{cr}
13:22:02 ADC1=4.9V>C 1{cr}
>O 1 R /LOGS/JANUARY/JAN03.LOG{cr}
>R 1 18{cr}
13:22:02 ADC1=4.9V>C 1{cr}
>


So I think this would be the correct command:
Code: [Select]
rprintf("O 1 R /LOGS/FEBRUARY/FEB30.LOG\r");// the \r for carriage return, I think . . .
But the sourcecode in BASIC looks like this:
Code: [Select]
SEROUT MP3R,N9600T,["PC F /Dramatic-Reveal-Horns1.mp3",CR]That doesn't make sense to me, because the command PC isn't in the manual! Try emailing them?

And make sure you use the right commands first so that its using the same baud rates.

You are right, just use the regulated 5V ADC to power it.

For receiving data, here is an example of how I do it with the Blackfin Camera below. The camera is on UART3, and the Axon is repeating the data (for debugging) to UART0 where bluetooth is connected to hyperterminal. Just read the data in the stored array if you want to do further processing.

Code: [Select]
main()
{
rprintf("a");//Send Blackfin command for 160x128 resolution

Blackfin_Echo(2);// the expected return data is size of 3
}

//Repeat Response, read in from Camera UART, output to another UART (for hyperterminal)
void Blackfin_Echo(int response_counter) //echos # of characters expected for each command
{
int temp;
int counter=0;

rprintfInit(uart0SendByte);//change UART to bluetooth to output data to hyperterminal

while(1)
{
temp=uart3GetByte();//get data from camera UART, returns -1 if no data present
//rprintf("trapped!");//debugging code, repeats if there is an error somewhere

      if (temp != -1)//if data received
{
rprintf("%c",temp);//output to hyperterminal
response[counter]=temp & 0x0F;//store values into an array, &0x0F strips ascii off to use in char strings

counter++;
      if(counter >= response_counter || temp == '\n')
{
rprintf("\r\n\r\n");//new line
uartFlushReceiveBuffer(3);//flush out receive camera buffer to stop phase shifting
break;
}
}
}
}

Hope this helps!

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: uMP3 and the Axon
« Reply #5 on: October 14, 2008, 05:43:40 AM »
It did but not entirely, you are in the data storage module not the playback module
http://www.roguerobotics.com/files/ump3/documentation/UMP3-110-A1-102.pdf

So for the carriage return i would use /r? or the CR after a comma at the end?
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,663
  • Helpful? 169
    • Society of Robots
Re: uMP3 and the Axon
« Reply #6 on: October 14, 2008, 06:14:54 AM »
Oops . . . yea, that command looks right . . . and it appears to use ASCII too.

Yea, you'll probably need to use the carriage return, so just add '\r' at the end of any command.

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: uMP3 and the Axon
« Reply #7 on: October 14, 2008, 06:34:05 PM »
I noticed on the Axon page you said you have not come up with a way to get strings of data, but the uMP3 sends me a string back to tell me it is ready, any thoughts as to how to avoid that problem? Can i safely assume that any data returned means i can send it data again? Thanks,
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,663
  • Helpful? 169
    • Society of Robots
Re: uMP3 and the Axon
« Reply #8 on: October 14, 2008, 11:26:43 PM »
Well, I came up with a way, its just still in beta. I posted the code a few posts up (tested and works with the Blackfin).

Quote
Can i safely assume that any data returned means i can send it data again?
If your code works without receiving data, you don't need to receive the data, just add in a delay and assume there was no error. But if you needed specific info returned for Axon processing, or error checking, you would need to read in that data.

Offline Dscrimager

  • Full Member
  • ***
  • Posts: 57
  • Helpful? 0
Re: uMP3 and the Axon
« Reply #9 on: December 10, 2008, 10:58:52 PM »
I followed up on a similar topic tonight in a much older thread.

I'll be hooking up a Rogue uMP2 player to one of my bots. I use them in my halloween shows.

This code is basic (I use a lot of stamps and a lone SX board in the haunt shows) and taken from another source but it shows the idea:

See this link http://www.efx-tek.com/php/smf/index.php?topic=39.0

and then I use it in my code for my haunt here is an early version:
http://www.efx-tek.com/php/smf/index.php?topic=698.0


The protocol is pretty simple once you got the basic connectivity out of the way.
This is also a good article http://www.parallax.com/dl/docs/cols/nv/vol6/col/nv128.pdf
 
Doug

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: uMP3 and the Axon
« Reply #10 on: December 12, 2008, 04:31:17 PM »
sorry, i just read quickly through the new posts since my last one.


If it is serial communication, wouldnt it also send an RS232 signal telling you it is ready? like DSR or somethin?

Offline Dscrimager

  • Full Member
  • ***
  • Posts: 57
  • Helpful? 0
Re: uMP3 and the Axon
« Reply #11 on: December 12, 2008, 08:31:24 PM »
There is a hardware 'busy' pin which can interface and use as a hardware switch, but otherwise you send it a command and it will reply that it is still playing ( you ask for status and it returns a P I believe)..no flow control on the serial line for this purpose it replies to commands while it is playing.

It can be paused, playing or stopped ( which is done with playing the last file).

So what many do is write a loop watching for it to reply that it is no longer playing.

Doug

Offline Dscrimager

  • Full Member
  • ***
  • Posts: 57
  • Helpful? 0
Re: uMP3 and the Axon
« Reply #12 on: December 29, 2008, 12:57:45 PM »
I have my uMP3 player working:
I am using the regular rprintf commands after setting the correct UART for it's output.

I am not tracking errors or anything than if it's ready and or playing yet, but I am playing a bunch of different files successfully and under control:

Call  init_uMP3(void) to start it up. Call play_track to play the tracks ( I have a fixed format that I use in different situations.)

Warning-> messy code to follow:

Code: [Select]
int wait_for_ready(void)
{
int temp;
while (uart0GetByte() != -1) {delay_ms(1);}; // drain any characters
for(int k = 0; k < 5; ++k)
{
uart0SendByte(CARRIAGERETURN);// send carriage return
delay_ms(2);
temp = uart0GetByte();
if(temp == uMP3READY) return TRUE;

for(int j = 0; ((j < 20) && (temp == -1)); ++j)
{
delay_ms(2);
temp=uart0GetByte();
if(temp == uMP3READY) return TRUE;
}
}
return FALSE;
}

int consume_to_ready(void)
{
int temp;
temp = uart0GetByte();
//rprintf("temp = %d\r\n",temp);
if(temp == uMP3READY) return TRUE;
for(int j = 0; ((j < 20) && (temp != uMP3READY)); ++j)
{
delay_ms(2);
temp = uart0GetByte();
//rprintf("temp = %d\r\n",temp);
}
//rprintf("temp final = %d\r\n",temp);
if(temp == uMP3READY) return TRUE;
return FALSE;
}

int check_for_playing(void)
{
int temp;
for(int j = 0; ((j < 20) && (!wait_for_ready())); ++j)
{
rprintf("Not Ready\r\n");
delay_ms(1);
}

rprintfInit(uart0SendByte);// initialize rprintf system and configure uart0 (USB) for rprintf
rprintf("PC Z\r"); // get status from uMP3
rprintfInit(uart1SendByte);
temp=uart0GetByte();
//rprintf("check_for_playing : Temp = %d\r\n", temp);
for(int j = 0; ((j < 20) && (temp == -1)); ++j)
{
delay_ms(2);
temp=uart0GetByte();
//rprintf("check_for_playing : Temp = %d\r\n", temp);
}
//if(temp == -1) return FALSE;
if(temp == 80) //"P"
{
rprintf("Playing something\r\n");
//rprintf("check_for_playing final: Temp = %d\r\n", temp);
//while (uart0GetByte() != -1); // drain any other characters
consume_to_ready();
return TRUE;
}
else
{
rprintf("Not playing something\r\n");
//rprintf("check_for_playing final: Temp = %d\r\n", temp);
//while (uart0GetByte() != -1); // drain any other characters
consume_to_ready();
}
return FALSE;
}


void init_uMP3(void)
{
//int temp;
    uMP3init = FALSE;

for(int i = 0; i < 32; ++i) // loop for at most 8 seconds
{
if(wait_for_ready())
//if(temp == uMP3READY)
{
rprintf("uMP3 ready\r\n");
//rprintf("Setting Volume\r\n");
rprintfInit(uart0SendByte);//change UART to uMP3
rprintf("ST V "); // set volume to maximum
uart0SendByte(254);
rprintf("\r");
rprintfInit(uart1SendByte);
if(consume_to_ready())
{
uMP3init = TRUE;
rprintf("uMP3 ready!\r\n");
return;// if we get ready response ">" we are through
}
else
{
rprintf("failed setting command\r\n");
}
}
else
{
rprintf("uMP3 NOT ready\r\n");
}
delay_ms(250);
}
//rprintfInit(uart1SendByte);// initialize rprintf system and configure uart1 (USB) for rprintf
}

void play_track(char preamble, int track)
{
if(uMP3init == TRUE)
{
rprintf("Playing track %c", preamble);
rprintf("%d.mp3\r\n",track);
rprintfInit(uart0SendByte);//change UART to uMP3
rprintf("PC F /"); // play track on uMP3
rprintf("%c%d.MP3\r", preamble, track);
rprintfInit(uart1SendByte);
}
else
rprintf("uMP3 not initalized\r\n");
}

 


Get Your Ad Here

data_list