Hellsmoke Posted November 8, 2023 Share Posted November 8, 2023 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 More sharing options...
0 attila Posted November 8, 2023 Share Posted November 8, 2023 Hi @Hellsmoke See the WF SDK/ samples/ py/ AnalogIn_Trigger.py DigitalIn_Trigger.py example Link to comment Share on other sites More sharing options...
0 Hellsmoke Posted November 20, 2023 Author Share Posted November 20, 2023 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 More sharing options...
0 attila Posted November 21, 2023 Share Posted November 21, 2023 Hi @Hellsmoke See the following example test1.py and the manual and the other available examples. Link to comment Share on other sites More sharing options...
Question
Hellsmoke
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
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 accountSign in
Already have an account? Sign in here.
Sign In Now