Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

QMH: create user Event in Consumer Loop

Solved!
Go to solution

you're right, meanwhile I noticed running in the error without noticing previously..

 

now I noticed, grrrrrrrrrr

 

annoying to put all this task into one change detection and at the event finding out, which one caused it... could be easier...

0 Kudos
Message 11 of 23
(1,068 Views)

so, next issue (I ran from error to Error)

 

I changed the initialization to

WWolf78_1-1615902556162.png

 

 

 

 

 

If I try to read the Inputs in an later stage, I got an timeout:

 

WWolf78_0-1615902475965.png

 

 

any suggestions why?

0 Kudos
Message 12 of 23
(1,061 Views)

Can't tell without more info.  Generically, there weren't enough changes detected to supply you with whatever # samples you asked for.  Could be a signal problem, a physical wiring problem, a timing problem (trying to read samples before changes start), a simple coding problem (requesting too many samples).  And more possibilities.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 13 of 23
(1,055 Views)

so, it still don't work

 

in the previous version i tried to read out the same channels I defined as trigger for an Event.

so i changed this to Inputs I only defined for the event:

 

WWolf78_0-1616064180001.png

 

 

and the same (wired into to different inputs):

 

WWolf78_1-1616064250025.png

 

if I press one of the buttons, I can see the system notice this but the Event does not trigger.

 

I don't get the reason why?

 

0 Kudos
Message 14 of 23
(1,045 Views)

Honestly, I think you'd be very well served to take two steps back from your relatively complex overall application and focus on a few details in small bite-size pieces.

 

Let's focus on the change detection stuff first.   Start a brand new vi.  Include *only* a single DO task with only your single E-stop input, which is apparently port0/line25.  Configure the task for change detection and register for a user-defined event.

 

Make an event handling loop that has event cases for *only* this change detection event and a GUI stop button.  Basically, limit yourself to exploring the most basic level of functionality first.  If you have trouble with this simpler example post your *actual code*, not just screenshots of parts of the code.  But if you do it right, and it works, come on back and we can discuss why the approach you took in the latest posting *didn't* work. 

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 15 of 23
(1,042 Views)

looks like thought transference, I was so annoyed I build basic functions to get it working.

 

(if this is the wrong location for this topic i can post elsewhere)

 

so the trials are:

I Have a switch at Line 25 and 27, I want to have an event if I press one of them, Best Case two separate events.

 

first one:

WWolf78_0-1616077448329.png

 

I got an Event when pressing the button at line 25, but none when pressing those at line 26

 

same here:

WWolf78_1-1616077561076.png

 

and here:

WWolf78_2-1616077578307.png

 

 

 

how do I get an Event at pressing either Button at line 25 or 27?

 

(offtopic if anyone knows: any solution for bouncing correction? by pressing the switch I get 15-20 Events)

0 Kudos
Message 16 of 23
(1,037 Views)

and this does not work either:

 

(i got an Event at pressing the button at line 25 but not when pressing the button at line 27)

 

WWolf78_0-1616081035271.png

 

0 Kudos
Message 17 of 23
(1,032 Views)
Solution
Accepted by topic author WWolf78

Remember how I suggested you make just 1 task with just 1 digital line?  None of your 3 approaches do that.  Instead you got into various problems I was trying to help you avoid.  (Don't worry, they aren't going away, you'll get your chance to tackle them later.)

 

Now, let's consider your first approach.  When you configured Change Detection on your task, you told it to be sensitive *only* to line25.  And so only line25 caused an event to fire.  Not much more to be said about that one.

 

Note also that you don't need a loop to put 2 channels into 1 task.  You can right-click a single channel constant, select "Browse...", then use standard conventions like Shift-click to select a range or Ctrl-click to add items separated from one another in the list.

 

Your other 2 approaches attempt to create 2 separate change detection tasks.  Your device won't be able to support that, as I already mentioned back in msg #10.

 

Switches with a lot of bounce may add a whole other level of difficulty.  For starters, I'm not sure whether you'll get a distinct software user-defined event for every hardware change detection event.  It isn't something I've tested at various hardware change speeds.

   And frankly, you probably shouldn't *want* that burst of pre-steady-state software events.  The presence of so much bounce would lead me to a different approach.

   Here's one that comes to mind: one digital change detection task, but don't register for the change detect signal event.  Instead, monitor your digital change detection task in an independent loop.  Figure out your method for identifying the final steady digital state at the end of any bounce. When you see that a change is stable, *then* fire one single software event after the bouncing is all done.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 18 of 23
(1,027 Views)

Thanks!

that was the solution!

 

WWolf78_0-1616403997275.png

this works!

 

 

I thought the Change detection accepts only one input, so I didn't try several ones...

 

regarding the bouncing:

I think I'll try an electronic solution by a schmitt-trigger (e.g. that one :https://www.mikrocontroller.net/articles/Entprellung), the software version will be complex and not so failure resistant as it requires...

 

Thanks for your help!!!

 

0 Kudos
Message 19 of 23
(1,013 Views)

Hello Together,

 

regarding the bouncing i've an update.

 

even with the trigger i sometimes i got two events.

to avoid that i created an software debouncing:

 

time comparison VI:

WWolf78_1-1623150935888.png

 

in the event structure:

 

WWolf78_0-1623150715434.png

 

if an event occurs i take the current timestamp and save this into the shift register

next time an event happens, i compare both times.

test with bouncing elements showed that those created times around 0 - 1ms

manual switching times were about 180 - 500ms,

so i choose to ignore anything below 150ms

 

(maybe this helps another one avoiding the same issue)

 

0 Kudos
Message 20 of 23
(896 Views)