As part of a little project I'm working on I need a variable voltage supply that is linear, or at least not PWM.
Keeping things tiny was important so I'm using a Seeeduino XAIO. And for the variable power supply the 'Mini 360' DC-DC Buck Converter.
I'm very much within the beginner threshold of electronics and coding. So feel free to correct me or expand on this.
Now, back to it. If only there was a way of adjusting the potentiometer on the Mini 360 via an Arduino.
I've actually seen a YouTube video where someone does this with a larger buck converter, but they use a servo to adjust the pot. That seemed a bit mad to me.
Mini 360 Schematic from Matt's Electronics. The MP2307 pin 5 looks like a contender. A data sheet for the MP2307 confirms this is the feedback input. If I vary the voltage between here and GND then we might be in luck!
First I unsoldered the tiny pot on the mini 360 and identified the pot pin that links to pin 5 on the MP2307. I soldered on a signal wire here - see image.
This is where the onboard DAC of the XIAO comes in handy. There is no point using a PWM pin, it needs to be DAC so you have the steady voltage input. As a test I used the Seeeduino sine wave code.
Connect the Arduino GND and the 360 GND (input side) together. Supply 12v to the 360 and voila!
A bit of fine tuning will be required when implementing into a project - the feedback voltage threshold is 0.925v for a start!
#define DAC_PIN A0 // Make code a bit more legible
float x = 0; // Value to take the sin of
float increment = 0.02; // Value to increment x by each time
int frequency = 440; // Frequency of sine wave
void setup()
{
analogWriteResolution(10); // Set analog out resolution to max, 10-bits
analogReadResolution(12); // Set analog input resolution to max, 12-bits
SerialUSB.begin(9600);
}
void loop()
{
// Generate a voltage value between 0 and 1023.
// Let's scale a sin wave between those values:
// Offset by 511.5, then multiply sin by 511.5.
int dacVoltage = (int)(511.5 + 511.5 * sin(x));
x += increment; // Increase value of x
// Generate a voltage between 0 and 3.3V.
// 0= 0V, 1023=3.3V, 512=1.65V, etc.
analogWrite(DAC_PIN, dacVoltage);
// Now read A1 (connected to A0), and convert that
// 12-bit ADC value to a voltage between 0 and 3.3.
float voltage = analogRead(A1) * 3.3 / 4096.0;
SerialUSB.println(voltage); // Print the voltage.
delay(1); // Delay 1ms
}