BNC 645 User Manual

Page 179

Advertising
background image

179

for(i=0;i<19;i++){

//Vary edge by 5 nsec steps

viPrintf(vi,"PULSe:TRANsition %E\n",0.00000001 + i * 0.000000005);

Sleep(300);

//Wait

300

msec

}

viClose

(vi);

viClose

(defaultRM);

}

Example: Pulse Width Modulation (PWM)

This program (found in the “Examples\PWM” subdirectory on the

CD-ROM) configures a pulse waveform with duty cycle, which is then slowly

modulated

by a triangle waveform.

//Pulse Width Modulation (PWM)

#include <visa.h>

#include <stdio.h>

void main (int argc,char *argv[])

{

ViSession

defaultRM,vi=0;

ViStatus

status;

char

instrDesc[]="USB0::5710::4002::TW00009009::0::INSTR";

viOpenDefaultRM

(&defaultRM);

status = viOpen(defaultRM,instrDesc, VI_NULL,VI_NULL, &vi);

if (status != VI_SUCCESS){

printf("Can

not

Open

device:\"%s\"\n",instrDesc);

return;

}

//This program uses low-level SCPI commands to configure

//the function gnerator to output an PWM waveform.

//The pulse is set up with a duty cycle of 35% and a depth

//of 15%, and will vary in width from 20% to 50% with the

Advertising