DATA OUT

DATA OUT

Postby mechancial » Wed Jun 04, 2014 4:19 pm

Is there a way to get bytes off of the Audio Codec Shield?

I would like to record audio, transcribe to digital, then transmit the digital in sequential packets of 512bytes each.

Input is by microphone ( I made the MIC_VB and IN_L mods ), Arduino UNO.

Has anyone had luck with spi, iic, serial, progmem, sdcard or spdr ?
I've been experimenting with all and habn't found a solution that doesn't crash.

If there's an example out there, getting data off of the board, that'd open a lot more uses.

Thanks!
mechancial
 
Posts: 4
Joined: Wed Jun 04, 2014 11:58 am

Re: DATA OUT

Postby guest » Thu Jun 05, 2014 10:07 am

the easiest should be the uart. if you are only interested in mono, thats 44.1ksps * 16b/sample = 705kbps. the issue here, is that this is not a standard computer baud rate. i think there is some hack to get it to do 1Mbps. this is also faster than i2c can run on most devices. the spi might also be able to do it. how much data do you want to send, and where do you want it to go? for an SD card, a specific library would have to be written.
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: DATA OUT

Postby mechancial » Thu Jun 05, 2014 11:14 am

Thanks for your reply... UART is fine for me; can I write to uart from within the ISR?

Sorry if this is a silly question, I'm a hobbyist. So far everytime I've tried to communicate by serial it kills the ISR...

I've got another arduino board with an SD shield and it's writing packets of 512 bytes of empty data. I can handle populating the array and writing the correct data if I could get it out of the Audio Codec Board.

For UART would I write to pin1 on the Audio Codec Board and read from pin0 on the SDcard board?

Here's my ISR code below, it's based on the buffer example (SIZE = 512).

Very grateful for an example code that would help to get the array out of the audio codec board.





ISR(TIMER1_COMPA_vect, ISR_NAKED) {
AudioCodec_data(&left_in, &right_in, left_out, right_out);
left_out = delaymem[location];
delaymem[location++] = left_in;
if (location >= SIZE) {
for (int counter = 0; counter < SIZE; counter++){
// OUTPUT delaymem[counter];
// SEND TO UART?
}
location = 0; // reset location
}
reti();
}
mechancial
 
Posts: 4
Joined: Wed Jun 04, 2014 11:58 am

Re: DATA OUT

Postby guest » Thu Jun 05, 2014 3:31 pm

you should be able to do that, although first check the write rate of your SD card. fill up a buffer, and time how long it takes to write it to the SD card. or even better, write 10 buffers worth, and see how long that takes. im suspecting there is some downtime between buffers. you can use millis() to measure this time. my concern is that data will come in faster than you can write it out.

also, a special uart routine will need to be written, and i can help with that. the reciever will need to let the transmitter know when it is ready for more data, as it may not be able to handle the max data rate at all times.
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: DATA OUT

Postby mechancial » Thu Jun 05, 2014 7:02 pm

Pulling a single byte or a short chain of bytes from the codec shield would be a nice start.
Is it possible to pull one byte out of the ISR?
At the moment, is there ANY method, or example of extracting data from the shield?

Looking through the forum, it seems several people have hoped to pull data, I wish I could figure it out, I'm 8 hours into testing different methods. Need help.... I believe this is a trivial task for someone who knows how to chat with WM8731.

I'm starting to get the impression that I need to put WM8731 on a breadboard and talk to it directly, which seems to be a big undertaking. I was hoping that the Audio Codec Shield would help to short-cut that.

If there's no existing example, is there a resource that can point me toward someone who can help dump the buffer from the audio codec shield?
mechancial
 
Posts: 4
Joined: Wed Jun 04, 2014 11:58 am

Re: DATA OUT

Postby mechancial » Fri Jun 06, 2014 8:22 am

guest wrote:you should be able to do that, although first check the write rate of your SD card. fill up a buffer, and time how long it takes to write it to the SD card. or even better, write 10 buffers worth, and see how long that takes. im suspecting there is some downtime between buffers. you can use millis() to measure this time. my concern is that data will come in faster than you can write it out.

also, a special uart routine will need to be written, and i can help with that. the reciever will need to let the transmitter know when it is ready for more data, as it may not be able to handle the max data rate at all times.




The SD card is writing at 51200 bytes per second.
10, 512byte buffers (5120bytes) wrote in 0.100001 seconds. SD write rate is 51,199 bytes per second.
Recording mono at 22kHZ, incoming data rate is 22,000bytes per second.

A little over half of the clock time should be available to transfer 512byte packets out of the WM8731 buffer and into the SDcard write buffer.

The remaining question is how to get the bytes out of the WM8731?

I'd be very grateful to learn more about a uart routine to send and receive the data.

(ie.... how to move a 512byte buffer from WM8731 into an array in the main loop)
mechancial
 
Posts: 4
Joined: Wed Jun 04, 2014 11:58 am

Re: DATA OUT

Postby guest » Fri Jun 06, 2014 11:10 am

mechancial wrote:The SD card is writing at 51200 bytes per second.
10, 512byte buffers (5120bytes) wrote in 0.100001 seconds. SD write rate is 51,199 bytes per second.
Recording mono at 22kHZ, incoming data rate is 22,000bytes per second.

A little over half of the clock time should be available to transfer 512byte packets out of the WM8731 buffer and into the SDcard write buffer.


are those bytes being transferred? 51kBps? the codecshield uses INTs, which are 2 bytes. so at 22ksps, thats 44kBps mono. which is pretty close, but might work.

so here is the main issue: the codecshield requires very specific timing, and can not have its interrupt blocked. this is one of the reasons i suggest putting all the code in the ISR, rather than the main loop. the standard arduino library for serial transfers uses interrupts, which migh block the codec. so a more direct version is required. i will see if i can write one up later today.
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: DATA OUT

Postby guest » Wed Jun 11, 2014 9:07 pm

sorry for the delay. this can transmit, but there is no data flow control, so the reciever will need to be good about handling interrupts quickly.

Code: Select all
// setup codec parameters
// must be done before #includes
// see readme file in libraries folder for explanations
#define SAMPLE_RATE 44 // 44.1Khz
#define ADCS 0 // no ADCs are being used

// include necessary libraries
#include <Wire.h>
#include <SPI.h>
#include <AudioCodec.h>

// create data variables for audio transfer
int left_in = 0x0000;
int left_out = 0x0000;
int right_in = 0x0000;
int right_out = 0x0000;

void setup() {
  UCSR0A = 0x02; // set to double speed
  UCSR0B = 0x08; // turn on transmitter
  UCSR0C = 0x06; // 8bit asynchronous mode
  UBRR0H = 0;
  UBRR0L = 0x00; // set to 2MHz - set to 0x01 for 1MHz
  AudioCodec_init(); // setup codec registers
  // call this last if setting up other parts
}

void loop() {
  while(1);
}

// timer1 interrupt routine - all data processed here
ISR(TIMER1_COMPA_vect, ISR_NAKED) { // dont store any registers

  // &'s are necessary on data_in variables
  AudioCodec_data(&left_in, &right_in, left_out, right_out);
 
  while (!( UCSR0A & (1<<UDRE0))); // wait for buffer to empty
  UDR0 = left_in >> 8;
  while (!( UCSR0A & (1<<UDRE0))); // wait for buffer to empty
  UDR0 = left_in;

  // dont forget to return from interrupt
  reti();
}
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm


Return to Audio Codec Shield

Who is online

Users browsing this forum: No registered users and 1 guest


cron