• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Microchip dsPIC33F 3.5mm Jack Input/Output Wiring

Status
Not open for further replies.

krazy

New Member
Hello everybody,

Forgive me if I am missing some basic points here but I am new to this so go easy on me. ;)

I am trying to wire a dsPIC33F to accept stereo audio in via a 3.5mm jack and then immediately put it back out in stereo via another 3.5mm stereo jack.

I cannot figure out the wiring though. I've never had to wire audio jacks from scratch before. I'm confused by all the different 'voltages' involved (your positive/negative but also your references) and how they are wired.

Could anyone explain or perhaps link to a diagram of how to wire something like this? I'm also confused on the PIC pinout for your DAC. You got 3 pins for each L/R DAC (pos, neg, 'middle point') and, I think, positive/ground references for analog modules (??) AND positive/ground reference inputs for analog voltages (???... didn't know the two could be separate).

Any suggestions?

Thank you!! :)

Datasheets:
-3.5mm Stereo Jacks
-dsPIC33FJ128GP802 28-pin SDIP Package
 

Someone Electro

New Member
You need to wire your negative or positive output to the 1st or 2nd contact on the jack the 3rd one is ground
 

kchriste

New Member
Forum Supporter
Unless I'm missing some info you posted in another thread/site:
You can't just wire up the 33F's ADC/DAC to an audio jack without first adding/removing DC bias. Depending on the application, you'll probably also need amplification and filtering.
 

krazy

New Member
When you say 'adding/removing DC bias' what do you mean? I am trying to understand how that terminology applies to this case.

Also, my application will be connecting an iPod to the uC then giving an output from the uC to connect to speakers. Basically a pass-thru element that will be doing some fancy stuff in between taking in the audio and passing it back out.

I'm really like a fish out of water for this section of my project. Any information, links, suggestions, anything you could impart would be very, very much appreciated! :)

Thank you!
 
Last edited:

Someone Electro

New Member
Oh yeah forgot you should put a capacitor between the pin and the audio jack to remove the DC out of the signal. The DAC puts put a nice big signal so it wont need amplification for a sound card and the output cant realy go too high since it runs on only 3.3V and the DACs max output is a lot less than the supply.

For a quick test you can run the DAC output trough a capacitor on to some headphones if you are woryed about damaging your soundcard (Not very likely at these small voltages)
 

krazy

New Member
Oh yeah forgot you should put a capacitor between the pin and the audio jack to remove the DC out of the signal. The DAC puts put a nice big signal so it wont need amplification for a sound card and the output cant realy go too high since it runs on only 3.3V and the DACs max output is a lot less than the supply.

For a quick test you can run the DAC output trough a capacitor on to some headphones if you are woryed about damaging your soundcard (Not very likely at these small voltages)
Good to know. Thanks for that.

So are you guys saying I need an amplifier for the ADC and nothing except a capacitor (0.1uF bypass?) for the DAC?
 

Someone Electro

New Member
Yup that is correct.

Oh and btw you also need a capacitor in the input of the ADCs amplifier and the amplifier having a virtual ground of Vdd/2 (I hope you worked with analog enough to understand this)
 

krazy

New Member
Gotcha.

And, for the record, the internal amplification on an iPod wouldn't be enough for the ADC?

What kind of amplification circuit do you think I'd need?

And I got the VDD/2 concept (analog signals pull or push the level higher/lower)... hard part is going to be finding a source for this level...
 

Someone Electro

New Member
Well tipical line levels are +/- 1V but this is not standard, some sound cards output +/- 2V when put to full volume.

Well you could do it without amplification but you lose ADC resolution that way. If its just for a little audio DSP fooling around it would be fine but if you want something quality you should get a proper external 16 bit audio ADC.

Oh and its easy to shift the DC bias of the signal to half Vdd. All you do is put a resistor from the ADC pin to Vdd and a nother resistor from the pin to ground. It makes a voltage divider that makes 2,5V out of 5V. The resistors can be anythyng from 1K to 100K, Lower the resistor the lower the input inmpendance so then you also need a bigger capacitor to get a good response down to 20Hz
 

kchriste

New Member
Forum Supporter
To add to SE's comments, don't forget to put a Low Pass Filter between the ipod and the 33F's ADC input. If you over-sample the signal you can get away with a simpler RC type LPF. You should also have a LPF after the DAC. I seem to remember that the DAC of the 33F has over-sampling built in, but the ADC does not so you'll have to do that part in software.
 

krazy

