Hello and first let thank anyone who is looking at this and wants to help tackle my opamp problem. Below is an drawing with a opa228P opamp along with my Arduino code. 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 of them all, luckily most of the gauges are from 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 even tho the vin remains the same on. So, I added a for loop to try and average them out but the swings are still pretty large. Also as you can see in the maping I left some deadzone to help calm down when at (0). Are there any issues with my setup? Do I have to add or remove something in order calm down the readings? Any help in this matter would be greatly appreciated. Please let me know if you need any more info and thank you for your help.
Andrew
For the most part I have it working and when sampling it trends correctly but I am getting some crazy swings even tho the vin remains the same on. So, I added a for loop to try and average them out but the swings are still pretty large. Also as you can see in the maping I left some deadzone to help calm down when at (0). Are there any issues with my setup? Do I have to add or remove something in order calm down the readings? Any help in this matter would be greatly appreciated. Please let me know if you need any more info and thank you for your help.
Code:
//***********Back Drive RPM*************
for (int i = 0; i < numberOfSamples; i++)
{
currentSample = analogRead(backdriveRPMpin);
currentValue += currentSample;
// delay(timeGap);
delay (10);
}
backdriveRPMvolts = (currentValue / numberOfSamples);
currentValue = 0;
currentSample = 0;
if (backdriveRPMvolts > 525)
{
backdriveRPM = map(backdriveRPMvolts, 525, 1023, -1, -2000);
}
if (backdriveRPMvolts < 495)
{
backdriveRPM = map(backdriveRPMvolts, 495, 0, 1, 2000);
}
if ( backdriveRPMvolts == 0)
{
return;
Andrew