AnalogIn problem

16 Jun 2011

Every linear circuit is a 'filter' yes.. You don't need to quote to me what a filter is. I just wanted to point out that an LC filter isn't used in wide band applications. But since you insist on doing things your way, have fun! :)

16 Jun 2011

hhahahaha women

Old is gold, how do you like corse noise generaters, see you when I have my scope... Its jitterman:)

17 Jun 2011

IGOR,

do you have any schematics for a very simple auto gain controller with a transistor:)

17 Jun 2011

nope.. AGC is not as a simple of a concept as it sounds. Look for an IC, there's a bunch that do what you are asking for.

17 Jun 2011

Igor Martinovski wrote:

nope.. AGC is not as a simple of a concept as it sounds. Look for an IC, there's a bunch that do what you are asking for.

Ha well I did transistor amplifier, was messing around for ages and did not even realized it needed DC and not AC:). I am going for the three Transistors gilbert cell I think.

It does not make sense to me how electric waves volts works in a physicly way. I need to see it hahah is a way to see now right..maybe with a aura camera???

I got a comparator ic, cause I think I read it can be done with one of them?

19 Jun 2011

I found out what the 7.5k was for http://en.wikipedia.org/wiki/Sample_and_hold

Igor anybody do you know if I am using the transistor as an input to the adc of mbed do I need a Rectifier or an inverter... only thing I can think of as to why I am getting what is happing. The transistor needs DC to power it.

19 Jun 2011

I see it is DC bias, I had a 150 picofarad was not enough maybe?

19 Jun 2011

was not that????

20 Jun 2011

I can get output from it... but no input to mbed adc with transistor... anybody know why??????

23 Jun 2011

Igor Martinovski wrote:

nope. It's not needed. Just design the appropriate filter and hope for the best.

The settling time of the actual ADC or DAC should be much faster than your filter anyway and should be of no consequence. If its not, then you need a faster converter.

This is the general way it works: Your requirement is 96kHz sampling rate of the ADC. The nyquist rate of this frequency is 48k. Now, you don't have to filter the input signal at all; however, if you don't filter at half the sampling rate with a very steep filter (i.e. a high order lowpass filter), you cannot be sure that your sampled signal is 40kHz or 400kHz! (or any other multiple thereof) due to the lack of information about the signal between samples. To avoid this uncertainty, we use a filter to make sure that signals more than 48k (more than half of the sampling frequency) don't enter our ADC. If we know that 400kHz can't enter the ADC, then we are sure that our 40kHz sampled signal is indeed 40kHz. So when you design your analog front end, just make sure you filter at half the sampling rate at least. Ideally, this should be a very good and steep filter, but a single-pole filter is better than nothing.

The fact that you're sampling near the limit of the ADC complicates matters, but you can assume that the ADC should settle faster than your filter anyway (after all, we are still sampling within the specifications), so you don't have to dwell about the settling time and rise time of your ADC because your filter is slower by design!

Since you're working on an audio application, I would go further and filter down to 20kHz (since we are using a single-pole filter) to be safe.

Same deal for the output..

If we use a 150 picofarad and 5.3k resistor and set the mbed ADC to 200khz.. we would be sure that we were sampling at 200khz or a little more...

So now we set the mbed to 100khz and we now know we can not be sure we are sampling at 100khz with the same resistors and capacitor.. what is the walk around for this problem.. flip flop??

24 Jun 2011

You're mixing up sampling frequency and bandwidth.. Filters affect the bandwidth of a circuit. Sampling frequency is determined in the digital domain and has very little to do with your input filter.

24 Jun 2011

Igor Martinovski wrote:

You're mixing up sampling frequency and bandwidth.. Filters affect the bandwidth of a circuit. Sampling frequency is determined in the digital domain and has very little to do with your input filter.

I don't get it......

24 Jun 2011

well it is true for the Bandwidth then

24 Jun 2011

If 15 PF high pass filter 50k, Bandwidth of 212.38 khz

Is that how it works then.. but what is result of acutally doing this different tho, and using Bandwidth filters that are made for each sampling rate of ADC

24 Jun 2011

Where can I get more info on load the DAC output.

24 Jun 2011

Right, filters limit the bandwidth, but they do nothing for the sampling rate. We need to limit the bandwidth to half the sampling rate to get meaningful singals in and out. The sampling rate is set in software and can be anything you like (within the capabilites of the DAC/ADC). The design procedure once again is:

1: Choose a sampling frequency for the software (i.e sampling rate)
2: Design a filter for half of that sampling frequency on the input and output (i.e. limit the bandwidth of the input signal)

24 Jun 2011

Igor Martinovski wrote:

Right, filters limit the bandwidth, but they do nothing for the sampling rate. We need to limit the bandwidth to half the sampling rate to get meaningful singals in and out. The sampling rate is set in software and can be anything you like (within the capabilites of the DAC/ADC). The design procedure once again is:

1: Choose a sampling frequency for the software (i.e sampling rate)
2: Design a filter for half of that sampling frequency on the input and output (i.e. limit the bandwidth of the input signal)

But but but in theory what happens once said capacitor and resistor are chosen.. what happens to that extra bandwidth when sampling the ADC a lower frequency load the DAC output is max 1k ??

24 Jun 2011

I am using a high pass filter with 100k and 100 picofarad,

