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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

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

Post by medelec35 »

One thing to bear in mind is overheads used to create a delay. If running at 4MHz
then 1us delay will actullay take about 16us.
The higher the clock speed the less the overheads, hence smaller delays will be more accurate.

Using 1*5/10 us will take longer due to processing time of the formula. @4MHz total time about 1ms
There are ways round this.
one of them is just waste some clock cycles with nop within a code block.

What frequency is clock speed?
Then I can help you with a 500ns delay.
Martin

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

Yes, Martin's remark is right. I forgot that "manipulation" plus "division" plus "result" takes 3(?) machine cycles so the Delay instead decreased will going increased :lol: Sorry guys for the mistake.
The problem of "hyperion007" actually is a misfit of his rotary encoder speed with the time consuming macro that sends data to PGA4311. I looked again in PGA4311 datasheet and seems to be very fast:
Serial Clock = 6.25MHz max
Serial Data Input setup = 20nsec minimum
Serial Data Input hold = 20nsec minimum
Chip Select Falling to Serial Clock Rising = 90nsec minimum
Serial Clock Falling to Chip Select Rising = 90nsec minimum
Maybe "hyperion007" could completely remove the "Delays" of macro?
In any case i am in waiting to see Martin's "magic" to reduce the Delay time below the 1usec limit of Flowcode. I guess that "hyperion007" has selected 4MHz clock speed for his PIC.
Best Regards FOTIS ANAGNOSTOU

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

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

Post by hyperion007 »

I am running a clock speed of 48Mhz with div/4

I might just try to remove the delays as you suggested but I don't know if that will be stable enough.

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

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

Post by hyperion007 »

