LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple pendulum graph

Hello everyone, 

can anyone please show me how a block diagram is supposed to look for setting up a simple harmonic oscillator and plotting a graph that emulates the pendulum motion (which can be supported with a plot of the angular displacement vs time)?

0 Kudos
Message 1 of 28
(720 Views)

On the front panel, I would use an xy graph with two points, one fixed and one for the end of the pendulum. Use round points interpolated with a line. Personally, I would use complex math to model the pendulum. You probably need some controls to set initial conditions and parameters, restart the simulation, and stop the program.

 

The block diagram depends on many requirements but typically a state machine is useful. What are controls that can change during execution? What are the starting parameters (damping, starting angle, mass, gravity, etc.). In general, you would need a toplevel loop and a shift register to keep track of the state.

 

In any case, there is no such thing as "supposed to look like". If you give this task to a million skilled LabVIEW programmers, you'll get a million different diagrams.

 

Can we assume that have had some basic LabVIEW training and maybe use the learning resources listed at the top of the forum? Is this a homework problem? Do you know all the required math and just need LabVIEW help or do you need help with both? Show us what you tried and where you got stuck. See how far you get.

0 Kudos
Message 2 of 28
(703 Views)

This is my first time using LabVIEW. Yes this is an assignment. 

 

Do you know if I need to use a formula node for each numeric constant's formula? I have inserted an image of what I have so far. I know there are a lot of mistakes, i'm just unsure of how to fix them or what to do instead. 

 

Thank you 

Screenshot 2024-12-09 at 02.09.20.png

0 Kudos
Message 3 of 28
(678 Views)

does this block diagram make more sense for a pendulum? 

block diagram.png

0 Kudos
Message 4 of 28
(672 Views)

@helloworld1111111 wrote:

does this block diagram make more sense for a pendulum? 

block diagram.png


 

Sorry, these are just pictures and none of them make any sense in terms of dataflow.

 

For example here you have a FOR loop that is cut off on top, so how are we supposed to guess what's there? The output of tick count is a 32bit ms counter and only relative values between two readings make any sense. You are not using them in any reasonable way. Then you have two independent while loops that generate the same data as fast as the computer allows and only once both loops are stopped manually will you ever see anything in the xy graph. Dataflow principle!

 

You need one toplevel while loop containing all data generation and output terminals. You can use the iteration terminal to calculate elapsed time based on the defined loop time. No interactive inner loop as shown in your previous picture. And no, you definitely never need a formula node for graphical programming. It is all basic math, I doubt you should use any express VIs at all, not even for the xy graph.

 

You need to learn the basics, maybe look at your course notes. Your code shows a complete lack of understanding.

0 Kudos
Message 5 of 28
(660 Views)

I am sure you searched this forum, but if you have not, here's a tiny VI to get you started that just simulates a pendulum in zero gravity and no damping (It will just spin forever!). Just expand the code with the additional requirements. Also read my comments here.

0 Kudos
Message 6 of 28
(658 Views)

Hello, thank you for the help! I managed to create a simple pendulum. However, I need to add damping to my code but I'm not entirely sure of how to do that. Do you have any tips or could there be any tutorials on here that could help me? I have attached an image of my code so far below

 

0 Kudos
Message 7 of 28
(482 Views)

Please attach "runnable code", which usually means "Attach the VI, the file whose extension is ".vi".  

 

Do you understand the code that (I'm guessing) you copied from some other Forum user?  Is it obvious to you why the indicator "SMH damped" doesn't do very much?  Do you understand the math that you are doing?  [A useful thing to help you remember "what you are doing" would be to put a text comment (double-click on a blank area of the Block Diagram and start typing in the Comment block that appears) that explains the formula you are evaluating.

 

To pass this course (and/or to get gainful employment using LabVIEW skills), you need to be able to go from "formula" or "computational task" to code (whether LabVIEW "pictures", C++/Python "text", or Web HTML).  This requires some effort on your part, which we are trying to encourage.

 

Bob Schor

0 Kudos
Message 8 of 28
(471 Views)

Hello, 

 

I have attached the runnable code. 

 

I used a code skeleton and expanded it. No I don't understand why the indicator doesn't do very much, I'm assuming its because I need to add a shift register? However I am not sure how to add a shift register in a while loop because there is no input of the count terminal. Thanks for the tip, I will work on the text comments. 

 

Also, I was wondering if I needed to use a case structure? 

0 Kudos
Message 9 of 28
(433 Views)

You should "save for previous" before attaching (2019 or below) so more can look at your code. Make sure the code is runnable right away, for example all controls should have reasonable default values.

 


@helloworld1111111 wrote:

I used a code skeleton and expanded it. No I don't understand why the indicator doesn't do very much, I'm assuming its because I need to add a shift register? However I am not sure how to add a shift register in a while loop because there is no input of the count terminal.


A shift register has nothing to do with an indicator. To create a shift register, right--click the loop boundary. Have you done any of the tutorials yet?

 


@helloworld1111111 wrote:

Also, I was wondering if I needed to use a case structure? 


You need a case structure if your code should have alternative code depending in a condition.

 

 

0 Kudos
Message 10 of 28
(405 Views)