Operating AD5780 EVAL Board Via MicroController

OK, so thanks in advance because I am new here. I am reading the AD57XX drivers here  https://wiki.analog.com/resources/tools-software/uc-drivers/renesas/ad5780 and am struggling to understand how to get the device working and understanding it properly. I am using code here https://github.com/maxgerhardt/arduino-ad57xx-driver/blob/master/src/main.cpp in order to test the DAC. I have several questions about the drivers and operation in general. I will itemize them if that is ok

  1. Where in the drivers am I performing Slave Select and where am I determining Clock Speed? I have looked through the C in the drivers library, and it seems that each command, whether reading or writing selects the Slave/Master each time? I see no reference to which pins on my microcontroller it is reference though so I do not know if any of this is right.
  2. Why do I need to be reading in the Control Register or anything from the DAC at all? Why does this matter? All I want is to output a voltage
  3. How do I perform the right conversion to a voltage that I want? The command " AD57XX_SetDacValue() " takes a long, but I do not understand how that relates to a float value of voltage. Say I want 2.35 Volts, or a Sine Function from -2 to 2 Volts, how do I do this conversion?
  4. I don't know how to debug the system in general. When I run the example code, which is supposed to output a triangle wave function, I get a sin function. Is this just background noise that the DAC outputs. I don't know how to tweak parameters or understand it. If the photo is low resolution, from peak to anti peak, the wave function is only about 300 mV.

Thanks in advance for all the help.

Parents
  • 0
    •  Analog Employees 
    on Mar 25, 2019 11:06 AM over 1 year ago

    Hi,

    Someone's currently looking into this query and will respond to you as soon as possible.

    Cheers,

    Ivan

  • Thanks Ivan, here I asked the question on StackExchange, so I answered 1 and 2. For 3, I suppose the drivers require me to convert from a float to the binary representation that the DAC requires, but I'm still confused by the best way to do this.

    I am also going to look around my department for a logical analyzer, but debugging advice would still be incredible. I'm surprised there's no guide to do something similar online yet

  • 0
    •  Analog Employees 
    on Mar 28, 2019 1:47 AM over 1 year ago in reply to andrewkhardy

    Can you take a scope shot of the digital lines? SDIN, SCLK, SYNC, SDO.

    Also can you insert  link LK7 to pull it low, this would ensure that the data written is transferred from the input shift register to the DAC register ? I don't see that you are controlling the LDAC pin using your controller.

  • OK, yes you are right. I added a cable at Pin 5 to connect to LDAC. I am reading the Standalone Operation section (pg 19 of the AD5780 datasheet, not the evaluation board) more closely now.  I have also attached LK7, but it still does not provide me with a voltage output.

    static const int pinMapping[] = {
    		5, //GPIO1 (LDAC pin) is D7
    		8, //GPIO2 (CLR pin) is D8
    		9, //GPIO3 (RESET pin) is D9
    		10  //slave select (SYNC pin) 

    these are the setting in pinMgtLayer that I have changed now. If I was to have a changing voltage output, would I also need a CLR pin? In lieu of that I could also use the CTRL register instead? Would I then need to write to the CTRL register everytime I update the voltage, like?

      AD5780_SoftInstruction(AD5780_SOFT_CTRL_CLR);

    I am also attaching scope readings for the pins as follows: SDIN

    SCLK

    SYNC

    SDO

    and finally my new LDAC pin

     Finally, is it necessary to have both DGND pins attached to my microcontroller? Would only 1 ground them?

  • 0
    •  Analog Employees 
    on Mar 29, 2019 2:12 AM over 1 year ago in reply to andrewkhardy

    You don't need to trigger the CLR and RESET pins every time you write on the AD5780.

    It seems different signals are coupling on your digital lines, if these are the actual signals then it definitely won't work.

    We would also recommend to shorten the connections of the digital lines to minimize parasitics that could affect the frame.

    Can you retake the scope shots and have all the digital lines on a single image? Also can you have the oscilloscope trigger on the SYNC falling edge pin.

    Single digital ground connection should be enough.

  • I do have a logic analyzer available to me, if we are at the point where the connections make sense, then I can upload images of that and try and diagnose? That will take me a moment to figure out, so let me know if there are any other suggestions, otherwise come Monday I will post logic analyzer photos.

Reply Children
  • 0
    •  Analog Employees 
    on Apr 2, 2019 1:52 AM over 1 year ago in reply to andrewkhardy

    Based on these scope shots, you are not sending 0x03, 0x3F 0xFF.

    For the AD5780, the data is valid on the falling edge of SCLK, so what you are actually writing on the part is 0x01 0x1F 0xFF. You are actually doing is doing a NOP (no operation) since your first 4 bits is "0000". See Table 7and Figure 2 on the data sheet.

    If you want to write on the DAC register, the first 4 bits should be "0001". For example you want to have a full scale output. the data you should send is 0x1F 0xFF 0xFC. Note that you have to pull the LDAC should be low.

    Refer to the SERIAL INTERFACE section on the data sheet for more details on how to write on the AD5780. Let us know if you have further questions.

  • Channel 3 is my MOSI and 4 is my CLK, how are you reading from this scope that I am not sending 0x03, 0x3F 0xFF ? That is what the SPI setting on the scope says I am sending out?

  • 0
    •  Analog Employees 
    on Apr 3, 2019 2:48 AM over 1 year ago in reply to andrewkhardy

    I'm looking at the falling edges of CLK and check if what is the level of MOSI at those times.

    Your scope interprets it at the rising edge of CLK, meanwhile the AD5780 reads it on the falling edge.

    The SPI mode that you are using is incorrect, You should be using SPI mode 1 or mode 2. You can refer to the following link for info regarding SPI modes.

    https://www.analog.com/en/analog-dialogue/articles/introduction-to-spi-interface.html

  • I do nut understand that. The SPI modes are set in

    unsigned char AD5780_Init(void)
    {  
        AD5780_CLR_OUT;    
        AD5780_LDAC_OUT;
        AD5780_RESET_OUT;
        AD5780_CLR_HIGH;
        AD5780_LDAC_HIGH;
        AD5780_RESET_HIGH;    
        SPI_Init(0, 1000000, 1, 0);
        
        return(1);    
    }
    

    where SPI_Init is defined as

    SPISettings spiSettings;
    unsigned char SPI_Init(unsigned char lsbFirst,
                           unsigned long clockFreq,
                           unsigned char clockPol,
                           unsigned char clockEdg)
    {
        // Add your code here.
    	int spiMode = 1;
    	//decode modes according to https://www.arduino.cc/en/Reference/SPI
    	if(clockPol == 0) {
    		spiMode = clockEdg ? SPI_MODE1 : SPI_MODE0;
    	} else {
    		spiMode = clockEdg ? SPI_MODE3 : SPI_MODE2;
    	}
    	int bitOrder = lsbFirst ? LSBFIRST : MSBFIRST;
    	//modify SPI settings object used in transactions
    	spiSettings = SPISettings(clockFreq, bitOrder, spiMode);
    
    	//set slave-select pins to output
    	PinMgt_PinOutput(PIN_ID_AD57XX_SLAVE_SELECT);
    
    	//this is used on the fly
    	return 1;
    }

    which seems to me to mean I am defining CPOL = 1 and CPHA = 0, which is SPI Mode 2.  This is what I want is it not?

  • 0
    •  Analog Employees 
    on Apr 4, 2019 1:56 AM over 1 year ago in reply to andrewkhardy

    CPOL= 1 and CPHA=0 is actually referred to as mode 3 on the link that I sent you.

    Can you try changing CPHA to "1"? This would make your data aligned to the falling edge of SCLK.