New Member
Hmmm... why do any of the converters need low pass filters? Sorry for the wide ranging and clearly uninformed questions... I am new to signal processing and, at that, audio processing. This is for a senior project, too... eek. :confused:
 

Someone Electro

New Member
Well he is suggesting a low pass filter for the ADC input to filter out freqencys above the ADCs sample rate.This is a another quality improvement but its not a must especially if your sample rate is going to be like 40Khz and above ( As far as i know the DAC works up to 100Khz)

Oh and btw you might be runnning a little low on memory for stuff like reverb since that reqires you to store like up to half a second of audio in ram.

Also you might want to check some stuff from microchip about audio, they made a 12 chanell EQ with a dsPIC
 

krazy

New Member
You guys are right. I got audio to go 'thru' the PIC (the PIC being programmed to loopback ADC->DAC).

The audio is coming out full of noise and barely audible.

So this means I'll need an opamp on the output, I guess? I'm not familiar with op-amps so could any suggest which type I might need (inverting, non-inverting, other)?

Btw, Electro, I'm just trying to suck in the audio, run 2 or 3 bandpass filters on it and run simple analysis on that then send the audio right back out while sending SPI messages based on the analysis. :)
 
Last edited:

krazy

New Member
What I don't understand though is why I need an op amp to begin with?

If the ADC can sample my signal correctly, and the DAC can put out up to 3.3V (WELL above what is needed to drive headphones).... how come I need an op amp, anywhere? Plus... the iPod/sources all have internal amplification in them (so we can safely assume the signal can be maxed out to top voltage levels)?

Perhaps I'm just wiring this wrong? Or my code is bad (is it bad if I am sampling at 100+Hz and my MP3s are only in 40Hz)?
 
Last edited:

Someone Electro

New Member
Its ok to connect headphones + capacitor to the DAC pin directly but tipicaly you should use a headphone amp because the DAC pin is not meant to give much current.

As for distrotion are you putting in a good signal to the ADC? The signal must not get to 0V or 3.3V cause it clips it. And with no input you should have Vdd/2 on that pin (Thats 1,65V)

Also i hope you are feeding the DAC in a proper way. You can NOT just put data in to the DAC like you can in the PWM or something. The DAC has a buffer that is reads and output at the set sample rate. You must never oweflow that buffer or let it run dry. A interupt can be set up so it interupts when the DAC buffer is ready to accept new data. The DAC should basicaly dictate the pace.
 

Sceadwian

Banned
At the very least you should use an opamp with better current drive to buffer the DAC. The linearity, accuracy, and distortion ratings for a DAC go out the window when you heavily load it, and the 16 or 32 ohms would definitly qualify as heavily loaded. The lighter you load the DAC the better.
 

krazy

New Member
Take a look at MicroChip's Audio PICtail Plus Daughter Board User’s Guide. for example schematics. You should be able to pick pieces of the schematic for your application.
There is also ADC-DAC loop back code on the site.
That's perfect. I'll dig into that, thanks. I am using the loopback code to test my circuit.


Its ok to connect headphones + capacitor to the DAC pin directly but tipicaly you should use a headphone amp because the DAC pin is not meant to give much current.
A headphone amp? Would an op-amp work for this?

As for distrotion are you putting in a good signal to the ADC? The signal must not get to 0V or 3.3V cause it clips it. And with no input you should have Vdd/2 on that pin (Thats 1,65V)
Honestly, I'm not sure of the signal strength. I'm just outputting from my iPod. So the signal comes in really weak but it sounds like it is clipping when I crank it to the max (even though you can barely hear it).

The big question: Does anyone know what kind of op-amp circuit I need? Inverting? Non-inverting? Other? I've got LM324Ns, UA741CNs, and LF356Ns which I can throw into the mix but first need to figure out how to wire it (and my amplifier circuits class is next semester! ack! :) )
 
Last edited:

Someone Electro

New Member
As i sead the DAC output is not meant for giving any current so it wont drive headphones to a very high volume, it is ok as a line signal tho to drive in to active speakers and such.

For driving headphones i would sugest to simply do a voltage follower circuit with a opamp, its simply connecting the inverting input to the output and driving the signal in to the noninverting input. This makes the opamp output the identical voltage as on its input. True that this dosent provide any amplification to the signal but the opamps output is capable of driving a few mA to up to 1A (depending on what opamp you use) Also the signal can still be driven in to active speakers since the voltage is kept the same only more current avalable for driving the headphones.

I hope to see some nice stuff with audio processing on that.
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top