Connect with us

Voltage controlled thru opamp playing up?

Discussion in 'LEDs and Optoelectronics' started by diagnostix, Apr 2, 2014.

Scroll to continue with content
  1. diagnostix

    diagnostix

    15
    0
    Apr 2, 2014
    Hi everyone, we have a project which has the following problem. We are reducing a variable voltage on a cars sensor which ranges from 0-5v. We are using a PIC18 and MCP6004 opamp as a buffer with 56k 33n 56k 4.7n RC filters in and out. The problems we are having are:

    1. At around 1.0v - 1.5v we are getting a small surge, and variable voltage which is like a pulsating surge. Beyond this voltage all seems to work fine.

    2. At 0.9v instead of reducing the voltage out, what seems to be happening is the voltage in rises instead?

    Has anybody an idea as to why this is, and perhaps a solution? We thought maybe it's opamp oscillation, or a feed back issue?

    Hope someone can help me.

    Thanks

    Mike:confused:
     
  2. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Hi Mike, and welcome to the Electronics Point forums :)

    Can you start by uploading a schematic please.

    Edit: Also, can you give us a link to the data sheet for the sensor please.
     
    Last edited: Apr 3, 2014
  3. diagnostix

    diagnostix

    15
    0
    Apr 2, 2014
    Thanks for the welcome. Anything obvious?
     

    Attached Files:

    Last edited: Apr 3, 2014
  4. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    The MCP6004 looks suitable.

    You should tie the non-inverting inputs of the unused amplifiers to something. For example, VSS.

    The smallest sized text on that schematic is barely readable.

    Can you give component values.

    Can you give a link to the transducer/sensor.

    How have you built up the circuit at present? Can you upload a photo of your construction?

    Do you have an oscilloscope?
     
  5. diagnostix

    diagnostix

    15
    0
    Apr 2, 2014
    Hi, thanks for the advice, this diagram does not show but the other amps are used for channel 2, which is an exact copy of channel 1.

    What is interesting is, today we have completely removed the PIC and jumped Input voltage to Output voltage and the unit works perfect! So maybe the fault is at the PIC end of things. We are using AD sample and exporting as PWM at 1250Hz, we already tried faster PWM but no difference there. Yes we have a scope. Do not have a link to transducer but it is a 5v pressure sensor with variable output. We appreciate your feedback.
     

    Attached Files:

  6. diagnostix

    diagnostix

    15
    0
    Apr 2, 2014
    Update: We have removed the second ADC to PWM output from the PIC software which seems to have removed the problem so perhaps now we think the fault lies with the programming of the PIC or the ability to process 2 voltages at once, but only processing 1 channel seems to have removed the problem, but I would not think that is the issue here and we need both channels. Any ideas where we are failing? We are running on internal Osc at 16MHz currently.
     
  7. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    Is it possible you cut and pasted the code for 1 channel to do that 2'nd channel and missed a change so that the 2'nd channel is messing with the 1'st?

    Bob
     
  8. diagnostix

    diagnostix

    15
    0
    Apr 2, 2014
    Hi Bob, thanks for the input, I think the code is ok, here is our code (pwm parts)

    PWM1_Init(10000); // Initialize PWM1
    PWM1_Start(); // Start PWM1 on Pin RC2
    PWM2_Init(10000); // Initialize PWM2
    PWM2_Start(); // Start PWM2 on Pin RC1
    ADC_Init(); // Initialize ADC


    pwm_duty = C1_OUT * 51.2;
    PWM2_Set_Duty(pwm_duty); // Set PWM Duty


    pwm2_duty = C2_OUT * 51.2;
    PWM1_Set_Duty(pwm2_duty); // Set PWM2 Duty
    }
     
  9. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    Never mind.

    Bob
     
  10. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    I think you'll need to post all of the code here.
     
  11. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    Try removing the 100nF capacitor on the output. Sound like it's oscillating, you have basically formed an RC time constant between the internal resistance of the op-amp and the capacitor. This might cause you problems.
    Adam
     
  12. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Which capacitor are you referring to, Adam?
     
  13. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    The 100nF on the output. I have seen this sort of thing cause issues even with buffers. It might be ok because of the 47R but it's worth considering.
    Thanks
    Adam
     
  14. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Ah, you mean C7. I was looking for a cap on an output. Yes, 100 nF directly on the output of a normal op-amp is guaranteed to cause problems! But as you say, the 47 ohm resistor in between is plenty high enough to prevent trouble.
     
  15. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    Having a look at the data sheet the capacitance graph only goes to 10nF and needs a resistor over 100R. I would get rid of it.

    But I have just noticed an even bigger problem which might explain the strange behaviour of the op-amp.

    The common op-amp buffer circuit that everyone uses, short out to non inverting input works ok for lowish impedance inputs that are varying d.c. This guy has got load of resistance on the non inverting terminal. this will cause issue if the feedback resistance is less than 100R. This upsets the input bias current and can cause the input protection diodes to short out the output causing the current limit circuit to cut in.

    So what you need to do is match the feedback resistor with the input resistance, but too high and you have issues with input offset currents.

    Another problem is formed by this fix is the RC of the feedback resistor and input capacitance which causes ringing on the output. The fix for this is a small capacitor across the feedback resistor.

    The standard op-amp buffer is ok with very slow changes in input voltage and as a d.c buffer. But with anything that's varying you have to be careful.

    Adam
     
  16. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Well, butter my buns! You're right! Figure 4-4 in the data sheet.

    I'm very surprised. The closed loop output impedance of the op-amp should be very low - under an ohm, I would expect. I would have thought that 47 ohms to a capacitor was by comparison a very weakly coupled load, and the op-amp would be able to handle it easily.

    I've done some research, and discovered that the op-amp's ability to drive a capacitive load is proportional to the closed loop gain. So a buffer is the worst case. I also noticed that the typical op-amp output impedances used in the examples are much higher than I thought they would be - 50 ohms in one case, and that's for a buffer. I don't see how the output impedance of an op-amp buffer stage can be so high... Can you explain, Adam?
    The OP wasn't clear about where the problem is occurring. Like you, I assumed that he meant that there was a nonlinearity in the hardware, but I think the problem is in the firmware that reads the ADC and generates a corresponding PWM signal. So I don't think the op-amp is actually behaving strangely. But not sure.
    I'm pretty sure you have this backwards. The problem with the protection diodes conducting occurs when the signal feeding the non-inverting input has a low impedance and changes more quickly than the op-amp's output can slew. The feedback on the inverting input can't follow the non-inverting input, and a voltage difference appears between the inputs. For op-amps that have protection diodes (this one doesn't), you can prevent damage by putting a resistor in series with either input (or both), although this obviously can degrade frequency response.
    Yes, input bias current is another reason why a resistor is sometimes connected in the feedback loop in a buffer circuit. The resistor is chosen to match the input signal's impedance, on the assumption that the input bias currents of the two inputs will be roughly equal and will produce roughly equal voltage drops across the two resistances (the source resistance and the feedback resistor), which will cancel out. This particular op-amp is a CMOS one, with bias currents measured in picoamps, so I don't think you need to worry about that! I would be more worried about the input offset voltage (4.5 mV max at room temperature).
    I don't see how the input capacitance can interact with the feedback resistance. They are connected to different inputs...
    I don't think so! Buffer stages are often used with very high frequencies. Video, for example. But I take the point that they can be less stable than stages with higher gain, especially into capacitive loads.
     
  17. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    Hi Kris
    Having a high source impedance reacts with the input capacitance causing a zero on the input. The noise gain of the amp increases at 6dB/octave but the gain reduces by 6dB/octave. This results in a 12dB point where they meet, this is an unstable condition.
    Standard buffers can be used in the conventional way but with lower source impedance than the 100’s of K he is using and lowering the resistance brings the issue with the protection diodes, and to fix that need the resistor which can cause ringing. Oh it can get so complicated for just a simple buffer.

    High speed buffers are designed for the job intended and although they will have input protection diodes they should normally have at least a couple of hundred ohms across the opamp to limit current if the diodes turn on. Also the increased slew rate will no doubt help with this.

    If the circuit stays as it is he will have to address the feedback impedance issue and fit a capacitor across it.

    If he lowers the input impedance then he will have to be careful of the protection diode drawing too much current, this is what I meant, probably didn’t explain it that well.

    The 50 Ohms output is manufactured so it can drive say coax cable. You need to check the datasheet first. But in general it will be the output resistance of the Op-amp divided by 1+the loop gain. So small gain reduces output resistance and also increases input resistance.

    The resistor feedback fix create an RC filter with the non inverting terminal which is an input also. I didn’t mean the actual signal input.
     
  18. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    Hey Kris you'll find this interesting. I simulated it and to be honest didn't expect to see anything. The simulations show the effect on power up of having to high a resistance on the input versus the feedback. The second graph I replaced the input resistance with a 10R. The graphs are of the output. The red trace is the current on the non inverting input and is 900nA.
    Adam
    What do you think is happening? Clue, it nothing to do with the internal diodes this time :)
     

    Attached Files:

    Last edited: Apr 4, 2014
  19. diagnostix

    diagnostix

    15
    0
    Apr 2, 2014
    const unsigned short VREF = 5.00;
    unsigned short pwm_duty, pwm2_duty;
    int res = 0, res2 = 0;
    float R_IN, R_OUT, R2_IN, R2_OUT;

    void main() {
    ANSELA = 0; // Digital
    ANSELB = 0; // Digital
    ANSELC = 0; // Digital
    ANSELD = 0; // Digital
    C1ON_bit = 0; // Disable comparators
    C2ON_bit = 0;
    TRISA0_bit = 1; // RA0 pin Input
    TRISA1_bit = 1; // RA1 pin Input
    TRISA2_bit = 1; // RA2 pin Input
    TRISA3_bit = 1; // RA3 pin Input
    TRISA4_bit = 0; // RA4 pin OUTPUT
    TRISD4_bit = 1; // RC4 pin Input
    TRISD5_bit = 1; // RC4 pin Input
    TRISD6_bit = 1; // RC6 pin Input
    TRISD7_bit = 1; // RC7 pin Input
    ANSELE = 0; // Configure RE pins as ANALOGUE
    TRISE1_bit = 1; // Configure RE1 pin as Input for Channel 1
    TRISE2_bit = 1; // Configure RE2 pin as Input for Channel 2
    PORTC = 0; // set PORTC to 0
    TRISC = 0; // designate PORTC pins as output
    PWM1_Init(10000); // Initialize PWM1
    PWM1_Start(); // Start PWM1 on Pin RC2 CH2
    PWM2_Init(10000); // Initialize PWM2
    PWM2_Start(); // Start PWM2 on Pin RC1 CH1
    ADC_Init(); // Initialize ADC


    do {

    res = ADC_Get_Sample(6); // Get 10-bit results of ADconversion
    R_IN = res * VREF/1024.0; // Calculate R1-IN in Volts

    res2 = ADC_Get_Sample(7); // Get 10-bit results of ADconversion
    R2_IN = res2 * VREF/1024.0; // Calculate 2-IN in Volts


    if (RD4_bit &&RD5_bit &&RD6_bit){
    R_OUT = R_IN * .82;
    R2_OUT = R2_IN * .82;
    }

    pwm_duty = R_OUT * 51.2; // PWM Duty equals R Out x 51.2
    PWM2_Set_Duty(pwm_duty); // Set PWM Duty

    pwm2_duty = R2_OUT * 51.2; // PWM2 Duty equals R2 Out x 51.2
    PWM1_Set_Duty(pwm2_duty); // Set PWM2 Duty

    while(1);
    }


    Thanks guys,we also pointed to the 100n and will take them off now, but I think we did this already earlier.

    These are the 2 things which seem to eliminate the cause, either delete the 2nd ADC - PWM and seems to work ok, or, use external 16MHz crystal instead of the internal osc. Another thing, PWM frequency is always out when using internal osc, 10000Hz gives us an output on the scope of 1250Hz? Using MikroC.

    Thanks for help
     
    Last edited: Apr 4, 2014
  20. diagnostix

    diagnostix

    15
    0
    Apr 2, 2014
    Removed the 100n, nothing altered, only thing that helps is the external osc. I would like to think 8MHz internal osc is way fast enough for this small program. I am thinking the PIC set up or the program is at fault somewhere?
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-