Post Go back to editing

AD9278-50EBZ + HSC-ADC-EVALCZ Acquisition from MATLAB

Hi

I have been trying to configure the AD9278-50EBZ and the HSC-ADC-EVALCZ for data acquisition.  I found the MATLAB script for acquisition on the AD9253 using the HadBoardApi and tried to adapt it (see code attached) to my hardware however, I have a challenge understanding which function calls and parameters are applicable to me.  The HadBoardApi is also poorly documented - the .chm file of the HadBoardApi throws some errors in the description field - so it is virtually useless.  The following are the specific issues I am having:

1. SPI Initialization Parameter:

board.SpiInitInterface(0, param) ---> What determines the number to enter into the first argument of the function? 

2. Which FPGA FIFO?

How do I know the index of the FIFO that must be used when calling the 'CaptureFifoBytes(numBytes, 0)' function?  I my troubleshooting, it seems like the index parameter has no effect/change on the output.

2.  Enabling and disabling of ADC channel:

How do I disable an ADC channel?  the AD9278 has 8 channels (A-H), how may I select say channel D.  Yes I know I have to write to a specific AD9278 register (0x04 or 0x05)  but nothing seems to change when I do that.

3.  Bits, Bytes, Words,.....?:

Can someone please explain how these are related on the two boards?  The AD9278 samples in 12 bit resolution by default and consequently (if I understand correctly) the values of the sampled signal should range from 0 to 4096 (offset binary), however when I run the MATLAB script it, values range only from 0 to 255?  Even when I try to change the bit resolution of the AD9278 to 8, 10 or 14bit, the values still remain in that range.

4. Extra zeros in sampled data: 

The attached image below shows what is typically obtained from the AD9278.  Why do I get zeros between each sample?

5.  FPGA register address

The MATLAB script for the AD9253 writes some data to the FPGA register address, can I get the FPGA register address for the AD9278?

I will appreciate some answers to these questions. 

Thanks,

Josiah

%The following dlls are required for using the library.
%These three dlls are needed in the same directory:
%HadBoardApi.dll
%HadSdpSupport.dll
%sdpApi1.dll
%If you have installed VisualAnalog these dlls will be in the VisualAnalog
%install folder as shown below.

%This needs to be the path to HadBoardApi.dll . Change if necessary.
hadInfo = NET.addAssembly('C:\Program Files (x86)\Analog Devices\VisualAnalog\HadBoardApi.dll');
% NET.addAssembly('C:\Program Files (x86)\Analog Devices\VisualAnalog\HadSdpSupport.dll');

% hadInfo.Classes
% showGenericMethods('HadBoardApi.HadBoard')

%*** Set FPGA file path. ***
%This FPGA program file is for the AD9653. The FPGA program file for AD9253 is AD9253_Main.bin
fpgaFilePath = 'C:\Program Files (x86)\Analog Devices\VisualAnalog\Hardware\HSC_ADC_EVALC\Octal_High_Speed.bin';
% fpgaFilePath = 'C:\Program Files (x86)\Analog Devices\VisualAnalog\Hardware\HSC_ADC_EVALC\High_Speed_Octal_synchronous_capture.bin';

% HadBoardApi.HadBoard.Compatibility;
% NET.setStaticProperty('HadBoardApi.HadBoard.Compatibility',HadBoardApi.CompatibilityFlags.('HadSdp'));
HadBoardApi.HadBoard.FindBoards()
HadBoardApi.HadBoard.BoardCount

%This assumes we found at least one board and want the first capture board found.
HadBoardApi.HadBoard.SelectBoard(0);

board = HadBoardApi.HadBoard.Board;

%Configure FPGA.
board.ConfigureFpga(fpgaFilePath);

%Configure memory map on ADC.
param = HadBoardApi.HadSpiParameters(1, 0, 1)
%param.LongInst = 1, param.LsbFirst = 0, param.SdoActive = 1
board.SpiInitInterface(1, param)

%This section is ADC specific.
%These are ADC SPI register addresses
%Write ADC registers as desired.
% Capture (mail)
board.SpiWrite(int16(hex2dec('00')), uint8(hex2dec('3C'))); % Soft Reset
board.SpiWrite(int16(hex2dec('08')), uint8(hex2dec('03'))); % Digital Reset
board.SpiWrite(int16(hex2dec('08')), uint8(hex2dec('00'))); % release from Digital Reset
board.SpiWrite(int16(hex2dec('14')), uint8(hex2dec('00'))); % set output format to Offset binary

% Power down unwanted channels
% board.SpiWrite(int16(hex2dec('04')), uint8(hex2dec('0F'))); % Disable channels E-H
% board.SpiWrite(int16(hex2dec('22')), uint8(hex2dec('01'))); % Power down channels E-H% 
% board.SpiWrite(int16(hex2dec('05')), uint8(hex2dec('0E'))); % Disable channels B-D
% board.SpiWrite(int16(hex2dec('22')), uint8(hex2dec('01'))); % Power down channels B-D

