Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2177

NI PCI-6542: Creating Dynamic Waveforms Using the HSDIO Library

$
0
0

Hello!

 

I am having problems understanding how to create waveforms using the HSDIO library to run on my PCI-6542 board. I need to create a program that turns one channel on for 12.5 microseconds, waits a set amount of time(i.e. 100 samples),  and turns another channel on for 12.5 microseconds.

 

This program is to be used in a phased array ultrasonic system.

 

Below is the Dynamic Generation example program that turns channels 0 - 2 on for 1024 samples.

 

/************************************************************************
*
*  Example Program:
*    DynamicGeneration.c
*
*  Description:
*    Generates a simple pattern on specified channels.
*
*  Pin Connection Information:
*    None.
*
************************************************************************/


/* Includes */
#include <stdio.h>
#include <limits.h>
#include "niHSDIO.h"

/* Defines */
#define WAVEFORM_SIZE 1024

int main(void)
{
   ViRsrc deviceID = "Dev1";
   ViConstString channelList = "0-2";
   ViReal64 sampleClockRate = 50.0e6;
   ViInt32 dataWidth = 4;
  
   ViUInt32 waveformDataU32[WAVEFORM_SIZE];
   ViConstString waveformName = "myWfm";
   ViInt32 timeout = 10000; /* milliseconds */
   
   ViSession vi = VI_NULL;
   ViStatus error = VI_SUCCESS;
   ViChar errDesc[1024];
   ViInt32 i;
   
   
   /* Initialize generation session */
   checkErr(niHSDIO_InitGenerationSession(
            deviceID, VI_FALSE, VI_FALSE, VI_NULL, &vi));
   /* Assign channels for dynamic generation */
   checkErr(niHSDIO_AssignDynamicChannels (vi, channelList));
   /* Configure sample clock parameters */
   checkErr(niHSDIO_ConfigureSampleClock(
            vi, NIHSDIO_VAL_ON_BOARD_CLOCK_STR, sampleClockRate));
   /* Query the Data Width Attribute */
   checkErr(niHSDIO_GetAttributeViInt32(
            vi, VI_NULL, NIHSDIO_ATTR_DATA_WIDTH, &dataWidth));
/* Populate waveform with ramp data */ for (i = 0; i < WAVEFORM_SIZE; i++) { waveformDataU32[i] = i; } checkErr(niHSDIO_WriteNamedWaveformU32( vi, waveformName, WAVEFORM_SIZE, waveformDataU32)); /* Initiate generation */ checkErr(niHSDIO_Initiate(vi)); /* Wait for generation to complete */ checkErr(niHSDIO_WaitUntilDone(vi, timeout)); Error: if (error == VI_SUCCESS) { /* print result */ printf("Done without error.\n"); } else { /* Get error description and print */ niHSDIO_GetError(vi, &error, sizeof(errDesc)/sizeof(ViChar), errDesc); printf("\nError encountered\n===================\n%s\n", errDesc); } /* close the session */ niHSDIO_close(vi); /* prompt to exit (for pop-up console windows) */ printf("\nHit <Enter> to continue...\n"); getchar(); return error; }

 

Questions:

How can I change the values in waveformDataU32 to create off and on states(instead of just always on)?

How do I select the channel that waveformDataU32 is applied to?

 

Thanks!

Zachary Geier


Viewing all articles
Browse latest Browse all 2177

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>