LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Osciloscope with function generators

I' m doing some simply osciloscope for school and I have few question about it.

 

1. Is it true that one program can only have one event structure? Because when
I do another program is blocking.

2. When I change something on the front panel it doesn't register until I change
something inside the event structure. How do I set up to receive new data?

3. How do I make that all data from the knobs are taken when starting the program?

 

0 Kudos
Message 1 of 10
(3,214 Views)
  1. You can multiple event structures in the same VI, but conflicts can occur if not properly implemented.
  2. A few thoughts. Each while loop iteration you are generating entirely new data.  This data will not be included in the signal until the while loop restarts.  The while loop will not continue until an event specified in the structure occurs.  You can test this by trying to press the stop button. 
  3. Do you need the event structure? If you’re regenerating the data each iteration any way, why not just remove the event structure all together?
0 Kudos
Message 2 of 10
(3,161 Views)

@mgudel00 wrote:

1. Is it true that one program can only have one event structure?

You can have more than one, but here you only need one.

2. When I change something on the front panel it doesn't register until I change something inside the event structure. How do I set up to receive new data?

I'll describe one method that will work for your code.

3. How do I make that all data from the knobs are taken when starting the program?

I'll describe one method that will work for your code.

 


There are a number of ways to do this, but here is one suggestion:

  • Create two Clusters, "FG Controls" and "Osc Controls".  In "FG", put all of the Controls for your Function Generators, and in "Osc", all of the Controls for your Oscilloscope.
  • Make a Type Def for each Cluster.  This is very important, as it will (a) let you add and remove controls to the Type Def as needed, and have the changes propagate everywhere they need to (saves lots of time looking for "forgotten wires").
  • We're going to make a Producer/Consumer Design Pattern linking your Event Loop to your Main Loop.  You can learn about this by opening LabVIEW, going to File, New ... (the dots are important), and choosing New, VI, From Template, Frameworks, Design Pattern, Producer/Consumer Design Pattern (Events).  This will create an example with documentation that explains what I'm saying.
  • My suggestion is to have your code consist of three parts -- an Initialization where you feed each of the three groups of Controls into three Bundle-by-Name Clusters (defined in the first point, above), so now all of your controls are held in (only) three Wires, greatly simplifying your design; a "top loop" consisting of a While Loop surrounding an Event Structure that tracks changes to any of the controls and serves as the "Producer"; a "bottom loop" that is another While Loop that contains a Case Structure that executes your code, also acting as the "Consumer".
  • Your code now consists of (to the left) an Initialization that produces three Cluster Wires containing all your Controls, an Event Loop, and a "Main" Loop.  Put three sets of Shift Registers into the two loops and initialize them with the three Cluster Wires produced in the Initialization Code.
  • Now the goal for each loop is much simpler.  The Event (Producer) Loop will fire when any Control changes.  It updates its copy of the relevant Control Cluster Wire in its Shift Register, then (via a Queue) sends the information to the Main Loop to get it to updates its copy of the Cluster Wire.

Oops -- sorry, I was not looking at the clock, and have an appointment soon.  I'll try to come back here this afternoon, and if someone else hasn't materially solved your question, I'll come back and continue.  One thing I'll look at, in the meantime, is just how well the Example Producer/Consumer template matches what I'm trying to convey (so I don't lead you too far astray).

 

Bob Schor

0 Kudos
Message 3 of 10
(3,152 Views)

Thank you a lot. I found something on youtube about clusters and I think I know how to do it now. 

Also, I found something about Costumer/Producer Design but I don't have an idea which parts I need to put in which loop. Is the way how loops are connected unique or I have to adapt  it to my project?

 

 

0 Kudos
Message 4 of 10
(3,144 Views)

I create event structure because without it a knobs for changing V/division wasn't work well. And it was the best way for solve that problem (which I know). If you have an better idea I would be happy if you share it with me.

0 Kudos
Message 5 of 10
(3,143 Views)

Aha!  Your questions show that you really do not know enough about LabVIEW to be undertaking such an ambitious Project.

 

So the first question to ask is -- Do you want to learn LabVIEW?  On the plus side, it is not as difficult to learn as some other Programming Languages, largely because it is graphical and a bit more intuitive than some, and it is kind of fun to use.  On the minus side, it does take some time and effort on your part.

 

The second question is -- what resources do you have?  Are you currently in school?  High school, college, or graduate school?  Do you have some familiarity with engineering disciplines (even casual, like an "interest")?  Are there faculty or "gurus" around?

 

If you look at the first page of the LabVIEW Forums, there are a number of tutorial possibilities listed.  Depending on your answers to the second question, some of these might not be available to you, but I strongly encourage you to spend a day or two doing as many of the basic tutorials as you can to get more familiarity with LabVIEW, its functions, and its behavior.  You should find the answers to the questions you asked in response to my earlier post.

 

