AnsweredAssumed Answered

iiolib function calls to load a waveform to AD9144 on DAQ2

Question asked by mike.ericson on Jan 12, 2015
Latest reply on Jan 14, 2015 by mike.ericson



I'd like to use iiolib function calls from Matlab to load a waveform to the AD9144 DAC on the DAQ2 board when connected to the ZC706 platform.  Here's what I have so far, but I think that there is something wrong with the part that loads the data since I do not see anything coming out of the DAC SMA after running it.  This code below is from the libiio_if.m file on github, with out_altvoltage0_TX1_I_F1_raw changed to out_altvoltage0_1A_raw.


I'm trying to find clues in the iio_oscilloscope source code, but if someone could provide a writeData function like the one below that is geared towards the AD9144 on the DAQ2 board, that would be very helpful.


Thanks very much,



        function ret = writeData(obj, data)

            % Initialize the return values

            ret = -1;


            % Check if the interface is initialized

            if(obj.if_initialized == 0)




            % Check if the device type is input

            if(~strcmp(obj.dev_type, 'OUT'))




            % Destroy the buffer

            calllib(obj.libname, 'iio_buffer_destroy', obj.iio_buffer);

            obj.iio_buffer = {};


            % Enable the DAC buffer output

%             ret = writeAttributeString(obj, 'out_altvoltage0_TX1_I_F1_raw', '0');

            ret = writeAttributeString(obj, 'out_altvoltage0_1A_raw', '1');

            if(ret < 0)

                obj.iio_channel = {};

                err_msg = 'Could not enable the DAC buffer output!';




            % Create the IIO buffer used to write data

            obj.iio_buf_size = obj.data_ch_size * obj.iio_scan_elm_no;

            obj.iio_buffer = calllib(obj.libname, 'iio_device_create_buffer', obj.iio_dev,...

                                     obj.data_ch_size, 1);


            % Transmit the data

            buffer = calllib(obj.libname, 'iio_buffer_start', obj.iio_buffer);

            setdatatype(buffer, 'int16Ptr', obj.iio_buf_size);

            for i = 1 : obj.data_ch_no

                buffer.Value(i : obj.iio_scan_elm_no : obj.iio_buf_size) = int16(data{i});


            for i = obj.data_ch_no + 1 : obj.iio_scan_elm_no

                buffer.Value(i : obj.iio_scan_elm_no : obj.iio_buf_size) = 0;


            calllib(obj.libname, 'iio_buffer_push', obj.iio_buffer);


            % Set the return code to success

            ret = 0;