08 Jun 2011

Hi,

As for the median, I do not like it either.

What I used in the past was just a very simple algoritme but effective that takes the average of two values if the value in between was off by a predefined percentage of full scale. It just filters spikes and not noise if the percentage is large enough.

So the data from the http://en.wikipedia.org/wiki/Median_filter sample would be preocessed like:

 2 80 6 3 (the unfiltered input) 2 (we just have to start somewhere) 2 4 (where 4 is the average of 2 and 6 because 80 is off to much) 2 4 6 (we do not consider the 80 anymore but use 4 and 3 to see that 6 is not off that much) 2 3 6 3 (final filtered data)

And as said before in my programs i would ALWAYS store 2,80,6,3 plus the percentage used to filter the spikes.

08 Jun 2011

@Wim et all

#### Quote:

 2 80 6 3 (the unfiltered input)

i see cases again and again where i have something like (i have 1/2 vcc on AD input, FFF is a faulty value)

7FF | 800 | FFF | FFF | FFF | 800 | 7FF ...

So there it does not help just to look at 3 values, because all 3 consecutive values are off and i get FFF as a valid value.

The other method is median (i hope i understand it correctly): Take the case i have three values: 000, FFF, 000, 000 Instead of having a value near zero i get (0+FFF+0+0) / 4 = ~ 400 which is far away from 0.

Is it in any way relevant which sampling rate is used (e.g. 1 MHz or 2 MHz chosen) ? Or can i be (in theory) sure when DONE bit is set, i have a valid value, it just takes longer or less longer to do the AD conversion ?

As an alternative: Has someone used an external AD converter (e.g. via SPI, I2C) ? Are there the same problems ? I accept noise, even big noise, but faulty values are not acceptable.

08 Jun 2011

Yeah but with capacitors, ferrite beads and a good breadboard and a battery power mic pre amp and to power the mbed with a battery you just don't need to filter or anything else, apart from what Dave Malham has done I don't really know what else to do, Look at me a newbie talking like a professional. I think the mbed would have been more than just tested before it reached market I think the error is perharps on are end.

if anybody knows where to get a coper-clad board or a brass breadboard would be good start here, don't fancy making a coper-clad board at the moment would sooner find a company that makes decent breadboards:)

08 Jun 2011

#### Philips Philips wrote:

Yeah but with capacitors, ferrite beads and a good breadboard and a battery power mic pre amp and to power the mbed with a battery you just don't need to filter or anything else, apart from what Dave Malham has done I don't really know what else to do, Look at me a newbie talking like a professional. I think the mbed would have been more than just tested before it reached market I think the error is perharps on are end.

if anybody knows where to get a coper-clad board or a brass breadboard would be good start here, don't fancy making a coper-clad board at the moment would sooner find a company that makes decent breadboards:)

The problem is very much to do with us. Analogue circuit design is tricky at the best of times, and the Mbed uses a tiny 3.3volt signal, it's going to be very sensitive. Note that the Arduino uses 5volt ADCs with are far less sensitive to noise.

But electronics is our hobby, we should embrace these problems and learn to solve them :)

09 Jun 2011

#### Philips Philips wrote:

Yeah but with capacitors, ferrite beads and a good breadboard and a battery power mic pre amp and to power the mbed with a battery you just don't need to filter or anything else, apart from what Dave Malham has done I don't really know what else to do, Look at me a newbie talking like a professional. I think the mbed would have been more than just tested before it reached market I think the error is perharps on are end.

if anybody knows where to get a coper-clad board or a brass breadboard would be good start here, don't fancy making a coper-clad board at the moment would sooner find a company that makes decent breadboards:)

The problem is very much to do with us. Analogue circuit design is tricky at the best of times, and the Mbed uses a tiny 3.3volt signal, it's going to be very sensitive. Note that the Arduino uses 5volt ADCs with are far less sensitive to noise.

But electronics is our hobby, we should embrace these problems and learn to solve them :)

Pictures speak a thousand words.

10 Jun 2011

I like to avoid magnetics for the A/D unless I need galvanic isolation. In the other post, a low pass filter with a 100khz cut off frequency did wonders. Note that the R/C values are 6.8k and 220pf. The low resistance keeps the input impedance low to make the input less susceptible to noise.

http://mbed.org/forum/bugs-suggestions/topic/1514/?page=2

10 Jun 2011

I am a nos kinda guy I don't like oversampling or audio filters.

10 Jun 2011

#### Philips Philips wrote:

I am a nos kinda guy I don't like oversampling or audio filters.

Just to be clear, filters in this sense are basically just a capacitor between the ground and the signal line. This is standard when building analogue electronics, you always build in a filter into the design to reject unwanted frequencies.

An engine ECU project I built using the Arduino required a lot of filtering, the electrical noise generated by a car engine is phenomenal... It's almost amazing electronics work at all in cars ;)

There are lots of things you can do to reduce the effect of noise... if you are using jumper wires, then I'll will often twist the ground and the signal wires together, that helps are great deal! Like this: /media/uploads/bloodline/photo.jpg

10 Jun 2011

#### Philips Philips wrote:

