Calculating....
1)The speed at which read() takes place. i.e. the read/write speed of the eeprom.
2)PinPlayTime and MaxPlayTime // defines the max time any pin is allowed to play.
interesting...
Mike noted
int PadCutOff[48] = {200,300,300,150,300,300,500,400,150,150,300,150,150,500,500,500,
300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,
300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300}; // Minimum Analog value to cause a drum hit, default=600
int MaxPlayTime[48] = {20,10,10,5,10,10,10,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10}; // Cycles before a 2nd hit is allowed, default=90
boolean activePad[48] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Array of flags of pad currently playing
int PinPlayTime[48] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Counter since pad started to play
// Making analog readings faster (for drumrolls) works with this code
// read http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1208715493/11 for more info
#define FASTADC 1
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
#if FASTADC
// set prescale to 16
sbi(ADCSRA,ADPS2) ;
cbi(ADCSRA,ADPS1) ;
cbi(ADCSRA,ADPS0) ;
#endif
// CALIBRATE THE SENSOR
//for (i = 0; i < 400; i++) // make the calibration take about 10 seconds (6 sensors)
for (i = 0; i < 2400; i++) // make the calibration take about 10 seconds (1 sensor only)
{
qtra.calibrate(); // reads all sensors 10 times at 2.5 ms per six sensors (i.e. ~25 ms per call) => ~4.17 ms per call for ONE sensor!!! to get 0 seconds calibration use i=400*6
}
for (i = 0; i < NUM_SENSORS; i++){
int calibMinOn=qtra.calibratedMinimumOn*;*
_ int calibMaxOn=qtra.calibratedMaximumOn*;_
_ // save minimum value to eeprom*_
* // need to divide by 4 because analog inputs range from*
* // 0 to 1023 and each byte of the EEPROM can only hold a*
* // value*
> The ADC accuracy also depends on the ADC clock. The recommended maximum ADC clock frequency is limited by the internal DAC in the conversion circuitry. For optimum performance, the ADC clock should not exceed 200 kHz. However, frequencies up to 1 MHz do not reduce the ADC resolution significantly.
>
> Operating the ADC with frequencies greater than 1 MHz is not characterized.
>
>
> So looks like using a prescale of 16 as above would give an ADC clock of 1 MHz and a sample rate of ~77KHz without much loss of resolution. BTW, this is the code to set the prescale to 16:
>
>
>
> Code:
> // defines for setting and clearing register bits
> #ifndef cbi
> #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
> #endif
> #ifndef sbi
> #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
> #endif
>
> // set prescale to 16
> sbi(ADCSRA,ADPS2) ;
> cbi(ADCSRA,ADPS1) ;
> cbi(ADCSRA,ADPS0) ;