Welcome, Guest
Username: Password: Remember me

TOPIC: ADC Noise Software Solution.

ADC NOISE SOFTWARE SOLUTION! 4 years 9 months ago #199

  • maykef
  • maykef's Avatar
  • OFFLINE
  • New Member
  • Posts: 11
  • Thank you received: 4
  • Karma: 2
I finally found a simple way to remove noise from of Arduino ADC, using a recursive low-pass filter. See the code:

int y0, y1, x0, x1, d0 = 0, d1 = 0; // filter variables

/* Use these equations to calculate the filter coefficients:

decay= e^(-1/n)

n is the number of samples that produce an equivalent time to discharge a capacitor. I use 7.

b0=1-decay a1=decay


y = x*b0 + delay*a1

delay=y


*/

x0 = in_ADC0;

y0 = ((x0*15)/100) + ((d0*85)/100);

d0=y0;


x1 = in_ADC1;

y1 = ((x1*15)/100) + ((d1*85)/100);

d1=y1;
The administrator has disabled public write access.
The following user(s) said Thank You: caleborion, shanemikel

ADC NOISE SOFTWARE SOLUTION! 4 years 9 months ago #203

  • shanemikel
  • shanemikel's Avatar
  • OFFLINE
  • New Member
  • Posts: 17
  • Thank you received: 5
  • Karma: 1
Could you please elaborate a little here. For instance, I don't see where x comes from before you get to y=x*b0+delay*a1 . Also, you're using decay and delay (but where did delay come from?). I can't tell if that is code or pseudocode decay=e^(-1/n) is that e to the power of (-1/n) or binary arithmetic? If you could attatch a copy of a working sketch with this in it it would be easier for me to follow.
The administrator has disabled public write access.

ADC NOISE SOFTWARE SOLUTION! 4 years 9 months ago #204

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 692
  • Thank you received: 146
  • Karma: 41
Thanks for your contribution :) ,I will try to code some examples and make some recordings :guitarfende :pedalmxr: :ampmarshall during this week,
Cheers! ;)
Last Edit: 4 years 9 months ago by Ray.
The administrator has disabled public write access.

ADC NOISE SOFTWARE SOLUTION! 4 years 9 months ago #206

  • maykef
  • maykef's Avatar
  • OFFLINE
  • New Member
  • Posts: 11
  • Thank you received: 4
  • Karma: 2
X = CURRENT INPUT

Y = CURRENT OUTPUT

DECAY = PARAMETER TO CALCULATE COEFFICIENTS

DELAY = PREVIOUS INPUT
The administrator has disabled public write access.

ADC NOISE SOFTWARE SOLUTION! 4 years 9 months ago #207

  • maykef
  • maykef's Avatar
  • OFFLINE
  • New Member
  • Posts: 11
  • Thank you received: 4
  • Karma: 2
Tip: This filter will make the signal a little more bass, so you have to test values for n, or add more gain on distortion effects.
The administrator has disabled public write access.

ADC NOISE SOFTWARE SOLUTION! 4 years 9 months ago #208

  • maykef
  • maykef's Avatar
  • OFFLINE
  • New Member
  • Posts: 11
  • Thank you received: 4
  • Karma: 2
You will use these formulas to calculate the coefficients before you put them on the code

e = 2,71828183 It'S LIKE pi = 3,1415
The administrator has disabled public write access.

ADC NOISE SOFTWARE SOLUTION! 4 years 9 months ago #211

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 692
  • Thank you received: 146
  • Karma: 41
... no progress here, I have tried to roughly code the idea but I cannot feel the difference on the background hiss:
// Licensed under a Creative Commons Attribution 3.0 Unported License.
// Based on rcarduino.blogspot.com previous work.
// www.electrosmash.com/pedalshield
 
 
int in_ADC0, in_ADC1;  //variables for 2 ADCs values (ADC0, ADC1)
int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10)
int LED = 3;
int FOOTSWITCH = 7; 
int TOGGLE = 2; 
double x_0=0, y_0=0,d_0=0;
 
void setup()
{
  //ADC Configuration
  ADC->ADC_MR |= 0x80;   // DAC in free running mode.
  ADC->ADC_CR=2;         // Starts ADC conversion.
  ADC->ADC_CHER=0x1CC0;  // Enable ADC channels 0 and 1.  
 
  //DAC Configuration
  analogWrite(DAC0,0);  // Enables DAC0
  analogWrite(DAC1,0);  // Enables DAC0
}
 
