Show Posts
Pages: [1] 2 3 ... 24
1  Products / Arduino Due / Re: Audio (yes, I know) on: September 04, 2014, 08:55:52 am
Im not sure how long those packet sending will take, so you should first find a way of sampling ?!
an idea below ( not sure youll have space for 8000 samples though

#include <DueTimer.h>
#define SMPL_RATE 8000
#define WAVE_SAMPLES 512
uint8_t wav_data[WAVE_SAMPLES];
uint16_t i;
uint8_t sample;
int myLed = 13;
bool f_sample = false;

void setup() {
  // put your setup code here, to run once:
  //  The master clock, MCLK = 84MHz. ADC prescaler is set to 0x01 which is "divide by 4" so
  //  the ADC clock is 84MHz / 4 = 21MHz. That is as fast as it can go.
  //  The ADC clock period is 1 / 21MHz = 37.6nS. 0xC sets STARTUP is 768. 768 / 21MHz = 36.6uS.
  //  Bingo! So, set STARTUP to a smaller number ( 2 ): (value = 16 / 21M = .76uS) :
  REG_ADC_MR = (REG_ADC_MR & 0xFFF0FFFF) | 0x00020000;  //  And the ADC loop now runs faster.
  pinMode(myLed, OUTPUT);
  //  Timer3.attatchInterrupt(myHandler).setFrequency(8000).start();
  // Is the same as:
  Timer3.setFrequency(SMPL_RATE); //setFrequency(long frequency) Set timer freq

void loop() {
  while (!f_sample) {
    uint16_t input0 = analogRead(0);
    sample = input0 >> 2  ;
    wav_data[i] = sample;
    if ( i >= WAVE_SAMPLES) {
      i = 0;
    digitalWrite(myLed, digitalRead(myLed) ^ 1);
    f_sample = false;


void myHandler() {
  f_sample = true;

The Timer3.start() can be used where you want to trigger the sampling, instead of the setup. Hope its self explanatory.
2  Products / Arduino Due / Re: Audio (yes, I know) on: September 02, 2014, 06:13:57 pm
Not sure how relevant it is, but the values expected  ( wav) are unsigned for 8 bit 8kHz (Unsigned 8 bit PCM) . Straight uncompressed MS-format (RIFF) WAV is the most compatible format for interchange..
Should save you some more work later, by the looks of it.

* and look at the Timer interrupt library for DUE, as advised above will solve some of your problems
3  Using Arduino / Interfacing w/ Software on the Computer / Re: Turn Serial Monitor Data into Graph? on: August 04, 2014, 06:15:39 pm
This, for starters?
Remember seeing another more advanced for several values with different colors...cant remember where though.
4  Products / Arduino Due / Re: What are the possible PWM frequencies? And how to set them. on: August 04, 2014, 03:11:58 pm
Highly instructive smiley
5  Products / Arduino Due / Re: How attach interrupt timmer with exact time interval on: August 04, 2014, 02:58:51 pm
SD card? SPI, so  keep it out of the interrupt.
As mentioned, you should keep the interrupt to a minimum. Use maybe a Boolean variable toggled inside the interrupt and then write it in the loop with a if( previousVar !=var) kind of thing ? previousVar would be the last known, and saved state
6  Using Arduino / General Electronics / Re: Wiring of 6 pots to Arduino on: August 04, 2014, 02:38:16 pm
Using that many pots, dont forget decoupling caps.  smiley Will allow you to use higher resistance pots and all.
7  Using Arduino / Programming Questions / Re: declaring several arrays (LUTs) on: August 03, 2014, 01:31:22 pm
Thanks .
8  Using Arduino / Programming Questions / Re: declaring several arrays (LUTs) on: August 01, 2014, 03:03:08 pm
No problem.
I meant initial purpose of a "one line solution".
Your way is a new way for me and ill use it
Thanks !
9  Using Arduino / Programming Questions / Re: declaring several arrays (LUTs) on: August 01, 2014, 02:56:52 pm
Defeats the initial purpose  smiley
It was something  that has baffled me. My intention is just to write better code, while readable.
Of course code obfuscating is an art in itself  smiley-cool
10  Using Arduino / Programming Questions / Re: declaring several arrays (LUTs) on: August 01, 2014, 02:47:32 pm
Arduino Due ( Code its working, nuh worries there).
Im getting engulfed in more and more lines of code .
Answer, anyone ?
11  Using Arduino / Programming Questions / declaring several arrays (LUTs) on: August 01, 2014, 12:48:49 pm
Im highly confused with this... and feel like its a silly question, tbh.
Isnt there a way of declaring several arrays of same length in just one line ?
In the style of

uint16_t ii, iii, iiii, iv;

As you can probably guess, they are-to-be LUTs

What im trying to short down is something like this :

uint16_t sin_data[WAVE_SAMPLES];
uint16_t cos_data[WAVE_SAMPLES];
uint16_t saw_data[WAVE_SAMPLES];
uint16_t tri_data[WAVE_SAMPLES];
uint16_t sq_data [WAVE_SAMPLES];

where WAVE_SAMPLES is already defined in

#define WAVE_SAMPLES 512

Thanks in advance
12  Community / Exhibition / Gallery / Dub && Wise Synth on: July 29, 2014, 03:36:05 pm
Just an update on my project
13  Products / Arduino Due / Re: Sampling frecuency of DAC on: July 03, 2014, 01:58:09 am
That code is only writing a value incoming from the serial port directly to the DAC.
 So i ask how are you controlling the frequency ?
how are the values being sent through the serial?
14  Products / Arduino Due / Re: How to set Sinewave with Frequency? on: July 03, 2014, 01:35:24 am
Above the Nyquist frequency. and starts aliasing. So, highest you can achieve should be :
Sampling_rate / 2 = Nyquist frequency
i.e. 44.100/2 =22.050 kHz
15  International / EspaƱol / Re: Mensajes de audio con Arduino, un sistema barato [INFO] on: November 16, 2013, 08:24:34 pm
Usa um RC low pass filter antes de lo altavoce, para limitar la maioria de los artifactos de lo PWM.
Se quiseras, hay postado algo sobre PCM and WAVE, de lo puento de vista de microcontroladores. Solo la introducion a elos... Mas para venir...
Quicas es util para vosotros..
*perdona mi espanol smiley
Pages: [1] 2 3 ... 24