Loading...
  Show Posts
Pages: 1 ... 57 58 [59] 60 61 ... 84
871  Using Arduino / Project Guidance / Re: EEPROM better than SD card for audio ? on: September 25, 2011, 04:36:38 am
I have had one last try at using the SD card.

I modified the Adafruit wave library to take my bcd inputs, but its exactly the same, it reads the 256Mb cards, but not most of the 2Gb cards.

Heres the code  below, I dont know if there is something stupid, otherwise I will carry on with the eeprom try, which I am rather out of my depth on I must confess...

Code:
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"

SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f; // This holds the information for the file we're play

WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time

int talkingPin = 19;  // high while audio playing to video chip to keep number on.
int aPin =18; //define pin numbers for bcd inputs from HT12D
int bPin =17;
int cPin =15;
int dPin =16;
int vtPin = 14; // define pin numbers for valid transmission input from HT12D
int track ; // define audio track number
int bcda ; // define bcd digitalreads for BCD/dec conversion
int bcdb;
int bcdc;
int bcdd;
int valid ;  // to be set high if vt in

// this handy function will return the number of bytes currently free in RAM, great for debugging!
int freeRam(void)
{
  extern int  __bss_end;
  extern int  *__brkval;
  int free_memory;
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end);
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval);
  }
  return free_memory;
}

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);

}

void setup() {
  // set up serial port
  Serial.begin(9600);

  pinMode (aPin,INPUT);  //bcd inputs from HT12
  pinMode (bPin,INPUT);
  pinMode (cPin,INPUT);
  pinMode (dPin,INPUT);
  pinMode (vtPin,INPUT);  // valid trasnmission input
  pinMode (talkingPin,OUTPUT); // display enable to vga chip

  putstring_nl("WaveHC with 9 inputs");

  putstring("Free RAM: "); // This can help with debugging, running out of RAM is bad
  Serial.println(freeRam()); // if this is under 150 bytes it may spell trouble!

  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

  // pin13 LED
  pinMode(13, OUTPUT);

   if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you  *****  TRIED BOTH
 // if (!card.init()) {    //play with 8 MHz spi (default faster!)
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
    sdErrorCheck();
    while(1);     // then 'halt' - do nothing!
  }
  // enable optimize read - some cards may timeout. Disable if you're having problems *** TRIED WITH AND WITHOUT AND true
 // card.partialBlockRead(false);
  // Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in
    if (vol.init(card, part))
      break;      // we found one, lets bail
  }
  if (part == 5) {      // if we ended up not finding one  :(
    putstring_nl("No valid FAT partition!");
    sdErrorCheck(); // Something went wrong, lets print out why
    while(1);     // then 'halt' - do nothing!
  }

  // Lets tell the user about what we found
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?

  // Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);      // then 'halt' - do nothing!
  }

  // Whew! We got past the tough parts.
  putstring_nl("Ready!");
}

