General question(s) about 'dirty' lines & isolation

Hey group...

I have a question about what I believe is dirty/noisy lines.. and how one goes about isolating things to get rid of noise..etc

Im not sure how much of this is a 'timer' issue and how much is 'noise/interference'.. so I'll explain whats happening...and be educated. :slight_smile:

I have a custom board, more or less a tiny (all smd) Arduino/Waveshield merged board.. (runs all WaveHC sketches..etc..etc.....& functions just like WaveShield)

I am experimenting with code some code and attempting to learn more about the FSM (Finite State Machine) type approach to doing multiple things at once in your code.. (instead of do one thing now.. wait till done.. do next thing..etc)..sorta like an advanced blinkWithoutDelay in my mind..

anyways...

what I was (am) attempting to do was play a simple audio file, in continuous loop (seamless/gapless playback).. and PWM fade an LED up & down, all without skipping a beat.
I believe I have accomplished that, but am having some 'issues'.. both with performance and quality.

1.) I understand the WaveHC/Waveshield uses Timer1 for its audio playback capabilities.. (I think I was told that means now PWM on pin9 now?) <--- but I have read other posts/comments about other PWM pins and timer issues..in conjunction with the WaveHC/Shield..

So this might be a reason for some of the problem(s)?

I play my audio file in a loop.. and I test using pin 3, 5 or 6...

pin3 makes the fade look insanly choppy..and blinky. More like a 'sputter'..in random intervals..(no rhyme or reason)

pin 5 fade IN perfect.. but fades OUT choppy..sputtering, but in a pattern..and eventually fades out..and then again, fades in smooth.

pin 6 fades IN & OUT perfect.. but I hear this 'whine' in the speaker from the audio output now..??

So I guess Im looking for some discussion from the more experienced members here??

Anyone play with the WaveShield and experience this stuff? (could just be hardware on my custom board..and WaveShield itself does NOT behave like this)..

Anyone have some good links/tuts (for a beginner like myself) to read up on isolation and clean signals for audio/pwm?

Thanks guys.. :slight_smile:

Sounds to me like the following info may be of use,

That and some better power supply bypassing... The Bypassing would be the faster of the two methods and likely less expensive too.

Bob

Thanks..

I guess I dont understand the links?? (maybe just missing the connection?) :slight_smile:

I have filtering....and the audio play back is fine.. there is just some noise somewhere.. (that and the Timer issues too?)

here is the schematic of my DAC/AMP..etc..

thanks

The design around the opamp is all wrong.

can you elaborate? explain?

dhenry:
The design around the opamp is all wrong.

There is a 'because' missing from your sentence, assuming you intended it to be helpful.

Im just trying to get a better understanding.. (a true understanding).. :slight_smile:

instead of relying on others, and/or just copying/pasting/merging portions of different schematics.. until tings work out. :slight_smile:

Im not as advanced as many of you here.. so links that talk about higher level approaches/works/theories doesnt give me the foundation to make those articles useful yet..

As far as "all wrong"..... as in, your saying it wont work?

Well it woks.. this is a 'done' project.. pcb's ordered, stencil ordered.. and a few boards even made already..

WaveHC sketches all seem to work/play..etc..

its just now that I am expanding on its uses, I am finding other things that I wanted to address.. such as the NOISE....(I think thats correct to call it?)

-AND-

(not that this is really a hardware problem.. but the use of the TIMER by the WaveHC lib/WaveShield for audio playback and its effect(s) on other PWM pins....etc)

I dont want to fight.. I am hoping someone who has been down this road before can share their ideas and have a nice, friendly discussion on it.. thats all.

:slight_smile:

I guess I dont understand the links?? (maybe just missing the connection?)

You said audio sampling, and a major source of "noise" and distortion is actually related to sampling
issues, and proper anti-aliasing filtering, and not simply noise in the electronics. It takes a fair amount
of digging to understand all that, but after all, if you're gonna play with sampled systems, you should
get into the theory too.

The design around the opamp is all wrong.

Jeesh, it's an LM386 integrated audio amp, and NOT an opAmp, and the ckt looks about right [although
I didn't check the d/s myself]. Actually, those amps tend to be a little noisy when operated in digital
systems.

BTW, I think C18 should be 0.01uF [10 nF] and not 100nF, which gives a low-pass frequency at approx
318 hz. C18 = 10nF will move it up to 3180 hz.

(I said audio sampling?)..

I dont even 'try' to mess with whats 'under the hood' as far the BASE WaveHC code.. that applies to the SD/Audio sampling (DAC communication..etc)..

I just trust that someone (much) more smarter than myself did things correctly? (and since its been out for a LONG time.. others would have noted/fixed the lib?)

I agree.. I need to understand it all.. I just need steps at a time..
reading some of the stuff was just over my head.. I need a better/easier foundation to build on I think

Thanks!

(I said audio sampling?)..

Looking back, you said 'timer issue', but anything involving a microprocessor and audio is about
sampling and antialiasing is always an issue. Poorly filtered signals are very noisy and horrendously
distorted. A .WAV file is a sampled signal stored in digital format.

got it...

so,..assuming the ode/sampling is all correct (fat16lib wrote the library, so Im assuming its on the up and up..and pretty lean/mean code)

that leaves me back at 'hardware' related and doing more about the filtering...yes?

