03-17-2020 07:45 AM - edited 03-17-2020 07:52 AM
Hi 99,
@labview99 wrote:
How can I use this data in another VI?
Change the connector pane of your VI to a more common 4-2-2-4 pattern, then wire the "data received" as output of this VI…
(This is pretty basic LabVIEW stuff you should have learned right in the first LabVIEW lessons you already should have taken from the Training section.)
You didn't take a lot of the suggestion you had so far, there is no learning curve recognizable:
(Forgot to change Velocidad to U8 datatype.)
03-17-2020 07:50 AM
Hi GerdW
I had already thought that, but if I do it that way, that VI is not worth checking all the positions because what input parameters do I put? The ones in the first position? And when do I have to check the second position? Do I repeat the same VI again?
03-17-2020 07:59 AM
Hi 99,
@labview99 wrote:
if I do it that way, that VI is not worth checking all the positions because what input parameters do I put? The ones in the first position? And when do I have to check the second position? Do I repeat the same VI again?
This VI has two input parameters: Posicion and Velocidad. When you need more, then you need to provide more inputs…
Your statemachine will call this VI, when it needs to be called: the state changes define when to call which state…
03-17-2020 08:04 AM
I don´t need more inputs. The problem is that if I call this VI when the position and speed are different, it won't be worth it
Best regards
03-17-2020 08:07 AM
@labview99 wrote:
Hi GerdW
I had already thought that, but if I do it that way, that VI is not worth checking all the positions because what input parameters do I put? The ones in the first position? And when do I have to check the second position? Do I repeat the same VI again?
Generally the purpose of a subVI is to encapsulate (enclose, contain) some code that we don't want to write over and over again, but do want to use repeatedly.
They behave like functions in more common text-based programming languages.
So when you check the first position, wire the first position values.
When you check the second, wire a different input via a control that you've connected to the connector pane.
Make things you want to change about your function between calls Controls that appear on the Connector Pane (i.e. parameters/arguments in a function) and things you don't want to change, don't put on the connector pane.
This allows reuse of the code in multiple situations.
Consider the following:
Here I have a subVI that adds a random value between 0 and 1 to the input value. It doesn't know (when I write it) what the input value "Offset" will be.
When I place it in a caller, I pass it a different argument each call (via the For loop) and then get an array of results, one per iteration.
The subVI is called one time for each iteration and uses a new argument.
03-17-2020 08:08 AM
@labview99 wrote:
I don´t need more inputs. The problem is that if I call this VI when the position and speed are different, it won't be worth it
Best regards
The entire point is to allow calling with a different speed and position value.
03-17-2020 08:31 AM
Hi,
I attach the programs that I have done.
I think I can't do it like that because this is worth it to me to send it to a position and check about that position. In the program that I have attached when I go to position 2 and want to check that it has reached the correct position, how do I then send it to position 3? because I have already connected that if it is true that you have reached the correct position go to the state of the machine of "position2"
Best regards
03-17-2020 08:38 AM
I feel like despite your hundreds of posts on the forum, you never quite seem to learn from the responses people give you. 😞
You would do the same thing in Position 3 case that you have already done in Position 2.
You failed to wire your case selector to the output of the shift register and instead wired it to an enum control. That control should be turned into a constant to tell your VI what state to start in, and wired into the shift register on the left hand side of the loop.
03-17-2020 08:42 AM
So I have to get a new state to check if it has reached correct position 3 too?
Best regards
03-17-2020 08:51 AM
Yes.
But if you really thought long term, you'd realize a move state and a position state could be used by 2, 3, 100, N positions without needing to duplicate them every time. You would put your positions and velocities in an array. You would put an integer in your state machine with a shift register. That way when you want to move to the next position, you would increment the integer in the shift register and move to the next state of "move". Then the Move state will select the correction position and velocity out of the array based on the value out of the shift register.