PGA2311 Digitally controlled pre-amp

Stian

New member
Nice.
Ive also been playing around with the PGA chips with an arduino. Got it working, but for some reasons the chip acted somewhat wierd after a while of use, started to clip the sound no mather what volume it was set to. Other than that, the chip worked good, and was very simple to send commands to.
 
Hi Stian am still working on it. Thats a strange problem you are mentionning. I am goign through the PGA2311 datasheet to understand how to send commands to this device. I'll keep posted
 
Project still alive but am scratching my head with that mechanical rotary encoder. I'll soon go forward with sending signals to PGA2311 all my time got taken up by a flyback design for which i did not have the right core too bad.
 
A great news to be shared here my PGA2311 is working connected to a 16F84A. Its in a very basic state volume level is pre-programmed in code and sent to PGA2311 on startup and signal is flowing nicely out :) using a sinewave generator and monitoring on a scope. I have a small detail to fix in my code and it should be ready for next step of implementation. Everything is written in Hi tech c lite
 
PGA2311 signals

Hi for anyone who might need it here is how you send data to a pga2311 in its basic form : PGA2311 Timing Signals.jpg
i don't have a logic analyzer to show the captured signal but this was taken from MPLAB SIM debugger and this is how i got the PGA2311 to work. Currently SID is being sent a volume level of 149. Note there are 2 things i did to make to make it work:

1) delay your signal to PGA2311 by moe than 100ms because at switch on the system is muted by sending 0x00ff which is an all zero signal to mute the ic. The signal needs to be sent after these 100ms. If sent before it does not accept your volume

2) Make sure the signal is sent in proper binary format i.e. least significant bit first then last most significant bit. For the 149 value shown here 10010101 is sent once for left channel on each rising SCLK pin signal then again 10010101 on the next rising edge clock value.

All this was accomplished through a 16F84A using only the basic htc.h library, no special library was used like i wrote all functions and they are triggered as follows:

1) Convert volume value as integer into binary using the basic modulous division principle to get the zeroes and ones into an array of integer- this gives the first 8 bits for one channel

2) Copy the first 8 bits into the remainig array of integer locations to get the 16 bit values needed for left and right channel (looping through a single 8 valued array of integer twice creates a small delay in execution cycle )

3) Set CS pin low, send the signal, set the clock to 1 then set both the signal and clock to 0 this is achieved by basic things like RA0=1, RA2=0 e.t.c. Note i used __delay_us to set the delays between CS, SCLK and SDI. The delays can be calculated from the datasheet from page 3 and page 9

and last but not least remember PGA2311 analog voltage is only +5 and -5V ref to analog ground, i read on internet some people fried the chip by accidentally powering +15V and -15V to the analog section be careful when you order online PGA2311 is more prominent than 2310 and check you chip number when you receive your order

Note: you won't find any of the above info in few lines like these on the net most are post in forums showing improper signals and requesting for debugging help this a proper working signal exclusive for diysmps :) enjoy!
 
Last edited:
More updates on this pre-amp. I have had to move to a PIC16F628A the 16F84A program memory had just reached its limit(By the end am sure i'll need to go to a 16F877A or the like if i need lcd interfacing). I have already implemented code to make th volume work as two push buttons (like on TV sets) i need to test it in a physical circuit.
One thing which the datasheet does not say i think is that the PGA series are linear potentiometers and normally a coded approach has to be implemented to increase/decrease the volume in a logarithmic form.
 
Working push button shcematic

I have successfully implemented and tested the following schematic:16F628A+PGA3211.JPG. the Ic is now working with a push button for up and down volume control. I did not have any problems with output going out of control or audible clicks on volume change. I did get very minor ones beaucse i did not properly bypass the power supply pins but thats easy to solve otherwise the circuit is working great. I did not show it in the schematic but it needs to be fed with a very low output impedance <100R and output to a high input impedance >10K. I did not also get any difference in sound by bypassing the volume control.
 
Working rotary encoder

Just finished a code using rotary encoder for the volume control. Conclusions from test seem that everything works but i will have to run it through a PGA2311 to test. The problem was reading the rotary encoder signals properly.
You will find a lot of tutorials all around the web but the ones leading the right way to the solutions are the ones related to "quadrature Encoder". But no where on there web is there a simple code that shows how a rotary encoder is implemented in software

first the concepts, a 3 pin quadrature encoder provides 2 square wave signals at 90 degree off phase with one another. There are a loooooot of charts of A and B signals on the web but to get a very basic understanding of 1 and 0 sent by the encoder this link showed how to understand it: http://www.youtube.com/watch?v=uh27ftADFKo

Passed that stage a mode detailed concept (NB i did not implement this logic in my code no need to detach and attach interrupt):http://www.youtube.com/watch?feature=endscreen&NR=1&v=HQuLZHsGZdI

To understand the direction there is a need to store the previous value from A and B as well as the new A and B value. The direction is obtained by doing an EXOr operation on current A value with previous B signal.
The exor operation will for instance always give 1 when the encoder moved forward and 0 when the encoder moved backward.

A trap to avoid when doing this on a microcontroller using hi tech c is to connect both A and B signals to RB4 and RB5 and use only RBIE interrupt. Do not mix INTE(RB0 interrupt) with RBIE(RB4 to RB7 interrupt)

Additional note for PGA2311, to get an attenuation from -96dB to 0dB corresponds to decimal values 0 to 192 respectively, i.e. the software counter incremented by the rotary encoder should stay within limits of 0 to 192.

I'll keep working and post back more results
 
Last edited:
The rotary encoder is working fine and the software SPI implementation is working properly. I did a few rough test with everything, scope the signals, debugged the encoder increments/decements using USART everything is working great. The only last thing i have to do before everytning works properly is transmit the increments/decrements of the rotary encoder MSB first. With hi tech c it means going brute force and using bitwise operators. I will keep posted as this last bit gets completed and upload a schematic afterwards
 
MSB transmission looks fine in simulation i need to put everything back on breadboard and give it a try before going for the pcb
 
hi jaydev sorry did not come here a long time. Yes it works well, I have made it work with 16F877A (a newer version is 16F887), STM32F and lately I got it to work with an STM8S. The PGA3211 behaves properly even when fed with an SPI at 3.3V. I will complete the project with an STM8S. Its the most cost effective micro for the job I have found. I will keep posted for updates.
 
Top