Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering waveforms to execute based on DIO input (HSDIO 6551)

First, let me correct my code.   The experiments I ran in the lab do not reflect how the actual hardware will work.  Let me correct the function call:

 niHSDIO_ExportSignal(genVi[0], NIHSDIO_VAL_DATA_ACTIVE_EVENT, "", NIHSDIO_VAL_PFI0_STR);

When running at greater than 25MHz, I've found that if you try to sync the Data Active Event and the Digital Edge Start Trigger on the same trigger line, like my previous post had, a regular generate/acquisition would not work correctly.

 

Let me also clarify my script.

In reality, it will be more complex.. but for example, it may look like this:

 

/*****************/

 /* Script setup */

/*****************

 myScript=
 "script myScript1 "

 "  Repeat forever "

"   Generate initWfm"

 "  Wait until scriptTrigger0 "
 "    Generate myWfm "
 "  end repeat "
 "end script ";

 

My intention was to keep the generation and acquisition sessions in-sync by linking the "data active" trigger to the "acquisition start" trigger. It was my understanding that the "Data Active Event" would only generate when the card generated a waveform.  Therefore, when the portion of the script "Generate initWfm" or "Generate "myWfm" was executed, the acquisition session would be in-sync with the generation session.  After generation, the "Data Active Event" trigger becomes inactive and the channels hold their last state.

 

When the portion of the script "Wait for scriptTrigger0" was executed, the card would be idle until the "Pattern Match start trigger" was present, indicated by one channel going to a certain logic state.

 

I've run this code..or something similiar in the lab and I'm pretty sure the hardware accepted it without error.  After I debug this against my DUT and can use an oscilloscope to verify timing, I will post whatever changes or updates I have come across.

0 Kudos
Message 11 of 12
(1,142 Views)

It seems I was mistaken on the triggering aspects.  I've only used HSDIO for simple burst operations.  I haven't needed to use much complex scripting techniques to achieve my goals.

 

After revising parts of my code, I've come down to this:

 

//The wait is just for easy viewing on the scope, it will not exist in the final version

 myScript=
 "script myScript1 "
 "  Repeat forever "
 "    Wait 100 "
 "    Generate myWfm "
 "  end repeat "
 "end script ";

 

//Init Generation Session

 HSDIO0GenErrChk(niHSDIO_InitGenerationSession(genDeviceID[0], VI_FALSE, VI_FALSE, "", &genVi[0]));
 HSDIO0GenErrChk(niHSDIO_AssignDynamicChannels(genVi[0], "0-19"));
 HSDIO0GenErrChk(niHSDIO_ConfigureSampleClock(genVi[0], NIHSDIO_VAL_ON_BOARD_CLOCK_STR, 5000000));  
 HSDIO0GenErrChk(niHSDIO_SetAttributeViInt32(genVi[0], "", NIHSDIO_ATTR_HWC_HARDWARE_COMPARE_MODE, NIHSDIO_VAL_HWC_STIMULUS_AND_EXPECTED_RESPONSE ));
 HSDIO0GenErrChk(niHSDIO_SetAttributeViString (genVi[0], "", NIHSDIO_ATTR_EXPORTED_SAMPLE_CLOCK_OUTPUT_TERMINAL, NIHSDIO_VAL_DDC_CLK_OUT_STR));
 HSDIO0GenErrChk(niHSDIO_ConfigureDataVoltageLogicFamily (genVi[0], "0-19", NIHSDIO_VAL_5_0V_LOGIC));  
 
 //Start on Logic 1
 HSDIO0GenErrChk(niHSDIO_ConfigureDigitalEdgeStartTrigger (genVi[0], NIHSDIO_VAL_PFI2_STR, NIHSDIO_VAL_RISING_EDGE));
 
 //Stop on Logic 0
 HSDIO0GenErrChk(niHSDIO_ConfigureDigitalLevelPauseTrigger (genVi[0], NIHSDIO_VAL_PFI3_STR, NIHSDIO_VAL_HIGH));
 

//Configure script

 HSDIO0GenErrChk(niHSDIO_ConfigureGenerationMode (genVi[0], NIHSDIO_VAL_SCRIPTED));
 HSDIO0GenErrChk(niHSDIO_WriteNamedWaveformFromFileHWS (genVi[0], "myWfm", "Card1.hws", VI_FALSE, VI_NULL));
 HSDIO0GenErrChk(niHSDIO_WriteScript (genVi[0], myScript));

 HSDIO0GenErrChk(niHSDIO_CommitDynamic (genVi[0]));

 

 

 /****************************************/
 /* Acquisition Setup for HS-DIO Cards */
 /****************************************/
 HSDIO0AcqErrChk(niHSDIO_InitAcquisitionSession (acqDeviceID[0], VI_FALSE, VI_FALSE, "", &acqVi[0]));
 HSDIO0AcqErrChk(niHSDIO_AssignDynamicChannels (acqVi[0], "0-19"));
 HSDIO0AcqErrChk(niHSDIO_SetAttributeViInt32 (acqVi[0], "", NIHSDIO_ATTR_HWC_HARDWARE_COMPARE_MODE, NIHSDIO_VAL_HWC_STIMULUS_AND_EXPECTED_RESPONSE ));
 HSDIO0AcqErrChk(niHSDIO_ConfigureSampleClock(acqVi[0], NIHSDIO_VAL_STROBE_STR, 5000000));   
 //HSDIO0AcqErrChk(niHSDIO_ConfigureDigitalEdgeStartTrigger (acqVi[0], NIHSDIO_VAL_PFI1_STR, NIHSDIO_VAL_RISING_EDGE));
 HSDIO0AcqErrChk(niHSDIO_ConfigureAcquisitionSize (acqVi[0], 1000000, 1));
 HSDIO0AcqErrChk(niHSDIO_ConfigureDataVoltageLogicFamily (acqVi[0], "0-19", NIHSDIO_VAL_5_0V_LOGIC));     
 
 //Start acquisition on logic 1 placed on pin 15
 HSDIO0AcqErrChk(niHSDIO_ConfigurePatternMatchStartTrigger (acqVi[0], "15", "1", NIHSDIO_VAL_PATTERN_MATCHES));
 //Export for generation session
 HSDIO0AcqErrChk(niHSDIO_ExportSignal (acqVi[0], NIHSDIO_VAL_START_TRIGGER, "", NIHSDIO_VAL_PFI2_STR));
 
 //Pause acquisition on logic 0 for Generation Session (does this work?? Can't export a pause trigger from acquisition session!)
 HSDIO0AcqErrChk(niHSDIO_ConfigurePatternMatchAdvanceTrigger (acqVi[0], "15", "0", NIHSDIO_VAL_PATTERN_MATCHES));
 //Export for generation session
 HSDIO0AcqErrChk(niHSDIO_ExportSignal (acqVi[0], NIHSDIO_VAL_ADVANCE_TRIGGER, "", NIHSDIO_VAL_PFI3_STR));
 
//Pause on logic 0, based on Advance trigger...
 HSDIO0AcqErrChk(niHSDIO_ConfigureDigitalLevelPauseTrigger (acqVi[0], NIHSDIO_VAL_PFI3_STR, NIHSDIO_VAL_HIGH));
 
 //HSDIO0AcqErrChk(niHSDIO_ConfigureIdleState (acqVi[0], "19-0", "ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ"));
 /************************************/
 /* Start the Acquisition Sessions */
 /************************************/
    HSDIO0AcqErrChk(niHSDIO_Initiate (acqVi[0]));

 /************************************/
 /* Start the Generation Sessions */
 /************************************/
 HSDIO0GenErrChk(niHSDIO_Initiate (genVi[0]));

 

----------------

It will successfully turn on when a logic 1 is placed on pin 15, but will not pause when a logic 0 is placed on pin 15.

I've tried to look up the definitions of "Pause Trigger", "Advance Trigger", and "Reference Trigger" with little luck.  Explanation of these would probably fix my problem, but I think this type of application SHOULD be able to be accomplished with setting up the right combination of start triggers and pause triggers.

0 Kudos
Message 12 of 12
(1,118 Views)