without causing a fight on the boards here.. I see the image/schematic posted really hasnt been commented on.. on how to apply (or change) for a fix? better filtering..etc..

I hear its 'all wrong'.. but how? is it really even wrong??

I thought I had filtering both before and after?..

thanks! :slight_smile:

BTW, I think C18 should be 0.01uF [10 nF] and not 100nF, which gives a low-pass frequency at approx
318 hz. C18 = 10nF will move it up to 3180 hz.

I calculated that wrong before. I used only 5K in the computation. R equivalent should be more like
R = (5K || (5K+5K)) = 3.3K, so

F3db = 1/(2pi3.3K100nF) = 477 hz
F3db = 1/(2
pi3.3K10nF) = 4770 hz

without causing a fight on the boards here.. I see the image/schematic posted really hasnt been commented on.. on how to apply (or change) for a fix? better filtering..etc..

I hear its 'all wrong'.. but how? is it really even wrong??

As I said, Zeus got it wrong again. I don't know about the DAC specifically, but as I said, the LM386 ckt
looks hooked up ok [assuming it's per the datasheet which I haven't checked].

This all takes a bunch of playing around = hard to do long-distance. It may need some more bypass filtering,
plus larger electrolytics on the power supply. You might try a small value R [10 ohms] in series with the Vcc
line to L386, and then add a 47uF cap there.

But I think it's more likely an anti-aliasing problem, ie the relationship between the output data sampling rate
from the uC into the DAC and the cutoff frequency of the low-pass filter on the input to the LM386 [ie
R5,R6,R8,C18].

With such as a simple 1st-order low-pass filter like you have, the output data sampling rate must be many times
higher than the cutoff frequency of the low-pass, else you'll hear a lot of hash. Anti-aliasing filtering is a
profession in itself.

This is why I said you really need to learn something about the theory behind what you're trying to do.
You're getting a lot of highly-paid help here for free, after all.

hi--

sorry.. since the schematic was done.. I have since went in and updated/changed some values..

I put in a pot to dial in both the R8 value (then metered it.. and put in closest resistor)

I also did the same for both R5/R6.. used a pot.. till it volume was 'ok' to my ear.. then metered the pot..replaced with static resistors:

values used in board that was made:

R5 = (47k updated)
R6 = (4.7k updated)
R8 = (100 ohm updated)

Is Zeus = dhenry?

anyways...

well last thing I want to do is piss anyone off with my 'free help'.... Im just looking for some 'discussion' is all.

People who are open to explain/teach... not demanding or a requirement by any means.

Audio (and much of electronics) is a new step for me.. (graphics/web developer by trade).

Its not that I dont 'try'.. it that I need to understand and re-iterate.. and have that 'reassurance' (by someone) that I understand and have it correct.. then I feel I can read/do other things and learn because the article, abbreviations, approaches make more sense is all..

anyways..

here is a more updated portion of the schematic.. to reflect the real values used on the board I am testing with..

I'll go back and read some of the articles again.. see if the more I read them.. the more things will 'click'?

thanks

That's far worse in the "wrong" direction. Approx low-pass frequency is

F3db = 1/(2pi100*100nF) = 15.9 KHz.

You have essentially NO low-pass filtering at all there. Small wonder it's noisy - for ALL the reasons I've
given in the past 3 dozen posts. I'm gonna let you figure it out now, given past suggestions - I'm tired now.

Also, your 47K/4.7K is giving you a 10:1 attenuation of your signal, last time it was 2:1, but that may be
what you need. You have to realize that, every time you change those values, you're affecting both
gain and frequency response. You should go learn about band-pass filters too.

http://www.google.com/search?num=10&hl=en&safe=off&site=imghp&tbm=isch&source=hp&biw=1153&bih=827&q=band+pass+filter&oq=band+pass+filter&gs_l=img.3..0l9j0i5i10.2416.4896.0.5494.16.15.0.1.1.0.161.1303.11j4.15.0...0.0...1ac.1.uasa5Cmx_30

When I had the original values in there.. you couldnt barely hear ANYTHING..

not only volume, but it was 'muffled'.. and clearly -not- being filtered correctly (although I guess its not being filtered correctly now either...lol)

but at least this 'direction' way.. i can HEAR things.. and they are mostly clear...etc..

but when I was using the PWM pins.. I could here a BUZZ.. -or-.. the led itself wasnt fading correctly..

Higher/lower C18/R8? higher/lower R5/R6?...

anyways.. guess its a bit over my head for now on how to fix it...

I'll try and go back and see if anything posted make sense the second/third time around :slight_smile:

Lowpass filtering needs to selected to sound good for the material selected.
Resistors were selected for attenuation of the up to 5V signal from the DAC into the LM386 that is set up for gain of 20 so the output wasn't clipping or going past peak to peak.
Not sure I'd run PWM on the same board - it was pretty packed with components. Running 0-5V PWM at 490 Hz with a low-pass filter selected to let most of the audio band thru will also let any PWM picked be amplified and sent out, 0-5V & 5V-0 transitions occuring at 1KHz.
Could try additional power supply decoupling, add parts in parallel to the existing caps.

RC lowpass filter calculator
http://sim.okawa-denshi.jp/en/CRtool.php
maybe go to 200 ohm for R8, will work its down to sounding muffled again tho.