Getting a voltage fluctuation

Hi I'm using a Linduino 2026C and LTC2664 demo board wth the 2376A-16 DAC.

I've got 2 issues.

the first is a problem where the voltage out put I am coding for is not being produced (it is 0.5 to 2V less) 

The second is that the Voltage output is fluctuating up to +/- 0.3V.

See Code Below for code.


#include <Arduino.h>
#include <stdint.h>
#include "Linduino.h"
#include "LT_SPI.h"
#include "UserInterface.h"
#include "LT_I2C.h"
#include "QuikEval_EEPROM.h"
#include "LTC2664.h"
#include <SPI.h>
#include <Wire.h>
#include <math.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

static uint8_t demo_board_connected;   //!< Set to 1 if the board is connected
int8_t selected_dac = 3;
//double metervoltage = 0;
double Calc_Voltage;
float logmetervoltage = 0;
double compCalc_Voltage;
float analog_received;
float Pi = 3.1415926535897932384626433;
float time;
float percentage;
float templitude;
float offset = 2.88;
float dac_voltage;
const int meterpin = A0;// pin that the airflow meter is connected to
const int LEDPin = 13;  // Pin the LED is attached to
float metervoltage = 0;   // the sensor value
float digitalcoeff = 0;
float flowrate = 0;
float flowrateaddup = 0;
float min_output = -10.0;
float max_output = 10;
//! Used to manipulate EEPROM data.
union eeprom_data_union
{
  struct data_struct_type               //! EEPROM data structure
  {
    int16_t cal_key;                    //!< The key that keeps track of the calibration
    uint8_t soft_span_range[4];        //!< SoftSpan range
    uint16_t dac_code_a[4];            //!< DAC Register A
    uint16_t dac_code_b[4];            //!< DAC Register B
    uint16_t toggle_word;               //!< Toggle control word
    uint8_t global_toggle_bit;          //!< Global toggle bit
    uint8_t mux_state;                  //!< Multiplexer address AND enable bit
    uint8_t reference_mode;             //!< Int. reference may be disabled in external reference mode (not required)
  } data_struct;                        //!< Name of structure

  char byte_array[sizeof(data_struct_type)]; //!< Array used to store the structure
};

eeprom_data_union eeprom; // Create union

// Constants

//! Used to keep track to print voltage or print code
enum
{
  PROMPT_VOLTAGE = 0, /**< 0 */
  PROMPT_CODE = 1     /**< 1 */
};

void setup()
{
 
  lcd.begin(16, 2);  //Activates and defines the LCD
  lcd.clear();
  // Setup  DAC  program

  char demo_name[] = "DC2376";  // Demo Board Name stored in QuikEval EEPROM

  quikeval_SPI_init();          // Configure the spi port for 4MHz SCK
  quikeval_SPI_connect();       // Connect SPI to main data port
  quikeval_I2C_init();          // Configure the EEPROM I2C port for 100kHz
 
 Serial.begin(115200);
 
  LTC2664_write(LTC2664_CS, LTC2664_CMD_SPAN_ALL, 0, LTC2664_SPAN_PLUS_MINUS_10V);

          // Initialize the serial port to the PC
}

//! Repeats Linduino loop

