Discussion:
HS-DIO 6552 Hardware Compare Issues
(too old to reply)
Jakeus
2007-03-14 18:40:13 UTC
Permalink
I am having a confusing problem with getting this hardware compare to work.  I followed this example, http://zone.ni.com/devzone/cda/epd/p/id/3419 , pretty well (at least I thought), and I could get the example working, however, not the code I created based upon it.  Here is my code, you can safely assume the variables are all defined and syntax before/after is good.
 
waveformDataU8=malloc(2*WAVEFORM_SIZE); for(i = 0; i < WAVEFORM_SIZE; i++) {   k=i*2;   waveformDataU8[k] = NI_DIO_0;   waveformDataU8[k + 1] = NI_DIO_L; }     niHSDIO_InitGenerationSession(deviceID, VI_FALSE, VI_FALSE, "", &genVi); niHSDIO_AssignDynamicChannels(genVi, genChannel); niHSDIO_SetAttributeViInt32(genVi, "", NIHSDIO_ATTR_HWC_HARDWARE_COMPARE_MODE, NIHSDIO_VAL_HWC_STIMULUS_AND_EXPECTED_RESPONSE ); niHSDIO_ConfigureSampleClock(genVi, NIHSDIO_VAL_ON_BOARD_CLOCK_STR, sampleClockRate);  niHSDIO_ExportSignal(genVi, NIHSDIO_VAL_DATA_ACTIVE_EVENT, "", NIHSDIO_VAL_PFI1_STR); niHSDIO_WriteNamedWaveformWDT(genVi, "", WAVEFORM_SIZE, NIHSDIO_VAL_GROUP_BY_SAMPLE, waveformDataU8);    niHSDIO_InitAcquisitionSession (deviceID, VI_FALSE, VI_FALSE, "", &acqVi); niHSDIO_AssignDynamicChannels (acqVi, acqChannel); niHSDIO_TristateChannels (acqVi, acqChannel, VI_TRUE);   niHSDIO_SetAttributeViInt32 (acqVi, "", NIHSDIO_ATTR_HWC_HARDWARE_COMPARE_MODE, NIHSDIO_VAL_HWC_STIMULUS_AND_EXPECTED_RESPONSE ); niHSDIO_ConfigureSampleClock(acqVi, NIHSDIO_VAL_ON_BOARD_CLOCK_STR, sampleClockRate);  niHSDIO_ConfigureDigitalEdgeStartTrigger (acqVi, NIHSDIO_VAL_PFI1_STR, NIHSDIO_VAL_RISING_EDGE); niHSDIO_ConfigureAcquisitionSize (acqVi, WAVEFORM_SIZE, 1);          niHSDIO_Initiate (acqVi); niHSDIO_Initiate (genVi); niHSDIO_WaitUntilDone (acqVi, 3000);    niHSDIO_GetAttributeViInt32(acqVi, "", NIHSDIO_ATTR_HWC_NUM_SAMPLE_ERRORS, &intErrors); niHSDIO_GetAttributeViReal64 (acqVi, "", NIHSDIO_ATTR_HWC_SAMPLES_COMPARED, &intTotal); niHSDIO_close (genVi); niHSDIO_close (acqVi);    printf("# of errors: %i\n",intErrors); printf("# of samples compared: %d\n",(long)intTotal); printf("Hit <Enter> to abort generation.\n"); getchar();
 
This code executes and runs perfectly, giving "0 errors, 512 samples compared".  However, when I change the data to be:
"   waveformDataU8[k] = NI_DIO_1;   waveformDataU8[k + 1] = NI_DIO_H;"
The code executes and prints, "256 errors, 512 compared". 
Is there something wrong with my initalizations?  Something I may have forgotten..?
Jakeus
2007-03-14 20:10:15 UTC
Permalink
Also, changing the array structure to:
   waveformDataU8[k] = NI_DIO_0;   waveformDataU8[k + 1] = NI_DIO_X;
or
   waveformDataU8[k] = NI_DIO_1;   waveformDataU8[k + 1] = NI_DIO_X;
 
produces 0 errors 512 samples compared. 
Any thoughts?  I'm completely stumped.
Jakeus
2007-03-15 15:40:18 UTC
Permalink
You got it!  I had the generation channel "0" and acquision channel "8", and my variables were defined as such.  I didn't have that channel also in the generation session.  I never saw the line "sprintf(channelString, "%s,%s", generationChannels, acquisitionChannels);" in the example.  I kept overlooking it and thought the generation channels were just the ones I entered in the text boxes.
And the cable delay you're speaking of, I think I had that problem in the example you sent me.  I was triggering fine using it all internally, but when going at speeds greater than 26MHz, it wouldn't work anymore.  I'll attempt to hook up things all at the terminal block and see what happens.
Loading...