void loop() {

  bcda = digitalRead ( aPin );  // read the state of the video micro "decode" data outputs 
  bcdb = digitalRead ( bPin );
  bcdc = digitalRead ( cPin );
  bcdd = digitalRead ( dPin );
  valid = digitalRead ( vtPin );  // check if signal received, set valid high

  if (bcda==1 && bcdb==0 && bcdc == 0 && bcdd == 0 ) { //longwinded bcd / dec decoding to give track number to be read
    track = 1;
  }
  if (bcda==0 && bcdb==1 && bcdc == 0 && bcdd == 0 ) {
    track = 2;
  }
  if (bcda==1 && bcdb==1 && bcdc == 0 && bcdd == 0 ) {
    track = 3;
  }
  if (bcda==0 && bcdb==0 && bcdc == 1 && bcdd == 0 ) {
    track = 4;
  }
  if (bcda==1 && bcdb==0 && bcdc == 1 && bcdd == 0 ) {
    track = 5;
  }
  if (bcda==0 && bcdb==1 && bcdc == 1 && bcdd == 0 ) {
    track = 6;
  }
  if (bcda==1 && bcdb==1 && bcdc == 1 && bcdd == 0 ) {
    track = 7;
  }
  if (bcda==0 && bcdb==0 && bcdc == 0 && bcdd == 1 ) {
    track = 8;
  }
  if (bcda==1 && bcdb==0 && bcdc == 0 && bcdd == 1 ) {
    track = 9;
  } 

// if ( valid == HIGH ){
 
  if (track==1 ) {
    playcomplete("doornum1.wav");
  }
  else;
  if (track==2) {
    playcomplete("doornum2.wav");
  }
  else;
  if (track==3) {
    playcomplete("doornum3.wav");
  }
  else;
  if (track==4) {
    playcomplete("doornum4.wav");
  }
  else;
  if (track==5) {
    playcomplete("doornum5.wav");
  }
  else;
  if (track==6) {
    playcomplete("doornum6.wav");
  }
  else;
  if (track==7) {
    playcomplete("doornum7.wav");
  }
  else;
  if (track==8) {
    playcomplete("doornum8.wav");
  }
  else;
  if (track==9) {
    playcomplete("doornum9.wav");
  }
 //}
}
// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  if (wave.isplaying) {//   set display enable high to vga chip
    digitalWrite(talkingPin, LOW);
  }
  else
  { 
    digitalWrite(talkingPin, HIGH);
  }
  while (wave.isplaying) {

  }
  // now its done playing
}

void playfile(char *name) {
  // see if the wave object is currently doing something
 //if (wave.isplaying) {// already playing something, so stop it!  cant happen with talkinpin
 //  wave.stop(); // stop it
//}
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file ");
    Serial.print(name);
    return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV");
    return;
  }
 if (valid == 1){  //  wont run without this here
    // ok time to play! start playback
    wave.play();

  }

}




872  Using Arduino / Project Guidance / Re: EEPROM better than SD card for audio ? on: September 22, 2011, 10:05:47 pm
Of course the other thing is that this test addresses, then writes, to each byte in turn.

I will be random addressing approx 5 Kb at a time, so just need to send the start address once, then read a whole string of bytes.

I havnt even connected the DAC yet, this was just a speed test routine in the library

I am going to see if I can test writing a couple of bytes , then test the retrieve time.  I will not actually be writing to the eeprom at all once it is "recorded"  except for the dummy write before each random read ( as per data sheet for the 24C1024 )
This is all interesting new ground for me.

The DAC I am using at the moment  is connected as in the top right of
 http://www.ladyada.net/media/wavshield/waveshield10schem.png
873  Using Arduino / Project Guidance / Re: EEPROM better than SD card for audio ? on: September 22, 2011, 04:13:45 pm
I eventually went back to the serial printout, which I thought was hung, and it reports:

Code:
E24C1024 Library Benchmark Sketch

--------------------------------
Write By Byte Test:

Writing data:...........................DONE
Total Time (seconds): 722
Write operations per second: 181
--------------------------------

--------------------------------
Read By Byte Test:

Reading data:...........................DONE

Total Test Time (secs): 83
Read operations per second: 1579
Total errors: 0
--------------------------------

If I cant get more than 1579 bytes ( or is it talking bits? ) I cant see it providing data fast enough to the DAC for the audio ???
874  Using Arduino / Project Guidance / Re: Arduino+TLC5940+12.8A LEDs on: September 22, 2011, 03:06:35 pm
I dont know how bumping it would help.

But what exactly do you want the LEDs to do, it looks like pillars of one colour strips in parallel or a couple of groups.

875  Using Arduino / Project Guidance / Re: EEPROM better than SD card for audio ? on: September 22, 2011, 02:56:22 pm
OK I have bought a 24C1024 eeprom, made up a little Mgyver shield, and studied the datasheet.

I have tried the benchmark example of http://www.arduino.cc/playground/Code/I2CEEPROM24C1024
but it gets to " writing data " and hangs.