% Reset channels
% board.SpiWrite(int16(hex2dec('04')), uint8(hex2dec('0F'))); % Disable channels E-H
% board.SpiWrite(int16(hex2dec('22')), uint8(hex2dec('02'))); % Power down channels E-H% 
% board.SpiWrite(int16(hex2dec('05')), uint8(hex2dec('0E'))); % Disable channels B-D
% board.SpiWrite(int16(hex2dec('22')), uint8(hex2dec('02'))); % Power down channels B-D

board.SpiWrite(int16(hex2dec('05')), uint8(hex2dec('31'))); % Enable channel A only
board.SpiWrite(int16(hex2dec('21')), uint8(hex2dec('00'))); % Set bit resolution
% board.SpiWrite(int16(hex2dec('14')), uint8(hex2dec('00'))); % Set data format (offset binary(00) or two's complement(01))
% board.SpiWrite(int16(hex2dec('0D')), uint8(hex2dec('03'))); % Set a Digital Test Pattern
board.SpiWrite(int16(hex2dec('FF')), uint8(hex2dec('01'))); % Device Update 


%% Configure FPGA memory map and capture data.

% Configure FPGA memory map.???????? Does this apply to the AD9278 and HSC-ADC-EVALCZ  ?????????
% param = HadBoardApi.HadSpiParameters(1, 0, 1)
% param.LongInst = 1, param.LsbFirst = 0, param.SdoActive = 1
% board.SpiInitInterface(0, param)

% This section configures the FPGA for a specific ADC.
% Again, the register writes here are ADC specific.
% These are FPGA register addresses
% board.SpiWrite(int16(hex2dec('01')), uint8(hex2dec('30'))); %16bits
% 1xframe DDR2lane byte-wise 

%Select which AD9653 or AD9253 channel you would like to read data.
%Select only 1
% board.SpiWrite(int16(hex2dec('02')), uint8(hex2dec('00'))) %read ChA
% board.SpiWrite(int16(hex2dec('02')), uint8(hex2dec('01'))); %read ChB
%board.SpiWrite(int16(hex2dec('02')), uint8(hex2dec('02'))); %read ChC
%board.SpiWrite(int16(hex2dec('02')), uint8(hex2dec('03'))); %read ChD


%%

numWords = 2^8;     % What exactly is a 'Word' in the context of these two devices (AD9278 & HSC-ADC-EVALCZ)?  Is this just a fancy name for 'Number of samples to acquire?'
board.FillFifos(int32(numWords), int32(10));

numBytes = numWords*2;  % Why multiple by 2?  Should it not be numWords*12bits/8bits?

% Capture bytes. May need to use 2 for the second parameter instead of 1
% for your eval board - How will I know which one to use?????
dataABytes = HadBoardApi.HadBoard.Board.CaptureFifoBytes(int32(numBytes), int16(1)); 

% Convert to matrix
dataABytesMatrix = uint32(dataABytes);

% Create new matrix with each two adjacent bytes combined into a single
% word
% dataAMatrix = dataABytesMatrix(1:2:end) + dataABytesMatrix(2:2:end)*256;

figure
plot(dataABytesMatrix); ylim([-512 512]);
axis 'square'

  • Hi Josiah,

    I am using the same configuration as you, but I am somehow not able to communicate with MATLAB. After putting the statements of compatibility for 64 bit MATLAB, the statement, HadBoardApi.HadBoard.FindBoards() always return 0. The communication with Visual Analog works perfectly.

    Did you use an older 32 bit version of MATLAB to establish the communication with the board?

    Best Regards

    Sitansu

  • Hi Josiah,

    I was able to figure out the issue, the sequence of the code in the following manner would be able to give you the proper output provided you have set all the writeable registers mentioned in the AD9278 Datasheet through board.SpiWrite(int(address), int(data)) function in MATLAB.

    To get the proper waveform, I used the following code:

    dataABytes = HadBoardApi.HadBoard.Board.CaptureFifoBytes(int32(numBytes), int16(1));

    %Convert to matrix
    dataABytesMatrix = uint32(dataABytes);

    % Create new matrix with each two adjacent bytes combined into a single
    % word
    dataAMatrix = dataABytesMatrix(1:2:end) + dataABytesMatrix(2:2:end)*256;

    figure
    plot(dataAMatrix);

    Further, if you have SpiController software to configure the SPI initially to be used with Visual Analog, you can actually view the register setting in there under Config -> Page ReadBack -> Read. This would show the data which has to be written through MATLAB into respective addresses. 

    Hope this is something which would help as this post was unanswered and I had the same problem

    Best Regards

    Sitansu Sekhar

  • Hi Sitansu and Josiah,

    I'm very sorry about the non-reply to Josiah's question.

    Sitansu, thank you so very much for addressing the question and sharing your knowledge with the EngineerZone community.

    Josiah, if you still need help with this I can ask the software group for additional information.

    FYI I was told by the software group that you need to use the 32bit version of Matlab to work with HSC-ADC-EVALCZ. I see you are getting some output, so you are probably already using the 32bit version.

    Take care,

    Doug