06-26-2012 10:18 AM
Hi,
I'm trying to use the input from digital signals generated by a physical button to trigger events/functions in the code I'm working on. I'm building a unit that will have buttons that will send input via the digital I/O lines of an SCB-68. I can read in the values of the lines, but I don't know how to have (for example) the line going high trigger an event in the program. Would it be best to have functions reading the lines running in different threads? I found an example in the CVI 8.5 help dealing with change detection events but wasn't able to make sense of it.
Thanks!
06-26-2012 10:26 AM
Which language are you using? In LabVIEW, I would tell you to use a shift register to hold the previous value and look for a change in state. On the change, I would use a queue or user event to trigger an action.
06-26-2012 11:21 AM
Using C and LabWindows.
06-28-2012 06:04 AM
Hello,
If you want to avoid polling, you will need to use the change detection event:
http://digital.ni.com/public.nsf/allkb/DF5719473800838086256F1E0054FD7B
I would image you would read a port at a time then in your event call back, see which bit has changed and call the appropriate function.
Maybe if you had some specific questions about the example I could help you further?
Otherwise, you would need a separate thread, reading the digital values and checking for a change. If a change occurs then call your function.
There should be plenty of DAQmx examples to help with reading digital data.
I hope this helps.