I notice there is no "begin" in the setup, which I think should be the memory reset  from the datasheet ?

I just want to try writing to and receiving from the eeprom for now.

I will try through the night and see how I get on.

My next task will be to find how to download the WAV files in bytes and store them on the eeprom.
 
876  Using Arduino / Project Guidance / Re: EEPROM better than SD card for audio ? on: September 21, 2011, 10:13:40 pm
The code I have been using is basically the example from the guy who writes the FAT libraries, and he reckons the wave HC is the one best suited to audio.
I have to have this project sorted out without the audio problem .  The audio part is just a small part of the project, which superimposes graphics on a HD LCD screen, which is working fine ...

I will try your idea with no libraries Bob, and start with a small example with just a couple of files, I think I can master the eeprom part, its similar to the RTC chip eeprom on the last project , which is working well.
I am not too sure about the DAC, but I have downloaded the datasheet and see what I can do.

The wavehc code is extremely complicated for us beginners, but I am hoping most of it is for the SD card side....
877  Using Arduino / Project Guidance / Re: EEPROM better than SD card for audio ? on: September 21, 2011, 01:13:27 pm
OK I have broken the announcements into 14 slices of WAV files totalling 259k ( I could probably trim them a little more )

In an ideal world I could just swap the SD card for a pair of AT24C1024W EEPROMs that are available locally.

I don't really understand how the waveHC library interacts with the DAC and the SD card, presumably the FAT side would be a much simpler random address on the EEPROM for the various sound files ?

To record the WAV files on the EEPROM would presumably be a separate sketch to import each byte or batch of bytes of the WAV file from the PC, via the Arduino board, and store them on the EEPROM?

I would then plug the eeprom into a socket on the project board, which has a 328 chip to read from the eeprom and feed to the DAC or whatever ?

am I on the right track, or trying to reinvent the wheel?
878  Using Arduino / Project Guidance / Re: EEPROM better than SD card for audio ? on: September 20, 2011, 09:26:50 pm
Thanks Bob
I think the first thing I must do is rerecord the anouncements with a view to making them smaller files - it didn't matter before with the SD cards.
Then I can see what size I must work on

879  Using Arduino / Project Guidance / Re: EEPROM better than SD card for audio ? on: September 20, 2011, 02:55:18 pm
It seems that there are many people who have the same problem with the larger memory SD cards, and I havn't found any answers posted yet.
The real problem is that it is intermittent, the card just doesn't respond after a while, replacing it works again for a while.
Replacing the card with a 250Mb version ( when I can find them ) works fine every time.

I have tried changing the buffer chip to several different types, and decoupling caps right on the socket of the card, but not found the answer........
880  Using Arduino / Project Guidance / Re: controlling a hundred solenoids on: September 20, 2011, 02:46:31 pm
If you are interested, I designed a PCB that has up to 20 x TPIC6B595 shift register/latches that can control up to 160 LED strips or solenoids of up to 500mA each. These chips also have clamp diodes built in.The outputs all latch, so you only have to update the chips when something changes.
The board has the arduino chip on board with a socket, and a 5v regulator and a wireless receiver module.
The board is in the .LAY format of the SPRINT pcb design format, but I can post the Gerber files, and the sketch.


881  Using Arduino / Project Guidance / EEPROM better than SD card for audio ? on: September 20, 2011, 10:02:58 am
I have a project that uses up to 9 audio announcements of about 4 seconds duration.
At the moment I am using a SD card, and the waveHC library, but unless I use a SD card of 250Mb or less it is unreliable, and sometimes won't read the card.

Would it be better to use some EEPROMs ?    the audio tracks are between 250 and 850k, but I am sure i can reduce the sampling without hassles.

I just need some advise here..........
882  Using Arduino / Storage / Re: EEPROM overwite previous data? on: September 10, 2011, 02:01:51 am
True Bob,  I do have prescription glasses that darken in sunlight, I forgot to test them on the white LEDs, I must check that.

