Hello Arduino community and first let thank anyone who is looking at this and wants to help tackle my opamp problem. Attached is an drawing with a opa228P opamp and my Arduino code below. I have an ancient drive that has an old analog display. What I am trying to do is use an Arduino attached to the gauges to do an analogread, luckily most of the gauges are 0 – 10 volts which makes it easy using a voltage divider for the Arduino to analogread it. The problem is one of the gauges reads from -2000 to plus 2000 and with a volt meter at -2000 it reads -10V and at 2000 it reads +10V so I understand I need to use an opamp so the Arduino can read it. I am pretty sure I am using the correct resistors in order to output 0 – 5 volts for the Arduino to read and then map accordingly with if statements like backdriveRPM=map(backdriveRPMvolts, 525, 1023, -1, -2000); and backdriveRPM = map(backdriveRPMvolts, 495, 0, 1, 2000);
For the most part I have it working and when sampling it trends correctly but I am getting some crazy swings. So, I added a for loop to try and average them out but the swings are still pretty large. I have also added a dead zone in the mapping to see if that can help when at rest (0). Are there any issues with my drawing? Do I have to add or remove something in order calm down the readings? Any help in this matter would be greatly apricated. Please let me know if you need any more info and thank you for your help.
have an ancient drive that has an old analog display.
Sorry, a what?
I am pretty sure I am using the correct resistors in order to output 0 - 5 volts for the Arduino to read
What does your voltmeter say?
Are there any issues with my drawing?[
yeah... I don't wee a drawing.
Your code is incomplete so it's hard to know what's going on. But, I suggest you use the serial monitor to "look at" your variables. If you don't know how to do that, start with the [u]Analog Read Serial[/u] to look at your raw ADC readings. Then, "print" your mapped variables and/or any other variables until you see where something's getting fouled-up.
And, you might need to simplify your code and write some little test programs to test & debug the inputs & outputs separately.
Probably, you don't need OPA after all, 3 resistors divider is easier option.
What important is safety, if it's industrial motor check for galvanic isolation.
That circuit cannot do what you want, and the op amp is probably oscillating because you have not included power supply decoupling. Decoupling capacitors on the voltage divider at +In, and on V+ and V- are absolutely required. Use 100 nF to ground, connecting as close to the IC pins as possible.
With that op amp, the voltage swing at the output is (V-)+2 to (V+)-2, which leaves you about 1 V swing total when you power it with 0 and 5V. If your gauges are intended to take 0 to 10V, you will need to power that circuit from a 12V supply.
And, since 0 V output is not possible with V- connected to ground, you need a negative voltage supply as well. There are "rail to rail" op amps where the output voltage will swing to ground.
First let me thank all of you for your help and input.
jremington, you are correct I just discovered that the opamp I was using would need a minimum of 7v bipolar supply.
I am looking at this rail to rail lower power opamp. Please let me know your thoughts. I would like to keep with a though hole option because I printed a bunch of PCBs sometime ago. At that time I did add the ability for an opamp, but until now I did need to.
I have also attached a LTSpice sim of the circuit showing it should work, but you know sims. I will forsure take your advise on the 100 nf decoupling capacitors.
Please let me know your thoughts on that linked opamp above. Thanks again.
The MCP6041 is intended only for high impedance loads (typically 50K Ohms) and can't supply more that a few microamps output current. It is also extremely slow.
Your gauges are likely to be very low impedance (I would not be surprised if they were a few hundred Ohms), in which case that op amp won't work at all. Measure the gauge terminal resistance and post the value.
MaterT already told in post#3 that you don't need an opamp to read negative or positive voltages.
Just three resitors of the right values can convert "-10volt to +10volt" to a positive voltage for the Yún.
Would the 3 resistor divider be linear like the opamp? One would have to then compensate with software which I would like to avoid if possible should it be non linear.
Well that and I have been trying to figure out where the formulas are so I can calculate which resistors to use for -10v/10v to 0 to 5 volts. That simulator is very handy and I have been trying find the correct resistors.
Hi,
When you measure the voltages on the meters you want to monitor, are you measuring across the meter terminals?
If so, are you sure that one, possibly the negative terminal of the meters are all connected together and connected to the "motor drive" gnd reference?
If you are not sure, please do two measurments, gnd to meter negative and gnd to meter positive and see if you measure any potential.