Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

reading a digital input from inside an analog callback

hi folks, I am working on a usb 6008 daq board with visual studio 2003 and measurement studio 7.1. I have an analog task working fine, now I need to read also a digital input to check if the user is pushing a button. I have created a digital task with a single channel and a single sample reading on demand, and I have put inside the analog callback the

 

Led1.Value = myDigitalReader.ReadSingleSampleSingleLine

 

code, so that when I change the input value, a led goes on and off.

the code compiles fine, but unfortunately when i run the program, at this line the program stops working without sending error messages. I have tried debugging but the cursor disappears. Any ideas?

it would be even better if there was a way to detect when the digital input changes its state without reading the input at each iteration.

tks

nunzio

0 Kudos
Message 1 of 3
(3,415 Views)

Hi nunzio,

 

you can try to modify your code as follow

 

Led1.Value = myDigitalReader.ReadSingleSampleSingleLine()

 

Otherwise you can read this or this post to try to find a different solution.

Please tell me if you resolve your issue.

 

Ciao!

______________________
Simone S.
Academic Field Engineer - Med Region
0 Kudos
Message 2 of 3
(3,397 Views)

Tks a lot Simone for your reply. It was my stupid fault, I hadn't correctly initialised the digital task. Now it works perfectly.

NI rules!

ciao

n.

 

 

0 Kudos
Message 3 of 3
(3,358 Views)