Show Posts
Pages: [1] 2
1  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: September 29, 2012, 01:23:39 pm
Thanks for this library ! I managed to get my module working. I used a noname 2GD card.

However, if i call the playVoice() or asyncPlayVoice() function once, nothing happen. I have to call the function several times to make the module work.

Another problem is that the playback stops 10 ou 20s after the beginning. I tried with 8bits 22050Hz and 8bits 11025Hz.

Has anyone succeeded in playing a long file ?

Thanks !
2  Using Arduino / Audio / Re: cheap sound module: what version is this? on: September 13, 2012, 04:33:21 am
Thanks for your answer.

I will use this module to build an alarm clock.  I hope the sound quality will be good enough for this use.
3  Using Arduino / Audio / Re: cheap sound module: what version is this? on: September 10, 2012, 01:47:47 pm
Hi all,

I also bought these modules.

I want to use them with a 5V Arduino.
As I have V1.5, I can choose between 3,3V and 5V.

But I don't see any 3,3V regulator on the board. As a result, how can the board supply the SD card with 3,3V (remember that SD cards only works with 2,5V-3,6V !) ?

Can anyone confirm that if I change the strap position from 3,3V to 5V and supply it with 5V, my 3,3V SD Card won't burn ?

Other questions, do someone have tried 2GB cards (not 4Gb or more SDHC card) with a 1GB partition ?

Thanks
4  Using Arduino / Programming Questions / Re: Interrupt when serial data available on: July 19, 2012, 09:25:43 am
Thanks for the replies.

I didn't find how to catch interrupt HardwareSerial.h/HardwareSerial.cpp, so I increased the buffer size and now it works.
I will try to optimize my code however.

Thanks.
5  Using Arduino / Programming Questions / Re: Interrupt when serial data available on: July 18, 2012, 09:02:47 am
Thanks for your answer.

Do you know how can I catch this interrupt ?
6  Using Arduino / Programming Questions / Interrupt when serial data available on: July 18, 2012, 08:00:23 am
Hi all,

My Arduino Mega 2560 needs to receive long strings (500-1500 octets) on the USB serial port, while doing very heavy tasks.
I check Serial.available() at the beginning of loop(), and I do other stuff in the other part of loop().

The problem is my stuff in loop() is too long and the serial buffer is sometime full before the next loop() turn. The end of my string is lost.

I was looking for enabling an interrupt which will let me read the incoming byte in priority.
The Serialevent() function is not appropriate because it is called the following loop() turn...

Is there a way to launch an interrupt when a byte is available on the serial buffer ?

Thanks for your reply.
7  Using Arduino / Audio / Problem while playing Wav files (SDcard & TLC7226 DAC) on: October 24, 2011, 01:24:11 pm
Hi all,
I need to play .wav files from a SD Card. I chose to use 22050Hz 8bits mono files.

