Hi, I'm currently working on a project that uses a MAX5250 DAC my issue is that the output voltage is very inaccurate and fluctuates terribly sometimes /- 0.4 volts to +/- 2 volts which for my project is very bad as I need a very accurate voltage. I've added a decoupling circuit near VCC which is just a 10uf and two 0.1uf capacitors in parallel. I tried adding smoothing caps (10V 100uf) at the outputs with no noticeable effect. I'm at a lost and considering switching over to PWM to analog conversion. If someone could help me figure out this fluctuation issues that would be great or if there is a new and better method for DAC that would make this simpler please let me know.
My Set-Up:
I have it wired like Figure 10 in the datasheet for a unipolar rail-to-rail circuit with the 10K resistors.
I'm using a voltage divider to get 2.5 volts for Vref.
My VCC is a constant 5V.
I'm using a teensy 2++.
My Code via Arduino interface:
Mod edit: code tags
My Set-Up:
I have it wired like Figure 10 in the datasheet for a unipolar rail-to-rail circuit with the 10K resistors.
I'm using a voltage divider to get 2.5 volts for Vref.
My VCC is a constant 5V.
I'm using a teensy 2++.
My Code via Arduino interface:
C:
#include <SPI.h>// inslude the SPI library:
const int slaveSelectPin = 7;// set pin 7 as the slave select for the digital pot:
word val = 0;
word val2 = 0;
float voltage;
void setup() {
Serial.begin(9600);
pinMode (slaveSelectPin, OUTPUT); // set the slaveSelectPin as an output:
SPI.setClockDivider(SPI_CLOCK_DIV4);
SPI.begin(); // initialize SPI:
digitalPotWrite(0,900); // 0-1023 EDIT HERE
}
/* Unipolar w/gain @Input 5.02V
* Trial| 1 | 2 | 3
* 1 = 0.15V - 0.33 -
* 50 = 0.25V - 0.55 - 0.28
* 100 = 0.45V - 0.79 - 0.50
* 150 = 0.55V - 0.99 - 0.71
* 300 = 1V - 1.62 - 1.56
* 750 = 2V - 3.69 - 3.30
* 900 = 3V - 4.49 - 4.10
* 1023 = 5 - 4.96 - 4.86
*
* Uni-Polar w/o gain
* 400 = 1
* 800 = 2
* 1000 = 2.5
*
*/
void loop()
{
//digitalPotWrite(5,5); //need to send a 16 bit word
delay(1000);
}
void digitalPotWrite(int address, int value) {
Serial.print(" Address: ");
Serial.print(address);
Serial.print(" Value: ");
Serial.print(value);
//channel 0 = 00110000 = 48
//Channel 1 = 01110000 = 112
//Channel 2 = 10110000 = 176
//channel 3 = 11110000 = 240 for 8
val = highByte(value << 2);
val2 = lowByte(value << 2);
if (address == 0)
{val = val+ 48;}
if (address == 1)
{val = val+ 112;}
if (address == 2)
{val = val+176;}
if (address == 3)
{val = val+240;}
digitalWrite(slaveSelectPin,LOW); // take the SS pin low to select the chip:
//SPI.transfer(B00111111); // works
//SPI.transfer(B11111100);
SPI.transfer(val);
SPI.transfer(val2);
//val = SPI.transfer(63); //works too
//val2 = SPI.transfer(B11111100);
digitalWrite(slaveSelectPin,HIGH); // take the SS pin high to de-select the chip:
Serial.print(" First: ");
Serial.print(val);
Serial.print(" Second: ");
Serial.println(val2);
Serial.print(" Expected Voltage: ");
voltage = 5.00 * (value / 1024.00);
Serial.print(voltage);
}
Attachments
-
756.8 KB Views: 11
-
223.6 KB Views: 9
Last edited by a moderator: