User Manual 3153
Using The Instrument 3-37
RI3153_MAX_SEG_NUMBER, VI_ERROR_PARAMETER2))
return( error );
max_size = ri3153_get_mem_size(vi);
if (error = ri3153_int32_range (number_of_points, RI3153_MIN_SEGMENT_SIZE,
max_size, VI_ERROR_PARAMETER4))
return( error );
/* select the arbitrary waveform segment */
if ((error = viPrintf(vi, "TRAC:SEL %d\n", segment_number)) < 0)
return( error );
if ((error = viPrintf(vi, ":SMEM:STATE OFF\n")) < 0)
return( error );
/* get the device ready to download via A24 space */
if ((error = viPrintf(vi, ":SMEM:MODE WRITE\n")) < 0)
return( error );
if ((error = viPrintf(vi, ":SMEM:STATE ON\n")) < 0)
return( error );
if ((error = viPrintf(vi, "*OPC?\n")) < 0)
return( error );
if ((error = viRead(vi, (unsigned char *) readbuf, RI3153_READ_LEN, &cnt)) < 0)
return( error );
/* try again */
if (readbuf[0] != '1')
{
if ((error = viPrintf(vi, "*OPC?\n")) < 0)
return( error );
if ((error = viRead(vi, (unsigned char *) readbuf, RI3153_READ_LEN, &cnt)) < 0)
return( error );
if (readbuf[0] != '1')
return( RI3153_BINARY_DOWNLOAD_FAILED );
}
error = viEnableEvent(vi, VI_EVENT_IO_COMPLETION, VI_QUEUE, VI_NULL);
error = viMoveAsync (vi, VI_LOCAL_SPACE, (ViBusAddress)data_pts, VI_WIDTH_16,
VI_A24_SPACE, 0L, VI_WIDTH_16, number_of_points, &job);
if (error < 0) {
viPrintf(vi, ":SMEM:STATE OFF\n");
return( RI3153_INVALID_FILE_DATA );
}
error = viWaitOnEvent (vi, VI_EVENT_IO_COMPLETION, 10000, &etype, &event);
if (error < 0) {
viTerminate( vi, VI_NULL, job );
viWaitOnEvent( vi, VI_EVENT_IO_COMPLETION, 0, &etype, &event );
viDiscardEvents( vi, etype, VI_ALL_MECH );
viPrintf(vi, ":SMEM:STATE OFF\n");
return( RI3153_INVALID_FILE_DATA );
}
viDiscardEvents( vi, etype, VI_ALL_MECH );
return( viPrintf(vi, ":SMEM:STATE OFF\n") );
}
int main (int argc, char *argv[]) {
/* Define a 24-point square wave */
ViInt16 data_pts[24] = {
4095, 4095, 4095, 4095,
4095, 4095, 4095, 4095,
4095, 4095, 4095, 4095,
0, 0, 0, 0,
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com