I've designed a circuit to generate a smoothed PWM signal using an Arduino, which then undergoes attenuation, amplification via a non-inverting op-amp, and finally has an approximate offset of 0.9V added. The circuit also includes a digital potentiometer intended to adjust the signal amplitude, but despite assembly and verification, the potentiometer's resistance remains fixed and unresponsive to control attempts.
PWM Generation: Direct from Arduino.
Smoothing: Via an RC filter.
Attenuation: Using a voltage divider.
Amplification: Through a non-inverting op-amp.
Offset Addition: Approximately 0.9V.
Issue: The digital potentiometer does not adjust as intended, seemingly locked at a specific resistance value. I have meticulously checked the soldering under a microscope and verified connections with a multimeter, finding no apparent issues. This leads me to suspect a potential design flaw or the MAX5495 is wrongly soldered because it's an SMD and i can't be 100% sure the pins are correctly soldered.
Additional Details:
I've developed and assembled the PCB based on this design. The code controlling the potentiometer was sourced from a forum, implying its reliability.
Code Snippet from Arduino forum
My Code:
#include <SPI.h>
const uint8_t CSpin = 10;
void setup() {
setupSPI();
setupPWM();
Serial.begin(115200);
}
void loop() {
for(uint16_t i = 0; i < 1024; i++) { // Loop over the full range of the digipot
update_digipot(0x01, i); // Update wiper position
delay(100); // Short delay between updates for visibility
}
delay(1000); // Wait for 1 second after completing a full range update
}
void update_digipot(uint8_t reg, uint16_t value) {
union {
uint16_t val;
uint8_t bytes[2];
} in;
in.val = value << 6; //as per datasheet
digitalWrite(CSpin, LOW);
//Write Wiper Register. 0x01: wiper1, 0x02: wiper2
SPI.transfer(reg);
//send upper value byte
SPI.transfer(in.bytes[1]);
//send lower value byte
SPI.transfer(in.bytes[0]);
digitalWrite(CSpin, HIGH);
}
void setupPWM() {
analogWrite(3, 30); // Set PWM to 50% duty cycle on pin D3
}
void setupSPI() {
pinMode(CSpin, OUTPUT);
pinMode(3, OUTPUT);
SPI.begin();
}