Jump to content

Digitally controlled preamp, PGA2310, PIC18F


markiemrboo

Recommended Posts

I'm both lazy and busy! Lazy in the sense that I still haven't got the motivation to finish the new amplifier case. I stuck it in the old amp case and am using it now, which makes me not too fussed about getting the case done. I've also been very busy designing, from scratch, a digitally controlled preamp to go with the new power amp. Digital is a lot of fun. Poor power amp case....

 

 

 

I thought I would post what I have been working on over the past couple of weeks. I feel it's at the point where, at least electrically, it should work.

 

General Features:

  • Rotary encoder, 2 channel digital volume / balance control, PGA2310 / PGA2311
  • Socketed audio input and output buffers
  • HD44780 LCD display with external backlight toggle
  • Digital relay based source selection with relay output mute
  • Software power on / off
  • PIC18F2480 / 2520 microcontroller
  • External power triggers (automatically turn on /off external amplifiers via preamp)
  • *I think it could possibly even be computer controlled via a PC serial port
  • *IR remote control
  • *Per source volume limits

* = software stuff that is entirely possible, but I haven't given it much thought yet

 

 

 

Design - Schematics and PCB Layout

 

I started with the power supply. Since the PIC will be turning the whole thing on / off, which allows me to use a fancy low voltage power button, it will need to be running all of the time. I started off designing a small +5v regulated and +12v unregulated supply to run the PIC and the mains switching relay, with a small PCB mount transformer. The analog and "peripheral" digital supplies will be running off a separate toroidal transformer, which will be switched on via the PIC. This should reduce power consumption while off / standby.

 

2005381003636835169_rs.jpg

 

2005374038118333841_rs.jpg

 

2005386357945094740_rs.jpg

 

2005382491915692960_rs.jpg

 

 

 

The next thing I did was designed the source selection. I wanted the phono sockets mounted on the PCB, as it should be easier to mount to a case and would mean no hideous mess of wires from the phono sockets to the PCB. It is again rather simple. In order to save PIC IO pins I have used a 74HC595 shift register. Initially this would enable 3 PIC IO lines to control 8 output lines. You simply clock in 8 bits of serial data (data and shift clock) and then latch it to the output (store clock), that is... whilst shifting data in the output doesn't change until you send the store pin a pulse. All 8 outputs change at the same time.

 

During some simple prototype testing of the LCD (more on that a bit later) I discovered that the output lines of the HC595 could be in any state with the Output Enable pin tied permanently low. I went to a bigger PIC (28 pin vs 18 pin) and now have the OE pins controlled by the PIC too, which means that I should be able to safely assume that all outputs will be low until I enable them via software. Why is this necessary? Well, I didn't want random source selection relays activating briefly on power up! If audio from the source was playing this would probably mean you would hear about 50ms of audio before the software managed to sort it out. It turns out that the 28 pin PIC didn't really require any extra board space with some strategic layout changes anyway! Bonus!

 

Anyway, this PCB has space for 7 switched inputs, 2 variable outputs (outputs which are attenuated by the PGA) and a single looped line level output (the signal of whatever source is selected before it gets to the PGA). The variable outputs are attached to a relay, which could also be used as a form of mute. The idea behind that relay, however, is to cut the signal to the outputs in order to prevent any power on / off noise getting to amplifiers.

 

2000827140127149351_rs.jpg

 

2000835249327700433_rs.jpg

 

2000839000405975630_rs.jpg

 

2000824710302446225_rs.jpg

 

 

 

Last, but certainly not least is 'the brains' of the preamp. This PCB contains everything else, and is somehow the smallest of the three PCBs! The board is separated so that the analog stuff is on the right hand side, and the digital stuff is on the left hand side. The fact that the PGA pinout has all the analog pins on the right and digital on the left made this the obvious way to lay it out.

 

On the analog side, the input and output buffer for each channel is on the same opamp. For instance, the left channel.... the input goes to one half of opamp A, and the output goes through the other half of opamp A. The right channel input / output uses opamp B. The only reason I did this is because it made the layout 100x easier :)

 

