03-14-2020 06:25 PM
Hey all. I have this assignment where I need to build a Vi to show a speed vs time graph of objects falling. I have the front panel built like the text book, but I am having trouble with the block diagram. I assume using the matlab script would be the easiest/best way, but I am having trouble coding this with the given equation. Any help would be much appreciated!
03-14-2020 07:25 PM
No need for Matlab. All you need is a FOR loop and a shift register. I assume the initial velocity is zero, so initialize the shift register accordingly.
03-15-2020
01:48 AM
- last edited on
11-07-2024
12:00 PM
by
Content Cleaner
As altenbach hinted, you only have a single variable here (at least, once the application is running).
Your v value will change over time (i.e. each iteration of a loop) and your time will change over time (i.e. each iteration it will increase by dt) but g and alpha are known before the start (unless alpha can be changed during the "falling" process - I'm assuming not).
Given you know the number of samples ("N"), you can use a For loop and the single Shift Register already mentioned to hold the value you're updating, and calculate "t" via the "i" terminal and a constant dt value of 0.001.
Plotting a Waveform Graph can be done with an array of Y values and a constant dt quite easily. If you only want to plot after the VI finishes the calculation (seems likely here) then you can have an indexing tunnel output for "v" and wire that to the Y input of Build Waveform (Analog Waveform) Function. The other values can be set as required (you might not care about t0).
03-15-2020 07:20 AM
@cbutcher wrote: and calculate "t" via the "i" terminal and a constant dt value of 0.001.
We don't even care about "t" unless we are not building a waveform data type (which would be silly not to use).
But, yes, a simple FOR loop with the numeric functions to do the math and a shift register to hold the velocity is all that is needed.
03-15-2020 08:57 AM
Ok, so this is what I have so far...
Is this what y'all are talking about? If so, how do I write the equation since Vn-1 is not known?
03-15-2020 09:11 AM
V_n-1 is just V from the previous iteration. All you need is an initial condition.
In the image you post, you've connected your dt to the shift register. Probably this isn't what you want - since that's fixed you can just use a normal tunnel or place the constant directly inside the loop.
The shift register is there for your changing value (I.e. V).
As an aside - crossrulz is quite right about the t value - for some reason I thought you needed it during execution for the calculation, but it isn't necessary for the calculation and for a waveform you do not need time values.
03-15-2020 09:13 AM
So how do I connect an empty variable to the shift register?
03-15-2020 09:29 AM - edited 03-15-2020 09:29 AM
03-15-2020 09:31 AM
The object is dropped so initial velo would be 0. So I should connect 0 to the shift register?
03-15-2020 10:09 AM
This is what I have now.