I am a nos kinda guy I don't like oversampling or audio filters.

Just to be clear, filters in this sense are basically just a capacitor between the ground and the signal line. This is standard when building analogue electronics, you always build in a filter into the design to reject unwanted frequencies.

An engine ECU project I built using the Arduino required a lot of filtering, the electrical noise generated by a car engine is phenomenal... It's almost amazing electronics work at all in cars ;)

There are lots of things you can do to reduce the effect of noise... if you are using jumper wires, then I'll will often twist the ground and the signal wires together, that helps are great deal! Like this: /media/uploads/bloodline/photo.jpg

So why does he avoid magnetics on the A/D line.

10 Jun 2011

Also because it has only one GND I couldy not put a Polarize capacitor between the the mic postive and negative of mbed, I tried that and it did not work the mic would go straight into the earphone output and created a loop I think well the recording sounded weird and low, maybe I did not do right but when I did that is what happend.

10 Jun 2011

oh it seems I might have done it wrong last time I put after the earphone out and it works now but is 2.2uf don't work as good as ferrite bead tho.

10 Jun 2011

#### Igor Martinovski wrote:

I like to avoid magnetics for the A/D unless I need galvanic isolation. In the other post, a low pass filter with a 100khz cut off frequency did wonders. Note that the R/C values are 6.8k and 220pf. The low resistance keeps the input impedance low to make the input less susceptible to noise.

http://mbed.org/forum/bugs-suggestions/topic/1514/?page=2

I did notice a difference with the ferrite beads but was not sure what it was hurting fidelty?

10 Jun 2011

#### Igor Martinovski wrote:

I like to avoid magnetics for the A/D unless I need galvanic isolation. In the other post, a low pass filter with a 100khz cut off frequency did wonders. Note that the R/C values are 6.8k and 220pf. The low resistance keeps the input impedance low to make the input less susceptible to noise.

http://mbed.org/forum/bugs-suggestions/topic/1514/?page=2

I did notice a difference with the ferrite beads but was not sure what it was hurting fidelty?

10 Jun 2011

Do it have something to do with amplification and volume.

10 Jun 2011

Do it have something to do with amplification and volume.

10 Jun 2011

The reason I tend not to use inductors and transformers in the signal path is because they are large, expensive and harder to come across. Why build an RL lowpass filter when an RC filter will do the job?

And as Matt said, filtering is almost always required, even if you have the cleanest ADC you should still use an input filter to avoid aliasing.

10 Jun 2011

I notice better amplification and volume without ferrite bead :)

10 Jun 2011

I would like more volt tolerance on analog input pins, at the moment with the usb lead is not much tolerance 3.7v, but it says in manual that when powered by Vin they have a 5 v tolerance, so maybe I have that to look forward to.

vacuum tube mic is like 4+ when I am screaming in it lol maybe need AGC

10 Jun 2011

I forget lpcxpresso has an extra GND pin:)

10 Jun 2011

You might need a proper front end for a mic, you shouldn't just plug mics and other audio equipment into the A/D directly.

11 Jun 2011

#### Igor Martinovski wrote:

You might need a proper front end for a mic, you shouldn't just plug mics and other audio equipment into the A/D directly.

You will have to give me link to what you are talking about because I have never heard of what you are talking about, but the best way I can think of when looking at some of the greatest designers work is mic amp then a AGC power amp? http://en.wikipedia.org/wiki/Automatic_gain_control

:)

11 Jun 2011

Also Igor can you use a non polarized capacitor for filtering from the adc mic mbed positive in line to mbed gnd, I just assumed it had to be polarized to do this.

11 Jun 2011

Hmmm...

Would be nice if I had a scope to measure tho:)

11 Jun 2011

Non-polarized caps are better in almost all applications. Electrolytic caps (i.e. polarized caps) have a higher leakage current and a higher ESR. For this reason, its best to avoid them in filter and coupling applications.

The advantage to electrolytic caps is the fact that they allow for large capacitance in a small package making them very useful for power supply filtering.

So yes, you can (and should) use non polarized caps whenever you can.

As for the 'front end' I was referring to. Before you can feed a signal in to an A/D, you usually have to condition the signal before it goes in the A/D converter.

Take the mic expample. A microphone outputs an AC signal (lets say -1V to 1V) but the mbed only accepts 0-3.3V. So you have to scale and shift the mic signal to fit into that 0-3.3V range. We can shift our example signal +1V so it will become 0-2V (this will work fine) but you might also want to add a little gain so you take advantage of the full A/D resolution (i.e. a gain of 1.6 will bring it up to 3.2V). This will 'convert' your -1V to 1V AC signal to 0 to 3.2V, perfect for the mbed.

Depending on your application, AGC might be overkill.

This is getting a bit off topic, try posting in the electronics and hardware forum :)

11 Jun 2011

#### Igor Martinovski wrote:

Non-polarized caps are better in almost all applications. Electrolytic caps (i.e. polarized caps) have a higher leakage current and a higher ESR. For this reason, its best to avoid them in filter and coupling applications.