On a serious note, one of my suppliers has a display with all the different colour LEDs on all day, including the blue ones that I use for illuminating flourescent targets,( they have so much ultra violet content.)
I have warned him about damage to his counterstaffs' eyes, I temporary ( 2 hours or so ) lost the sight of one eye a couple of years back when experimenting with a couple of ultraviolet LEDs, so I am very wary now.
883  Using Arduino / Storage / Re: EEPROM overwite previous data? on: September 09, 2011, 05:15:13 pm
I blame it on being hard to read the screen after 3 days testing the previous project with 1000 ultra bright white LEDs :-)   I could literally switch off the rooms normal lights without seeing any difference - depending on the numbers being displayed of course !
884  Using Arduino / Storage / Re: EEPROM overwite previous data? fixed on: September 09, 2011, 08:05:31 am
I found the problem.....

I had  Wire.endTransmission();    after setting the pointer , removed it and it works
885  Using Arduino / Storage / Re: EEPROM overwite previous data? on: September 09, 2011, 07:41:18 am

I am back on the RTC project again, and am having trouble writing to the DS1307s RAM,  I have tried a basic sketch just to store and retreive some data ( below )
Am I doing something stupid here?  It just gives me the old data back from the RAM

Code:

/*  just loading the ram for testing
 */
#include <Time.h> 
#include <Wire.h> 
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t
byte prevday ;          //  prev days of month for display
byte prevmonth ;         //prev month for display
byte prevyear ;         //prev year  for display
byte prevbest ;   // highest longest interval up to 99
byte upperbyte;   //  of previous unix days
byte lowerbyte;   //  -"-
unsigned long old_unix_days;
unsigned long  unidays;
unsigned long  unisecs;
//*************************************************************************************
void setup()  {
  Serial.begin(9600);
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if(timeStatus()!= timeSet)
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");     
     Wire.begin(); // no address, we are master
  Serial.begin (9600);     
}
void loop()
{
 
 
    prevday = 12;
  prevmonth= 10;
  prevyear = 33;
  prevbest = 87;
  upperbyte = 22;
  lowerbyte = 44;
 
 Wire.beginTransmission(0x68); 
  Wire.send(0x08);  // to start of RAM
  Wire.endTransmission(); 

 
 
  Wire.send (prevday);
  Wire.send (prevmonth);
  Wire.send (prevyear);
  Wire.send (prevbest);
  Wire.send (upperbyte);
  Wire.send (lowerbyte);
  Wire.endTransmission();
 Serial.println("finished loading"); 

  Wire.beginTransmission(0x68); 
  Wire.send(0x08);  // to start of RAM
  Wire.endTransmission(); 
  Wire.requestFrom(0x68,6 );  // Read back first six RAM addresses
  prevday = Wire.receive();
  prevmonth = Wire.receive();
  prevyear= Wire.receive();
  prevbest = Wire.receive(); 
  upperbyte = Wire.receive(); 
  lowerbyte = Wire.receive();
  Serial.print ("prev day read " );
  Serial.println (prevday, HEX);
  Serial.print ("prev month read " );
  Serial.println (prevmonth, HEX);
  Serial.print ("prev year read " );
  Serial.println (prevyear, HEX);
  Serial.print ("prev best read " );
  Serial.println (prevbest, HEX);
  Serial.print ("upperbyte read " );  Serial.print (upperbyte, HEX); Serial.print (" ,  upperbyte read " );  Serial.println (upperbyte, HEX);
  Serial.print ("lowerbyte read " );  Serial.print (lowerbyte, HEX);  Serial.print (",   lowerbyte read " ); Serial.println (lowerbyte, BIN);
  long old_unix_days = word (upperbyte, lowerbyte);
  Serial.print(" old_unix_days = ");  Serial.print (old_unix_days); Serial.print(",   old_unix_days = "); Serial.println(old_unix_days, BIN);
}
Pages: 1 ... 57 58 [59] 60 61 ... 84