This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DAC121C081: Issue with DAC programming in Energia and Tiva C series

Part Number: DAC121C081
Other Parts Discussed in Thread: ENERGIA, TPL0102-100, TPL0401A-10, REF5030,

Hello everybody
I have problems with programming DAC.
First of all my project has one part where I would need to get a linear analog voltage from -1.5v to 1.5v. idea was to use Digital potentiometer to get 0->3V and then feed into opAMP with 1.5v on noninverting input so to "split" it in half and in the end obtaining -1.5V <-> 1.5V.
well, analog circuitry part works very vell, but I can't get the 0->3V.
I have tried TPL0401A-10 and it works wery vell ( I am using Tiva C series platform and Energia for control). problem was that TPL0401A-10 has 128 taps giving me a very low resolution in the end. that is why I switched to TPL0102-100 for its 256 taps and with the same code (of course, an address has been changed and a number Val to 255) in the end, I get something from the picture ( I am using 10k pull-up resistors, same as for the TPL0401A-10).


Then I changed to DAC121C081 and made little evaluation board, where DAC is powered from REF5030 and it has 10K pull-up resistors. (again I am using Tiva C and Énergia with Adafruit MCP4725 library for DAC and it works, problem is that minimum on DAC is 0V, which is ok but maximum I get is 0.2V ?? ( see figure DAC, where Tiva has driven DAC and recorded ADC value directly).


Can anyone help me to solve programming side for both DAC121C081 and TPL0102-100?
I would prefer DAC for its much better resolution but  I would also like to know what is the problem with  TPL0102-100.
Thank you all in advance.

  • Hi Gabriel,

    I am having trouble envisioning the circuit.  Do you think you could share a schematic?  In addition, if you could capture the a scope image of the communication that would be helpful as well.  

    Thanks!

    Paul

  • Hi Paul

    Thank You for the fast response.

    I will put the somehow general schematics.

    For the  TPL0102-100 A0 is GND, A2 Is V+(5V) and i have tried wit A1 being GND or V+, does not change a thing. H terminal is at V+, L is at GND and Wiper is measured (V out).

    For the DAC121C081 I have left ADR0 floating. I have also measured DAC output with oscilloscope an it is the same as the one read out with Tiva ADC as one would expect.


    Currently I am not capable of putting screen shot of the communication but I will shortly.
    Thank You
    Best regards

  • Gabriel,

    I suspect that there is an issue with your communication, as the transfer function is linear. I would verify that you TIVA code is correct, and that you have no issues with bit order or any mistakes in your math. I would also verify that you are not accidently writing to any of the devices power down functions. A scope capture of the I2C frame will be very informative.

    In addition, you may want to measure your supply with a scope as the DAC is changing. If you are seeing large transients it could be that your current drive capability of the supply is problematic or there is a series resistance somewhere.
  • Hi Paul

    I have the figure from the scope.
    CH1 is the SCL line and CH2 is the SDA. ( but I believe that it is not necessary to mention that).

    I have also tested power supply and here is the figure for that also ( CH1 is the DAC output, and CH2 is the voltage directly at the DAC input between it and decoupling cap of 0.1uf)

    I will include code I have adopted a little bit for this DAC together with original library.

    If You could go thru that it would be most helpful

    Thank you

    Regards
    DAC_code and Library.zip

  • Gabriel,

    I looks like that library you are using sends for I2C is sending 4 byte frames, where the 2nd byte is some command byte for the MCP4725. In your scope shot you can see that there are too many clock pulses between the START bits. The DAC121s081 uses a three byte frame, so the MSB byte of the DAC code is being written to the LSB byte of the DAC. You should try using the Arduino "Wire" library and format your own 3 byte frame.
  • Paul
    Oh yes, I see the problem, looking back through data sheet I see that it is necessary to have 3-byte frames.
    I have tried to use "Wire" library but unfortunately, unsuccessfully, I only get two-byte frames.
    And honestly, I am a not confident that  I could solve it on my one.
    Would it be too much of me to ask you to send me the code example for this DAC?
    Thank You in advance

  • Gabriel,

    I would bet that the issue you were having using the Wire library had to do with a wrong (missing) address byte or the function Wire.write() command only accepting a single byte at a time.  In your code you have the DAC value stored as a unsigned integer of 32 bits.  You really only need two bytes.  Setting your DAC Code as a simple unsigned int will keep it as 2 bytes.  You then need to send two different Wire.write commands, one for each byte of the unsigned integer.

    Give that a try and see if it works.  I did not test the code!

    #include <Wire.h>
    
    unsigned int daccode = 0;
    
    void setup()
    {
      Wire.begin(); // join i2c bus
    }
    
    void loop()
    {
      Wire.beginTransmission(0x0C); // Transmit to addres 0x0C
                                    // device address is specified in datasheet
      Wire.write(daccode>>8 );      // Only the high byte (MSB) of the two byte unsigned int should be sent, 
                                    // so shifting eight bits will put the byte in the LSB position
      Wire.write(daccode & 0x00FF); // the third byte sent needs to be the LSB of the two byte unsigned int.  
                                    // a bitwise AND mask will remove the MSB byte
      Wire.endTransmission();     // stop transmitting
    
      daccode++;        // increment value
      if(daccode == 4096) // if reached 4096th position (max)
      {
        daccode = 0;    // start over from lowest value
      }
      delay(1);
    }

  • Hi Paul

    Originally didn't work but after adding  Wire.setModule(1); in setup and changing the address of DAC from (0x0C) to (0xC) it works perfectly :D

    Thank You wherry much !!

    Here is the picture from ADC readout of the DAC values