LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog output and input step signal

This is my first program I am drawing up and I need to make a program that will output an analog signal that increments after T time by V amount until it reaches M maximum voltage. My goal after that is to take that signal as an input and show it live as it steps up.

 

This is what I had so far but the output not showing what I want it to.

Green144_0-1655392906182.png

 

 

I still haven't implemented the T amount of wait. I am most confused on frequency of signals and continuous vs non.

0 Kudos
Message 1 of 6
(1,486 Views)

When I give my "Introduction to LabVIEW" to Engineering undergraduates (whom I assume have some experience with Programming), I have a slide called "Concept of Time" that has the following Bullet Points:

  • Most Programming Languages ignore Time
  • Time is an intrinsic element of LabVIEW
  • There are functions that "Wait N Milliseconds"
  • Other functions "wait for an Event" to run

I assume you already know about the While.  Have you learned about the Shift Register and how it interacts with the While Loop?  Let's assume your Analog Signal can be represented by a Dbl.  You didn't say where it starts, so let's call it B (for "Begin").  You mention that your Time Step is T (let's make T an integer, representing milliseconds, since that's what the "Wait N Milliseconds" seems to want).  Each step, you want to increment (or "Add") V to whatever value is present in the Loop (which, you remember, started with B).  You keep going until you reach the value M, at which point you stop the Loop.

 

OK.  You can do this with a single While Loop, a single Shift Register on the left (and automagically appearing on the right) edge of the While Loop, which (inside the Loop) will represent the "Current Value".  So where do you want the Loop to start?  [Hint -- it is held in a Control named with a letter near the beginning of the alphabet).  Remembering how Shift Registers work, where should you wire this Control so that the Loop starts with this value?

 

So what happens inside the Loop?  You increment by V.  OK, express that in LabVIEW.  And what do you do with this "incremented Value"?  Well, you want it to be the "next" value (remember how a Shift Register works ...).

 

Only two more variables to place.  How much time do you wait before "looping"?  Use a Time function and wire the "Wait Time" to it.  Finally, what is the condition that says "Stop the Loop, I Want to Get Off!"?

 

Now, here's the neatest part of all -- once you've done this, put a Waveform Chart on your Front Panel and, on the Block Diagram, place it inside the While Loop.  Branch the Wire that (more-or-less) goes from the Left Shift Register to the Right Shift Register (interacting with some other stuff) to the input of the Chart.  When you run your program, you should see your Chart update exactly in time (and value) with the code you are running.  Increase T, it slows down.  Decrease V, the slope decreases.  What happens if you make V negative?

 

Bob Schor

0 Kudos
Message 2 of 6
(1,463 Views)

Wonderful response thank you! Unfortunately I am still not seeing the wave step in comparison to the old data, it is just showing a horizontal line move up with. The graph I am trying to retain is one of a staircase. 

0 Kudos
Message 3 of 6
(1,444 Views)

@Green144 wrote:

Wonderful response thank you! Unfortunately I am still not seeing the wave step in comparison to the old data, it is just showing a horizontal line move up with. The graph I am trying to retain is one of a staircase. 


Attach your LabVIEW code (a file with the extension ".vi", not a picture of the Block Diagram (unless you know how to create a LabVIEW Snippet).  I (or another enterprising Colleague on the Forums) should be able to very quickly "spot the problem" and set you straight.

 

Bob Schor

Message 4 of 6
(1,441 Views)

I couldn't seem to be able to edit the original post so here is a reply with the attempt and my original files attached. 

 

 

Download All
0 Kudos
Message 5 of 6
(1,428 Views)

Hello, Green144.

 

     Close, but no cigar.  [That's a very old saying, and probably not appropriate, my apologies].

 

     I'm taking the liberty of posting a picture of what I had in mind.  With the exception of my substituting a Waveform Chart for the Waveform Graph that you used (I'll explain in just a moment), the rest of the code is (I hope) precisely what I suggested you build.  Notice there are no Express VIs, which (as an educator) I dislike because it hides simple concepts that need to be understood to use LabVIEW effectively.

 

     Charts are designed to work hand-in-hand with "sampled data", where time (an intrinsic LabVIEW datum), particularly equally-spaced times, are involved.  Think of an Oscilloscope (which uses a "Time Sweep") or a Chart Recorder (which scrolls).

 

     When you go to duplicate this VI from the Picture, drop a Waveform Chart on the Front Panel.  On the Block Diagram, right-click the Waveform Chart icon and from the DropDown menu, choose "Create Property Node".  You'll get a long Drop-Down menu.  All the way at the bottom is "History".  Click it and put it somewhere on the Block Diagram (you can move it later).  Put your cursor over the bottom of the Node until you get it to a double-arrow that you can click and draw down one step (to give you a second "History", as that's the last entry).  Left Click on either History -- what you want, instead, is XScale, Multiplier.  XScale is near the bottom, and if you click it, it will open up and you can find Multiplier under "Offset and Multiplier".  What this is doing is setting the time interval being plotted to units of 0.1 sec.

 

     Be sure you place this Property Node outside the While Loop -- you want it to be run before you enter the While Loop.  To ensure it, click on the Error Out connector of the Property Node and drag it to the left edge of the While Loop (where it becomes a Tunnel) -- this guarantees that the Chart is set before it is used.

 

     I know, I'm not supposed to digress into Charts (which you'll use a lot in LabVIEW, probably, more than Graphs), but once I get my Teaching Hat on, it's hard to stop.  Right-click the Chart and select X Scale, Formatting.  It will probably be set to "Absolute Time" (meaning "Time on the Clock", not "Elapsed Time".  Go choose "Relative Time", then click "Advanced Editing Mode".  Change the Format String to "%<%S%2u>t".  The "%<>t" means it's a Relative Time.  The "%S%2u" inside the angle brackets means "Show Seconds and fractions to 2 places" (so 10 seconds will show as 10.00).

 

     Whew.  Now run it.  I hope you like the results.  If it doesn't quite do what you want, right-click where you think the problem lies and see if the online Help suggests so.mething.  [As I recall, there's pretty good Help with Charts and Graphs ...].

 

Bob Schor

 

Oops, forgot to attach the Picture ...

Green144 Lesson.png

 

 

0 Kudos
Message 6 of 6
(1,419 Views)