Jump to content

Trigering an event when the boolean indicator changes states


Recommended Posts

I am trying to trigger an event each time the boolean indicator changes states. The boolean indicator is connected to a digital DIO. Each time the state is changes from low to high i must read the data and each time it changes from high to low i want to read data as well. so on the state change i want to call the read function.

can anyone help me out please? thank you:)

Link to comment

I am trying to trigger an event each time the boolean indicator changes states. The boolean indicator is connected to a digital DIO. Each time the state is changes from low to high i must read the data and each time it changes from high to low i want to read data as well. so on the state change i want to call the read function.

can anyone help me out please? thank you:)

Hi mandya14,

i think that is impossible for an indicator to send an event at an event structure... Even in my last project a find that a numeric double indicator does not trigger any value change event...

In my application the event would be sent when the I/O loop change the value via the Value (trigger) property...

Even a control with the Disable property set to 1 or 2 is not able to trigger events!

To solve the problem, i change the indicator with a control and than I put an rectangular trasparent decoration to mask the control itself...

Or make a tiny loop that trigger the event whenever detect a change in the boolean value...

Osvaldo

Link to comment

Thank you for your replies.:)

Osvaldo i didn t understand what u did ? i am sorry....U think maybe i can save the value of my boolean indicator to a local variable and each time compare it to the new value?? like comparison of an old and the new value? if they are the same i don t read if they are different than i read...I don t hink i will have race conditions...

Can u please explain how u handled ur event handling??

ShaunR the problem is that i already have the iUSBDAQ HYTEK as an interface and i am reading digital input from it but thank you

Link to comment

Hi mandya14,

Sorry for bad English ... but not my mother tongue ...

Let me understand...

I guess you a while loop containing a VI (from your device driver toolkit) that returns the status of DIO and you set the value of this DIO directly into a boolean indicator through its terminal.

On the other hand you have another while loop that contains an event structure with which you collect the event "value change" on the indicator whose value is set from the di DIO...

I understand you correctly?

If it is correct, your problem is that setting the value of an indicator in this way *does not* trigger any "Value Change" event!

If instead of using an indicator you use a control (of course you should set its value though its local variable), then when the program writes the new boolean value, automatically would be triggered a "value change" event that you can catch with the event structure.

Osvaldo

p.s. The comparision would be done between the new value en the old one memorized in an shift register or using a feedback node...

Edited by osvaldo
Link to comment

I am trying to trigger an event each time the boolean indicator changes states. The boolean indicator is connected to a digital DIO. Each time the state is changes from low to high i must read the data and each time it changes from high to low i want to read data as well. so on the state change i want to call the read function.

can anyone help me out please? thank you:)

One easy way to accomplish this is to write to a Value (Signaling) property node rather than to the indicator itself. That will trigger the event, and you can use the OldVal and NewVal event terminalts to determine if the value has changed. See attached vi.

BoolIndEvent.vi

Link to comment

TobyD :D:D thank you i guess this will solve my problem:)

i read before that using a value signaling inside a while loop is bad. i dunno why but if you re telling me that this will work than i will definitively try it!

Thank you again:thumbup1:

Link to comment

I am trying to trigger an event each time the boolean indicator changes states. The boolean indicator is connected to a digital DIO.

If your digital DIO is driving the change in your indicator you might want to look into "Change Detection" if this is available for your DIO.

http://decibel.ni.co...t/docs/DOC-2280

If this makes sense for your application you can use Change Detection with a User Event to limit polling of the processor.

This user event could include the code you currently have in your event, plus the change of the boolean indicator.

This way the change of the DIO line is driving the event and boolean indicator instead of vice versa.

When I used the example above with at 6533, I did notice that the user Event was generated when calling the code; for some reason.

There was an easy work around since after this first "misfired" user event the next Change Detection events were successfully triggered.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.