void loop()
{
  int16_t user_command;
  static  uint8_t selected_dac = 3;     // The selected DAC to be updated (0=CH0, 1=CH1 ... 8=All).  Initialized to CH0.
  uint16_t dac_code;
 
 analog_received = analogRead(meterpin); //read the sensor      metervoltage *
 metervoltage = (analog_received*0.0488759);
 logmetervoltage = 1.123*log(2*metervoltage)+2.3522;
    time = micros()% 100000;
  percentage = time / 100000;
templitude = sin(percentage * 65)* logmetervoltage;//   
  Calc_Voltage = templitude; //2.88 is can offset to generate the 0.00488759=digitalcoeff
  dac_voltage = templitude;
       dac_code= (LTC2664_voltage_to_code(dac_voltage,
                     LTC2664_MIN_OUTPUT[eeprom.data_struct.soft_span_range[3]],
                     LTC2664_MAX_OUTPUT[eeprom.data_struct.soft_span_range[3]]));
                     

   
  eeprom.data_struct.dac_code_a[selected_dac] = dac_code;
  LTC2664_write(LTC2664_CS, LTC2664_CMD_WRITE_ALL_UPDATE_ALL, 0, dac_code); // Send dac_code

 eeprom.data_struct.soft_span_range[selected_dac] = 3;

  user_command;
 LTC2664_write(LTC2664_CS, LTC2664_CMD_SPAN, selected_dac, LTC2664_SPAN_PLUS_MINUS_10V); // eeprom.data_struct.soft_span_range[selected_dac]);
  Serial.print("voltage  ");
  Serial.println(dac_voltage);
  Serial.print("metervoltage  ");
  Serial.println(metervoltage);
  Serial.print("templitude  ");
  Serial.println(templitude);
Serial.print(LTC2664_MAX_OUTPUT[eeprom.data_struct.soft_span_range[selected_dac]], 3);
  Serial.println(F(" V"));
lcd.setCursor(3, 1);
      lcd.print("FLOW  RATE");
      lcd.setCursor(4, 0);
      lcd.print(logmetervoltage);
      lcd.print(" ccm");
 
  }

Parents Reply Children
  • I'm not modifying the board.  nor the code.  right now,  I'm using the 2376A sketch from the LTsketchbook.  right now it is producing double the correct voltage, for ex. whe I enter 2V, i get a 4 V out put, 1.5V input results in 3V output.  I disconnected the LCD,  should that make a difference?

  • also, does the J1 connector share the same serial bus as the digital outputs 0-13?

  • any chance we csan have a phone conversation concerning this?

    thnaks

    Justin

  • 0
    •  Analog Employees 
    on Feb 8, 2019 5:35 PM in reply to griiker

    It sounds like you aren't in the range you think you are in.  If you are in the 0-10V range the DAC code will be 4*Vref, but in the 0-5V range the code will be 2*Vref which explains the factor of two you are seeing. 

  • Okay. 
    I'm using internal 2.5V reference voltage.
    I've set MSP0, the MSP1 and MSP2 jumpers to 1.
     according to the data sheet, this is "Softspan" for +/- 5V.
    I've still got the problem where I'm not getting an output voltage that matches the input exactly. 
    this is clipped from the serial monitor and is what I get when I upload the DC2376A sketch and the end of the menu:

    Present Values:
      Selected DAC: All
      SoftSpan range: -0.0000 V to 61028.4882 V
      Toggle Register:
    Enter a command:
    When I start the serial monitor, I MUST set the span before I do anything else, otherwise, the serial monitor will freeze when I select the desired Soft Span range.  

    even then, I get voltages that are off the mark.
     
    Present Values:
      Selected DAC: All
      SoftSpan range: -5.0000 V to 5.0000 V
      Toggle Register:
    Enter a command:
    After getting the desired settings, When I select 3, which writes and uploads an input voltage to the DAC, and then select 1 to input a voltage and and then input a voltage, I do not get the voltage entered, rather, I get something way off the mark ex when i enter 1V I get 8.01V.  other Voltage inputs also d not match up
    Entered value:            Resulting voltage
    -1                                   -3.174
    -2                                   -5.02
    1                                      8.01
    2                                        2.385
    3                                         4.24
    5                                         7.94
    I've tried a few different settings with the jumpers,  and found that when I have the jumpers set with MSP0 and MSP1 to 0 and MSP2 jumpers to 1, i get close to the voltage input:
     
    -1                                   -1.043
    -2                                   -2.086
    1                                      1.043
    2                                        2.086
    3                                         3.12
    5                                         5.21
    This is about 4% off the desired voltage.
    I've been trying to change the code so that the DAC will produce a +/- 5V output (AC current) when reading a 0-5VDC signal.  I'm basically taking the 2376A code and removing bits of code that I don't need.  I'm finding that this is causing some of this inaccuracy and it makes no sense why this is so.
    Justin