Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

dichannels

I have a problem with Reading a digital IO port with measurement studio and DAQmx.  I have upgraded to 9.2 and it appears to improve the problem; but it is not fixed.  I am still getting a error popup that contains no information that will crash my code at a random time several hours after the start.  If I remove the sleep(350) from the code, the error pops up after a couple seconds -- so it is repeatable. I have attempted to read a specific channel, I have attempted to use an event, I have attempted almost every possible configuration to get around this problem.  This is an error in the DAQmx library.

 

I need some help with this.  Our system runs for days at a time...

 

Task task_DIOAcquire = new Task("DIO_acquire_task");
task_DIOAcquire.DIChannels.CreateChannel("NF_6733_Right/port0",
                     "AcquireChannel",
                     ChannelLineGrouping.OneChannelForAllLines);
DigitalSingleChannelReader channel_DIOAcquire = new DigitalSingleChannelReader(task_DIOAcquire.Stream);
                            
while (!flag_ContactClosure)
{
    dio_state = channel_DIOAcquire.ReadSingleSamplePortUInt32();

    if (flag_DIO_low) // wait for the trigger to go low before checking if it goes high
    {
        // if we get the signal start acquiring.
        if ((dio_state & 0x80) != 0)
        {
            flag_ContactClosure = true; // wait for the trigger to go low before checking if it goes high
        }
    }
    else if ((dio_state & 0x80) == 0)
        flag_DIO_low = true; // trigger went low, we can wait for it to go high now

    Thread.Sleep(350);
}

0 Kudos
Message 1 of 7
(4,204 Views)

Hello

 

I would recommend running one of the shipping examples included with the NI-DAQmx driver to observe if this error still occurs (Windows Start>All Programs>National Instruments>NI-DAQ>Text Based Code Support>.NET Examples>Digital>Read Values). Also, in the event that the error is hardware related, check to see if you can control the device correctly in Measurement and Automation Explorer (MAX) Test Panels i.e. (MAX>Devices and Interfaces>right click on the DIO device> Test Panels). Troubleshooting a non descriptive error can be tricky, but If you can run these examples successfully, we can eliminate DAQmx as being an issue

 

Best regards,

 

Ali M

Applications Engineer

National Instruments

0 Kudos
Message 2 of 7
(4,186 Views)

No, I got the code from the examples.  I got this one and the single channel reader and the use of an interrupt which is not supported by my card all from the examples.  I have the 6733.  I, in fact, was able to get the error to repeat using your examples by removing the wait between reads.  Overflow the buffer - or whatever - and watch the crash occur. The error returned is not trappable, system just crashes.

 

I have even put a 1 sec wait in the code to make sure the library can recover.  Does not help.  The error occurs at a random time between 2 and 12 hours later.

0 Kudos
Message 3 of 7
(4,181 Views)

Can you control the NI 6733 in MAX/Test Panels?

 

Best regards,

 

Ali M

Applications Engineer

National Instruments

0 Kudos
Message 4 of 7
(4,152 Views)

Yes, it self tests fine.  The system works for hours at a time.

 

Just try removing the sleep from your example code.  Watch the untrappable error pop up.

 

Thanks

bill

0 Kudos
Message 5 of 7
(4,132 Views)

Passing the sef test is good sign regarding the device status, I was mostly concerned about being able to run the device in MAX Test Panels. i.e. right click on the device under Devices and Interface>Test Panels. Also, which NI DAQmx example are you using?

 

 Best regards,

 

 Ali M

 Applications Engineer

 National Instruments

 www.ni.com/support

0 Kudos
Message 6 of 7
(4,108 Views)

I solved the problem.  Turns out I was reading on one thread and writing on another.  Caused a random conflict.  Error reporting is lacking even in your example code.  System now runs for days at a time without trouble.  Thanks for your help.

0 Kudos
Message 7 of 7
(3,777 Views)