![Connect Tech DAG103 Скачать руководство пользователя страница 30](http://html.mh-extra.com/html/connect-tech/dag103/dag103_user-manual_2652840030.webp)
Xtreme I/O Express ADC-DAC
Users Guide
Document: CTIM-00435
Revision: 0.08
Page 30 of 47
Connect Tech Inc. 800-426-8979 | 519-836-1291
Date: 2016-11-18
Application Examples
Example A: Simple DAC outputs
In this example we will set all of the DAC outputs to
Unipolar
Mode (0 to +15V),
then we will set DAC0 & DAC1 to +5V, DAC2 to be +10V and DAC3 to be +15V.
//unipolar setup
CTIFPGAWrDword(pbrd, BarIndex, DAC0 + IO_PINS_CONTROL, 0xC);
//enable normal operation
CTIFPGAWrDword(pbrd, BarIndex, DAC0 + CMD_PASSTHRU, 0x3C);
//Set DAC0 to +5V and DAC1 to +5V
CTIFPGAWrDword(pbrd, BarIndex, DAC0 + CH0_DATA, 0x4000 << 16 | 0x4000);
//Set DAC2 to +10V and DAC3 to +15V
CTIFPGAWrDword(pbrd, BarIndex, DAC0 + CH2_DATA, 0xC000 << 16 | 0x8000);
Example B: PWM Setup
#define
BOARD_GAIN 4
#define
BOARD_VREF 5
#define
CLK 102000000
void
pwmSetup(CtiUfpgaBoard* pbrd, U8 BarIndex,
U16 lowcnt,
U16 highcnt, U8
freqMult, U16 highCode, U16 lowCode)
{
U32 pwmCnt, pwmCtrl, pwmLvl, siggen, rb;
float
freq;
float
period;
// Disable Output PWM
siggen = 0x0;
CTIFPGAWrDword(pbrd, BarIndex, DAC0 + TRG_SIGGEN_PWM, siggen);
// Setting pwm cycle
period = (
float
)(( highcnt)*freqMult )* (
float
)1/CLK;
freq = 1/period;
pwmCnt = (highcnt << 16) | lowcnt;
CTIFPGAWrDword(pbrd, BarIndex, DAC0 + PWM_LOW_COUNT, pwmCnt);
printf(
"Period = %f; Freq = %f\n"
, period, freq);
if
(period < 4* 0.000004)
{
printf(
"Period %f is less than %f, which 4 times the DAC settlign
time\n"
, period, 4* 0.000004);
}
// Setting pwm levels
pwmLvl = (highCode << 16) | (lowCode);
CTIFPGAWrDword(pbrd, BarIndex, DAC0 + PWM_LOW_VAL, pwmLvl);
// Enabling pulse gen
pwmCtrl = (0x0 << 16) | (freqMult << 8) | 0x8 | 0x4;
CTIFPGAWrDword(pbrd, BarIndex, DAC0 + PWM_CTRL, pwmCtrl);