void loop()
{
  //Read the ADCs
  while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete.
  in_ADC0=ADC->ADC_CDR[7];               // read data from ADC0
  in_ADC1=ADC->ADC_CDR[6];               // read data from ADC1  
  POT0=ADC->ADC_CDR[10];                 // read data from ADC8        
  POT1=ADC->ADC_CDR[11];                 // read data from ADC9   
  POT2=ADC->ADC_CDR[12];                 // read data from ADC10 
 
  //Add volume feature with POT2
  out_DAC0=map(in_ADC0,0,4095,1,POT2);
  out_DAC1=map(in_ADC1,0,4095,1,POT2);
 
  x_0 = in_ADC0;
  y_0 = ((x_0*15)/100) + ((d_0*85)/100);
  d_0 = y_0;
 
  //Write the DACs
  dacc_set_channel_selection(DACC_INTERFACE, 0);       //select DAC channel 0
  dacc_write_conversion_data(DACC_INTERFACE, y_0);//write on DAC
  dacc_set_channel_selection(DACC_INTERFACE, 1);       //select DAC channel 1
 // dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC
}

This is an asynchronous volume/booster example (clean.ino) with the noise removal idea, I have tried also a sampled approach (implemented into clean_sampled.ino) but again nothing better :(
The administrator has disabled public write access.

ADC NOISE SOFTWARE SOLUTION! 4 years 8 months ago #219

  • maykef
  • maykef's Avatar
  • OFFLINE
  • New Member
  • Posts: 11
  • Thank you received: 4
  • Karma: 2
You must apply the filter immediately after storing the values of ADC, before any processing:

// Licensed under a Creative Commons Attribution 3.0 Unported License.
// Based on rcarduino.blogspot.com previous work.
// www.electrosmash.com/pedalshield


int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1)
int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10)
int LED = 3;
int FOOTSWITCH = 7;
int TOGGLE = 2;
int x_0=0, x_1=0, d_0=0, d_1=0; // NO NEED DOUBLE USE INT AND LONG
long f_0=0, f_1=0;

void setup()
{
//ADC Configuration
ADC->ADC_MR |= 0x80; // DAC in free running mode.
ADC->ADC_CR=2; // Starts ADC conversion.
ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0 and 1.

//DAC Configuration
analogWrite(DAC0,0); // Enables DAC0
analogWrite(DAC1,0); // Enables DAC0
}

void loop()
{
//Read the ADCs
while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete.
in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0
in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1
POT0=ADC->ADC_CDR[10]; // read data from ADC8
POT1=ADC->ADC_CDR[11]; // read data from ADC9
POT2=ADC->ADC_CDR[12]; // read data from ADC10

//USE IT HERE

x_0 = in_ADC0;
f_0 = ((x_0*13)/100) + ((d_0*87)/100);
d_0 = (int)f_0;
in_ADC0 = (int)f_0;

x_1 = in_ADC1;
f_1 = ((x_1*13)/100) + ((d_1*87)/100);
d_1 = (int)f_1;
in_ADC1 = (int)f_1;


//Add volume feature with POT2
out_DAC0=map(in_ADC0,0,4095,1,POT2);
out_DAC1=map(in_ADC1,0,4095,1,POT2);


//Write the DACs
dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0
dacc_write_conversion_data(DACC_INTERFACE, y_0);//write on DAC
dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1
// dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC
}
Last Edit: 4 years 8 months ago by maykef.
The administrator has disabled public write access.
The following user(s) said Thank You: shanemikel

ADC NOISE SOFTWARE SOLUTION! 2 years 11 months ago #649

  • BowDown
  • BowDown's Avatar
  • OFFLINE
  • Senior Member
  • Posts: 55
  • Thank you received: 6
  • Karma: 2
I am going to test this soon. What have other members found? Does this work?
The administrator has disabled public write access.

ADC NOISE SOFTWARE SOLUTION! 2 years 11 months ago #652

  • Ray
  • Ray's Avatar
  • OFFLINE
  • Moderator
  • Posts: 692
  • Thank you received: 146
  • Karma: 41
We did not make much progress here... maykef published some code but we tried them without much success.
In theory it should be simple, just summing some samples before releasing them should filter the high freq noise.
Last Edit: 2 years 11 months ago by Ray.
The administrator has disabled public write access.
Time to create page: 0.341 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio