Hi-Fi audio preamplifier using Burr-Brown PGA2310

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

I decided to build this project, firstly to help a member of forum and secondly because it was a good opportunity for me to explore new devices such as rotary encoders and the widely used in audio industry Stereo Volume Control PGA2310 of Burr-Brown. The whole project will be a manually – remotely controlled high fidelity audio preamplifier. The nice PIC16F887 is the heart of control circuit. It can offers 36 pins as I/O thanks to its internal precise oscillator and MCLR modules. Flow Code proved again a precious tool for the development of program offering everything ready thanks to its wonderful graphical interface! Never had to use C or assembly code - from which I know few things.
Let’s take a look on PGA2310 digital section (Figure 1). A lot of control and data ports are available making it very flexible. In the current project I make use of just 3 ports: a) SCLK (clock to synchronize PGA2310 with the host controller during data transmission), b) SDI (serial data input) and c) MUTE (active Low). The required serial data format is very simple: 16bit long, 8bits for each channel, b0 - b7 = L0 - L7 and b8 – b15 = R0 – R7 where L0 – L7 represents the Gain of Left channel and R0 – R7 the Gain of Right channel. There is no special demand for the serial clock (Figure 2); it can has a frequency from… 0 up to 6.25MHz and 80nsec minimum width for both Low and High semi periods; given this Hi and Low states of clock is not necessary to be equal. Serial data are transferred into PGA2310 registers during the rising edge of clock. Thanks to this simplicity there is no need of using any of the timer outputs of PIC; we simply have to set an output – that represents the synchronization clock - in Hi and Low state and to MASK sequentially one by one the 16 bits of two registers that hold a word of Gain data. Gain of each channel is set by an 8-bit code in straight binary format. The formula that gives the gain setting is: Gain (dB) = 31.5 – [ 0.5 X ( 255 – N) ] where N is the decimal equivalent of the existing 8-bit code. When N = 0 the internal logic circuit of PGA2310 recognizes a MUTE condition and connects its input multiplexer to analog GND. When N = 1 – 255 Gain takes a value within a range from -95.5dB up to +31.5dB. Inside the program only integer numbers are calculated while numbers with fractional part are rejected. Thus we have a numerical sequence of: -95, -94, -93… +30, +31dB. This simplifies the Gain calculation and printing on LCD display.
Looking at Flow Code control panel, we can see a 2 X 16 LCD display connected at port C.0 – C.5, two momentary switches PWRON/STBY and MUTE connected at port B.4and B.5 respectively. Flow Code does not offer rotary encoder unit, so it is simulated – I have seen enough members on the forum that use the same trick – with one momentary and one toggle switch. The toggle defines the direction (CW or CCW) and the momentary reproduces steps like an encoder. There are two square Led of which the green represents the relay that activates the analog power supply (in audio devices is mandatory the use of separate power supply for the analog section unless the noise of MCU oscillator could be pass into the audio signal path) and the red that simply indicates the MUTE state of PGA2310 (active LOW) so when Led is off means that MUTE is activated. There are another 3 round Led: The red is lit when device is in Stand-By mode. In digitally controlled audio devices stand-by means that the analog power supply is deactivated, while the digital supply remains active to keep the microcontroller running continuously. The green Led shows the serial clock Hi and Low state, and the blue one shows the serial data transmitted i.e. is lit when a transmitted bit is “1”. In the current project I have adopted the use of common type relays (non Latching) so the use of EEPROM is redundant. Let’s look at the Flow Code:
After the MAIN macro beginning we have to initialize the switches. Because we use the same momentary switch to enable and disable the analog power supply, the program should recognize if the switch is pressed for first or second time. To this, a variable named “Power_Sw” is used; when the PWRON/STBY switch is pressed and “Power_Sw = 0” the program starts the activation process (Power ON); if “Power_Sw = 1” the program starts the deactivation process (Stand By). The same applies to the MUTE switch for which a variable named “Mute_Sw” is used. Thus, in the beginning of program we have to reset the flags (= “0”) of these two variables. Then, we have to initialize the variable “counter” in which is stored the existing number of steps executed from Encoder. By default, when PGA2310 is powered a reset of its internal logic is executed, is placed in MUTE state and in its internal Gain registers is written “00h”, so we have to give an initial value “0x00” in variable “counter”. This initial process is necessary because the SRAM registers that used to store these variables take unpredictable values during micro powering. Returning to the program Flow, we can see that in the next command the Port B (change state or IOC according to Microchip) interrupt is enabled and when occurs it calls the Macro “Scan_Switch”. It should be noted that P16F887 offers this interrupt possibility on all 8 pins of Port B while its predecessor P16F877 only from RB.4 to RB.7. Then the program Flow enters into a conditional Loop. Because the given condition is “While 1” and is checked at the start of the Loop, it means that is always TRUE resulting in a continuously executed Loop which can be “broken” only by an interrupt request like this of Port B - change state. So, if any of the 3 switches is pressed it causes interrupt and calls the ISR which is the Macro “Scan_Switch”.
In the beginning of macro “Scan_Switch”, we have to define the Port register and the variable that is related with the next operations of program. This definition is given into Input icon “Port B” in which is also defined the variable “SWITCH” that used to store the code of switch pressed. Next from this, there are 3 sequential Decision icons for the recognition of switch that is pressed. When the switch code matches with the test number of a Decision, program Flow is turned to its “yes” branch. If the switch pressed is the POWERON/STBY and after a small delay (10ms for debounce) the program tests if it is pressed for first or second time. This executed inside a Decision in which is checked if the flag of variable “Power_Switch” is set ( = 1 ) or reset ( = 0 ). Accordingly the program Flow is turned either to the “Yes” or “No” branch for the execution of Disable (Stand By) or Enable (Power On) process of preamplifier. In a similar way is executed the MUTE process, when is recognized that the MUTE switch is pressed. To prevent any activity of the MUTE switch and Encoder, during preamplifier Stand-By mode, in the beginning of the “yes” branch of each Decision is first checked if the flag of variable “Power_Switch” is set (=1). When the switch STEP is pressed and recognized by the corresponding Decision we can see that first the Port interrupt is – temporarily - disabled. In this way the steps of Encoder can be counted one by one using the variable “counter”, and a possible confusion of step number calculation can be avoided if the Encoder is “crazy” turned by the user. In the next step the program calls the Macro “COUNT”.
After the beginning of Macro “COUNT”, first is defined the Input of toggle switch which is the RA.0 (to the present) and the variable “switch_A0” in which is stored the state of switch (Hi or Lo). In the following Decision is checked the state of switch: if it is Low (= “0”) the program Flow is turned to the NO branch to increment the “counter”. If it is Hi (= “1”) is turned to the YES branch to decrement the counter. In both branches, first a check is made whether the Counter has reached its maximum or minimum value. The maximum value of counter which corresponds to a Gain integer is 254 (+31dB), while the minimum is 2 (-95dB). In any of the two cases, the counter stops to increment or decrement. That is necessary because prevents a counting loop, which may result in a steep (and dangerous to loudspeakers) transition from minimum to maximum Gain (volume) and vice versa. If not the case, then counter continues to increment or decrement according to the position of toggle switch. This is executed by the Calculation “counter = counter + 2” or “counter = counter – 2” respectively. As we have seen only even "N" numbers can result in integer Gain value, so increment or decrement of counter by “2” rejects numbers with fractional part. It should be noted that the program Flow, up here, is temporary and serves just for simulation. An actual “gray scale” rotary encoder usually executes 24 steps per revolution and under the given program structure, only the half number (12) would be calculated. Let’s stay tuned with this to the present. The rest part of Macro will be – less or more – the same in the final project. In the next step of program Flow, is checked if the “counter” holds a number greater than 192. The number N = 192 corresponds exactly to “0dB”. A value of counter bigger than 192 results in positive dBs, while a value of counter less than 192 results in negative dBs. I have simplified the formula of Gain calculation which for positive dBs results in the equation: Gain (+dB) = ( N – 192 ) / 2. For negative dBs results in the equation: Gain (-dB) = ( 192 – N ) / 2. Where N is the number of steps executed by Encoder and is contained into the variable “counter”. In any case, the program Flow is turned to the corresponding branch of Decision “If counter > 192?” and in the following steps the above calculation is executed while the result is stored into the variable “Gain_dB”.
All indications are printed on LCD display at constant x, y coordinates except the Gain value which can have a length of 1 (“0”), or 2 (e.g. “+3”) or 3 (e.g. “-36”) characters. Some precaution of LCD display is needed before the update of Gain value. Take for example the current program: The Gain is printed at the upper right corner of display. The string “dB” is constant and is always printed on squares 14-15 of first line { x = 14, y = 0 }. The value of Gain is printed on squares 11, 12 and 13. To be tidy its appearance on the display, if the number to be printed is “0” coordinates should be { x=13, y=0 }. If the number is unary with sign then coordinates should be { x=12, y=0 } and if it is decade with sign coordinates should be { x=11, y=0 }. Also, before the renewal of Gain value, first the old value must be cleared - unless display will show hieroglyphics instead numbers. To clear the 3 characters that represent the Gain value we have to print 3 spaces on their place. That is executed after the calculation of variable “Gain_dB” with two LCD macro commands: In the first the cursor is placed at { x = 11, y = 0 } and then, 3 spaces are printed { LCD Display Print String “ “ }. In the following Decision is checked “If Gain_dB=0?” and if it is so, a jump to connection point “A” or “B” is executed by the program, and the “0” is printed at square 13 exactly before string “dB”. If “Gain_dB” is not “0” the program Flow continues to the NO branch where the variable is checked by the Decision “If Gain_dB > 9?” if holds a decade number and if it is so, program Flow is turned to YES branch to print a signed decade number at { x = 11, y = 0 }. If “Gain_dB” is equal or less than “9” the program Flow is turned to NO branch to print a signed unary number at { x = 12, y = 0 }. That’s all.
I have to mention two members of forum “medelec35” and “Dutchie_World_Wide” who helped me – when I was newbie in Flow Code – to learn this nice program sequence that offers a professional appearance of continuously updated numerical indications on display, without flickering. Thanks again guys.
Before the end of macro “COUNT” the flag of a variable “Counter_update” is set (=1). Then the program Flow returns to the MAIN Loop where the flag of “Counter_update” is continuously checked by a Decision “If Counter_update is TRUE?”. Because the flag of “Counter_update” has been Set (=1), which means that is TRUE, the program Flow is turned to its YES branch and calls the macro “SERIAL_OUT”.
Inside the macro “SERIAL_OUT” the 8-bit code that holds the variable “counter” and which is the binary equivalent of the Gain setting, is transmitted in serial format thru Port RD.4 of micro which is directly connected to SDI of PGA2310. That is obtained by Masking one by one the 8 bits of “counter” in sequence, starting from the LSB. The result of each Mask operation is stored into variable “Serial”. Take a look on the Flow Chart of “SERIAL_OUT”: After the beginning, in the first Calculation “Serial = counter AND 0x01” the LSB of variable “counter” is checked and the result is stored into variable “Serial”. In the following Output icon the clock output RD.3 that is connected directly to SCLK of PGA2310 is set to Hi state. Then the PGA2310 input register is ready to receive the first transmitted bit. Next from this, the content of variable “Serial” is extracted to the serial output RD.4 for transmission. The following Delay of 10μsec keeps the clock output in Hi state for a while, so that reception of LSB from PGA2310 to be sure. In the next step, the clock Output is cleared (“Output 0D.3) and remains in Low state for 10μsec. After this, the second bit of “counter” is tested (“Serial = counter AND 0x02”) and the previously described steps are repeated until the extraction of the last bit of “counter” which is the MSB. Before the end of macro “SERIAL_OUT” the flag of variable “Counter_update” is cleared (=0) and the program Flow returns in the Main macro, at the Yes branch of Decision “If Counter_update?” and the Port interrupt is enabled again. Then, the Main Loop is reactivated and runs continuously waiting for the next interrupt request. At this point, a whole cycle of program, starting from an interrupt request, has been completed.
It should be noted that the given max clock frequency of PGA2310 is 6.25MHz resulting in a minimum period of 0.16μsec. In the current program, the two Delays of 10μsec placed after the Hi and Low states of serial clock combined with the time needed from MCU to complete the transmission of each one bit results in a sum of 22μsec as much or F = 45.4545KHz which is sufficiently fast for the current project and within the clock range of PGA2310. Another one issue is that in the PGA2310 datasheet is not expressly referred which bit is received first. From the timing figures, I can suppose that the reception sequence is bit0 first - bit16 last. Having this in my mind I did the development of macro “SERIAL_OUT” in which the LSB of “counter” is first transmitted. This can be confirmed only by testing the program on the actual project; unfortunately I haven’t in my hands a PGA2310, I hope that I will have money left over next month (that is the true Greek economic crisis) to buy a PGA2310, a rotary encoder and two LM4562 or four LME49710 to build a complete preamplifier.
By observing the blue Led, you can see the serial transmitted byte. Do the following: Select from “Project Options” menu a simulation speed of 20 and place on Variable window the variables: counter, GAIN_dB, Serial and Clock. Run the simulator. Press first the PWRON/STBY switch to enable the project. After the initial process the program returns in the Main Loop, while on the display is printed -95dB. While running the program, double click on the variable “counter” inside the Variables window. In the box that opens, you can change the “counter” value; print e.g. 180 and click OK. That is equal to -6dB of Gain. Press the STEP switch – for a while to take effect the interrupt because the speed of program is slow – and the “counter” will increment to 182. If you press again the STEP switch, the expected number of “counter” will be 184. Before this, make your calculation: N = 184  Gain (dB) = 192 – 184 / 2 = -4dB that will printed on display. With the help of windows calculator, make the following conversion: Print on calculator the decimal 184 and then select Binary; the result will be “10111000”. That means that the blue LED should be lit when the program Flow pass over the Calculation icons “Serial = counter AND 0x08” “Serial = counter AND 0x10”, “Serial = counter AND 0x20”, and “Serial = counter AND 0x80”. Press the STEP switch, and keep your eyes - big care needed – on the Flow Code red frame running over program icons. When it passes into the macro “COUNT”, press the PAUSE button of simulator. Now, by pressing the “Step Into” button (or F8 function key on your keyboard) once at a time, you will navigate step by step thru the Flow Code simulator in the current program sequence. Press again and again the “Step Into” and some time the program will enter in the macro “SERIAL_OUT”. Then, you have to observe if the blue Led lit on the correct Calculation icons described above. At the same time, you can observe and the green Led that simulates the clock output. Try it and with other values of “counter”, is wonderful to watch live a serial code transmission.
Of course, the macro “SERIAL_OUT” should be repeated and for the other channel. I will do this in the next part of article combined with Balance operation, Input select and remote control function. In this first part, we have built the main frame of project.
Thanks for your time
Fotios

Please see in the last post for the updated software v1.2
Attachments
PGA2310_block.jpg
PGA2310_block.jpg (64.78 KiB) Viewed 25627 times
PGA2310_SDI.jpg
PGA2310_SDI.jpg (101.75 KiB) Viewed 25627 times
Last edited by fotios on Thu Aug 04, 2011 5:28 am, edited 4 times in total.
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

To avoid a possible confusion because pictures and project *fcf file was sticking in the first post, i deleted the "fcf file from it and i attach again in this post.
Thanks for your comprehension, and forgive me.
Fotios
Please see in the last post for the updated software v1.2
Attachments
PGA2310preamp_v1.0.fcf
(39.84 KiB) Downloaded 701 times
Last edited by fotios on Thu Aug 04, 2011 5:30 am, edited 2 times in total.
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

I have good news! Just now I ordered samples: 4 X LME49710 from National Semiconductor, and 1 X PGA2310 + 4 X OPA132 from Texas Instruments. I am an idiot :lol: since I had forgotten that I have accounts at both companies! The other good news is that I found 3 encoders from old, out of order CD and MD players, in the warehouse of my home! Yippee! From the rest parts i am OK. I have everything in my stock.
Please forgive me for my outburst of joy.
Fotios
Last edited by fotios on Sat Jul 16, 2011 5:56 am, edited 2 times in total.
Best Regards FOTIS ANAGNOSTOU

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by Benj »

Always a good feeling when you realise you already have everything you need :)

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

In the second part of project, I added in the program code the functions “Input select” and “Balance”. I also did some modifications on the LCD display printing. Some necessary new macros and variables have also been added. As I said in my previous post, I found 3 rotary encoders – equipped with push button switch - from old and out of order devices. Henceforth, the rotary encoder will execute all functions except “Power On / Stand By” and “Mute” which will remain under the control of the switches connected at port RB.4 and RB.5 respectively. B6 switch represents the switch that is included on the rotary encoder and provides the “MENU” function. Let’s take a look on the related macro “MENU”: Menu switch it offers a choice between 3 functions of encoder by giving 3 different values in a variable called “Menu_Sw”. By default, when the program is launched, “Menu_Sw” takes value “0” which means that the encoder serves as a Volume control which is the principal function of it. When Menu switch is pressed for first time it causes interrupt (see in the macro “SCAN_SWITCH”), the “Menu_Sw” takes a value “1” and the macro MENU is called. Inside this macro, “Menu_Sw” is checked by 3 sequential Decisions and because matches with the 2nd “If Menu_Sw = 1?” the encoder is loaded with the INPUT Select function and the macro INPUT is called. Inside this macro, the program flow enters in a conditional Loop “Until SWITCH = 1”; the related switch is the MENU, and the Loop is executed continuously until MENU is pressed. Inside the Loop, 8 Inputs can be selected sequentially in either direction, by turning the encoder either CW or CCW. When the program flow exits from the Loop, the “Menu_Sw” takes a value “2” and the program returns again in the macro MENU. Now the value “2” of “Menu_Sw” matches with the 3rd Decision, the encoder is loaded with the Balance function and the macro BALANCE is called this time. Few words about Balance: It is well known in all audio devices, as a function that ensures equal volume between L & R channel. Technically, when e.g. the L channel has a level of 2dB bigger than R channel it does not means that we have to increase the R channel by 2dB for balance; it means that we have to reduce the L channel by 2dB. For this reason when the program enters in the macro Balance for first, a jump to connection point “D” is always executed and thru the following commands “0dB” is printed for both L & R channel on the display. The functionality of encoder is exactly the same like a balance potentiometer. When is CCW turned (L ch) simply the Gain of Right channel is decreased in steps of 1dB (starting from “0” thus negative dB). The same applies when encoder is CW turned (R ch) to the Left channel. When encoder reaches “0db” then it starts a reduction of the level of the opposite channel. When MENU switch is pressed, the program flow exits from the Loop, the “Menu_Sw” takes a value “0” and the program returns again in the macro MENU. Now the value “0” of “Menu_Sw” matches with the first Decision and the encoder is loaded again with the Volume function. This branch is different from the other 2 because: 1) there is no need for VOLUME macro call, it is the principal macro and is called every time the encoder is turned. 2) Balance indications on the display must be cleared and replaced with the current volume indications. To this, before the end of branch, the program part of the macro VOLUME which defines the values printed on display is repeated. Next from this, the program flow returns in the MAIN macro Loop and the Volume function is reactivated.
Some new and indispensable variables have been added, which are initialized during Power On of preamplifier because in Stand By mode the SRAM registers that keep these variables are not cleared. This ensures the correct start - up of preamplifier which should always starts with MUTE enabled, “-95dB Volume” and “0dB Balance” for both channels.
At this point the second part of project is finished. In the third part, we have to “join” the Volume and the Balance functions. Is not so easy; when Balance is adjusted should be audible so we need separate SERIAL_OUT macros for L & R channel. When this part of program will be completed it only remains the incorporation of Remote Control function on the program code.
Thanks again for your attention
Fotis
Please see in the last post for the updated software v1.2
Attachments
PGA2310preamp_v1.1.fcf
(90.1 KiB) Downloaded 604 times
Last edited by fotios on Thu Aug 04, 2011 5:31 am, edited 1 time in total.
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by philip davies »

Hi Fotis,

I see that this project is coming along nicely. Have you tried it for real yet or just on flowcode?

I have to say I like the idea of using a rotary encoder with a built in push button, something I haven't been able to find yet, but I'll keep looking but for now I'm going to take a closer look at the fcf file you've posted on here.

By the way, will I be able to use an LCD compatible VFD display for the preamplifier?

Kind Regards

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

Hi Phil
First of all: Welcome to the "Flowcode V4 users" club! :D
No, i haven't try yet the project on actual hardware. Just yesterday i received the sample of PGA2310 that i ordered from T.I., and i will receive tomorrow the 4 samples of LME49710 that i ordered from NSC. With these TOP parts, i will be able to build a nice and working preamplifier for which an input buffer stage before PGA2310 and an output buffer stage after it are needed. This is the analog part and will implemented on a separate PCB including the Input select relays. In another one PCB (designed to fit in a front panel) i will implement the digital part: LCD display, encoder, STBY Led, IR receiver, push button switches and PIC16F887 with ICSP header for on-board programming. The last because i am not sure by 100% for the Gain bytes transmission sequence. In the current fcf i supposed that the correct sequence is Left bit0 first - Right bit7 last and this is probably corredt but this can be verified only with a scope and a function generator connected at the In - Out terminals of PGA2310. Unless, i have to invert the transmission sequence of Gain bytes.
To the present, i do the code test using the Flowcode simulator but i can confirm you that the prediction of this simulator is by 99,9% true. When i have completed (hope in 2 days) the "join" of Balance and Volume functions, i could try the program using my E-Blocks and one veroboard including the encoder and the PGA2310. Instead this, i would prefer to construct the two PCBs, it is most easy for me. For the Balance function, i included it on the program since PGA2310 offers this posibility. By any way, this function is absolutely transparent when you select to skip it - just by turning the encoder - on the actual project.
As for the rotary encoder, if i remember well you said that you have an optical one. You can use it, simply you have to add an extra push button switch for the MENU function. If you wish, you can find enough rotary encoders equiped with switch at Farnell e.g. http://uk.farnell.com/alps/ec12e2424407 ... tt=1520813 for 1.15 GBP, is very cheap and is ALPS.
For the VFD display, you said that you have a Noritake http://uk.farnell.com/noritake-itron/cu ... tt=1495416 that is by sure compatible with LCD display command lines. If you are not sure, check it again please or make a question in Farnell.
Cheers
Fotis
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by philip davies »

Hi Fotis

Well thank you for your warm welcome :D

Yes you are correct, I do have an optical rotary encoder and yes I do have a Noritake Itron VFD display. As for the encoder I might try the one you have suggested that farnell stock but if it hasn't got the same quality feel that the optical one has then I might just use a seperate push button item for scrolling through the menu but as you pinted out it is an Alps encoder. My power amplifier has an "Anti Vandal" switch for switching it off and on, the switch has a nice feel to it and finishes off the amplifier quite nicely so I might use exactly the same ones on the pre-amp so that they both match.

As for the display I did get in touch with Noritake Itron and they have confirmed that the VFD display that I own will work with standard LCD commands. They also pointed out two other displays that will also work with LCD commands.

Thanks again Fotis :)

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

In the third part of build of this project, I had to resolve two issues: 1) The combined operation of Volume and Balance control, and 2) The correct code for the use of Encoder, a thing that proved very difficult on the actual hardware. Rotary encoders are usefull and peculiar devices and their implementation to the program code is a real headache. Thus, while I started using Port B interrupt for all switches finally I forced to replace it with a pseudo-interrupt consisted from a sub-loop combined with a new macro named “MANUAL”. Consequently i had to rearrange the program structure to avoid stack overflow issues. PIC16Xxxx devices have a 8-Level deep hardware stack and the use of both “Port” and “INT” interrupts on the current project can cause stack overflow. We need by any way the “INT” interrupt for the remote control function. All the above issues could be easily resolved with the use of a PIC18 (it has deeper stack level, bigger memory and 3 interrupt sources in addition to the PORT B4-B7 interrupt) but I did not want to replace the PIC16F887 that adopted from the beginning.
A big part of the initial code has been changed, while new macros and variables have been added. In a same way, some of the initial variables have been removed. It is of big importance that this time I have checked the new code on actual hardware using E-blocks and not only on the simulator. I have soldered A and B outputs of encoder in parallel with SW6 and SW7 of switch board, and the built in switch of it in parallel with SW5. You can try the project by using either FC simulator or E-Blocks, the results are true like in the actual hardware. The encoder that i use works by 99% correctly, is an ALPS with 18 detents and produces 17 pulses per revolution at each one of its otputs A or B. Its response is somehow slow during Volume or Balance adjustment because after each step the Serial output and the LCD display values should be updated. In this way, if the encoder is crazy turned, only the predetermined - by the program timing - steps will be executed. However, each time the serial data output transmission is right and in accordance with the “dB” value indicated on the display.
Below you can find some instructions to run the program in simulator and some explanations for the functions:
Run the simulator at maximum speed. To activate the device you must press the "PWRON" switch (B3). The display shows - by default - that the CD input has been selected and that the Gain is -95dB for both channels. The last is true; when the PGA2310 is powered its internal Gain registers are cleared (0x00 Left - 0x00 Right, that corresponds to -95dB) which means that is placed in MUTE state.
Press the MUTE switch (active LOW) and the corresponding Led will turned off. Press again the MUTE switch to activate the output. By pressing the MENU switch you can navigate between the 3 functions which are: Volume (selected by default), Input and Balance. It should be noted that the MUTE function is not available when Input and Balance functions have been selected (maybe later i will change it) and only the PWRON switch is available allways. The 2 switches B6 and B7 represent the B and A outputs of encoder. When either of the 2 switches is pressed executes only one step (e.g. -95dB--> -94dB etc.); you have to release the switch and to press again to execute the next step. In this way the 2 switches mimic the function of a Rotary Encoder.
I did an improvement in Balance function to work exactly like a traditional Balance potentiometer. Provided that the Volume level has been adjusted in something greater than -95dB (unless no Balance!) say L=-80dB & R=-80dB, we can now adjust the Balance between the 2 channels. When B6 (represents the CCW rotation of encoder) is pressed it starts a decrement of the Right channel Gain in the desired level - up to -95dB which is the min Gain. Then we have to press the B7 (represents the CW rotation of encoder) to start... what? Of course, firstly an increment of the Right channel Gain up to -80dB adjusted previously by the Volume function and then a decrement of the Left channel Gain up to -95dB (it took me 3 days and a lot of code changes to obtain the correct logic for this function ). This part of code works like... a traditional "pair of scales". I already have in my mind 2 - 3 other applications (not necessarily for Audio use) in which the code of Balance function will be usefull.
Using the FC simulator, you can observe the Clock and the Serial Data Output function. You simply have to place the speed of simulator at 1000 so as the CLK and SDO transitions can be visible on the correspoding green and blue leds.
I hope that I did a comprehensive description of the functionality of project. I am already in the process of implementing and the remote control function which I think that will not be so difficult like the current part which took me 10 days to complete it.
Thanks for your time.
Fotios
Attachments
PGA2310preamp_v1.2.fcf
(86.39 KiB) Downloaded 606 times
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by philip davies »

Hi Fotios

I have just seen your last reply and I have just downloaded the fcf file you have uploaded on this thread. I have just ordered some parts in order to try this on actual hardware so i can see it work for real. For now it seems to work with out any problems on my copy of flowcode.

I was going to modify the display readout slightly so that when the software is runing in normal volume mode, only one volume setting is shown instead of seperate L and R readings, but after having a good play with the software I quite like the idea of having both readings on display because if a change has been made to the balance setting then it's continued to be on display when the encoder is used for the volume setting.

Thanks again Fotios

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

Here is an update of program that I did after the launch of the last upgrade v4.5 of FlowCode that includes the new RC5 component. It was a good opportunity to try it on a real multimedia device like this preamplifier. Moreover, this wireless protocol is addressed exclusively for such type devices. I also did an update in Rotary Encoder code after a successive exchange of posts with medelec35 in his nice thread http://www.matrixmultimedia.com/mmforum ... =26&t=8773 (thanks Martin :D ), and a lot of experiments with 3 different type encoders. Basically the types are two: a) Continuous and b) Detent equipped. The implementation of a continuous rotary encoder in program is relatively easy. The issue is that this type is suitable only for volume control. In my project I have adopted the use of encoder for 3 functions: volume control, balance and input select. For input selection the encoder should be stay “locked” when is not operated and this could be obtained only by detents. Detents add complexity in decoding because encoder's A and B switch state at detent positions differs from constructor to constructor. In ALPS and BOURNS encoders both A and B switches are open in detent positions, while in Panasonic encoders switch A is either open or closed at each detent position and the state of B switch is unpredictable. In the attached fcf the code is written for a Panasonic encoder.
I also decided to make changes in the program to be more “technical” – of course, as I can with the programming knowledge I have – by using all the possibilities that offers PIC16F887. I have adopted the use of PORT B interrupts (or IOC) and I have enabled the internal weak pull-ups of the same Port to mace economy in external parts. Now the external parts around the micro are just 4: 1) a detent rotary encoder equipped with push switch (for MENU function) 2) a push switch for MUTE function 3) a push switch for the PWRON/STBY function and 4) an IR receiver IC.
Another one useful function that I added is a mini subroutine at the beginning of program that gives the possibility of Address recognition of the remote control handset used. To this, a MCLR should be happens e.g. by disabling and re-enabling the power supply of micro. After this, we have to press within 3 seconds the MUTE switch connected at the micro so that the program be turned inside the subroutine. That is indicated on the LCD display by a message REMOTE CONTROL INITIALIZE. Then, within 3 seconds we have to press and hold down a key on the remote control, until the message ADDRESS = 0 (in the case that the remote control is TV compatible) appears on the display. Now we can release the key; a new message REMOTE CONTROL READY ! ! ! will be displayed on LCD showing that the Address has been stored in the EEPROM of micro. When this procedure has been completed, during the normal program execution and each time a new RC5 signal is received, its Address is compared with the Address stored in the micro and only a TV remote handset is recognized by the program.
At this point, the main part of program is completed, is fully operational either manually or remotely (I tested it up to death, and works by 99.9% correctly). It remains to join it with the PGA2310 for the final tests and possible corrections. Soon, I will upload and the version for the ALPS encoder.
Attachments
PGA2310preamp_Panasonic_RC5.fcf
(125.38 KiB) Downloaded 477 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

As i promised, here is the other fcf that suits to ALPS detent encoders. I would like to make a brief explanation of the decoding method used: In both cases (ALPS or Panasonic) only the A switch causes IOC interrupt (falling edge), while the Port interrupt of pin RB.6 in which B switch is connected is disabled by default, i.e. B switch can't cause interrupt. When the encoder is turned the A switch interrupt occurs repeatedly and each time the state of B switch is checked to determine the direction of rotation; CW or CCW. Intermediate transitions of both switches between detents are omited; only the first transitions are taken into account. Here a sample of transitions for comparison. The upper patern is this of ALPS while the lower is this of Panasonic:
Image
Regarding the RC5 signal process by the program, it should be noted that the Toggle bit of each received packet is also collected for use with the PWR and MUTE commands. In multimedia devices these 2 commands should be executed at once, that means if e.g. MUTE switch on remote control handset is held down constantly, the program should recognize this condition to not change continuously the state of MUTE output; this should be done only if the switch is released and pressed again. In the first version of RC5 protocol decoding published by Matrix Multimedia (a great work of Sean), a special macro named "SignalEdge" was used in which the Toggle bit does not taken into account and so the PWR and MUTE commands are executed in a same maner like VOL+, VOL- etc. In the new version, we can collect the Toggle bit to use it in any command we want. That is a very nice addition! :D In my flowchart, you can see that i use the Toggle bit for PWR and MUTE commands, while i did a split of commands in two macros, "RC5_STA" and "RC5_CON". In "RC5_STA" the PWR and MUTE commands are decoded, while in "RC5_CON" the CH-, CH+, VOL- and VOL+ are decoded. For this last macro, the Toggle bit is not collected because in multimedia devices these 4 commands run in "zapping" mode. In the beggining, i had a small problem with these commands, e.g. when i pressed momentarily the VOL+ key on remote control handset the volume increased by two units instead one. The same with the other keys, CH-, CH+, VOL-. This means that, two successive RC5 packets had time to received. I gave a solution by disabling RX before the call of "RC5_CON' macro, by placing a delay of 120 - 140 ms after the return from macro, and by re-enabling RX at the end of branch. You can see it at the Main macro of program. Although it works without errors, i have a sense that is some tricky :( , realy i don't know (have you any better idea for this?), i will try again latter. To the present i have to try the program in collaboration wih the actual devices PGA2310, input relays and PWR relay.
Thanks for your attention
Fotis
Attachments
PGA2310preamp_ALPS_RC5.fcf
(124.51 KiB) Downloaded 507 times
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by philip davies »

Hi Fotis,