The digital side of things caused the most trouble. Because I was using separate supplies for the PIC and all the other digital stuff, I wasn't sure if I was able to connect the control lines of ICs on the separate supply safely. Many hours searching yielded no helpfulness, so I enquired at DIYaudio and all that should hopefully be needed is a resistor on the IO lines to limit current. Shortly after this I figured out the correct search terms and found a very helpful page explaining this, and a couple of other more complicated methods. I don't believe I will need to deal with the more complex circuits, as everything is still 5v (the page was for 3.3v to 5v interfacing). Even if the supplies do differ, I believe all of the devices I am using have clamping diodes, which together with the current limiting resistors should keep the devices safe.

 

With that problem out of the way (though it'll probably go wrong, but hey...), everything became pretty simple. The only moderately interesting feature to explain now is the LCD backlight control. I am using 6 out of 8 lines on the HC595 to control the LCD in 4 bit mode, which leaves me with two LCD outputs free. I implemented a simple transistor switch on the backlight supply, so I can turn on / off the backlight (and possible PWM fade it) via software :) There is space for a collector / emitter bypass resistor, which means that instead of turning it completely off, when in the off state a small amount of current will flow and it will instead light very dimly.

 

The source selection / menu buttons (currently 8 buttons) use a single PIC line by using the ADC feature of the PIC. Each button will change the voltage seen by the pin slightly, so you can determine which button was pressed. A nice simple idea which I picked up off of DIYaudio, not my own.

 

The LCD display will at the very least be showing the currently selected source, mute status and volume. Additional features as I get in to the coding may include a menu, per source volume / balance settings, (per source?) automatic and manual external power triggers, IR remote control and other such goodies.

 

2005689069654189880_rs.jpg

 

2005660930723554218_rs.jpg

 

2005611505323563354_rs.jpg

 

2005618179586818400_rs.jpg

 

 

 

LCD prototype

 

This is a much bigger project than the PIC power button, so I decided to prototype controlling the LCD via a HC595 with a spare PIC12F chip (the 18F chips look much nicer). The schematic for the LCD part works, and I managed to initialize the display and get it to display some text on each line. This is where I stumbled upon the Output Enable problem. When powering on the displays backlight would turn on even though I hadn't told the PIC to do so, it would then turn on and off as it should. The best approach to fix this would be to be able to control the Output Enable line. Other than that, all good and quite simple, at least for basic text!

 

The software for the LCD prototype is obviously a very small portion of what is required for this project, but I feel pretty confident about it after writing that small piece... at least getting the basics working (volume, source select, some status text on the LCD)!

 

2004242439812680373_rs.jpg

 

 

 

I'm going to stop messing with the circuit now, hopefully get it printed off and produce PCBs for it over the next couple of days. With any luck it should all work, and after populating the PCBs I will just need to write the software for it :) I like software.

Share this post


Link to post
Share on other sites

That looks rather interesting!

 

It would be good if you could get a USB-Serial interface going, and control the amp by a PC.

 

Seriously, when you get this and the power amp finished... methinks you should consider going into production :)

Share this post


Link to post
Share on other sites

It's scary to me that all of this makes perfect sense!

 

I've actually been starting to design my own digitally controlled pre-amp as well, which is pretty coincidental. Mine's for my home-baked guitar effects, but the similarities are certainly there. I'll be following this closely. Thanks for being my guinea pig! :P

 

Good luck with the build!

Share this post


Link to post
Share on other sites

That looks rather interesting!

 

It would be good if you could get a USB-Serial interface going, and control the amp by a PC.

 

Seriously, when you get this and the power amp finished... methinks you should consider going into production :)

 

USB would certainly be a nice way of interfacing with it. It would require some sort of USB IC though. I was going to start simple, just a small headphone amp... no LCD / source select etc, but ended up with this. I am a bit backwards some times! I imagine a USB chip could be added without much hassle, if the rest of the thing does actually work.

 

I was just thinking "two bit" serial, which should be easy enough. One line to send data to the PIC from the PC and the other to send from the PC to the PIC. In all honestly, I may not get around to actually doing this... but I am fairly sure it's possible. The external crystal would have to be removed (use internal oscillator) to free up the two lines though.

 

