Pages: 1 [2] 3   Go Down
Author Topic: Audio Delay  (Read 3335 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

perhaps i can use it also for the teensy : http://ruggedcircuits.com/html/quadram.html
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24317
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not.
No "perhaps".
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Sr. Member
****
Karma: 0
Posts: 339
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

isnt it possible to just use a slower memory type like sd cards (how fast is it actually?) and buffer the samples in the internal memory, so there is more time to save them on the external memory.

I thought that was the theory and best approach  ?!?! Or have i missed summat ?!
Logged

10 LET Loop=Infinite
20 GO TO 10

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24317
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It might be, if you had some form of DMA to get the data to/from the SD card and not tie up the processor.
Sadly...
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://majolsurf.net/wordpress/?page_id=1001

i ll take a closer look to this
Logged

West Des Moines, Iowa USA
Offline Offline
Sr. Member
****
Karma: 2
Posts: 428
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I did a bit of tweaking on my QuadRAM this morning to write and verify 8-byte (unsigned long long) data and got

Code:
Writing  512K QuadRAM (412432 usec)
Checking 512K QuadRAM (449696 usec)
512K test completed in 862128 usec.

So there may be some considerable merit to dxw00d's suggestion of Mega+QuadRAM.
Logged

There's always a better way!

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i just read that flash memory will die after about 10 000 times deleting a bit, does this mean arduinos and other micro controllers will die after being on for a while?

Well for one thing the whole memory doesn't die, it is organized into pages. Second, it is writing that wears it out, not reading. So you can program the Atmega chip 10000 times (ie. upload 10000 programs) before you have a problem. So you would have to program it 12 times a day, every day in the year, for over 2 years, before you had a problem.

In practice you normally get the program right and then deploy it.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
today i received those SRAM chips used in the link I posted before (23K256).
Ive seen here http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1290379685
that it already has been implemented a library for the arduino.

Because my board is different i took a look in the class the user "carl" has written and changed the parameters to my board.

this is the original code from carl for the teensy
Code:
#define setupSPI SPCR = 0x50 //Master mode, MSB first, SCK phase low, SCK idle low, clock/4
#define setupDDRB DDRB |= 0x2e  //set  SCK(13) MOSI(11) and SS1 , SS2 as outputs
#define selectSS1 PORTB &= ~0x04  //set the SS to 0 to select SRAM 1
#define deselectSS1 PORTB |= 0x04  //set the SS to 1 to deselect SRAM 1
#define selectSS2 PORTB &= ~0x02  //set the SS to 0 to select SRAM 2
#define deselectSS2 PORTB |= 0x02  //set the SS to 1 to deselect SRAM 2
this is how i adapted it to the teensy 1.0 (it doenst work yet)
Code:
#define setupSPI SPCR = 0x50 //Master mode, MSB first, SCK phase low, SCK idle low, clock/4
#define setupDDRB DDRB |= 0x7  //set  SCK(13) MOSI(11) and SS1 , SS2 as outputs
#define setupDDRB DDRC |= 0x4
#define selectSS1 PORTB &= ~0x01  //set the SS to 0 to select SRAM 1
#define deselectSS1 PORTB |= 0x01  //set the SS to 1 to deselect SRAM 1
#define selectSS2 PORTC &= ~0x04  //set the SS to 0 to select SRAM 2
#define deselectSS2 PORTC |= 0x04  //set the SS to 1 to deselect SRAM 2
http://www.pjrc.com/teensy/card1a.pdf
My SS1 Pin on the teensy is PB0 so i thought the binary to set this PiN as an output is just to set DDRB to 000 0001 thats  (the bit on the right should be PB0 am I right?)
because the SCLK and MOSI PINS have to be outputs to the binary for DDRB is 0000 0111 which is the number 0x07 in Binary

for the other Bit stuff i did it the same way. But the test Program wont work

Do you think i have to change more in the code?

In the cpp file which contains the functions defined in the constructor of the .h file are some hex values too, but i dont know anything about them.
Code:
SRAM2class::SRAM2class()  //constructor
{
setupDDRB;
setupSPI;

deselectSS1;  //deselect if selected
deselectSS2;  //deselect if selected

selectSS1; //setup SRAM1
RWdata(0x05);//read status register
int Sreg = RWdata(0xff);//get status value
deselectSS1;

if(Sreg != 0x41) //are we in sequential mode
{
selectSS1;
RWdata(0x01); //write to status reg
RWdata(0x41);  //set sequencial  mode
deselectSS1;
}//end of set sequential mode for SRAM1

selectSS2; //setup SRAM2
RWdata(0x05);//read status register
Sreg = RWdata(0xff);//get status value
deselectSS2;

if(Sreg != 0x41) //are we in sequential mode
{
selectSS2;
RWdata(0x01); //write to status reg
RWdata(0x41);  //set sequencial  mode
deselectSS2;
}//end of set sequential mode for SRAM2
}//end of constructor

void SRAM2class::writestream1(int address)
{
deselectSS1;  //deselect if still selected
deselectSS2;  //deselect if still selected
selectSS1; //select now
RWdata(0x02);//write to address
RWdata(address >> 8);//msb address
RWdata(address);//lsb address  
}//end of write stream SRAM 1

void SRAM2class::writestream2(int address)
{
deselectSS1;  //deselect if still selected
deselectSS2;  //deselect if still selected
selectSS2; //select now
RWdata(0x02);//write to address
RWdata(address >> 8);//msb address
RWdata(address);//lsb address  
}//end of write stream SRAM 2

void SRAM2class::readstream1(int address)
{
deselectSS1;  //deselect if still selected
deselectSS2;  //deselect if still selected
selectSS1; //select now
RWdata(0x03);//read from address
RWdata(address >> 8);//read from address
RWdata(address);
}//end of read stream SRAM1

void SRAM2class::readstream2(int address)
{
deselectSS2;  //deselect if still selected
deselectSS1;  //deselect if still selected
selectSS2; //select now
RWdata(0x03);//read from address
RWdata(address >> 8);//read from address
RWdata(address);
}//end of read stream SRAM2

void SRAM2class::closeRWstream(void)
{
deselectSS1;  //deselect
deselectSS2;  //deselect
}//end of close RW stream

byte SRAM2class::RWdata(byte data)
{
 SPDR = data;
  while (!(SPSR & _BV(SPIF)))
    ;
  return SPDR;
}//end of RWdata

Does anyone see a Problem?

Another thing i am not sure with is:
carl used a 820 Ohm and 1.5kOhm voltage divider to get the 5 V signal from the arduino to 3,3V
Because i didnt have those values I took 6,2kOhm and 10kOhm.

is that too much ?
« Last Edit: May 08, 2012, 11:22:45 am by Flub » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got it working! now lets see if i can save audio in it.
But I have some problems with understanding the test code below.

in the for loop there is no occurance of the variable i, i had expected something like
for (unsigned int i=0; i< 32768; i++) {
SRAM2.RWdata(i);
}
but there is no i in between the brackets, how does it work then?

Code:
SRAM2.writestream1(0);  // write to SRAM 1
unsigned long stopwatch = millis(); //start stopwatch
for(unsigned int i = 0; i < 32768; i++)
SRAM2.RWdata(0x55); //write to every SRAM 1 address
Serial.print(millis() - stopwatch);
Serial.println("   ms to write full SRAM 1");
SRAM2.readstream1(0);   // start address from 0
for(unsigned int i = 0; i < 32768; i++)
{
if(SRAM2.RWdata(0xFF) != 0x55)  //check every address in the SRAM1
{
Serial.print("error in SRAM 1 at location  ");
Serial.println(i);
break;
}//end of print error
if(i == 32767)
Serial.println("no errors for SRAM 1 in its 32768 bytes");
}//end of get byte
Serial.println(" ");

SRAM2.writestream2(0);  // write to SRAM 2
stopwatch = millis(); //start stopwatch
for(unsigned int i = 0; i < 32768; i++)
SRAM2.RWdata(0xaa); //write to every SRAM 2 address
Serial.print(millis() - stopwatch);
Serial.println("   ms to write full SRAM 2");
SRAM2.readstream2(0);   // start address from 0
for(unsigned int i = 0; i < 32768; i++)
{javascript:void(0);
if(SRAM2.RWdata(0xFF) != 0xaa)  //check every address in the SRAM2
{
Serial.print("error in SRAM 2 at location  ");
Serial.println(i);
break;
}//end of print error
if(i == 32767)
Serial.println("no errors for SRAM 2 in its 32768 bytes");
}//end of get byte
Serial.println(" ");

delay(1000);
« Last Edit: May 08, 2012, 01:33:02 pm by Flub » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I haven't read the datasheet, but some devices auto-increment. In other words, they assume that, if you don't specify a new address, you want to read/write to consecutive ones. This assumption saves sending an address for every single access when you might want to store 20 bytes in a row.
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 339
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im following this closely , as ill soon start working on a delay as well to implement in the dub siren im developing.
Thanks for sharing it all !!
Logged

10 LET Loop=Infinite
20 GO TO 10

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thats it Nick! Thank you!
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can someone help me out with creating a shift register from an octal d-type flipflop chip?

http://pdf1.alldatasheet.com/datasheet-pdf/view/28018/TI/SN74LS377N.html

I want to serially load it with 8 bit for the DAC

Do i have to connected Q1 with D2 and Q2 with D3 and Q3 with D4 etc ?

Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8436
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That sounds about right, Crossroads is always posting a circuit to do this.

Why not use the right chip for the job?

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I dont wont to order via internet just to test the delay, because i try to find a 12 serial input dac later anyway
Logged

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