Jump to content

Error "...is a member of a cycle" during simulation


Recommended Posts

Hello. This is my first post here, so I apologize in advance if an answer to my problem has already been provided somewhere.

I have to model and simulate a gantry crane in LabView for my engineer's thesis. The draft looks like this:

WqOc10F.png

Here are the final equations for the model:

i32uJTc.png

Since I'm not really big on all the modeling stuff like transfer functions etc. I used the simplest way I know to model this - by using summation, gain, multiplication and integrator blocks in a simulation loop and then wiring all the necessary parameters. However, I stumbled upon a problem after finishing the wires... (Sorry in advance if it looks a little messy)

Ro7deiM.png

So, all the broken wires are a part of a cycle and I can't run the simulation. I know that this is due to the fact that the second derivative of x is dependent on the second derivative of phi while the second derivative of phi is also dependent on the second derivative of x, and I know it all has something to do with Direct Feedthrough and I need to make it into Indirect Feedthrough using a function which has Indirect Feedthrough in it, but I don't quite understand how to utilize it here.

Could anyone please lend me a hand here? I'd really appreciate a fast and simple answer, since I'm kind of short on time for this.

Link to comment

A broken wire is like a syntax error in a text-based language; you have coded something that is not valid. This is not to say you've implemented the formula correctly, but something you've coded does not meet the language requirements. It's like "Jane walks" is a valid sentence (noun and verb), but "Jane Billy" is not (noun and noun).

If you select View->Error List then a window will appear providing the reason the wires are broken.

Link to comment

As I stated, I know the reason why the wires are broken, I just don't know what to do to fix them. Viewing the Error List won't help much, because it just tells me that the parts of the diagram are interdependent, but doesn't say what to do specifically to fix it.

Link to comment

So what are the messages?

Just occurred to me that you have a simulation with no feedback nodes or shift registers. Both are used to send values from one instance of a loop to the next. Without the messages, I would guess your problem is the compiler is trying to find someplace to start and is looping back on itself.

Link to comment

Yes, the messages, as I said in the thread title, are saying this:

AVnC3mT.png

The details are exactly the same for all messages.

I know I probably need some feedback nodes, or something else with indirect feedthrough, but I don't know where to put it and how to configure it. I'm still pretty new to LabView, modeling and simulation.

Edited by Shleeva
Link to comment
8 hours ago, Jordan Kuehn said:

Looking at the equations suggests to me that the issue is not the code, but the equations themselves.  They rely on each other cyclically... 

That's fine in mathematics. Writing equations like this provides a concise yet complete way of describing a system. However, this format doesn't lend itself nicely to programmers' code.

 

On 1/25/2017 at 5:30 AM, Shleeva said:

I have to model and simulate a gantry crane in LabView for my engineer's thesis.

...

I'd really appreciate a fast and simple answer

The easiest answer for you is one that you already understand.

So tell us: What techniques have you learnt in your engineering course for solving differential equations in LabVIEW (or in any other software environment, like MATLAB or Mathematica)?

 

On 1/25/2017 at 5:30 AM, Shleeva said:

Here are the final equations for the model:

i32uJTc.png

Since I'm not really big on all the modeling stuff like transfer functions etc. I used the simplest way I know to model this - by using summation, gain, multiplication and integrator blocks in a simulation loop and then wiring all the necessary parameters.

I haven't used the Control & Simulation loop before so I don't know what features it has for solving differential equations.

However, the first thing I'd try is to substitute the top equation into the bottom equation, and see if that allows you to solve for φ.

If not, then my analysis is below.

 

--------

Those are Differential Equations, which describe "instantaneous", continuous-time relationships. You can't wire them up in LabVIEW as-is to solve for x and φ.

I would first convert them into Difference Equations, which describe discrete-time relationships. Difference Equations make it very clear where to insert Feedback Nodes or Shift Registers (as mentioned by Tim_S), which are required to resolve your "member of a cycle" problem.

You'll also need to choose two things before you can simulate/solve for x and φ:

  1. Your discrete time step, Δt. How much time should pass between each iteration/step of your simulation?
  2. Your initial conditions. At the start of your simulation, how fast and which directions are your components moving?
Link to comment
5 hours ago, JKSH said:

So tell us: What techniques have you learnt in your engineering course for solving differential equations in LabVIEW (or in any other software environment, like MATLAB or Mathematica)?

I don't need to really solve anything myself, because the Simulation loop in LabView has built-in ODE solvers (like Runge-Kutta) for different equation orders, and can include a fixed or a variable time step.

 

5 hours ago, JKSH said:

However, the first thing I'd try is to substitute the top equation into the bottom equation, and see if that allows you to solve for φ.

That's what I tried doing next, and it did allow me to solve for φ, but it returns some weird values. And I also need to solve for x somehow, and it repeats the error in φ.

 

5 hours ago, JKSH said:
  1. Your initial conditions. At the start of your simulation, how fast and which directions are your components moving?

I think that this is might actually be the core of the problem here. The initial conditions for x and φ should both be 0, but I just don't know how to set them in this loop.