In the meantime, I'm going to explore coming up with an example Project that illustrates some of what I was starting to say in my earlier post, which I now realize is "over your head" at your current level of experience.  It may take me some more time, so spend it with the tutorials (and do answer my questions so I'll know what needs more explanation).

 

Bob Schor

0 Kudos
Message 6 of 10
(3,139 Views)

Exactly. This project is the first thing what I have done in LabVIEW.

 

I chose to make an osciloscope in LabVIEW for the final work on college. All I was know (before) about it is that it is some graphical language and that I can make osciloscope in it. So, all I know is what I done in it. 

The basic source of my knowledge about it is youtube and generaly internet.

Ye, I want to learn LabVIEW because it looks interesting to me. 

 

Now when you told me what to do I will explore it. Thank you very very much!!

 

I'm not very good in English so I hope you will understand what I wrote. 

Have a good day 😄

0 Kudos
Message 7 of 10
(3,136 Views)

Kudos to you for being so willing to learn!  As a "reward", and to give you some incentive to explore some code and figure out "What was he thinking?", I threw together some ideas about how I would make a Function Generator using some of the principles I mentioned in my earlier post.

 

Here are some things that are probably new to you, but which I encourage you to learn about and to use as you start playing with LabVIEW:

  • LabVIEW Project.  This is a method to organize pieces of a LabVIEW "project" so that everything opens and closes at the same time.  I organize my LabVIEW Projects to match the Folder Structure on my disk (though this is not required).
  • Enums.  This is a way to allow you to handle (small integer) numeric data (for example, your Waveform dial, where "Sine" returns 0, "Square" returns 1, etc.  An Enum is just a way to create a list of names that will be associated with small integers, so I created an Enum I called Waveform that starts with Sine, Square, etc. (cleverly chosen to exactly match the values coming from your Waveform Control).
  • Type Defs (or Type Definitions).  For every Enum that I create and every Cluster that I define, I create a TypeDef, LabVIEW's way of "freezing" the Definition.  There are a number of important examples, not the least being that it allows you to set rules for variables and wires that carry these types.  If you decide, for example, to add another Waveform to your Function Generator, you edit the Enum (for example, you might decide to make Uniform Noise and Gaussian Noise as Waveforms).  Doing so will probably "break" things, but when you "repair the errors", you'll do so by writing the code you need for your new Types.  This Example has two -- ENUM Waveform and TYPE Function Generator.
  • The same way you use Type Defs to encapsulate and "isolate" variable structures, you should use sub-VIs to "hide the details" and encapsulate functionality in your code.  A good rule of thumb is no Block Diagram should be bigger than would fit on a single Laptop Screen (so no fair using 27" huge desktop monitors -- you'll write much better LabVIEW code if you restrict your desktop environment to using a 15" or 17" monitor, as it (should) force you to use sub-VIs.  Normally any Project I write has hundreds of sub-VIs, but each is small, simple, and easy to understand.
  • Learn to use the LabVIEW Icon Editor and create an Icon for every sub-VI and for every TypeDef that you create.  Also, particularly for sub-VIs, write a brief description (right-click the Icon/connector image in the upper-right corner, choose Properties, and find Description) that include 1-2 sentences about What It Does and lists the Inputs and Outputs, much like the LabVIEW Help for functions.
  • Try to always use the 4-2-2-4 (which I believe is the default in LabVIEW 2014) connector pattern for your sub-VIs.  Error In and Error Out should always be part of your design, and should be in the lower left and lower right corners.  Note that this means you shouldn't have too many inputs or outputs -- one of each is OK, more than three is problematic.
  • Note the use of Clusters to bundle together multiple related wires.
  • Don't be afraid to develop your own Style for LabVIEW Programs.  You'll notice elements of my own Style -- adding CAPITAL prefixes to LabVIEW source file names and separating TypeDefs to their own folder (I'd also have a Sub-VI folder, except I don't have any sub-VIs in this example).  Do whatever helps you keep organized.  If you do anything somewhat sophisticated, you'll either have one huge Block Diagram with hundreds of wires that will be almost impossible to manage, or many small Block Diagrams with many sub-VIs, and having a naming Style will help you keep order.

Good luck with your endeavors.  Don't worry about your English -- it is much better than my Polish!

 

Bob Schor

Message 8 of 10
(3,131 Views)

I've seen there are projects. But I didn't know how to realize the oscilloscope so I often changed a parts. So it was complicated to me. 

Also, I was thinking of making a separate function generator from the oscilloscope, but I didn't know how to connect them, so I gave up.

Thank you once again 😄

0 Kudos
Message 9 of 10
(3,122 Views)

Hi Rob I hope you're doing well 

I have questions about sending data from this function generator by mqtt

Please give me your email I want you to see what I did

0 Kudos
Message 10 of 10
(1,220 Views)