From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

detection of a change on an Digital Port by Event

How can i programm a detection of a change on a digital port by using the GeneralEvent function from the measurement studio. I would use the DIO 32 HS card and the PCI 6527.
0 Kudos
Message 1 of 11
(4,539 Views)
Greetings,

Below I have included links to an example program and KnowledgeBase that demonstrate and document the use of change detection in Visual Basic:

6527 change detection using Visual Basic


Using Change Notification with the NI 6527 in Visual Basic

Good luck with your application.

Spencer S.
0 Kudos
Message 2 of 11
(4,528 Views)
It seems that the "detection of a change 6527" works only on the event of "MouseMove", I tried to use some different events in the EventSinkForm like "MouseDown", "MouseUp", "KeyPress", etc., none of them works, what is the secret?
Thank you for your help
0 Kudos
Message 3 of 11
(4,336 Views)

Hi PIGM-

Can you elaborate on what happens when you try to use the other events?  How exactly do they "not work?"

You may also be interested to know that change notification is supported for the NI 6527 with NI-DAQmx, and it's considerably easier to work with than Traditional (Legacy) NI-DAQ.  I have attached an NI-DAQmx example to this message.

Tom W
National Instruments
0 Kudos
Message 4 of 11
(4,324 Views)

Thank you for your response.

(1) What happened is that: I used the code (refer to the link above) using tradition DAQ which works well, however, if I changed the event from MouseMove to MouseUp/MouseDown/KeyPress, it just does not work.

(2) I will think about transfering to DAQmx.

So, In tradition DAQ, Does the "Change Detection"  work only on the single event of "MouseMove"?

Regards.

 

Thank you for your help
0 Kudos
Message 5 of 11
(4,322 Views)

Hi PIGM-

I'm still not clear on how it doesn't work.  Do you simply never see the event fire?  Are you modifying the event both in the target form as well as the host form?  You will also need to update the notification values (i.e. Const WM_MOUSEMOVE = &H200 only applies to a MOUSEMOVE event).  Some googling for the various event names should turn up the values for those notifications (for example, Private Const WM_LBUTTONDOWN As Long = &H201).

Hopefully this helps-

Tom W
National Instruments
0 Kudos
Message 6 of 11
(4,305 Views)

Thank you for your response,

What I did is:

1. In Form1,

    Const WM_MOUSEUP = &H210

DIG_Change_Message_Config 1, 0, "0.0", "0.1", EventSinkForm.hWnd, WM_MOUSEUP, 0

DIG_Change_Message_Config 1, 1, "0.0", "0.1", EventSinkForm.hWnd, WM_MOUSEUP, 0

2.In EventSinkForm

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Form1.Callback
End Sub

Then the event has never been fired.

Thank you for your help
0 Kudos
Message 7 of 11
(4,298 Views)

Hi, Tom,

surprise!

I read your code about "change detection" using DAQmx, and found that It is NOT driven by interrupt/event like the one using tradition DAQ.

Can you give piece of code about REAL change detection using DAQmx dirven by interrupt/event?

Thanks.

Thank you for your help
0 Kudos
Message 8 of 11
(4,297 Views)

Hi PIGM-

Actually, the first example I posted does use change detection (i.e. hardware-timed latching of new data on a change of value).  You seem to be actually asking about an example of change notification (software-timed callback/event response to a change); a good NI-DAQmx example to get you started would be the ANSI C NI-DAQmx Events example "C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Events\Signal\Change Detection\Read Dig Chan-Change Detection Event"

Hopefully this helps-

Tom W
National Instruments
0 Kudos
Message 9 of 11
(4,278 Views)

Hi, Tom,

Thank you very much.

You are right that I am looking for "Change Nodification" which is driven by Interrupt/Event.

The condition to me is that I have to use Visual Basic due to the other equipment (not NI ones), currently I am using the code from NI in which there is a form EventSinkForm, and I met some issues like I mentioned above.

And for the NI cards I have (PCI 6527, PCI 6024E), it seems that it is the only way to work with interrupt/event driving code in VB (I got confirmation that I can not use Generic DAQ Event controls for them.)

So, could you give me the sample code about "change nodifiction" using DAQmx in VB? (C code does not help becuase the callback routine issue.)

Thanks.

 

Thank you for your help
0 Kudos
Message 10 of 11
(4,277 Views)