View Full Version : Op Amp help, perhaps its the propeller?
05-06-2008, 12:04 PM
I am using the example in the process and control book listed here www.parallax.com/Store/Books/EducationalTexts/tabid/181/CategoryID/66/List/0/Level/a/Default.aspx?SortField=ProductName,ProductName (http://www.parallax.com/Store/Books/EducationalTexts/tabid/181/CategoryID/66/List/0/Level/a/Default.aspx?SortField=ProductName,ProductName)
- RL is a small DC motor
- My propeller will PWM into P2 for a max of 3Volts
The problem i am suffering from is as follows: The output from the op-amp will begin to drive to max voltage if i leave P2 open (just pull the wire off of pin2 on my propeller). I can fix this but i want to know more about he op-amp itself. Why is it doing this? Is it due to some type of reverse leakage current back into my
RC circuit (R1 and C1)?
I thought the Op-amps inputs (pins 5 &6) want to balance each other, but when P2 is an open (i assume drops to 0 volts when i pull the jumper wire) the transistor begins to drive "RL" to max current.
Please i have searched wikipedia and other sites but no luck...
05-06-2008, 01:31 PM
Since the input to the opamp is very high impedance then treat it as you would a floating input and use a pull-down resistor on P2 of around 100K. Also, the charge on C1 will take quite a while to discharge if you disconnect P2. The voltage build-up on C1 is probably due to leakage on the pcb, try cleaning the flux residue off the pcb (assuming it's a proper pcb, post a pic?). In any case use a pulldown.
The opamp is used in non-inverting DC configuration and it's gain is set to Rf/Ri + 1 = 2 so therefore I guess you are trying to drive a 6V motor which won't happen with just a little LM358. Do you have an NPN as an emitter follower on the output of the opamp? The LM358 needs a supply of at least 1.5V more than the output voltage plus add in another 0.6V if you use the emitter follower which means you probably need +9V to drive a 6V motor.
05-06-2008, 02:25 PM
I have employed a pull down resistor and your right around 1Mohm it seems to clean things up. As far as leakage on the PCB I am still in breadboard mode. http://forums.parallax.com/images/smilies/wink.gif I am a bit lost on "high impedance" I guess it means a high opposition to change in current? If so, how is this helpful or no helpful?
Yes i am using a MOSFET as the driver to the motor, sorry for not seeing that sooner when i posted.
More on the subject of a 1Mohm pull down - Would this affect my low pass filter? I am a "keep it simple stupid" type of guy
05-06-2008, 02:34 PM
Put the pulldown on the P2 side of R1 and then it doesn't matter too much what value you use. As it is now it forms a voltage divider which is not what you want although 1M is sufficiently high anyway not to bother.
The 2N7000 is a bit on the light side for mosfets as it's only rated at about 200ma continuous and 300mw. Best to use a beefier device than this unless you like to see some magic smoke.
Personally I wouldn't bother with the opamp circuit and I would just drive a mosfet directly from pwm to control the motor speed.
05-06-2008, 02:51 PM
I agree with you somewhat on driving the mosfet right off of PWM pin 2 and thus discarding the OP-AMP altogether, but i need feedback to the microcontroller. I have tried running the MOSFET in various configurations to give me data back to my A/D but no such luck. Besides i am trying to learn more about the OP-AMP. I will put R5 where you mentioned and i am sure it will work.
I still remain a bit confused on op-amps, i mean what can i benefit from a HIGH input impedance and what about a low output impedance? This I learned in school but i am still foggy on the whole concept.
** as a side note: the motor runs @ 2.7 Volts / fifty to one hundred milliamp. ;) depending on the model
05-06-2008, 04:53 PM
Impedance refers to the "resistance" but unlike pure DC resistance impedance changes with frequency. Something that may be high impedance at low frequencies can be low impedance at high frequencies (a capacitor). So rather than limit ourselves to saying high resistance we say high impedance because the actual resistive load it presents can vary with frequency but usually at the frequencies we drive them at it's high impedance.
The ideal "operational amplifier" will have infinitely input impedance and infinitely low output impedance because you don't want it to load up the input signal and you don't want the output affected by the load. Many opamps can present a high input impedance in the region of 100's of megaohms but the output is limited usually to driving 10's of milliamps.
If the motor runs at 2.7V then you shouldn't need any gain on the opamp at all as at the moment it could swing to over 6V. But the N-channel mosfet is in an awkward configuration as this type of configuration is fine for a bipolar transistor which only requires about 0.6V across the base and emitter to drive it (in fact it is not the voltage that drives it but the current). The mosfet requires about 5V across the gate and source to drive it which means if the motor needs 2.7V then the drive voltage will need to be a few volts higher. So a rail-to-rail opamp and a biopolar transistor would be a better choice and you could operate straight off the 3.3V supply.
The PWM configuration only requires an RC filter from the motor to the A/D converter to work. But bear in mind that motors do generate a back EMF and that could interfere with the monitoring. Current monitoring is another method you could use.
Hope this helps.
05-06-2008, 05:23 PM
high-impedance means the "input-resistor" of the OP-Amp is very high. The inputs of an OP-Amp have minimum 10 MegaOhm up to 10 Giga-Ohm.
So the current flowing into the OP-Amp is very low. This is the case if you have no other resistors connected from OP-Input to ground or Supply.
These resistors change the input-impedance of your circuit of course.
High-impedance is good for sensors that deliver a very small current or if the sensor has a high resistor-value itself
If the sensor has a high resistor-value itself and the OP-Amp would cause a big current you would have a big voltagedrop across the sensor.
And then the circuit would get a wrong sensorsignal. In your case if the OP-Amp is connected to a propeller-IO this does not matter
The Prop-IO-PIN can deliver up to 40 mA.
Very high impedance-inputs are like an antenna for EMV flying around everywhere. And even the length
of the PIN coming out of the dip-housing could be enough antenna to receive electromagnetic energy making the output flipping up and down
IN CASE you are using an amplifying factor of 100000 or more or no feedback-resistor at all.
low-output impedance means
you can deliver a high current to the load connected to the OP-Amp-output and the output-VOLTAGE will stay high.
With a high output-impedance a growing current would cause a reasonable voltage-drop "inside" the OP-Amp.
maximum output voltage of the OP-Amp 6V
Output-resistance 50 Ohm ("inside" of the OP-Amp)
1.) now you connect a load with a resistance of 10000 Ohm
current: 6V / 1 MOhm = 0,0006 A
voltage-drop "inside" 50 Ohm * 0,0006 A = 0,03V = does not matter at all
2.) now you connect a load with a resistance of 100 Ohm
current: 6V / 100 = 0,06 A
voltage-drop "inside" 50 Ohm * 0,06 A = 3V = half of the voltage is lost because of the high output impedance of 50 Ohms
This is an educating example with values far away from real OP-Amps.
In real the calculations are more complicated because you have to calculate the load and the output-impedance
at the same time (which i did not) but the calculation abobe shows the principle what happens
So if you need a high INput-impedance and low OUTput-impedance you can use an OP-Amp
as a "voltagefollower" or sometimes it is called "impedance-changer"
a voltagefollower has always amplifing factor 1 = no amplifying at all, but changes the impedance
05-06-2008, 09:48 PM
I thought the Op-amps inputs (pins 5 &6) want to balance each other,
THis is a common almost true way of describing opamps, but it is misleading. In fact, the opamps only wants to multiply the difference between the two inputs by a very high gain factor (10^5-10^6). The opamp does not try to balance its inputs, ever. It is the external feedback structure that attempts to do this and thus reduce that very high gain factor to a more useful controlled factor (2 in your case).
I am guessing that when you disconnect P2 (before the 1M to ground was installed) the slight input bias current of the opamp floated the + input off ground
05-06-2008, 11:02 PM
I think I am starting to understand the basics, thanks every one who replied.
Peter, you mentioned
The mosfet requires about 5V across the gate and source to drive it which means if the motor needs 2.7V
then the drive voltage will need to be a few volts higher.
So a rail-to-rail opamp and a biopolar transistor would be a better choice and you could operate straight off the 3.3V supply
I was under the impression that a mosfet only needed a very small voltage across the gate. I guess I am wrong ill need to take a look over at wikipedia. Again Thanks everyone.
05-07-2008, 06:09 AM
The Vgs or gate threshold voltage at which the mosfet begins conducting is typically 2 volts which doesn't sound like much anyway. Bear in mind though that conditions do apply, for instance the Vgs is measured with a drain current (Id) of 1ma, hardly useful for anything. To drive heavier loads you need to get that gate voltage closer to 5 volts and if you are really serious then 10 volts is more typical of most mosfets to get their Rds(on) as low as possible.
The trouble with putting an N channel mosfet in the high side (sourcing) is that the gate voltage has to be much higher than the source voltage (output). In a normal "grounded source" configuration this is not hard to do but in the "source follower" the source might be at 3V which means the gate has to be a few volts higher so that the voltage across the base-source is at least a few volts. Of course this is really applicable when you run the mosfets in digital on/off fashion but it still applies when you run it in a linear fashion.
Since you have opamp buffering it makes so much more sense to put a common npn in place of the mosfet. Even a modest TO92 pack can handle 500ma or more and the opamp is very happy to drive it although using an LM358 means you have to have a supply of a couple of volts higher then you need to output.
05-07-2008, 08:07 AM
Yes i have tested and tested and think you are correct. I put in a PNP and have much greater control. Thanks again
05-08-2008, 09:27 PM
A little bit OT - assuming you have the pins to spare, did something to arrest flyback spikes and were incredibly gung-ho, is it not possible to gang the outputs of the prop together to drive the little motor directly? I've done this before with standard logic gates (a hex inverter, for example) with great success.
05-08-2008, 09:52 PM
You can gang some outputs of the prop together, but you have to be willing to burn out a few Prop chips. If you make a programming mistake and accidentally get the pins wrong, you can drive one connected pin high and another low causing a short circuit. Now the testing done for the production of the datasheet indicated that Propeller I/O drivers seem to be built robustly enough to survive this abuse, but it's not guaranteed. Do keep in mind that there are overall current limits for the chip and for groups of I/O pins and you have to respect those or you'll burn out the internal interconnect wiring on the chip.
05-09-2008, 08:40 AM
Mike, I only suggested it because the OP said the motor drew 150mA. Of course you run the risk of burning out your prop, but it's a dirt simple and easy way of getting movement into your projects. Perhaps using a very simple buffer (such as the 74HC04 I mentioned) would provide a safer interface while keeping the level of complexity low. You could even socket the '04, so if you burn it out it's simple enough to slot another one in.