This code is working and when I measure the resistance between A and B, there is 26K. Now when I attach the wires to meet the setup and I apply an input voltage, the Gain is not correct.
I thought the gain would be : - (28.2)/(6.5) ~-4x. The gain effectively is round 2x.
Someone has any experience with using the digipot in a opamp circuitry?
I can't comment on the code, but have you considered whether you might be exceeding the absolute maximum ratings of the digital potentiometer (see p.5 of datasheet).
How are you powering it? What will be your maximum input swing? The ±12V supply to the op-amp makes me wonder whether the voltage between A and B might exceed the limits.
As you noted from the spec sheet, most (if not all) digital pots require one end of the pot to be at ground potential thus they cannot be used in a floating application.
You could use it connected to ground to vary the gain in a non-inverting op amp configuration.
digital potentiometer?the unicorn, A horse , but not? a mystical creature , some people think they exist yet no one has seen one? as a famous person once told me......a digital potentiometer has a +20% to -20% true....... a magical thing with 30's tolerances?hmmmm......... I am looking forward to the unicorn of IC's.........gnd, I assume not floating (or isolated) ∏
I misspoke (again ). I didn't properly look at the data sheet. Either or both resistor terminals can be above ground as long as they are within the voltage range of Vdd to ground.
Figure 2-30 has a 2.5volt DC offset at the non-inverting input. This causes the output to be centered around +2.5Volts, so that all terminals of the pot are always between 0 and +5V. In your circuit, the pot terminals will need to swing below ground.
To make your circuit work you need to do something similar. You will need to run your op-amp at a single 5V rail with a DC offset. AC couple the input and output with capacitors.
Depending on the magnitude of the signal you are working on, you may need to attenuate the input first, then make up for the lower voltage with a fixed gain AC amplifier after the variable gain stage.