Discussion:
generation and acquisition at the same time ni-hsdio
(too old to reply)
ak123
2008-01-24 18:10:08 UTC
Permalink
Hi,
I'm currently using c++ to work with the pci 6551. I've satisfactorily managed to generate and acquire data on separate occasions. However now I'm trying to acquire data whilst generating outputs. Is this possible? If so, I require a trigger to initiate the acquisition and fetch, and continue this process until I choose to abort.
Snippets of the code are as follows:
 
Generation:

checkErr(niHSDIO_InitGenerationSession(deviceID, VI_FALSE, VI_FALSE, VI_NULL, &vi));
checkErr(niHSDIO_AssignDynamicChannels (vi, channelList));

checkErr(niHSDIO_ConfigureSampleClock(vi, NIHSDIO_VAL_ON_BOARD_CLOCK_STR, sampleClockRate));

checkErr(niHSDIO_ConfigureDigitalEdgeScriptTrigger(vi, triggerID, triggerSource, triggerEdge));

checkErr(niHSDIO_ConfigureGenerationMode(vi, NIHSDIO_VAL_SCRIPTED));
checkErr(niHSDIO_WriteNamedWaveformU32(vi, waveformName, WAVEFORM_SIZE, waveformDataU32));

c heckErr(niHSDIO_WriteScript(vi, script));

checkErr(niHSDIO_Initiate(vi));
Acquisiton:
checkErr(niHSDIO_InitAcquisitionSession(aqdeviceID, VI_FALSE, VI_FALSE, VI_NULL, &aqvi));

checkErr(niHSDIO_AssignDynamicChannels (aqvi, channelList));

checkErr(niHSDIO_ConfigureSampleClock(aqvi,NIHSDIO_VAL_STROBE_STR, sampleClockRate));

checkErr(niHSDIO_ConfigureDigitalEdgeStartTrigger(aqvi, triggerTerminal, triggerEdge));
checkErr(niHSDIO_Initiate(aqvi));
 
Any suggestions? I've tried using multirecord fetch but even that isn't continuous.
I've tried the example multirecord supplied with the card.
 
Thanks,
Arifa
ak123
2008-01-30 16:40:11 UTC
Permalink
Hi Tom,
Sorry for the late reply, couldn't remember which category I posted the question. Thanks for that suggestion.  I was using the example that you suggested however I required a retriggerable acquisition which I solved by putting the initiate function in a continuous for loop. But I've moved from that topic but still got a slight problem, it's with tristating and WDT. I posted a separate message,not sure if you are familiar with WDT but the post was as follows:
I'm working on generating and acquiring data using the pci 6551 with visual c++.
Since I require a channel to go into high impedance during acquisition, im using writenamedwaveformwdt function. However , I don't quite understand what the 3rd parameter (samples to write) should be. According to the help file it is the number of channels multiplied by waveform size, but during debugging I get memory corruption error. Snippets of my code is as follows:
#define WAVEFORM_SIZE 100000#define WDT_SIZE 100000#define SAMPLES_TO_READ 50   ViRsrc deviceID = "Dev1";   ViConstString channelList = "0-3";   ViInt8 VoltageConfigurationSupported = 0;   ViReal64 sampleClockRate;   ViConstString triggerSource = "PFI2"; //generation trigger   ViInt32 triggerEdge = 12;   ViConstString triggerID = "ScriptTrigger0";   ViInt32 dataWidth = 4;   ViUInt8 waveformData[WAVEFORM_SIZE];   ViConstString waveformName = "myWfm";for (bit = 0; bit < 1000 ;bit++)     {     waveformData[z] = 0;     z++;     waveformData[z] = 0;     z++;     waveformData[z] = 1;     z++;     waveformData[z] = 0;     z++;
bit++;    }   /* Note: waveform names are referenced in script */   ViConstString script =       "script myScript "      "   repeat forever "      "     wait until ScriptTrigger0 "      "     repeat 1 "      "     generate myWfm "      "     end repeat "      "   end repeat "      "end script";
 
/* Initialize generation session */   checkErr(niHSDIO_InitGenerationSession(            deviceID, VI_FALSE, VI_FALSE, VI_NULL, &gvi));
 /* Reset Device */
   checkErr(niHSDIO_ResetDevice (gvi));
 
   /* Assign channels for dynamic generation */   checkErr(niHSDIO_AssignDynamicChannels (gvi, channelList));                /* Configure clocking parameters */   checkErr(niHSDIO_ConfigureSampleClock(            gvi, NIHSDIO_VAL_ON_BOARD_CLOCK_STR, sampleClockRate));
               /* Configure hardware script trigger */   checkErr(niHSDIO_ConfigureDigitalEdgeScriptTrigger(            gvi, triggerID, triggerSource, triggerEdge));               /* Configure generation mode for scripted generation */   checkErr(niHSDIO_ConfigureGenerationMode(gvi, NIHSDIO_VAL_SCRIPTED));
   checkErr(niHSDIO_WriteNamedWaveformWDT(gvi,waveformName,WDT_SIZE,NIHSDIO_VAL_GROUP_BY_SAMPLE,waveformData));        /* Write script to device */
Kabul
2008-01-31 15:40:09 UTC
Permalink
Hi, When you run your code in debug mode, does everything operate as you are expecting it to? Do you get any error codes while in debug mode?When you reduce "wdt_size" to 8, you say the data isn't what you are expecting. What are you expecting and what is actual result you get?
Regards,
ak123
2008-02-01 13:10:11 UTC
Permalink
Hi Kabul,
I figured out what the problem was, i varied the waveform size and wdt and i assume i got the proportion right and the data is as expected. When I said as expected, I was chucking out predetermined data, therefore when i monitored the data lines it wasn't what i put in. for example if i passed values 0-7 to lines 0-2, i should see the equivalent as a waveform on the scope. The values I used are:
WAVEFORM_SIZE 599999
WDT_SIZE 100000
However there seems to be a triggering issue, which I would like some advice on. Using the above waveform size, and the onboard clock at 50 MHz,if I trigger the card at 400Hz, I see the data at every rising trigger edge as expected. However if i increase triggering to a few KHz, the data is being chucked out at all random times.   After experimenting a bit I reduced the waveform size when using the writenamewaveform function to about 2 and the output data seems exact at every rising edge when triggering at few KHz. Therefore my question is, what delays are involved to cause this? And is there anyway I can go abouts resolving it? Have had a look at DirectDMA, but don't know if that would solve anything and how would I implement it in my program?
Thanks,
Arifa

Loading...