資源簡(jiǎn)介
AD9959,四通道的信號(hào)發(fā)生器,輸出頻率能夠達(dá)到200Mhz,輸出的頻率相位獨(dú)立可調(diào),幅值再500毫伏左右

代碼片段和文件信息
/*
?*?Test?program?for?divisor?calculation?using?reciprocal?division.
?*/
#include
#include
#include
#include
#include “AD9959.h“
#define INCR 0.000005 //?The?smaller?this?number?the?more?test?data?points
#define MAXERR 0.08
#define MAX_FREQ (500*1000*1000)
bool verbose?=?false;
class?MyAD9959
:?public?AD9959<
2 //?ResetPin
3 //?ChipEnablePin
4 //?UpdatePin
//?25000000?(reference_frequency)
//?SPIRate?SPIClkPin?SPIMISOPin?SPIMOSIPin
>?{};
void?test_dividers(MyAD9959&?dds)
{
int count?=?0;
int low?=?0;
int high?=?0;
uint32_t last?=?1;
uint32_t freq?=?0;
int decade?=?2;
int pow10?=?10;
double two32?=?pow(2?32);
double sum_of_squares_gen?=?0;
double sum_of_squares_acc?=?0;
double sum_of_squares_high?=?0;
double sum_of_squares_low?=?0;
uint32_t core_clock?=?MAX_FREQ;
#if defined(CLOCK_MULTIPLIER)
//?Test?with?a?reduced?clock?rate
dds.setClock(CLOCK_MULTIPLIER); //?Half?the?core_clock?frequency
core_clock?/=?(20/CLOCK_MULTIPLIER);
#endif
for?(double?freqr?=?10;?freqr?<=?core_clock/2;?freqr?*=?(1+INCR))
{
freq?=?floor(freqr+0.5);
if?(freq?==?last)
continue;
last?=?freq;
if?(freq?>?pow10*10)
{
decade++;
pow10?*=?10;
printf(“Progress?to?%d:?%d?frequencies?tested?%d?low?%d?high?%d?bad\n“?pow10?count?low?high?count-low-high);
}
uint32_t divisor?=?dds.frequencyDelta(freq);
uint32_t accurate?=?floor(two32*freq/core_clock?+?0.500);
double fgen?=?1ULL*core_clock*divisor/two32;
double facc?=?1ULL*core_clock*accurate/two32;
double epsilon_gen?=?fgen-freq;?//?difference?between?desired?and?generated?reciprocal?method
double epsilon_acc?=?facc-freq;?//?difference?between?desired?and?generated?normal?method
sum_of_squares_gen?+=?epsilon_gen*epsilon_gen;
sum_of_squares_acc?+=?epsilon_acc*epsilon_acc;
bool bad?=?0;
if?(fgen?>?freq)
{
sum_of_squares_high?+=?epsilon_gen*epsilon_gen;
if?(fgen? high++;
else
bad?=?1;
}
if?(fgen? {
sum_of_squares_low?+=?epsilon_gen*epsilon_gen;
if?(fgen?>?freq-MAXERR)
low++;
else
bad?=?1;
}
//?printf(“Wanted?%u?Gen?%0.4f?Acc?%0.4f?Epsilon?gen?%g?acc?%g\n“?freq?fgen?facc?epsilon_gen?epsilon_acc);
if?(verbose)
printf(“%u?->?%u?for?%.4f?“?freq?divisor?fgen);
if?(divisor?==?accurate)
{
if?(verbose)
printf(“good\n“);
}
else
{
if?(verbose)
printf(“expected?%u?(%s)\n“?accurate?bad???“bad“?:?“acceptable“);
}
count++;
}
printf(“%d?frequencies?tested?%d?low?%d?high?%d?bad\n“?count?low?high?count-low-high);
printf(
“Frequency?Standard?Deviation?using?reciprocal?method?%gHz?accurate?%gHz\n“
sqrt(sum_of_squares_gen/count)
sqrt(sum_of_squares_acc/count)
);
printf(“Upward?deviation?%.5g\n“?sqrt(sum_of_squares_high/count));
printf(“Downward?deviation?%.5g\n“?sqrt(sum_of_squares_low/count));
}
int
main(int?argc?const?char**?argv)
{
MyAD9959 dds;
if?(--argc?>?0?&
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2017-09-13?01:06??AD9959-master\
?????文件???????????7??2017-09-13?01:06??AD9959-master\.gitignore
?????文件???????15459??2017-09-13?01:06??AD9959-master\AD9959.h
?????文件????????6608??2017-09-13?01:06??AD9959-master\README.md
?????文件?????????322??2017-09-13?01:06??AD9959-master\keywords.txt
?????文件?????????243??2017-09-13?01:06??AD9959-master\library.json
?????文件?????????271??2017-09-13?01:06??AD9959-master\library.properties
?????目錄???????????0??2017-09-13?01:06??AD9959-master\test\
?????文件?????????474??2017-09-13?01:06??AD9959-master\test\Arduino.h
?????文件?????????435??2017-09-13?01:06??AD9959-master\test\SPI.h
?????文件??????????53??2017-09-13?01:06??AD9959-master\test\compile
?????文件????????3068??2017-09-13?01:06??AD9959-master\test\ddstest.cpp
- 上一篇:黑馬57期不加密版.txt
- 下一篇:url采集/全自動(dòng)采集url
評(píng)論
共有 條評(píng)論