Link to comment
On 1/27/2017 at 4:38 PM, Shleeva said:

the Simulation loop in LabView has built-in ODE solvers (like Runge-Kutta) for different equation orders, and can include a fixed or a variable time step

That's quite cool.

Note that your system is non-linear (due to the sine and cosine functions). Do you know if those built-in ODE solvers cope well with non-linear systems?

 

On 1/27/2017 at 4:38 PM, Shleeva said:

That's what I tried doing next, and it did allow me to solve for φ, but it returns some weird values. And I also need to solve for x somehow, and it repeats the error in φ.

It's best to get it working for φ alone first (meaning you need to make sure all your values are non-weird), before you even consider solving for both x and φ at the same time.

One quick and dirty technique is to take your "solved" φ variable, pass it through differentiator blocks to calculate (d^2 x / d t^2), and then pass that through integrator blocks to find x. This will avoid the "member of a cycle" problem, but might cause errors to accumulate.

 

On 1/27/2017 at 4:38 PM, Shleeva said:

The initial conditions for x and φ should both be 0, but I just don't know how to set them in this loop.

See http://zone.ni.com/reference/en-XX/help/371894H-01/lvsim/sim_configparams/

Link to comment
On 29.01.2017 at 5:37 AM, JKSH said:

Note that your system is non-linear (due to the sine and cosine functions). Do you know if those built-in ODE solvers cope well with non-linear systems?

They make do, although they can put a massive strain on the processor - in my other model, where I have to calculate the position of a pendulum driven by a DC motor and then visualize it, there are some sine and cosine functions to compute and my computer has a hard time doing the calculations in real time. There are other solvers, like SDIRK 4, which can speed it up a bit, but it's still a big hassle for the processor and I'm forced to set the simulation timestep pretty high (like 0,1 s) so that it eases some burden but makes the simulation and visualization choppy.

On 29.01.2017 at 5:37 AM, JKSH said:

 

One quick and dirty technique is to take your "solved" φ variable, pass it through differentiator blocks to calculate (d^2 x / d t^2), and then pass that through integrator blocks to find x. This will avoid the "member of a cycle" problem, but might cause errors to accumulate.

I've already tried this workaround, and unfortunately the results where nowhere near what they should've been.

On 29.01.2017 at 5:37 AM, JKSH said:

Unfortunately these settings are only for configuring the simulation parameters which determine the way the simulation is run, like the solver of choice and the time step, or timing settings which allow you to synchronize the simulation with a specific source to make the simulation run at a desired speed.

Link to comment
On 1/25/2017 at 1:09 PM, Shleeva said:

I know I probably need some feedback nodes, or something else with indirect feedthrough, but I don't know where to put it and how to configure it. I'm still pretty new to LabView, modeling and simulation.

Fair warning: I haven't touched CD&Sim toolkit in 6 years, but I wanted to try to help out.

I think your cycle is outlined by the blue arrows below.  Have you tried adding a feedback node in the red box below? You may also need one in the green box, not sure.  I don't have the CD&Sim toolkit, but my gut tells me this would at least fix the "Wire is a member of a cycle" errors.

mjzvirt.png

 

P.S. Feedback nodes are in the Structures palette.

bNmVC17.png

 

  • Like 1
Link to comment

Yes, the blue arrows do outline the cycle. I put a Feedback Node in the red rectangle and wired 0 to the Initializer Terminal and the cycle error got fixed so I was able to run the VI, but the graph wouldn't even move forward, so it doesn't work properly. And when I put an additional Feedback Node in the green box with 0 wired to the Initializer Terminal, I got a new error (sorry but somehow I can't post the screenshot, so a quote will have to do):

Quote

 

Control and Simulation Loop 'Control and Simulation Loop': VI failed to compile.

Details: An error occured in compiling this VI.

 

and the "Show Error" button just points to the whole Simulation Loop. Maybe I should put a different value for the Initializer Terminal?

Link to comment
On 1/31/2017 at 6:55 AM, Shleeva said:

I put a Feedback Node in the red rectangle and wired 0 to the Initializer Terminal and the cycle error got fixed so I was able to run the VI, but the graph wouldn't even move forward, so it doesn't work properly. And when I put an additional Feedback Node in the green box with 0 wired to the Initializer Terminal, I got a new error

This is just a guess, but I think the Control and Simulation (C&S) loop treats your code as a continuous-time model, and does some conversion behind-the-scenes to produce a discrete-time model for simulation. A feedback node breaks time continuity, so it's quite possible that the feedback nodes would interfere with the C&S loop's ability to solve your equations.

I don't have the toolkit installed so I can't play with it, but I'm not sure if the C&S Loop is capable of solving such complex simultaneous differential equations like yours.

I would still do some calculus and algebra to make your equations more simulation-friendly first, before feeding them into LabVIEW. For example, it's pretty easy to get an expression for x. See:

...where y = φ, A = F/(M+m), B = m*l/(M+m), C = constant of integration (related to initial conditions).

 

If you still want to try to get the C&S loop to process your equations unchanged, try asking at the official NI forums and see if people there know any tricks: http://forums.ni.com/

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.