Discussion:
Digital IO Async Callback with Read
(too old to reply)
bryan C.
2007-08-03 22:10:11 UTC
Permalink
I am developing an application using Measurement Studio 2005 and I am having a design issue that I hope someone can help me with.  I am using an NI USB-6229 digital input channel to read the value of a contact switch to find out if the switch is open or closed.  While the application is running, I will need to know when the switch transitions from high to low, and low to high.  However I will also need to read the current value of the switch at startup and a couple of times during the run cycle.
 
I am currently using an asynchronous callback to a function that will handle the transitions of the channel.  The problem that I am having is that I can't read the current digital value of the channel without getting a runtime error saying that the channel reasources are in use.  Is it possible to read the channel value without ending the asynchronous callback method or is there another solution that I haven't tried?  I would like to avoid starting an stopping this method continuously, but if that is the only way I would like to know that too.
Thanks for your help!
 
   
Jon B.
2007-08-07 15:10:13 UTC
Permalink
Matt A.


You mentioned checking the last pattern that was latched,
how would you do that in VB .NET 2005? I have both the asynchronous and digital
change event detection setup and working, but I cannot figure out how to
capture any data from the LAST event. The tutorial you linked to regarding digital change event and masking bits seemed promising, but can you get direct access to those bits?

The reason I highlight LAST is I am having problems with a
bouncing switch. I have done as much hardware debouncing as I can, but there is
still a little ripple. For both a change event and asynchronous read, the
buffer of samples to read goes from 20-100 depending on the circuit I use. Each
one of these raises an event. I have tried slowing down the sample rate, but it
doesn't seem to change this problem dramatically.

Thanks for the help!

Jon

Loading...