I've tried both fcf files that you have posted for the panasonic and alps encoder but for some reason both files won't run on my copy of flowcode. It doesn't show any errors or anything. I press play to simulate the code and the first thing that happens is the countdown for the 3 second delay for the subroutine. After the delay i try to press the power on button and nothing happens. I have also tried to press the mute button during the 3 second delay and again nothing happens.

Does it run properly on your copy? also if it does work on your copy, do you have any ideas why it wont run on mine?

Thank you for your help

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

philip davies wrote:Hi Fotis,

I've tried both fcf files that you have posted for the panasonic and alps encoder but for some reason both files won't run on my copy of flowcode. It doesn't show any errors or anything. I press play to simulate the code and the first thing that happens is the countdown for the 3 second delay for the subroutine. After the delay i try to press the power on button and nothing happens. I have also tried to press the mute button during the 3 second delay and again nothing happens.

Does it run properly on your copy? also if it does work on your copy, do you have any ideas why it wont run on mine?

Thank you for your help

Phil
Hi Phil
Glad to hear you again. Reason that projects does not simulated, is a lack of FC simulator: I have enabled the Port Interrupt (IOC) on all pins of PortB, so each time a switch is pressed and changes state triggers the Port interrupt. Unfortunatelly only RB.4 - RB.7 Port interrupts are simulated by FC, and since PWRON switch is connected at RB.3 can't activate the program. For my own use during simulation, i add a small routine that reads RB.3 as an input and accordingly activates the program. When simulations are completed, i remove it because on actual hardware both fcf work correctly. I attach the modified version, so you can play with simulator. The 2 toggle switches, simulate the operation of encoder. To increment e.g. volume, do this: B7on-->B6on-->B7off-->B6off... To decrement do the inverse: B6on-->B7on-->B6off-->B7off...
Fotis
Attachments
PGA2310preamp_Panasonic_RC5_sim.fcf
(125.73 KiB) Downloaded 523 times
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by philip davies »

Hi Fotis

Thanks :) Glad to see that this project has taken shape very nicely :D

I've tried the new fcf file that you have posted, it now works with me to :)

How is your preamplifier coming along? I have been busy working on two monoblock amplifiers that will be used with this pre-amp :D

Thank you for posting the modified fcf file

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

philip davies wrote:How is your preamplifier coming along? I have been busy working on two monoblock amplifiers that will be used with this pre-amp :D

Thank you for posting the modified fcf file

Phil
You're welcome! Nice to hear that you build monoblocks, what kind are these? Bipolar or Mosfet?
I am in the prosess of drawing schematics and pcb layouts to test the project on actual mode. I hope in 1 week from now, i will have a complette and working preamplifier. I will use two LME49710 as input buffers and another two as output buffers arround PGA2310.
Fotis
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by philip davies »

Hi Fotis

The monoblocks I have use a Mosfet output stage and are rated at roughly 300W each. I think i will install them both in one enclosure instead of having two separate ones but both amps will be completely independent and have they're own separate power supplies. For testing purposes i used a small mixing desk to drive both amplifiers with good results, although the mixer is a little on the cheap side. I also have been working on a valve amplifier for quite some time but I think that its going to need a lot of work before it's completed.

Here's a question for you, have u thought about installing some kind of EQ on your preamp? like I said I'm using a mixer to drive my pre-amp and I find that the EQ on it is quite useful to fine tune the sound to my licking and to also help with some bad recordings. Let me know what you think of this idea :D

Phil

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by philip davies »

Hi Fotis,

Please excuse my error,

On the second paragraph it says that i use a mixer to drive my pre-amp, what it should say is that I use the mixer to drive my power amps, do excuse my error :)

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

Hi Phil
Do you know the technical explanation of term "Monoblock" in audio amplifiers? Is the use of separate metal box for each channel, so the two channels to be galvanically isolated between them. Galvanic isolation means that GND nodes of channels are isolated between them. That is of big importance in audio, monoblocks obtain a better "Crosstalk" ratio compared to "Dual - Mono" designs where two channels included in a common metal box - like in your case - are supplied from individual power supplies, and far better from ordinary designs where two channels are supplied from a common power supply.
Regarding your question about equalizer, usually is included in commercial cheap preamplifiers. In true Hi-Fi products, never. I always follow this rule which also is a rule of DIY projects. A graphic equalizer should be a separate unit. There are nice ICs offered from Analog Devices for this task, i don't remember codes this time, i have to search in my DOCs. By any way, i will do it for your sake. For now let me finish the current project, in which i already have included the extra "balance" function that is not offered - from those i know - by other simillar projects.
Fotis
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by philip davies »

Hi Fotis

Yes I understand what you mean about a true monoblock where both amplifiers are in seperate enclosures To be honest I am very tempted at purchasing two small enclosures even though I have alreay a nice enclosure that is big enough to fit both amplifiers and they're powersupplies.

I agree that an EQ is fitted to cheap hifi preamplifiers, I have also never seen them on expensive equipment. I will have a look at those ic's from analog devices. I might put together a graphic equalizer but the preamplifier won't have any EQ built in.

Thanks for your advice on the subject of monoblocks. I personally thought it made no difference as long as both amplifiers don't interact, I.e have a seperate psu for both amps, I'm going to have a think about it and maybee buy to small enclosures.

Thanks again :)

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

philip davies wrote:Thanks for your advice on the subject of monoblocks. I personally thought it made no difference as long as both amplifiers don't interact, I.e have a seperate psu for both amps, I'm going to have a think about it and maybee buy to small enclosures.

