import ctypes from ctypes import * import os import matplotlib.pyplot as pyplot import numpy as np import time import pandas as pd '''******************************** Loading the HSDCPro Automation DLL ****************************************************''' start=time.time() if('PROGRAMFILES(X86)' in os.environ): #selecting the DLL path from HSDC Pro installed location based on 32 bit or 64 bit OS dll_path = "C:\\Program Files (x86)\\Texas Instruments\\High Speed Data Converter Pro\\HSDCPro Automation DLL\\64Bit DLL\\HSDCProAutomation_64Bit.dll" else: dll_path = "C:\\Program Files\\Texas Instruments\\High Speed Data Converter Pro\\HSDCPro Automation DLL\\64Bit DLL\\HSDCProAutomation_64Bit.dll" HSDC_Pro = ctypes.WinDLL(dll_path) '''*************************************************************************************************************************''' '''***************************************ADC Configuration Settings********************************************************''' '''*************************************************************************************************************************''' Boardsno = b"T873D94Z(10AX115)-TSW14J57revE" #Serial Number of board to be connected. Eg: "TIVHIV9Z" or "TIVHIV9Z-TSW1400" Devicename = b"ADC12DJxx00_JMODE5" #ADC device to be selected(should be same as what appears in the HSDC Pro GUI selection drop down box. Datarate = 6.4e9 #ADC output Data Rate ChannelIndex = 0 #0-Based Select ADC Channel InputTargetFrequency = 0 TestSelection = 0 #0-Time Domain 1-Single Tone 2-Two Tone 3-Channel Power #Trigger Options TriggerOption = 0 #0-Normal Capture 1-Software Trigger 2-Hardware Trigger NoofChannels = 1 #Get Array of Capture Data Number_Of_Samples_Per_Channel = 524288//2 NumberOfSamplesForAnalysis=524288//2 OffsetSamplePerChannel = 0 Capture_Data_Array_Len = NoofChannels * Number_Of_Samples_Per_Channel; # Number_of_Samples_per_channel * Number_of_Channels CaptureData_16bits = (c_ushort*Capture_Data_Array_Len)() #Initializing the array for the total number of samples CaptureData_32bits = (c_uint*Capture_Data_Array_Len)() #Initializing the array for the total number of samples Enable = 0 #1-Enable Additional device parameters 0-Disable Additional device parameters TimeoutinMs = 30000 '''*************************************************************************************************************************''' '''**************************** The actual call to the function contained in the dll ***************************************''' '''*************************************************************************************************************************''' print ("Connecting to board : " +str(Boardsno)) Err_Status = HSDC_Pro.Connect_Board(Boardsno,TimeoutinMs) print ("Error Status = " + str(Err_Status)) print ("Selecting ADC Device : " +str(Devicename)) Err_Status = HSDC_Pro.Select_ADC_Device(Devicename,120000) print ("Error Status = " + str(Err_Status)) print ("Reloading Device INI...") Err_Status = HSDC_Pro.Reload_Device_INI(TimeoutinMs) print ("Error Status = " + str(Err_Status)) print ("Using HSDC Ready function to check if the GUI is Ready...") Err_Status = HSDC_Pro.HSDC_Ready(120000) print ("Error Status = " + str(Err_Status)) print ("Passing ADC Output Data Rate = " + str(Datarate)) Err_Status = HSDC_Pro.Pass_ADC_Output_Data_Rate(c_double(Datarate),TimeoutinMs) print ("Error Status = " + str(Err_Status)) print ("Setting No of Samples as " + str(Number_Of_Samples_Per_Channel)) Err_Status = HSDC_Pro.Set_Number_of_Samples(c_ulonglong(Number_Of_Samples_Per_Channel),TimeoutinMs) print ("Error Status = " + str(Err_Status)) print ("Setting ADC Analysis Window Length as " + str(NumberOfSamplesForAnalysis)) Err_Status = HSDC_Pro.ADC_Analysis_Window_Length(c_ulong(NumberOfSamplesForAnalysis),TimeoutinMs) print ("Error Status = " + str(Err_Status)) print ("Selecting ADC Channel " + str(ChannelIndex)) Err_Status = HSDC_Pro.Select_ADC_Channel(c_ulong(ChannelIndex),TimeoutinMs) print ("Error Status = " + str(Err_Status)) TriggerModeEnable = 0 SoftwareTriggerEnable = 0 ArmOnNextCaptureButtonPress = 0 TriggerCLKDelays = 0 print ("Settingng Normal Capture") Err_Status = HSDC_Pro.Trigger_Option(TriggerModeEnable,SoftwareTriggerEnable,ArmOnNextCaptureButtonPress,c_ubyte(TriggerCLKDelays),TimeoutinMs) print ("Error Status = " + str(Err_Status)) print ("Starting normal capture..") Err_Status = HSDC_Pro.Pass_Capture_Event(TimeoutinMs) print ("Error Status = " + str(Err_Status)) Err_Status = HSDC_Pro.Get_Capture_Data_32bits(Number_Of_Samples_Per_Channel,OffsetSamplePerChannel,CaptureData_32bits,Capture_Data_Array_Len,TimeoutinMs) print ("Error Status = " + str(Err_Status)) Err_Status = HSDC_Pro.Get_Capture_Data_16bits(Number_Of_Samples_Per_Channel,OffsetSamplePerChannel,CaptureData_16bits,Capture_Data_Array_Len,TimeoutinMs) print ("Error Status = " + str(Err_Status)) pyplot.plot(CaptureData_16bits,label="podaci16") pyplot.legend() pyplot.show()