I connected a TLC7226 parallel DAC to my Arduino Duemilanove. The datasheet is here : http://www.ti.com/lit/ds/symlink/tlc7226.pdf
I use the first DAC (it's name DACA in the datasheet), that's why I connected A0 and A1 to ground. The D0-D7 pins go to the Arduino, as /WR one. Voltage reference is 5V.

A speaker is connected between OUTA and ground, through a 100 ohm resistor and a 10µF capacitor.

The DAC works well, I can hear a square wave for instance. I also read data from my SD card. The problem is when I read a byte from the file and I write it on the DAC, I can't recognize the music. There's just "cracking sounds".

Here is my code, sorry for the French :

Code:
#include <SD.h>

/*
  Connexion SD Card :
   ** MOSI (Violet) - pin 11
   ** MISO (Violet) - pin 12
   ** CLK (Gris) - pin 13
   ** SS (Blanc) - pin 4
*/


File fichier;
byte octet;
int i;



int pin_D[8] = {A0, A1, A2, A3, A4, A5, 2, 3}; // Here is connected my DAC
int pin_Enable = 7;





void Ecrire_DAC(byte val) // Write a byte to the DAC
{
    int i;
    
    for(i = 0; i < 8; i++) // I know that way to write the byte is slow. It's just for debug.
        digitalWrite(pin_D[i], bitRead(val, i));
    
    digitalWrite(pin_Enable, LOW);
    delayMicroseconds(5);
    digitalWrite(pin_Enable, HIGH);
    
    //Serial.print("Ecriture de ");
    //Serial.println(val, HEX);
}


void setup()
{
    int i;
    
    
    // Configuration du port série
    Serial.begin(115200);
    
    
    // Configuration du DAC
    pinMode(pin_Enable, OUTPUT);
    digitalWrite(pin_Enable, HIGH);
    for(i = 0; i < 8; i++)
        pinMode(pin_D[i], OUTPUT);
    Ecrire_DAC(0);
    
    pinMode(10, OUTPUT);
    if(SD.begin(10))
        Serial.println("Initialisation de la carte SD reussie.");
    else
        Serial.println("Echec de l'initialisation de la carte SD.");
    
    fichier = SD.open("22khz8b.wav");
    if(fichier)
        Serial.println("Ouverture du fichier reussie.");
    else
    {
        Serial.println("Echec de l'ouverture du fichier.");
        return;
    }
    
    fichier.seek(300); // make sure the pointer comes over the data
    
}




void loop()
{
    octet = fichier.read();
    Ecrire_DAC(octet);
    delayMicroseconds(45);
}
Even if the speed of the music will be very approximative, because I don't wait precisely 45µs between each byte, I thought I can hear something.

Can someone help ?
Thanks
8  Using Arduino / Programming Questions / Re: Help to modify a pin in a library on: August 20, 2011, 05:43:33 am
Help please...
9  Using Arduino / Programming Questions / Re: Help to modify a pin in a library on: August 18, 2011, 02:30:42 pm
I'd start by looking for something that referenced the number "3" and a pin.
(though if I were writing a published library, I'd make it more obvious and easier to change in the first place)

Hi,
Indeed, I think I have to change theses lines (in red) :

Quote
/* Sends an IR mark for the specified number of microseconds. */
void IRsend::mark(int time) {
    // The mark output is modulated at the PWM frequency.
  TCCR2A |= _BV(COM2B1); // Enable pin 3 PWM output
  delayMicroseconds(time);
}

/* Leave pin off for time (given in microseconds) */
void IRsend::space(int time) {
  // Sends an IR space for the specified number of microseconds.
  // A space is no output, so the PWM output is disabled.
  TCCR2A &= ~(_BV(COM2B1)); // Disable pin 3 PWM output
  delayMicroseconds(time);
}

void IRsend::enableIROut(int khz) {
  // Enables IR output.  The khz value controls the modulation frequency in kilohertz.
  // The IR output will be on pin 3 (OC2B).
  // This routine is designed for 36-40KHz; if you use it for other values, it's up to you
  // to make sure it gives reasonable results.  (Watch out for overflow / underflow / rounding.)
  // TIMER2 is used in phase-correct PWM mode, with OCR2A controlling the frequency and OCR2B
  // controlling the duty cycle.
  // There is no prescaling, so the output frequency is 16MHz / (2 * OCR2A)
  // To turn the output on and off, we leave the PWM running, but connect and disconnect the output pin.
  // A few hours staring at the ATmega documentation and this will all make sense.
  // See my Secrets of Arduino PWM at http://arcfn.com/2009/07/secrets-of-arduino-pwm.html for details.

 
  // Disable the Timer2 Interrupt (which is used for receiving IR)
  TIMSK2 &= ~_BV(TOIE2); //Timer2 Overflow Interrupt
 
  pinMode(3, OUTPUT);
  digitalWrite(3, LOW); // When not sending PWM, we want it low

 
  // COM2A = 00: disconnect OC2A
  // COM2B = 00: disconnect OC2B; to send signal set to 10: OC2B non-inverted
  // WGM2 = 101: phase-correct PWM with OCRA as top
  // CS2 = 000: no prescaling
  TCCR2A = _BV(WGM20);
  TCCR2B = _BV(WGM22) | _BV(CS20);

  // The top value for the timer.  The modulation frequency will be SYSCLOCK / 2 / OCR2A.
  OCR2A = SYSCLOCK / 2 / khz / 1000;
  OCR2B = OCR2A / 3; // 33% duty cycle
}

Of course, it isn't lines 3 and 4 which raises a problem, but lines 1 and 2. I don't know what does these lines mean.

Well that library has some example files and the below shows that the users sketch defines what input pin should be used when calling the IR receive function:
My problem concerns the emitting led, which is obviously on pin 3.
10  Using Arduino / Programming Questions / Help to modify a pin in a library on: August 18, 2011, 12:38:16 pm
Hi all,
I use a arduino IR library to receive and send IR codes.
The pin used by the IR emitting led is written directly in the library, it's Arduino pin 3.
Everything worked well, untill I forgot the resistor for the IR led. Since that mistake, this Arduino pin doesn't sink or source any current.

I have to change the pin directly in the library to choose another one, but I don't know how to do this.
That's the concerned code of the library :

Code:
/* Sends an IR mark for the specified number of microseconds. */
void IRsend::mark(int time) {
    // The mark output is modulated at the PWM frequency.
  TCCR2A |= _BV(COM2B1); // Enable pin 3 PWM output
  delayMicroseconds(time);
}

/* Leave pin off for time (given in microseconds) */
void IRsend::space(int time) {
  // Sends an IR space for the specified number of microseconds.
  // A space is no output, so the PWM output is disabled.
  TCCR2A &= ~(_BV(COM2B1)); // Disable pin 3 PWM output
  delayMicroseconds(time);
}

void IRsend::enableIROut(int khz) {
  // Enables IR output.  The khz value controls the modulation frequency in kilohertz.
  // The IR output will be on pin 3 (OC2B).
  // This routine is designed for 36-40KHz; if you use it for other values, it's up to you
  // to make sure it gives reasonable results.  (Watch out for overflow / underflow / rounding.)
  // TIMER2 is used in phase-correct PWM mode, with OCR2A controlling the frequency and OCR2B
  // controlling the duty cycle.
  // There is no prescaling, so the output frequency is 16MHz / (2 * OCR2A)
  // To turn the output on and off, we leave the PWM running, but connect and disconnect the output pin.
  // A few hours staring at the ATmega documentation and this will all make sense.
  // See my Secrets of Arduino PWM at http://arcfn.com/2009/07/secrets-of-arduino-pwm.html for details.

  
  // Disable the Timer2 Interrupt (which is used for receiving IR)
  TIMSK2 &= ~_BV(TOIE2); //Timer2 Overflow Interrupt
  
  pinMode(3, OUTPUT);
  digitalWrite(3, LOW); // When not sending PWM, we want it low
  
  // COM2A = 00: disconnect OC2A
  // COM2B = 00: disconnect OC2B; to send signal set to 10: OC2B non-inverted
  // WGM2 = 101: phase-correct PWM with OCRA as top
  // CS2 = 000: no prescaling
  TCCR2A = _BV(WGM20);
  TCCR2B = _BV(WGM22) | _BV(CS20);

  // The top value for the timer.  The modulation frequency will be SYSCLOCK / 2 / OCR2A.
  OCR2A = SYSCLOCK / 2 / khz / 1000;
  OCR2B = OCR2A / 3; // 33% duty cycle
}



Thanks for your help
11  Using Arduino / Programming Questions / Re: Several files in a sketch on: July 29, 2011, 09:42:43 am
Thanks ! It works fine !

I think I would be interesting to put this tip in the documentation.

Have a nice day,
12  Using Arduino / Programming Questions / Re: Several files in a sketch on: July 29, 2011, 04:37:42 am
Thanks for your response.
But that's exactly whay I've done ! To create my new tab, I clicked on  the right arrox, next "New tab" and I typed "functions.c" as filename.

Another idea ?
13  Using Arduino / Programming Questions / Several files in a sketch on: July 28, 2011, 04:03:05 pm
Hi all !
i'm working on a big sketch for an Arduino Mega 2560. As the sketch is quite large, I want to split it in several files.
 So, I made a new sketch called "Test" (very original !).
Here is the code :

Code:
bool led = 0;

void setup()
{
    pinMode(13, OUTPUT);
}

void loop()
{
    blink(&led);
    delay(1000);
}

And I added a new tab called "functions.c" which contains that code :
Code:
void blink(bool *led)
{
    *led = !(*led);
    digitalWrite(13, led);
}

but that code doesn't compile..
How can I split my code in several files ?
Thanks for your answers
14  Forum 2005-2010 (read only) / Français / Re: Ajouter RAM arduino on: January 05, 2011, 12:21:47 pm
Merci à vous deux pour vos réponses. Le nombre de réécritures possibles sur une SD card ou une EEPROM n'est pas vraiment un problème, car nous sommes en école d'ingénieur et ce n'est qu'un projet purement pédagogique et les photos sont prises à des intervalles de temps plutôt long.

Je vais voir le datasheet pour rajouter la RAM dont tu parles et me rendre compte de la complexité des connexions. Si c'est à notre portée on utilisera cette solution, sinon on se rabattra sur une RAM ou une EEPROM spi ou i2c, ou une SD card (si j'ai bien compris, les 3 dernières solutions sont à peu près équivalentes au niveau de la complexité de programmation).

Si vous avez d'autres idées ou suggestions n'hésitez pas.
Merci beaucoup
15  Forum 2005-2010 (read only) / Français / Ajouter RAM arduino on: January 05, 2011, 07:17:28 am
Bonjour
J'utilise un Arduino Mega connecté à une caméra. Les images doivent ensuite être transmises via Wifi.

Pour des raisons pratiques, j'ai besoin de pouvoir stocker l'image (compressée préalablement en jpeg par la caméra) entière dans une mémoire temporaire avant de commencer à l'envoyer.

J'ai pensé à utiliser une mémoire RAM (SRAM?) de 64Ko externe.
Savez vous si cela est envisageable ? Si oui, comment fonctionne l'adressage?
L'idéal serait de pouvoir déclarer des variables qui seraient stockées dans cette ram (par ex byte image [65536]; ) pour pouvoir les manipuler facilement. Mais je ne sais pas comment fonctionne un mappage de ce type.

Sinon, je me rabattrai sur une EEPROM i²c mais cela sera nettement moins pratique (obligation de lire/écrire octet par octet).

Merci d'avance pour votre aide
Pages: [1] 2