I am getting nowhere with this :(

I changed some settings and some code so that everything now works when running @ 48Mhz with no divide (as fast as it will go)

But I cannot make the PGA4311 work. I have tried both without any delays and with 1us delays

So it looks like this:

1 - Calculation: SDO = N AND 0x80
2 - Output SDO to A3
3 - Delay 1us
4 - Clock ON to A1
5 - Delay 1us
6 - Clock OFF to A1
7 - Delay 1us

And repeat (but with N AND 0x40, 0x20 etc.)

But the PGA4311 is not responding at all.

I have had it working in the past with another PIC

Last night I worked on this problem for probably 4 hours without any progress :(

From what I understand this shouldn't even come close to the maximum speed of the PGA4311 right?

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

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

Post by hyperion007 »

Never mind. It turned out to be the USB Slave component that caused this problem. I had to disable everything that had to do with the USB Slave function, then the Serial Out macro worked like a charm, even without any delays.

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

Hi,

Is there a substitute mcu that I can use instead of the PIC16F887? I would like some extra memory for the code. I have tried to use PIC18F4525 but after doing this I cannot get the RC5 section to work.

Many thanks :)

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

Hi Phil
Probably this issue caused from wrong configuration of P18F4525 which differs a lot from this of P16F887. OTOH, i had issues when tried to program a P18F45K22 but this is a new device and is impossible to program it with EB006 or MPLAB ICD2. For that reason i bought the PICKIT 3 but the problem still remain. Take a look here: http://www.matrixmultimedia.com/mmforum ... 47&t=12438.
Neverthelles i dont think that the same applies to P18F4525, it is an old device. Well, the best solution it is to write a simple code in P18F4525 (e.g. to blink one or two LEDs, or to type in display a simple text) and if works, then your configuration settings are correct. I have stocked some P18F4520 (simillar to P18F4525) and i will give a try to check if there is any mistake into FlowCode 4.
I will reply you asap.
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

Hi Fotios,
I will give your suggestion a try. When I first tried to swap mcu I had problems with the speed of the software on the hardware. It simulated fine on simulator but when running it on actual hardware the speed was very slow. Other members of the forum kindly made some suggestions in the configuration settings and also suggested that I made sure that the clock speed in the project options are set correctly but the speed was still slow.

Another member suggested I add a c-code "osccon = 0x6E;" because the reset default clock frequency is 1 MHz on the PIC18F4525 not 4MHz. This did speed up the hardware to normal speed but I noticed that the RC5 no longer works.

I need to buy some more 18F4525 as I think the one I currently own is faulty as Flowcode can no longer ID the mcu. I can also buy some PIC18F4520. I will also be buying a 13.5v psu to run the EB006 board instead of relying on the 5v available from usb socket on my computer

P.S I have FlowCode 5 Proffesional if that helps with solving the problem.

Thanks

Phil

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

looking at the code I can't see that IOC interrupt is activated.

Thanks

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

Phil i think that RC5 component it is time critical and will work only with 4MHz clock. What suggested from other members regarding OSCCON register is correct. 0x6E = 0110 1110 which corresponds to a setting of IRCF<2:0> bits = 110 = 4MHz. Take a look please on P18F4525 datasheet in internal oscillator section. You should also notice that all Port.B pins of P16f887 offer IOC (i don't remember if we used IOC in the code for the encoder outputs) while P18F4525 only from Port RB.0 - RB.3.
Please take a look in code if IOC interrupt is activated and let me know. Interrupt handler of P18 series is most complex from this of P16 series as it offers 3 pins of Port.B for external interrupt sources. These 3 interrupts must have a priority level. Probably you haven't configured the port RB.0 interrupt for highest priority. For that reason the IR detector could not cause interrupt. There is a bit IPEN in RCON register which if cleared disables the priority level of interrupts and then the P18 works in compatible mode with P16 mcus. From what i've read this bit is cleared by default after a POR (Power On Reset) so there is no priority level at interrupts. I don't know if this cause the problem.
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

I am not sure if IOC interrupt is activated in the code. Could you tell me roughly where I should be looking?

on the Microchip website it says that the internal oscillator can support 31kHz to 8MHz with 4xPLL.

How do I make sure that I have configured port RB.0 interrupt for highest priority?

Many thanks

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

I think that a secure POR (Power On Reset) will initialize all registers of P18F4525 with factory preset values. In these included the OSCCON register which initialized at 1MHz by default, so you have to change the preset at 4MHz thru the C command "osccon = 0x6E;" at the beggining of program code. Don't take into account the 4xPLL, does not matters in the given application. The IPEN bit of RCON register is also cleared by default after a POR and so any interrupt priority is dissabled and the P18 runs in P16 compatible mode which simplifies the interrupt handling process.
Regarding IOC interrupt, if is enabled, in these P18F45xx a priority level between them and the RB.0 main interrupt (IR receiver) probably is needed because their functionality is enough different from P16F887.
Another major difference between P16F887 and P18F4525 is that the first has the possibility to generate an internal MCLR signal without the need to tie the MCLR pin at VDD while the P18F4525 no. For that reason in the original circuit the MCLR pin of P16F887 is modified as spare digital input and the POR works securelly in any instance. I remember (before start working with FlowCode) that we used P18F4520 in a SCADA system and allways we tied its MCLR pin at VDD thru the Microchip's suggested circuit in page 43 of P18F4525 datasheet. Take a look please on it, maybe this traditional reset circuit that is still used today could resolve your problem.
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

Hi,

Thank you for explaining that for me. I think I understand what you have suggested. I have looked at the datasheet on the microchip website and reading that has also helped me understand.

The datasheet also suggests that I need to add a resistor betwean VDD and MCLR. Should I do the same?

I have ordered some new PIC18F4520 and some PIC18F4525 mcu's to try as I don't trust the 18F4525 that I currently have because FlowCode and PPPv3 is having difficulty in detecting the mcu in the EB006 board. I have also bought a 13.5v psu to power the board instead of relying on USB power. Once I receive everything I can then try again :D

Thanks again for your kind help. I will let you know how things progress

Phil

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

Hi,

I did manage to re-program the mcu (18F4525) this evening after sorting out a small glitch I had with FlowCode not being abled to ID the target device. I still can't get the IR receiver to work even after tying MCLR pin to VDD via using microchip's circuit. All other functions work with no problems.

I am stuck at this point because I don't know how to set the priority level of RB.0. Is this something I could add to the original code?

Thanks,

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

OK, with the external reset circuit a correct POR (MCLR) is ensured. Try to check your hardware if works correctly i.e. if the IR receiver produces output signal and if the signal arrives at micro RB.0. To this, remove the micro from its socket - to prevent any short circuit - and with a voltmeter check the voltage at the pin of the socket that corresponds to RB.0. The output of IR receiver is constantly 5V when there is not incoming remote control signal. Then press any button on remote control handset and the voltmeter should show some small - because the signal transitions are very fast - voltage drops from 5V, e.g. you could see an unstable indication on its screen. I suppose that you dont have available any oscilloscope. If the indication of voltmeter is constantly 0V or 5V then the problem is on the hardware. Check this first and leave for later the... famous "interrupt priority level" :D
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

Hi,

I've checked the IR receiver on my hardware. I removed the microchip from its socket and there is 5v pressent on the RB.0 pin on the IC socket. When pressing any of the buttons on the handset the voltage drops but is unstable for my DMM to meassure the voltage correctly. But the voltage does drop from 5v. I will also re-check my external reset circuit just to make sure it is correct.

Thanks

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

OK, your DMM 5V measurement at RB.0 and the voltage drop "unstable" measurement when handset transmits it shows that IR receiver works OK and that the signal arrives at RB.0.
Give me some time to make some thoughts. Will reply you soon.
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

The exact voltage is 4.9v at pin RB.0. When a button is pressed on the remote handset the voltage at pin RB.0 fluctuates betwean 4.3v to 4.45v.

I was hoping to try another PIC18F4525 but I am still waiting on some new ones to arrive.

Many thanks for your help.

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

The train of pulses produced by IR receiver is very fast and you could see them in detail only with oscilloscope. But this fluctuation of DMM between 4.3 to 4.5V is an indirect method to check if pulses are produced by IR and arrive at RB.0. So everything is OK. Also 4.9V stable in iddle mode it's OK.
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

I completely forgot to mention that after changing the mcu in FlowCode to the 18F4525 that when trying to compile the code to hex an error is flagged up in the Icon List. It points out that there is an error in C - Code. this is the error that is flagged up :- wpub = 0xFE;

In order for FlowCode to compile to hex I removed this C - Code from the Main Macro. Could this be causing me the problems with the IR receiver? If it helps I could post the revised fc. file on the forum.

Thanks

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

OK, the WPUB and the OPTION registers are not included in P18F4xxx for that reason the C-code error message. You have removed the C-code wpub = 0xFE; and that is correct. To enable all internal wake pull ups (which eliminates the need of use external pull-up resistors) you also have to change the previous C-code from option_reg.NOT_RBPU = 0; to intcon2.NOT_RBPU = 0;
I think that i have located the issue of IR receiver. Port B pins 0 to 4 are configured as A/D inputs after a master reset (POR) by default and probably the INT0 of RB.0 does not work. You have to change these 4 pins from A/D inputs to digital inputs. Open the configuration table of chip and go to the box Port A/D Enable. There are two selections but only the half of the text is visible. Place the arrow of the mouse on the box and after a while a white box should pop-ups. If it shows PORTB <4:0> configured as analog inputs on RESET click on the arrow of box and select the second line. Place again the arrow of mouse on the box and this time the pop-up window should shows PORTB <4:0> configured as digital inputs on RESET. Click OK and exit from configuration table. From what i've read on P18F4xxx datasheet the INT0 is enabled after reset by default except the interrupt triggering edge as RB.0 weak pull up is enabled (RB.0 is continuously in HI state) and trigger is set to occur in the rising edge of IR signal by default. To select the falling edge write this C-code intcon2.INTEDG0 = 0; and to be sure that INT0 is enabled write also intcon.INT0IE = 1; Although in original project i haven't connected nothing at RB.1 and RB.2 pins (on which applied the other two interrupts INT1 and INT2) to be sure that you will not have problems is better to disable the interrupts on these pins. Write the following two C-codes: intcon3.INT1IE = 0; and intcon3.INT2IE = 0;.
Summarising, delete all C-codes from your flowchart and place a new one in the beggining with a bunch of 6 instructions (included the OSCCON setting at 4MHz):

Code: Select all

osccon = 0x6E;
intcon2.NOT_RBPU = 0;
intcon.INT0IE = 1;
intcon2.INTEDG0 = 0;
intcon3.INT1IE = 0;
intcon3.INT2IE = 0;
Try this first and let me know if works. Then, If you still have problem upload your fcf to I make the modifications and to check configurations etc.
Best Regards FOTIS ANAGNOSTOU

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

I will give that a try this evening after work. I am hopping some new PIC18F4525 and PIC18F4520 today. My current PIC18F4525 sometimes won't ID when compiling using FlowCode or PPPv3. I will try what you have suggested and I will let you know if it works :D

Many thanks again for your kind help

Phil

philip davies
Flowcode v5 User
Posts: 118
Joined: Wed Jun 29, 2011 1:09 pm
Has thanked: 17 times
Been thanked: 6 times
Contact:

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

Post by philip davies »

I received some new mcu's but unfortunately the PIC18F4525's have not arrived as my local retailer has none in stock until next week. is it possible for me to try PIC18F4520 mcu's instead? Also I have used RB.2 for an output. the output is used to trigger a power amp to switch it on and off with the pre-amp on/off button or to switch off the power amp when a pair of headphones is connected to the pre-amp.

Thanks

Phil

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

Phil i checked the C-code commands i wrote you and i tried with a P18F4520 (it has same registers like 4525) and i got error messages. Then i changed the commands syntax and i tried again. Please read again my previous mail. Meanwhile i will try a small FlowCode with RC5 compo and some LEDs (just to check the IR receiver) and will inform you if works
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

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

Post by fotios »

philip davies wrote:I received some new mcu's but unfortunately the PIC18F4525's have not arrived as my local retailer has none in stock until next week. is it possible for me to try PIC18F4520 mcu's instead? Also I have used RB.2 for an output. the output is used to trigger a power amp to switch it on and off with the pre-amp on/off button or to switch off the power amp when a pair of headphones is connected to the pre-amp.

Thanks

Phil
That will not work to the present as RB.2 is configured as digital input. Later will change it as an output. Now try the C-code i quote above.
Best Regards FOTIS ANAGNOSTOU

Post Reply