The advantage to electrolytic caps is the fact that they allow for large capacitance in a small package making them very useful for power supply filtering.

So yes, you can (and should) use non polarized caps whenever you can.

As for the 'front end' I was referring to. Before you can feed a signal in to an A/D, you usually have to condition the signal before it goes in the A/D converter.

Take the mic expample. A microphone outputs an AC signal (lets say -1V to 1V) but the mbed only accepts 0-3.3V. So you have to scale and shift the mic signal to fit into that 0-3.3V range. We can shift our example signal +1V so it will become 0-2V (this will work fine) but you might also want to add a little gain so you take advantage of the full A/D resolution (i.e. a gain of 1.6 will bring it up to 3.2V). This will 'convert' your -1V to 1V AC signal to 0 to 3.2V, perfect for the mbed.

Depending on your application, AGC might be overkill.

This is getting a bit off topic, try posting in the electronics and hardware forum :)

So its really ok to connect a non polarized cap when I measure it on a multimeter if the volts was postive the output would be postive the pole capacitor would output postive and if negative it would output negative so I just thought if postive is connected it would input postive into gnd??

11 Jun 2011

Non-polarized caps are inherantly safer. If you reverse the polarity on a polarized cap, it will probably leak, or explode (depending on the voltage and voltage rating)

You can always use a non-polarized cap for anything, just make sure that the voltage rating is appropriate. For micro controller applications, you don't need to worry about rated voltage too much. 3.3V is low enough to assume that the cap will be ok.

If you are working with power supply circuits, you need to watch out for polarity and voltage ratings for caps. Otherwise, the cap will explode and make the room smell really bad for a bit.. :P

11 Jun 2011

#### Igor Martinovski wrote:

Non-polarized caps are inherantly safer. If you reverse the polarity on a polarized cap, it will probably leak, or explode (depending on the voltage and voltage rating)

You can always use a non-polarized cap for anything, just make sure that the voltage rating is appropriate. For micro controller applications, you don't need to worry about rated voltage too much. 3.3V is low enough to assume that the cap will be ok.

If you are working with power supply circuits, you need to watch out for polarity and voltage ratings for caps. Otherwise, the cap will explode and make the room smell really bad for a bit.. :P

If could answer this igor would be nice, don't have big fancy scope:(

The settling time of the DAC is 1 μs max, and the maximum current is 700 μA. This allows a maximum update rate of 1 MHz. 0 1 The settling time of the DAC is 2.5 μs and the maximum current is 350 μA. This allows a maximum update rate of 400 kHz. 31:17 - Reserved, user software should not write ones to reserved bits. The value read from a reserved bit is not defined

The settling times noted in the description of the BIAS bit are valid for a capacitance load on the AOUT pin not exceeding 100 pF. A load impedance value greater than that value will cause settling time longer than the specified time. One or more graph(s) of load impedance vs. settling time will be included in the final data sheet.

So it would seem that I need to measure the settling time of analog output with a scope to determine what capacitance to use, as you can see wrong capacitance will cause longer settling times, is that correct:)

Where is that big fancy scope I need:)

If I want the dac to have a maxium update rate of 48khz what size picofarad do I need anybody.

It say this in data sheet where is this graph???

One or more graph(s) of load impedance vs. settling time will be included in the final data sheet.

11 Jun 2011

Also tell me dirty secret of the use of resistors to get more mojo out of mbed:)

11 Jun 2011

Lol. The secret of resistors is ohms law :P

But anyway. The output specifications you are quoting usually aren't taken in consideration when building little circuits on a breadboard.

Output/Input impedance and bandwidth can get somewhat technical, so to make quick calculations we can usually make a few assumptions:

1. Assume Input impedance in infinite and input capacitance 0. 2. Assume Output impedance is 0.

This allows us to tailor our own bandwidth (or rise time if you prefer) by adding some R and C to the circuit (i.e your 48khz requirement).

The cutoff frequency of a single-pole lowpass (one resistor, one cap) is 1/(2*pi*RC). Since resistors come in more values than capacitors, we should pick an appropriate capacitor value first (I like 1nF), and then calculate for resistance:

R = 1/(2*pi*(1nF)(48kHz)) = 3315 ohms, or 3.3k ohms

We got pretty lucky this time! Our values are almost exactly standard cap and resistance values. This won't always be the case however, and you might have to choose a different capacitance value to get close to a standard resistance value result.

This won't actually be the result (since we didn't take into account the output impedance of the mbed) but it should be close enough.

Oh, and it seems you're working on some audio application, in which case, your output filter cutoff frequency needs to be (at most) half of your sampling rate, so your resistance and capacitance should be 1nF and 6.8k. for a cut off frequency of 24kHz.

11 Jun 2011

#### Igor Martinovski wrote:

technical

I wanna get really technical igor:) I will try what you say but I think it's way too high:)

Considering 1mhz is only 100 picofarad, but this 1000 picofarad is the best so far which I am sampling at 98khz and by my calculation the capacitor provides a little more than that 100khz or so.. just guessing tho no scope:)

At least I think I am sampling at 98khz:P lol err 96khz

ok lol 1000 picofarads is 1 nf lol