Igor would this work as a buffer for the DAC so I don't load the DAC I want to get a lower output with the npn before the high pass filter.. I can get lower output with npn

do you know of any schematics for a high and low pass filter

but with maybe just 100k or probably different resistor values. /media/uploads/mbed2f/transistor-as-a-voltage-amplifier-circuit.png

04 Jul 2011

Igor Martinovski wrote:

Every linear circuit is a 'filter' yes.. You don't need to quote to me what a filter is. I just wanted to point out that an LC filter isn't used in wide band applications. But since you insist on doing things your way, have fun! :)

Are you saying to use a Band pass filter then??? why don't you post one of your secret schematics anyway.

12 Jul 2011

Hello everybody, I want to share my finding with you. I had many problems with the noisy ADC of Mbed. I managed to solve this problem with steady success with the use of a simple statistical filter.

My filter works this way: 1. Calculate the mean value among all values, since the beginning of acquisition.

2.Calculate the STANDARD DEVIATION (is this the correct term in English?) of the values

3. Reject the data which value is ABOVE the value of the sum: mean value + standard deviation

4. Reject the data which value is BELOW the value of the difference: mean value - standard deviation

Visualization: http://upload.wikimedia.org/wikipedia/commons/7/7e/Standard_deviation_illustration.gif

This way the very high peaks get cancelled because they don' t respect the condition of the filter. I had great results, the ADC now works perfectly. But some issues have to be addressed, like the data accumulation and possible overflow. I have very little time to work on this so I can' t post a fully wroking code or library. Hope this is useful! Here it is a code snippet:

while(1){

read=analog.read();

sumx2+=read*read;

sum2x+=read;

acc=h*sumx2-(sum2x*sum2x);

sigma=(1.0/h)*sqrt(acc);

TC+=read;

TF=TC/h;

if(read<(sigma+TF)){

if(read>(TF-sigma)){

//Use your data here//

} }

h+=1.0; }

Bye

15 Jul 2011

I'm not sure your algorithm is correct, I think you mean something like:

long h = 1;
double sumx=0.0, sumx2=0.0, var, sigma, read, TF;

while(1){
  read=analog.read();
  sumx2+=read*read;
  sumx+=read;

  var=(sumx2-sumx*sumx/h)/h;
  sigma=sqrt(var);

  TF=sumx/h;

  if(read<(sigma+TF)){
    if(read>(TF-sigma)){
      //Use your data here//
    }
  }
  h++; 
}

In any case the program cannot run forever because eventually h will overflow and also sumx and sumx2 are limited by range and precision. Because 'read' is always positive, sumx will always increase, also sumx2 will always increase because squares are always positive (even if you remove the bias). Furthermore, at some point, sumx and sumx2 will be so large that further 'read' and 'read'^2 will not be added to the sum due to the limited precision.

A better algorithm is found in the 'on-line algorithm' by Knuth: http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance

16 Jul 2011

Also the algorithm won't do what you expect it to do because after some time the mean and stddev will reach stable values (e.g. 0.5 and 0.1 resp.) which will severely compromise your data (in the example everything outside <0.4, 0.6> will be rejected).

16 Jul 2011

Why try to fix something that does not exist, bloody hell... I just put a germanium diode on the ADC input pin and even that fixed it.. I will take that picture if you want:)

16 Jul 2011

errrrmm little tippeys I think I may have put the diode back to front upside down.. she likes her chocolate..says you can't have any:)

/media/uploads/mbed2f/photo0765.jpg /media/uploads/mbed2f/photo0767.jpg

16 Jul 2011

whoa, ehrm, this demonstrates again that math is not an opinion. But my algorithm really works, anyway!

17 Jul 2011

Indeed Math is not an opinion. I absolutely believe that your algorithm works for you, moreover I think that my algorithm will not work for you (for the reasons given above). All I'm saying is that your magic number sigma is not the standard deviation of the input samples.

08 Jul 2013

Hi thanks for the code above. I tested it and it was working, though am new to mbed and c programming. please could you guide me on ADC conversion for NXP LPC1768 at 10KHz, 5volts input and display the result via tera term on pc.

thanks in advance. please the question am asking might seem simple for those who are good in c coding, as for me, its entirely new.

08 Jul 2013

Francois Rigaud wrote:

/media/uploads/Rigaud/rapport_test_adc_mbed_f_r_01-03-2011.pdf

This is a numerical filter to MBED ADC, it is not my job, maybe it could be better, Best regards, François Rigaud /media/uploads/Rigaud/main_test_filter_adc_francois_rigaud.cpp

05 Dec 2018

In case any newcomer is searching for a solution to this problem and has trouble finding it in this lengthy thread, I can confirm that Karri Palovuori has it cracked.

All my analogue inputs were picking up random spikes - noise apparently arising from the LPC1768 board itself.

The cure is to solder a 10nF ceramic capacitor between the relevant pin (15 to 20) and the ground side of the large, yellow surface mount component adjacent to pins 17 to 19, on the underside of the board. The ground side of that component is next to pin 19 (closest to the CE mark).

Two things to mention. Firstly, you must reassure yourself that the circuit being monitored will not be adversely affected by the 10nF capacitor across the signal line and ground. Secondly, the LPC1768 will stand slightly proud of its socket because the capacitor lead you wrapped around the analogue input pin stops you inserting it all the way.