03-13-2017 05:34 PM
Hi everyone, i am new to Labview and i easily lost my way trying to figure some issues on a program i'm working on. So the issue is that i've been trying to establish specific conditions for an event structure, and a while loop, with local variables, results from logic ops.. Well while surfing the internet for some answers, i discovered that it is required to a value(signaling) for the both of the structures to be "recognised".. Sadly i couldn't create one for the local values or the outcome of the logic ops.. i know the issue i mentioned might be stupid, but i'm simply stuck in the mud trying to figure out how to finish a project, with something new to me on a very limited period of time, so your help will be greatly appreciated.. Thanks 🙂
Solved! Go to Solution.
03-13-2017 05:43 PM
Show us some code!
Events typically are for user interactions, not for algorithms. Also local variables are typically for UI tasks, not computations.
What is your program supposed to do? Let's start here!
03-13-2017 06:15 PM
altenbach it's good to see you here, been seeing your posts all over the forum! 🙂
Well i wouldn't say algo are what you'll find in the program but here is the thing:
The program mainly is about a UI that consists of controlling a stepper motor via an Arduino. The stepper motor is attached to a "disk" marked with various position, uuh let's say a marked knob. The user, with the UI, has the ability to change automatically from a position to another without having to intervene manually.. I tried to begin with the command part so i began with something virtual, like virtual sensors etc. The blinking LEDS are equivalent the direction of rotation of the motor.
Anyway the huge amount of repetitions and case structures is because of the issue i previously mentioned, they were a desperate try to turn around it to some degree..
Please bare me with what you're about to witness, it's been about 2 days since started with Labview! ^^"
The 'capteur' are supposed to be position sensors just in case..
03-13-2017 06:32 PM - edited 03-13-2017 06:35 PM
Yes, you need to start with more tutorials. 😄
03-13-2017 06:47 PM - edited 03-13-2017 06:50 PM
will do haha!
Again forgive me for the mess you saw, but just two things, before the stock of case structures you saw i used while loops, the problem is the values do show up, the condition to stop spinning (the results of the logic ops) they show operate correctly only once then the program gets stuck in an infinite loop and no longer responds, and in the event structure, they have no effect at all, only the values coming from the "mechanical" ones work without any issue. Do you have any idea why? And if you do not mind, if i may ask, why is the case event preventing the bigger loop from spinning?
03-13-2017 08:46 PM
Regarding the Event Structure stopping the While Loop from spinning - the while loop will only start the next iteration (i.e. loop) when everything inside itself is finished.
The event structure only does something when one of the 13 cases you've specifically given happens - and since you've set the timeout to '-1', the timeout case never happens (so you could delete that case for timeout = -1 always, or you could make it so the event loop can timeout.) In this case, it seems like maybe you would want to change the timeout value to a small(ish) positive value, but as altenbach mentioned, you might not need it at all if you restructured the code (depending on the real source of input).
Regarding the top Case Structure, you have many cases with the same content as altenbach mentioned, but moreover, each contains three more case structures where only one will ever execute, and the one chosen only changes the timer value. Since this is all the same code in each case, a subVI seems like a good choice, but I've placed below a snippet (you can drag and drop it onto a block diagram) that shows both altenbach's suggestion of grouping the cases, along with some simplification of the cases themselves. The 0 and 7 cases are also joined (with each other), because they also only change the timer value.
03-15-2017 06:29 PM - edited 03-15-2017 06:30 PM
I couldn't be more grateful for your replies, thanks to your advice i got my system somehow working! Thank you so much who ever you are! 😄