LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Event Structure VI, but having issues getting it to work.

I have an overall pretty simple VI, but it is the first time I am trying to use the event structure and having some issues with it. The signal I am capturing comes from a hand driven wheel. Due to this I do not want to continuously have data being saved. The wheel has a reference encoder inside of it as well. What I would like to do is for every pulse of the reference encoder have labview save the value of the input signal at that exact moment for one full revolution. I've attached my current VI, the left loop just waits for the index to pulse before starting to gather data. Then, the right loop is used for the actual data acquisition. The reference encoder has 8192 pulses per revolution, which is why that is the stop condition. The problem I am having is that when I run the VI the first part works, when it sees the index it switches to the other loop, but the loop with the event structure doesn't capture any data. The array remains empty. I'm thinking I have something not right about the event structure, since I've never used them before, and that is causing the issue.   

0 Kudos
Message 1 of 11
(3,263 Views)

Can you attach your VI instead of a picture.

0 Kudos
Message 2 of 11
(3,248 Views)

Here is the VI.

 

It is slightly different than picture as I was playing with the array thinking if I moved it outside the loop it may fix the issue.

0 Kudos
Message 3 of 11
(3,239 Views)

Your code makes no sense. What would cause a change in the channel names and trigger the event, ever? (And if you would manually change them at run time, they would not make a difference to the configuration because that code has passed).

 


@randomguy77 wrote:

... I was playing with the array thinking if I moved it outside the loop it may fix the issue.


 

Why would turning the 2D array into a 3D array using an autoindexing while loop tunnel would make any sense or "fix" any issue? That 3D array indicator will only get data once the loop completes.

 

Why is there a timeout event if you don't wire a timeout value.

 

Why are there 3 instances of "read scan"? If you would design the code as a proper state machine, you would only need exactly one.

0 Kudos
Message 4 of 11
(3,225 Views)

What would cause a change in the channel names and trigger the event, ever?

 

I'm not following. Is the even not set up for a change in value? The channel name part is just for the channels to scan, but doesn't effect the actual event right?

 

Why would turning the 2D array into a 3D array using an autoindexing while loop tunnel would make any sense or "fix" any issue? That 3D array indicator will only get data once the loop completes.

 

Because I'm not an expert at labview, and don't know how everything interacts within it.

 

Why is there a timeout event if you don't wire a timeout value.

 

It just came with the event structure. I don't want it to time out, and read that if you don't wire anything to it the default is -1 meaning it won't timeout.

 

Why are there 3 instances of "read scan"? If you would design the code as a proper state machine, you would only need exactly one.

 

Literally have zero idea how to do that.

0 Kudos
Message 5 of 11
(3,215 Views)

The "value" of the channel name control is the entered "name". It has nothing to do with the data.

 

Event structures are primarily used to handle user interactions on the front panel (few exceptions). I would strongly recommend to go back to the tutorials.

 

(Sorry, posting by phone)

0 Kudos
Message 6 of 11
(3,186 Views)

After looking back at the event I realized the error and changed it to "Digital Input Ports.Digital Input Ports:" Value Change which I would believe to be the correct event for a changing value right? I ended up looking up state machines for labview and understood how to do them, just never called them that. C is my main programming language, and tend to just use what things are called there in labview as well.

 

Let me ask this then. Is the case structure the best tool for capturing data at a specific point from a reference signal? With the input signal being generated from a hand turned wheel, so not a constant speed, what is the best way to capture the current values during every pulse from the reference signal?

0 Kudos
Message 7 of 11
(3,175 Views)

@randomguy77 wrote:

After looking back at the event I realized the error and changed it to "Digital Input Ports.Digital Input Ports:" Value Change which I would believe to be the correct event for a changing value right?


No. Same problem. You get a trigger it the user make a different selection in the listbox. And since the code has already read that control, the new value will not make a difference. Don't use an event structure and just poll the instrument at regular intervals.

0 Kudos
Message 8 of 11
(3,159 Views)

So then using a case structure instead of an event structure would work better? Pretty much outside the case case check to see if the pulse has gone high, and if it has then use that to trigger the case and capture the data at that exact point?

0 Kudos
Message 9 of 11
(3,150 Views)

Why not capture all the data and discard what you don't want?

0 Kudos
Message 10 of 11
(3,145 Views)