soerenbnoergaard / Pic-Utilities

Vaious utilities and projects for PIC and dsPIC
0 stars 1 forks source link

Circuit diagram #1

Open hananabilabd opened 6 years ago

hananabilabd commented 6 years ago

Hi Um just wondering if the circuit to this code attached in the website is doing filtering meaning that filters are done by capacitors attached not the digital filters inside the dspic ,, and what if i want to make the filters what is the general circuit for the adc for audio in and Dac for audio out

soerenbnoergaard commented 6 years ago

Hi, I am not sure I understand your question. The circuit attached to my website (http://soerenbnoergaard.dk/project_adcdac.html) has a few filtering capacitors but the frequency response is generally flat through the circuit.

I would recommend spending a bit of time designing a better anti-aliasing low-pass filter (0-20kHz) before the ADC. The same filter could also be replicated on the output, although the signal quality from the DAC is generally ok.

The low-pass filter code in here is a very simple digital filter.

It has been a long time since I looked at this circuit. I believe i found the ADC too noisy, so I did not get to use it much.

Best regards, Søren

hananabilabd commented 6 years ago

Thanks "It has been a long time since I looked at this circuit. I believe i found the ADC too noisy, so I did not get to use it much." Did you mean by that the ADC of the dspic is noisy ??

soerenbnoergaard commented 6 years ago

Hi.

Yes, i think the ADC of the dspic was quite noisy. I think it showed spikes at 48000 Hz when sampling at this frequency.

You could easily use an LM358, but you should probably use a 5V supply for this to get a signal swing close to the 3.3V range of the dspic.

I would probably use one of the amps in the lm358 as a single-supply Sallen Key filter (2nd or 3rd order low pass filter with cutoff at around, say, 16kHz) and then the second amp as a buffer just before the ADC.

Best, Søren

hananabilabd commented 6 years ago

To avoid noise in increasing components number can't I make this filter (0 -21 khz ) inside dspic ?

soerenbnoergaard commented 6 years ago

Unfortunately, the filter must be analog to avoid aliasing. A simple rc filter might mere ok as long as you have the buffer before the adc. I am pretty sure the dspic will be fried at 5V, so you would need a regulator -- e.g a cheap AMS1117 and two 10uF capacitors.

Best, Søren

hananabilabd commented 6 years ago

aha actually um gonna use this dspic to make a prototype to digital Hearing aid , to be able to increase the gain of some frequencies band , Since you have worked on it , Have I made a perfect choice by using it?

soerenbnoergaard commented 6 years ago

As I said, it might be a bit noisy, but I do not really have any better single-chip alternative. It would probably be better to have an external audio adc/dac/frontend chip. I think some have built-in anti-aliasing and are made for audio/speach. Then you could use a microcontroller with a suitable digital interface to communicate with it.

I have some AD74111 because they were cheap, but have not tried them yet.

hananabilabd commented 6 years ago

The problem now is that i can't even hear nearly any voice coming out of the speaker , dspic_shematic

soerenbnoergaard commented 6 years ago

You probably need to bias the input of the first amp so you signal swings around e.g 2V instead of ground. Second, I am not sure you can drive an 8 ohm speaker directly from the opamp -- try using lighter load (e.g an oscilloscope or an aux input of an audio amplifier) -- the output should go through a capacitor in any case. Third, I think the 2.2 uF capacitor should be replaced with a short to ground so the output amp is also biased. The output amp should also be powered fro 5V.

hananabilabd commented 6 years ago

Sir I have 2 question for you capture22 In this schematic what would you change if you just replace the audio in with an electret microphone -- the second inquiry capture Is this frequency response (the attenuation of greater than 100 HZ) is due to the RC circuit or the you made a low-pass digital filter inside the dsPIC ?

soerenbnoergaard commented 6 years ago

Hi,

If you just want to use my circuit without the suggestions I have above about anti-aliasing filter, I would do the following:

  1. At the "Audio In" connection, have your electret microphone with a pull-up resistor (and perhaps some amplification if needed). You can find electret microhone circuits with a search on google.
  2. The frequency response shown is straight through the device. Notice, that the y-axis only shows a deviation of about 0.1 dB, which is not much at all -- so you should consider it flat.

Best, Søren

hananabilabd commented 6 years ago

In Fact i was going to use sallen key low pass and i got the components and everything , but then i said i must ensure first there is a signal coming out of the dspic , but after all the modifications i still get a noisy sound from the aux earphone . in fact i make the same circuit as yours with all the components except for the MCP6022 I used LM358 ( as MCP can't be found in my country :( )

hananabilabd commented 6 years ago

it works after all , Thanks a lot
capturee

I still have a little question here in the schematic the 1K OHM here is it a variable resistance or what ?

soerenbnoergaard commented 6 years ago

Hi, yes, the 1k is a potentiometer where the center pin is connected to the + input through the 10k resistor. It should probably be located around midways to begin with.

You could also try to replace the 2M2 resistors with 100k--220k resistors and the input capacitor from 1uF to 10uF.

Also, I seem to remember that the output of the LM358 must be loaded somehow. Your could try to add a 1k resister from the opamp to ground in both cases.

I hope you can get it working :-)

Best, Søren

hananabilabd commented 6 years ago

Thanks for help sure um going to try that but about the sallen-key low-pass filter should i put it directly after the 100n capacitor or after the 2.2M biasing resistor capture lowpass sallen key

in fact i tried to put it before and after but i get no sound , should the op-amp of the sallen-key filter has 2M2 bias resistors ?

soerenbnoergaard commented 6 years ago

It should be before the 100nF capacitor.

Notice that you need a "single supply" version of the sallen key filter unless you have a negative power supply. So yes, you need some biasing resistors and an additional input series capacitor for the filter.