Hey,
I just bought an MCP4725 DAC to my current project where I'm trying to control an engine by RPM by increasing and decreasing voltage.
I'm however having some difficulties with the setVoltage method. It seems like when I've set it once, it can't change.
I left the loop out because it's not relevant at the moment.
#include <Adafruit_MCP4725.h>
#include <FreqMeasure.h>
#include <PWM.h>
Adafruit_MCP4725 dac;
int pwm_output = 11;
int32_t frequency = 17500;
long new_freq;
long RPM;
long RPM_tot;
long RPM_wanted = 0;
long voltage = 4095;
void setup() {
Serial.begin(9600);
dac.begin(0x62);
dac.setVoltage(voltage, false);
InitTimersSafe();
FreqMeasure.begin();
SetPinFrequency(pwm_output, frequency);
pinMode(pwm_output, OUTPUT);
int sensorValue = analogRead(A0);
pwmWrite(pwm_output, sensorValue/4);
bool volt_change = dac.setVoltage(0,false); //motor should here stop, but continues.
if(volt_change){
Serial.println("VOLT CHANGED.");
}
}
The weird part is that it still prints "VOLT CHANGED". Any ideas what could be wrong? Or does the setVoltage method have limitations?
Thanks
W