X9C103 Pot Control - Help Calibration

Hello,

I’m new to the forum and Arduino Scene in general but have coded a few things for my project already i’m just stuck on this particular feature.

My Project
I want to use the Arduino to control the X9C103 digital pot.
I have attached a photo with the circuit diagram or similar to what i’m trying to achieve.

In the diagram you can see on the non-inverting input of the op amp i have a photo transistor this will be replaced with an photo amplifier but they work the same way they output from 0V-5V depending on the light.

On the inverting input i have 2 10k pots which i want to replace with the digital pots.
These pots are used to set the output of the op amp so that its sits at 6V so you can see the output swing from 12v to 0V if the light input changes intensity. What i’m trying to achieve is when i press a button the pots will adjust so that the output will be set at 5v so obviously i need to read the output and get the pots to adjust accordingly. (its like calibrating the output)

Any help is much appreciated as its seeming to be really difficult to get my head round

You mean that on button press the output becomes 6V at the current input voltage? How can the Arduino know what's that current input voltage?

Another value is required that determines the gain, e.g. full scale input and output voltages. Or do you want a fixed gain? The gain must be known before the offset can be adjusted.

Without further information I'd mimic the manual calibration procedure, by adjusting the pots and watching the output voltage. Eventually you need more buttons for increasing and decreasing the pot settings.

You mean that on button press the output becomes 6V at the current input voltage? How can the Arduino know what's that current input voltage?

No when you press the button the pots will adjust so that the output of the op amp will be 6V

Another value is required that determines the gain, e.g. full scale input and output voltages. Or do you want a fixed gain? The gain must be known before the offset can be adjusted.

The Gain and Offset is set by the potentiometers

Without further information I'd mimic the manual calibration procedure, by adjusting the pots and watching the output voltage. Eventually you need more buttons for increasing and decreasing the pot settings.

I want it to self calibrate because at the moment we have pots controlling this i want it to be done automatically

Mission impossible :frowning:

i have something like this but its not working

#include <X9C.h>

#define UD 8
#define INC 9
#define CS 10

const int pinWiper = A5;

X9C pot;

void setup() {

pot.begin(CS, INC, UD);

Serial.begin(9600);

}
void loop() {
// put your main code here, to run repeatedly:

int feedbackValue = analogRead(pinWiper);
Serial.println(feedbackValue);
float feedbackVoltage = (feedbackValue * 5.0)/1023.0;
Serial.println(feedbackVoltage,3);
delay (1000);

if (feedbackVoltage > 2.5){
pot.trimPot(1, X9C_DOWN, false);
}
else if (feedbackVoltage < 2.5){
pot.trimPot(1, X9C_UP, false);
}

}

Ignore the messy code but im stuggling with this:

if you have ever used the x9c digital pot before then you should know how it works other wise its quite simple but not for me.
Basically when the feedbackvoltage1 is read by the arduino i want it to zero the pots to min and then step up pot1 until it hits 5v and then if it cant step up pot2 untill it hits five volts.

for the feedback im using a potential divider on the output of a op amp see the circuit attached. The non inverting input has a light sensor on it.

#include <X9C.h>

#define UD 10
#define INC 11
#define CS2 12
#define CS1 9
const int pinWiper1 = A5;
const int pinWiper2 = A4;

X9C pot1;
X9C pot2;

void setup() {

pot1.begin(CS1, INC, UD);
pot2.begin(CS2, INC, UD);

Serial.begin(9600);
pot1.setPotMin(false);
pot2.setPotMin(false);

}
void loop() {
// put your main code here, to run repeatedly:

int feedbackValue1 = analogRead(pinWiper1);
//Serial.println(feedbackValue);
float feedbackVoltage1 = (feedbackValue1 * 26.1)/1023.0;
Serial.println(feedbackVoltage1,3);
if (feedbackVoltage1 > 5.5){
pot2.trimPot(1, X9C_UP, false);

}

else if (feedbackVoltage1 < 5.2){
pot2.trimPot(1, X9C_DOWN, false);
}
if (feedbackVoltage1 > 5.5){
pot1.trimPot(1, X9C_UP, false);

}

else if (feedbackVoltage1 < 5.2){
pot1.trimPot(1, X9C_DOWN, false);

}
}

Topics on the same subject merged

Hi,

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
OPs diags;


Thanks.. Tom... :slight_smile:

MasonSheppard:
int feedbackValue1 = analogRead(pinWiper1);
float feedbackVoltage1 = (feedbackValue1 * 26.1)/1023.0;
Serial.println(feedbackVoltage1,3);

Which values are shown in the SerialMonitor? What does 26.1 mean to you?

What's pinWiper1?
What's pot1 and pot2? Better rename into potOffset and potGain.
What means X9C_UP to the resistance, are you sure?