Jump to content
Fourth of July -- Digilent US offices closed ×
  • 0

AnalogIn with DigitalOut Trigger


Hellsmoke

Question

Hi 

I use AnalogDiscovery2 and AnalogDiscovery3 SDK with C#.

I want to record AnalogIn0 (+1) signal if DigitalOut1 (2) goes from low to high.

I tried this but I never get a signal record.

 

int dSamples = 8192 / 8;
double sampleBuffer = new double[dSamples];

// Define and enable AnalogIn0
AnalogDiscovery.FDwfAnalogInChannelEnableSet(m_hdwf, 0, 1);
AnalogDiscovery.FDwfAnalogInChannelRangeSet(m_hdwf, 0, 5.0);
AnalogDiscovery.FDwfAnalogInChannelOffsetSet(m_hdwf, 0, 2.5);
AnalogDiscovery.FDwfAnalogInAcquisitionModeSet(m_hdwf, AnalogDiscovery.acqmodeRecord);

// Enable and set DigitalOut1
AnalogDiscovery.FDwfDigitalOutEnableSet(m_hdwf, 1, 1);
AnalogDiscovery.FDwfDigitalOutIdleSet(m_hdwf, 1, AnalogDiscovery.DwfDigitalOutIdleLow);  // DOUT low

// Define and set Trigger
AnalogDiscovery.FDwfDigitalOutTriggerSlopeSet(m_hdwf, 2);
AnalogDiscovery.FDwfAnalogInTriggerSourceSet(m_hdwf, AnalogDiscovery.trigsrcDigitalOut);
AnalogDiscovery.FDwfAnalogInTriggerConditionSet(m_hdwf, AnalogDiscovery.DwfTriggerSlopeRise);

AnalogDiscovery.FDwfDigitalOutIdleSet(m_hdwf, 1, AnalogDiscovery.DwfDigitalOutIdleHigh);  // DOUT high

byte psts = 0;
while (true)
{
    AnalogDiscovery.FDwfAnalogInStatus(m_hdwf, 1, out psts);
    if (psts == AnalogDiscovery.DwfStateDone)
    {
        break;
    }
}

// get samples
AnalogDiscovery.FDwfAnalogInStatusData(m_hdwf, 0, sampleBuffer, dSamples);
 

What is wrong or what is missing?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi Attila

Thank you for your answer. But it doesn't work for me.

I tried everything to trigger an AnalogIn with a DigitalOut and I went through the examples. I think I don't get the principle of AnalogDiscovery triggering.

I have a general question:
    It is possible to start automatically an AnalogIn signal recording at the moment when a DigitalOut pulse signal is going from High to Low?

 

Regards

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...