Post Go back to editing

Python Script to Automatically Capture and Save Waveform in Rx Port

Category: Software
Product Number: ADRV9026

Dear AD support,  I am posting this to ask whether you have some example python codes to automatically capture and save the waveform at Rx port for ADRV9026 platform. I am planning to capture and save the waveforms in a span of 48 hours, an automatic script to do that can be really helpful. Thank you so much in advance!

  • Please see attached.

    #################################################################################
    #GUI Version: 5.0.0.76
    #DLL Version: 5.0.0.57
    #Cmd Server Version: 5.0.0.57
    #FPGA Version: 0xD9000007
    #ARM Version: 5.0.0.32(ADI_ADRV9025_ARMBUILD_TESTOBJ)
    #StreamVersion: 8.0.0.5
    #################################################################################
    import System
    import clr
    import time
    import os
    import math
    import datetime
    from System import Array,Int16
    #Import Reference to the DLL
    import System
    import clr
    import time
    from System import Array
    clr.AddReferenceToFileAndPath("C:\\Program Files\\Analog Devices\\ADRV9025 Transceiver Evaluation Software_x64_FULL\\adrvtrx_dll.dll")
    from adrv9010_dll import AdiEvaluationSystem
    from adrv9010_dll import Types
    from adrv9010_dll import Ad9528Types
    from adrv9010_dll import FpgaTypes
    
    
    
    def RxCapture(RxChannel,path,captureTime):
        #####################################################################
        ######### Create a lsit of array to hold the data ###################
        #####################################################################
        Data = Array.CreateInstance(int, 0)
        Rx_data_list = []
        for i in range(20):
            Rx_data_list.append(Data)
    
        #####################################################################
        ################ Capture RX data and save in file ###################
        #####################################################################
        ch_dict =	{ 0x01: "RX1", 0x02: "RX2",0x04: "RX3",0x08: "RX4",0x10: "ORX1",0x20: "ORX2",0x40: "ORX3",0x80: "ORX4"}
        channel = ch_dict[Rxchannel]
        i_now = datetime.datetime.now()
        time = "%s_%s_%s_%s_%s_%s" %(i_now.day,i_now.month,i_now.year,i_now.hour,i_now.minute,i_now.second)
        Filename = "%s_%s" %(channel,time)
        
        f = open('%s\\%s.txt'%(path,Filename), 'a')
    
        if Rxchannel <= 0x08:
            ch_mask = Rxchannel
        elif (Rxchannel == 0x10) | (Rxchannel == 0x20):
            ch_mask = 0x10
        elif (Rxchannel == 0x40) | (Rxchannel == 0x80):
            ch_mask = 0x20
    
        Rx_data_list = link.platform.board.PerformRx(FpgaTypes.adi_fpga9010_RxTollgateTrigSources_e.ADI_FPGA9010_IMM_TRIG,ch_mask,captureTime,captureTime*2)
        print "capture done"
        
        if Rxchannel == 0x01:
            I = Rx_data_list[0]
            Q = Rx_data_list[1]
        elif Rxchannel == 0x02:
            I = Rx_data_list[2]
            Q = Rx_data_list[3]
        elif Rxchannel == 0x04:
            I = Rx_data_list[4]
            Q = Rx_data_list[5]
        elif Rxchannel == 0x08:
            I = Rx_data_list[6]
            Q = Rx_data_list[7]
        elif (Rxchannel == 0x10) | (Rxchannel == 0x20):
            I = Rx_data_list[8]
            Q = Rx_data_list[9]
        elif (Rxchannel == 0x40) | (Rxchannel == 0x80):
            I = Rx_data_list[10]
            Q = Rx_data_list[11]
        
        for i in range(len(I)):
            f.write(str(I[i])+'\t'+str(Q[i])+'\n')
            
        f.close()
    
    def spiRead(address):
        data = adrv9010.Hal.SpiByteRead(address, 0)
        print "SPI Read Address " + hex(address) + ": " + hex(data[1])
    
    def spiWrite(address, data):
        adrv9010.Hal.SpiByteWrite(address, data)
        print "SPI Write Address " + hex(address) + ": " + hex(data)
    
    #Create an Instance of the Class
    link = AdiEvaluationSystem.Instance	
    connect = False
    
    if (link.IsConnected() == False):
        connect = True
        link.platform.board.Client.Connect("192.168.1.90", 55556) 
        print "Connecting"
    
    if (link.IsConnected()):
        adrv9010 = link.Adrv9010Get(1)
        print "Connected"
        ##### YOUR CODE GOES HERE #####
    
        #####################################################################
        ################### Enable the RX/ORX/TX paths ######################
        #####################################################################
        Rxchannel = 0x01     #Just change the mask here and the respective channel will get captured.
        Txchannel = 0x01
        link.platform.board.Adrv9010Device.RadioCtrl.RxTxEnableSet(Rxchannel,Txchannel)
    
        #####################################################################
        ################### Capture data and set file path ##################
        #####################################################################    
        captureTime = 2  # in milli seconds
        path = 'C:\\Users\\RBitra\\OneDrive - Analog Devices, Inc\\Ram_Onedrive\\Test_Scripts\\Ram\\Madura'
        RxCapture(Rxchannel,path,captureTime)
    
    else:
        print "Not Connected"
    
    if (connect):
        link.platform.board.Client.Disconnect()
        print "Disconnected"

  • Thank you so much for the code provided. In my setup, I am using the TDD and Tx waveform is 10ms and Rx waveform is 11ms as shown in the first figure.
     Ideally, what I expected to see when capturing manually should look like this,

    where the blue one is my transmitted signal and the red one is my received signal.
    In the script, I changed the captured time to be 11ms and the code is able to save as expected.However, there are some issues with the captured waveform. The received waveform that captured using the script is:
     
    To me, this seems like the problem of controlling the transmitted waveform. So I would like to ask if there is some code that I can add so that Tx and Rx waveform can start simultaneously? Also, is there any function that can save normalized data as in the manual mode?

    Thank you so much in advance! 

  • It looks like you are using tirgger source as immediate per the code.

    Please change that to TDD SM per the enum below:

    Rx_data_list = link.platform.board.PerformRx(FpgaTypes.adi_fpga9010_RxTollgateTrigSources_e.ADI_FPGA9010_IMM_TRIG

  • Thank you so much for your help! Do you know how to enable normalization for the saved data, just like we normally do in the manual mode?