209 lines
6.1 KiB
C++
209 lines
6.1 KiB
C++
|
|
// ˵<><CBB5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>ʽ<EFBFBD><CABD>ȡAD<41><44><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
#include "stdafx.h"
|
|||
|
|
#include "windows.h"
|
|||
|
|
#include "stdio.h"
|
|||
|
|
#include "conio.h"
|
|||
|
|
|
|||
|
|
#include "ACTS1000.h"
|
|||
|
|
|
|||
|
|
int InputRange;
|
|||
|
|
|
|||
|
|
#define AD_DATA_LEN 256*1024 // Ҫ<><D2AA>ȡ<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD>AD<41><44><EFBFBD>ݳ<EFBFBD><DDB3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>
|
|||
|
|
float fADBuffer[AD_DATA_LEN]; // <20><><EFBFBD>仺<EFBFBD><E4BBBA><EFBFBD><EFBFBD>(<28>洢ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>)
|
|||
|
|
int main(int argc, char* argv[])
|
|||
|
|
{
|
|||
|
|
HANDLE hDevice;
|
|||
|
|
int DeviceLgcID;
|
|||
|
|
ULONG ulDDR2Length = 0;
|
|||
|
|
ULONGLONG ulDDR2LengthByte = 0;
|
|||
|
|
|
|||
|
|
ACTS1000_PARA_AD ADPara; // Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ACTS1000_STATUS_AD ADStatus;
|
|||
|
|
ULONG nRetSizeWords;
|
|||
|
|
ULONG nAvailSampsPoints;
|
|||
|
|
ULONG nRead;
|
|||
|
|
|
|||
|
|
int nCurrentChannel = 0,nADChannel = 0;
|
|||
|
|
ACTS1000_AD_MAIN_INFO ADMainInfo;
|
|||
|
|
|
|||
|
|
|
|||
|
|
DeviceLgcID = 0;
|
|||
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID:");
|
|||
|
|
scanf_s("%d", &DeviceLgcID);
|
|||
|
|
hDevice = ACTS1000_CreateDevice(DeviceLgcID); // <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
|||
|
|
if(hDevice == INVALID_HANDLE_VALUE)
|
|||
|
|
{
|
|||
|
|
printf("CreateDevice error...\n");
|
|||
|
|
_getch();
|
|||
|
|
return 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ACTS1000_GetMainInfo(hDevice,&ADMainInfo); // DDR2<52>ij<EFBFBD><C4B3><EFBFBD>(<28><>λ<EFBFBD><CEBB>MB)
|
|||
|
|
|
|||
|
|
switch (ADMainInfo.nDeviceType>>16)
|
|||
|
|
{
|
|||
|
|
case 0x2012:
|
|||
|
|
printf("PXIE%04X\n",ADMainInfo.nDeviceType&0xFFFF);
|
|||
|
|
break;
|
|||
|
|
case 0x2111:
|
|||
|
|
printf("PCIE%04X\n",ADMainInfo.nDeviceType&0xFFFF);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
printf("ACTS1000-%04X\n",ADMainInfo.nDeviceType);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ulDDR2LengthByte = ADMainInfo.nDepthOfMemory;
|
|||
|
|
|
|||
|
|
|
|||
|
|
InputRange = ACTS1000_INPUT_N1000_P1000mV; // Ҫ<><D2AA><EFBFBD>û<EFBFBD><C3BB>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
memset(&ADPara, 0x00, sizeof(ADPara)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ȷ<EFBFBD><C8B7>ֵ0(ǿ<>ҽ<EFBFBD><D2BD><EFBFBD>)
|
|||
|
|
|
|||
|
|
// Ԥ<><D4A4>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ADPara.SampleMode = ACTS1000_SAMPMODE_CONTINUOUS; // <20><><EFBFBD><EFBFBD><DEB5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ADPara.FreqDivision = 1;
|
|||
|
|
for (int nCH=0; nCH<ADMainInfo.nChannelCount; nCH++)
|
|||
|
|
{
|
|||
|
|
ADPara.bChannelArray[nCH] = TRUE; // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>0<EFBFBD><30><EFBFBD><EFBFBD>
|
|||
|
|
ADPara.InputRange[nCH] = InputRange; // ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̷<EFBFBD>Χ
|
|||
|
|
ADPara.CouplingType[nCH] = ACTS1000_COUPLING_DC; // ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
}
|
|||
|
|
ADPara.M_Length = 0; // M<><4D><EFBFBD><EFBFBD>
|
|||
|
|
ADPara.N_Length = 1024*32; // N<><4E><EFBFBD><EFBFBD>
|
|||
|
|
ADPara.PFISel = ACTS1000_PFISEL_TRIG_IN;
|
|||
|
|
ADPara.TriggerMode = ACTS1000_TRIGMODE_POST; // <20><EFBFBD>
|
|||
|
|
ADPara.TriggerSource = ACTS1000_TRIGMODE_SOFT; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ADPara.TriggerDir = ACTS1000_TRIGDIR_NEGATIVE; // <20>½<EFBFBD><C2BD>ش<EFBFBD><D8B4><EFBFBD>
|
|||
|
|
ADPara.TrigLevelVolt = 0;
|
|||
|
|
ADPara.ReferenceClock = ACTS1000_RECLK_ONBOARD; // ʹ<><CAB9><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
ADPara.TimeBaseClock = ACTS1000_TBCLK_IN;
|
|||
|
|
ADPara.bMasterEn = 0;
|
|||
|
|
ADPara.TrigCount = 1;
|
|||
|
|
ADPara.SyncTrigSignal = ACTS1000_STS_TRIGGER0;
|
|||
|
|
ADPara.bClkOutEn = 0;
|
|||
|
|
ADPara.ClkOutSel = ACTS1000_CLKOUT_REFERENCE;
|
|||
|
|
ADPara.bTrigOutEn = 0;
|
|||
|
|
ADPara.TrigOutPolarity = ACTS1000_TOP_POSITIVE;
|
|||
|
|
ADPara.TrigOutWidth = 50;
|
|||
|
|
ADPara.bSaveFile = 0;
|
|||
|
|
_stprintf_s(ADPara.chFileName, 256, _T("%s"), L"I:\\3.pci");
|
|||
|
|
|
|||
|
|
if(!ACTS1000_InitDeviceAD(hDevice, &ADPara)) // <20><>ʼ<EFBFBD><CABC>Ӳ<EFBFBD><D3B2>
|
|||
|
|
{
|
|||
|
|
printf("InitDeviceAD error...\n");
|
|||
|
|
_getch();
|
|||
|
|
return 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int ChannelCount = 0;
|
|||
|
|
for(nADChannel=0; nADChannel<ADMainInfo.nChannelCount; nADChannel++)
|
|||
|
|
{
|
|||
|
|
if(ADPara.bChannelArray[nADChannel] == TRUE)
|
|||
|
|
{
|
|||
|
|
ChannelCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
LONG ulTime = GetTickCount();
|
|||
|
|
double dResult;
|
|||
|
|
__int64 i64Cnt=0;
|
|||
|
|
LONG ulTmp=0;
|
|||
|
|
LONG ulSecCnt=0;
|
|||
|
|
|
|||
|
|
if(!ACTS1000_StartDeviceAD(hDevice)) // <20><><EFBFBD><EFBFBD><EFBFBD>豸
|
|||
|
|
{
|
|||
|
|
printf("StartDeviceAD Error...\n");
|
|||
|
|
_getch();
|
|||
|
|
}
|
|||
|
|
if(!ACTS1000_SetDeviceTrigAD(hDevice)) // <20><><EFBFBD><EFBFBD>AD
|
|||
|
|
{
|
|||
|
|
printf("SetDeviceTrigAD Error...\n");
|
|||
|
|
_getch();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ulTime = GetTickCount();
|
|||
|
|
ULONGLONG ulReadCount = 0;
|
|||
|
|
nRead = AD_DATA_LEN;
|
|||
|
|
if (ADPara.bSaveFile) // <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
while(TRUE)
|
|||
|
|
{
|
|||
|
|
if(!ACTS1000_GetDevStatusAD(hDevice, &ADStatus))
|
|||
|
|
{
|
|||
|
|
printf("GetDevStatusAD Error\n");
|
|||
|
|
goto ExitRead;
|
|||
|
|
}
|
|||
|
|
if(_kbhit())
|
|||
|
|
goto ExitRead; // <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
|
|||
|
|
Sleep(1);
|
|||
|
|
|
|||
|
|
ulTmp = GetTickCount()-ulTime;
|
|||
|
|
if (ulTmp/1000>ulSecCnt)
|
|||
|
|
{
|
|||
|
|
ulSecCnt = ulTmp/1000;
|
|||
|
|
dResult = ADStatus.lSavePoints*1.00/((ulTmp+1)/1000.0);
|
|||
|
|
dResult=dResult/1000000.0;
|
|||
|
|
printf("%dS ",ulSecCnt);
|
|||
|
|
printf("%.3fM<EFBFBD><EFBFBD>/<2F><>\n",dResult);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
while ( !_kbhit() )
|
|||
|
|
{
|
|||
|
|
if(!ACTS1000_ReadAnalog(hDevice, fADBuffer, nRead, &nRetSizeWords, &nAvailSampsPoints,5.0))
|
|||
|
|
{
|
|||
|
|
printf("ReadDeviceDmaAD error...\n");
|
|||
|
|
_getch();
|
|||
|
|
goto ExitRead;
|
|||
|
|
}
|
|||
|
|
if (nRetSizeWords<=0)
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
ulReadCount+=nRetSizeWords;
|
|||
|
|
#if 1
|
|||
|
|
ulTmp = GetTickCount()-ulTime;
|
|||
|
|
if (ulTmp/1000>ulSecCnt)
|
|||
|
|
{
|
|||
|
|
ulSecCnt = ulTmp/1000;
|
|||
|
|
dResult = ulReadCount*1.00/((ulTmp+1)/1000.0);
|
|||
|
|
dResult=dResult/1000000.0;
|
|||
|
|
printf("%dS ",ulSecCnt);
|
|||
|
|
printf("%.3fM<EFBFBD><EFBFBD>/<2F><>\n",dResult);
|
|||
|
|
ULONG nTChannel = 0;
|
|||
|
|
for(int Index=0; Index<8; Index++)
|
|||
|
|
{
|
|||
|
|
for(nADChannel=nTChannel; nADChannel<ChannelCount; nADChannel++)
|
|||
|
|
{
|
|||
|
|
if(ADPara.bChannelArray[nADChannel] == TRUE) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
nTChannel = nADChannel + 1;
|
|||
|
|
printf("CH%02d=%6.2f\t", nADChannel, fADBuffer[Index]); // <20><>ʾ<EFBFBD><CABE>ѹֵ
|
|||
|
|
if ((Index+1) % ChannelCount == 0)
|
|||
|
|
{
|
|||
|
|
nTChannel = 0;
|
|||
|
|
printf("\n");
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} // for(Index=0; Index<64; Index++)
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ExitRead:
|
|||
|
|
ACTS1000_StopDeviceAD(hDevice); // ֹͣAD
|
|||
|
|
ACTS1000_ReleaseDeviceAD(hDevice); // <20>ͷ<EFBFBD>AD
|
|||
|
|
ACTS1000_ReleaseDevice(hDevice); // <20>ͷ<EFBFBD><CDB7>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|