Production... well, this power amp is still working great and sounds ace. I am very much considering creating a small site with these two projects and seeing if anyone is interested in buying PCBs, either bare, with components, or fully soldered. I don't think I would sell finished units any time soon though. :)

 

That looks hella complicated, but somehow... it looks sweet :D

 

:D

 

It's scary to me that all of this makes perfect sense!

 

I've actually been starting to design my own digitally controlled pre-amp as well, which is pretty coincidental. Mine's for my home-baked guitar effects, but the similarities are certainly there. I'll be following this closely. Thanks for being my guinea pig! :P

 

Good luck with the build!

 

That sounds awesome! I hope you post about it as things progress a bit. I don't mind being a guinea pig either ;) I will post any issues I encounter etc, so I hope that this may help you out with your project in some way!

 

I have actually just spotted a small change to the power supply, very shortly after posting. I can take the secondary +5v regulator off of the +12v regulated output (for source select relays), rather than the analog regulated +ve output. Whoops :)

 

Thanks for the luck too. I've been looking over it for about a day now, just going over and over to make sure I have everything right. I did just move to the 28 pin PIC today though....

 

Out of curiousity ... what microcontroller are you intending on using for your project?

Edited by markiemrboo

Share this post


Link to post
Share on other sites

Out of curiousity ... what microcontroller are you intending on using for your project?

Well, I have an HC12 from my college days. So the "free" aspect of that is quite nice. But it's a bit overkill and could be more trouble than the savings are worth. My logic should be very simple, so I think I may look for something more streamlined. It's basically a bunch of standalone guitar effects boards, and I'll just need the digital logic portion for controlling digital relays for each channel (or pass-through). I actually etched my first pcb the other day. You'd be proud. :lol: I'll get a thread up with some pics once I populate it, but first I have to find a small enough dremel collet for the tiny drill bits :)

 

But yeah, you're MUCH farther along in your concepts, and I'll certainly be watching your progress here for some ideas towards my own design.

Share this post


Link to post
Share on other sites

Well, I have an HC12 from my college days. So the "free" aspect of that is quite nice.

 

Ah nice! I hear the "Free"scale stuff (har har) is supposed to be rather nice. :)

 

But it's a bit overkill and could be more trouble than the savings are worth.

 

That would be quite a shame I reckons! Quick searching suggests it's a 100 odd pin beast, so I can see how that would be a pain!

 

I actually etched my first pcb the other day. You'd be proud. :lol: I'll get a thread up with some pics once I populate it, but first I have to find a small enough dremel collet for the tiny drill bits :)

 

:lol: wicked stuff. Drilling them is quite a pain! I look forward to seeing that though :D

 

But yeah, you're MUCH farther along in your concepts, and I'll certainly be watching your progress here for some ideas towards my own design.

 

:)

Share this post


Link to post
Share on other sites

I soldered near enough everything to the power supply board today. Unfortunately I can't test the analog / peripheral digital supply half as I don't have a spare transformer, and I can't be bothered to rip out the transformer from my preamp to test it at the moment :) The PIC / mains relay power supplies work and the relay switches fine when fed 5v, so that's a good start.

 

Here's a couple of pictures. I find the different size caps give it a sort of pro look. I didn't have exact values so I just picked out caps that had the right voltage specs and used them, all good brand name of course.. Rubycon and Panasonic!

 

2004658611256675445_rs.jpg

 

2004682622518500474_rs.jpg

 

 

 

I now need to clean up the main PCB because of the alignment issue. I hope to get that done and everything soldered up tomorrow.

Share this post


Link to post
Share on other sites

Looks good, master.

 

:wub:

 

 

 

 

I attacked the main PCB with a dremel this morning and soldered everything on to it. Can't really tell it has been hacked up when all the stuff's mounted on the board :)

 

I will possibly be applying power later today to see if anything ... explodes ... so far. Also to see if I can program it in circuit OK.... :ph34r:

 

For now, heres another picture:

 

2002749126230183006_rs.jpg

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...