Phil
Hi Phil
Galvanic isolation has to make with another very important thing. Ground loops and "hum noise". That is applicable mainly in devices with large voltage gain like power amplifiers (e.g. your amplifier of 300W has a voltage gain Av = 35 approx.) and phono preamplifiers (Av = 2000). Big power amplifiers are supplied from big transformers (300W per channel needs a 300VA mains x-former) and metal cases must be electrically earthed, so GND nodes of both channels should be connected to chassis. Signal GND should also be connected to chassis for good screening, but NOT at the same point with power supply GND. For this reason, the shield of input signal socket is soldered on PCB at the "clean GND" point, in some distance from the power supply "dirty GND" point.
There is no reason you do unnecessary expenses. You can use without fear a single metal enclosure for both channels in "dual - mono" configuration. There is a trick to separate the GND nodes of channels between them, using a R-C filter. I always use it, the same all DIYers and all serious constructors of Hi-End equipment. It is very effective. I attach a picture that shows the connections, the capacitor could be MKT (polyester) but a MKP (polypropylene) presents smoother absorption in current spikes and so it is strongly suggested. Please don't spend money for luxury axial MKP caps, economic MKP radial caps can do the job just fine.
Fotis
Attachments
GROUND CONNECT.jpg
GROUND CONNECT.jpg (62.14 KiB) Viewed 24903 times
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by philip davies »

Hi Fotis

I see what your trying to do with the earthing arrangements for the amplifier, I think i've seen this done inside an external power supply for a Soundcraft mixing desk a while a go. Apparently it is bad practice to connect the PSU GND directly to the electrical earth because it can introduce noise in the audio circuit, dunno if that's true but I can understand what your doing to try and help isolate both amplifiers from each other.

Anyway i'm going to give that a try when i install both amps in the enclosure. :)

Thanks again :)

Phil

Grahamm
Flowcode V4 User
Posts: 10
Joined: Thu Sep 08, 2011 11:53 am
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by Grahamm »

Hi Fotios
Really excellent work on your design. Congratulations on the depth of the functionality and sophistication you have designed into this project.
I want to do something a lot simpler with remote control and not using the BB/TI volume control chip and I will contact you soon regarding some issues and to solicit advice on what I have in mind as I am an absolute beginner with Flowcode.
Thank you for sharing your knowledge with us.
Regards
Graham :D

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

Hi Graham
I am really very happy to see that the problem of your registration on FC v4 forum has been solved. Well, welcome to our company. :D
I will study your questions as fast as possible. Please stay tuned :)
Fotis
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Contact:

Re: Hi-Fi audio preamplifier using Burr-Brown PGA2310

Post by fotios »

In this post is attached the schematic of the project on which I am currently working.
It is the ultimate version of the project which is addressed mainly to the devotees of perfection. Latching relays are exclusively used for ensuring the lowest possible power consumption and the absence of any EMI interference in the audio signal because their coils do not require continuous power. An instant pulse of 15msec is sufficient to activate the relay coil to change the position of its contacts.
The only drawback is that a Latching relay needs dual control lines, one for the SET coil and one for the RESET coil. But the nice PIC16F887 micro can offer all of its pins as general I/O ports thanks to its internal oscillator and MCLR modules. So it can manage up to 9 relays of this type.
As we make a jump from an experimental to a real world project, the actual hardware and the program code must be changed. 1) I selected to include 5 inputs which is a standard in most commercial devices. 2) I changed the operation of MUTE function, since around PGA2310 4 buffers are used. So the mute function has been removed from it and now is loaded on a relay. 3) I added an extra pair of control lines to manage a power latching relay to switch on or off the analog power supply. 4) I added a red Led to light when device is in STAND-BY mode (i.e. the analog supply is off and only the digital supply is active) 5) at the end, I added a control line to enable or disable the backlight Led of LCD display. It is noticeable that with all these additions there are 4 pins left over for use as general I/O lines and 1 pin for use as digital input.
Two ULN2003 are used to isolate the outputs of the micro from the excess load of relay coils, and a transistor from the excess load of LCD backlight Led. Remember that the maximum ability of micro to source or sink current is up to 25mA. You may also notice that the COM pin of ULN2003s is independent from the 5V digital supply rail. This offers the possibility of the use of relays equipped with any type coil: 5V, 12V or 24V. For example, I have in my stock relays with coils of 12V. Thus when 5V relays are used, simply we have to join COM pins of ULN2003s (NET “SPL RLY”) with the 5V digital supply rail (NET “SPL1). If relays are 12V, then we have to add an extra 12V stabilizer (7812) in the digital power supply for these. For this reason the use of a transformer with 12V secondary is recommended.
In the end I left the description of the 3 control lines of PGA2310. These are: a) ZCEN (Zero Cross Enable), b) SDI (Serial Data Input) and 3) SCLK (Serial Clock). All 3 are connected at Port RE. The PGA2310 includes a useful function, the ZCEN or Zero Crossing detection that can provide noise-free level transitions. The concept is to change gain settings only during zero crossing (cross at 0V) of input audio signal. In this way audible glitches are minimized and the volume control is performed smoothly, like in traditional analog potentiometers.
You may notice that PIC16F887 I/O lines are purposively allocated on its concrete Ports. That offers you the possibility to “simulate” the project operation using E-blocks: 1) EB006 programming board, 2) Two EB004 Led boards connected at Port C and Port D, 3) EB005 LCD board connected at Port A, 4) EB060 RC5 Infrared board connected at Port B 5) A custom patch board including two tactile switches and the encoder (you can get their control lines from the patch system connector of EB060 RC5 board).
Thanks again for your attention
Fotis
Attachments
PGA2310 PRE CONTROL 1.pdf
(47.6 KiB) Downloaded 870 times
Best Regards FOTIS ANAGNOSTOU

Post Reply