Shleeva 0 Posted January 24, 2017 Report Share Posted January 24, 2017 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: Here are the final equations for the model: 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) 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. Quote Link to post

Tim_S 70 Posted January 25, 2017 Report Share Posted January 25, 2017 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. Quote Link to post

Shleeva 0 Posted January 25, 2017 Author Report Share Posted January 25, 2017 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. Quote Link to post

Tim_S 70 Posted January 25, 2017 Report Share Posted January 25, 2017 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. Quote Link to post

Shleeva 0 Posted January 25, 2017 Author Report Share Posted January 25, 2017 (edited) Yes, the messages, as I said in the thread title, are saying this: 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 January 25, 2017 by Shleeva Quote Link to post

Tim_S 70 Posted January 26, 2017 Report Share Posted January 26, 2017 Searching for the message on NI's website gives you a lot of hits including a better description of what the message means. Connecting an output to an input breaks LabVIEW code. Putting feedback nodes and shift registers in allows you to fix the where the code is broken. Quote Link to post

Jordan Kuehn 78 Posted January 26, 2017 Report Share Posted January 26, 2017 (edited) Looking at the equations suggests to me that the issue is not the code, but the equations themselves. They rely on each other cyclically... Edited January 26, 2017 by Jordan Kuehn Quote Link to post

JKSH 82 Posted January 27, 2017 Report Share Posted January 27, 2017 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: 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 φ: Your discrete time step, Δt. How much time should pass between each iteration/step of your simulation? Your initial conditions. At the start of your simulation, how fast and which directions are your components moving? Quote Link to post

Shleeva 0 Posted January 27, 2017 Author Report Share Posted January 27, 2017 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: 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. Quote Link to post

JKSH 82 Posted January 29, 2017 Report Share Posted January 29, 2017 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/ Quote Link to post

Shleeva 0 Posted January 30, 2017 Author Report Share Posted January 30, 2017 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: See http://zone.ni.com/reference/en-XX/help/371894H-01/lvsim/sim_configparams/ 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. Quote Link to post

dterry 3 Posted January 30, 2017 Report Share Posted January 30, 2017 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. P.S. Feedback nodes are in the Structures palette. 1 Quote Link to post

Shleeva 0 Posted January 30, 2017 Author Report Share Posted January 30, 2017 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? Quote Link to post

dterry 3 Posted January 31, 2017 Report Share Posted January 31, 2017 My guess is the green FB node wasn't necessary. I would remove it and use standard debugging techniques to with the problem. Do highlight execution and probes work in sim loops? Quote Link to post

JKSH 82 Posted February 2, 2017 Report Share Posted February 2, 2017 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: Finding dx/dt: http://www.wolframalpha.com/input/?i=Integrate+A-B*(d^2y%2Fdt^2*cos(y)+-+(dy%2Fdt)^2*sin(y))+with+respect+to+t Finding x: http://www.wolframalpha.com/input/?i=Integrate+A*t-B*(dy%2Fdt*cos(y))+%2B+C+with+respect+to+t ...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/ Quote Link to post

## Recommended Posts

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.