Jump to content

General Code


meocop

Recommended Posts

Hello,

In my application, I have two xy graphs, one for the North and the other for the South. So depending on what the user input is (N or S), I want to plot the information on the correspondent graph. I used Match True/False string to capture the user input, then use a Case structure to pass my information to the correspondent graph. I does not work. Please see my attached VI and help!!!

Download File:post-4960-1159977483.vi

Link to comment
Hello,

In my application, I have two xy graphs, one for the North and the other for the South. So depending on what the user input is (N or S), I want to plot the information on the correspondent graph. I used Match True/False string to capture the user input, then use a Case structure to pass my information to the correspondent graph. I does not work. Please see my attached VI and help!!!

A cursory look at your VI tells me that the Case Structure has the same outputs in both the cases. That would not work.

-Khalid

Link to comment
Hello,

In my application, I have two xy graphs, one for the North and the other for the South. So depending on what the user input is (N or S), I want to plot the information on the correspondent graph. I used Match True/False string to capture the user input, then use a Case structure to pass my information to the correspondent graph. I does not work. Please see my attached VI and help!!!

Your graph will display data if you turn on autoscaling for the y axis.

You haven't really stated the problem so I can understand it, the example code is a big mess with no effort made to document it, or make it neat for reading. Also, it sounds a like like school work. For those reasons I am not going to be very specific with my help. If you make it hard for us to even read the code or understand its goals then it is much less likely you will get useful advise.

Please understand that good advise actually takes work to think up and present. You should be willing to work fairly hard in order to get hard work from us. If you have worked hard I can not tell. It just looks like a big sloppy mess. Sending us code is a good first step, but it needs to be quality work to the best of your ability. An extreme minimum of effort on your part is that we should not have to move icons around just to see where your wires go. Your code is unreadable.

Consider this methodology:

Take the problem one step at a time.

First generate good data. And check the data before moving on to the next step. There is no point in trying to graph nonsense. You give no clues as to what the data should look like so I can't guess if it is the generation of it that is a problem or the display.

I suggest you place probes or indicators much earlier in the dataflow so you can see if you are doing anything like what is needed. Or scrap the whole vi and start over with simples steps.

Mike

Link to comment
Your graph will display data if you turn on autoscaling for the y axis.

You haven't really stated the problem so I can understand it, the example code is a big mess with no effort made to document it, or make it neat for reading. Also, it sounds a like like school work. For those reasons I am not going to be very specific with my help. If you make it hard for us to even read the code or understand its goals then it is much less likely you will get useful advise.

Please understand that good advise actually takes work to think up and present. You should be willing to work fairly hard in order to get hard work from us. If you have worked hard I can not tell. It just looks like a big sloppy mess. Sending us code is a good first step, but it needs to be quality work to the best of your ability. An extreme minimum of effort on your part is that we should not have to move icons around just to see where your wires go. Your code is unreadable.

Consider this methodology:

Take the problem one step at a time.

First generate good data. And check the data before moving on to the next step. There is no point in trying to graph nonsense. You give no clues as to what the data should look like so I can't guess if it is the generation of it that is a problem or the display.

I suggest you place probes or indicators much earlier in the dataflow so you can see if you are doing anything like what is needed. Or scrap the whole vi and start over with simples steps.

Mike

Mike,

- You're absolutely right that my code is a mess and unreadable

- You're wrong that this is school/course work

Attached is a simplified version. Basically depending on the user input (N or S), I want to plot on the Norht or South graph. I have two analog signals, one used for x and one for y. I use 2 RG in their places in the code. Where I am stuck is in the False case, I don't know how to wire. Your help is appreciated.

Meocop

Download File:post-4960-1159988801.vi

Link to comment
Mike,

- You're absolutely right that my code is a mess and unreadable

- You're wrong that this is school/course work

Attached is a simplified version. Basically depending on the user input (N or S), I want to plot on the Norht or South graph. I have two analog signals, one used for x and one for y. I use 2 RG in their places in the code. Where I am stuck is in the False case, I don't know how to wire. Your help is appreciated.

Meocop

I see Christopher has given you some help.

I did have one idea you might like to know about. You can tag your North and South data when you collect it by clustering it with a boolean where N = 0 and S = 1. Then when you need it you unbundle the boolean to pick the case you want. You are not limited to booleans and only two potentials, you can bundle an enum with unlimited choices instead, and therefore unlimited case selections. Clustering is useful whenever you want two unlike but related pieces of information to travel together.

Mike

Re- attach the test.vi

MC

Check out the VI again. That's my solution to my problem. The code is horrible, but it does the job. Pleae share a better way of doing this if you think up one.

Make sure you use capital N or S.

Thank you,

MC

I think the concepts you need are Shift Registers and Enabling Indexing of loops. Take a look at the example attached. The Shift Registers allow you to watch the data build. Enabling indexing puts the same collection of data on the output border of the loop for display when the vi is stopped.

Both functions are accessed by right clicking the loop border.

I threw in an initalization sequence frame that runs as soon as the vi is started to clear the graphs and to reseet the stop button.

Mike

Download File:post-48-1160014207.vi

Link to comment
  • 2 weeks later...
I see Christopher has given you some help.

I did have one idea you might like to know about. You can tag your North and South data when you collect it by clustering it with a boolean where N = 0 and S = 1. Then when you need it you unbundle the boolean to pick the case you want. You are not limited to booleans and only two potentials, you can bundle an enum with unlimited choices instead, and therefore unlimited case selections. Clustering is useful whenever you want two unlike but related pieces of information to travel together.

Mike

I think the concepts you need are Shift Registers and Enabling Indexing of loops. Take a look at the example attached. The Shift Registers allow you to watch the data build. Enabling indexing puts the same collection of data on the output border of the loop for display when the vi is stopped.

Both functions are accessed by right clicking the loop border.

I threw in an initalization sequence frame that runs as soon as the vi is started to clear the graphs and to reseet the stop button.

Mike

Thank you all for helping me. You guys are great!!!

MeoCop

Link to comment
Admin Note: This is a great example of how to participate on the LAVA Forums! :thumbup:

Crelf and Mike,

What I want to do is to to take a bunch of data points on my N part and then a bunch of points on my S part, then calculate some statistical vaules such as max and min. So I used the Enabling Index concept and it seemed to work. However I kept getting 0 for the min and I am not sure why. Please help.

Meo Cop

Download File:post-4960-1161363802.vi

Link to comment
Crelf and Mike,

What I want to do is to to take a bunch of data points on my N part and then a bunch of points on my S part, then calculate some statistical vaules such as max and min. So I used the Enabling Index concept and it seemed to work. However I kept getting 0 for the min and I am not sure why. Please help.

Meo Cop

Try something like this

Dan

Download File:post-114-1161366024.vi

Link to comment
Try something like this

Dan

Thank you Dan, but I don't think your program works the way I want it. The max and min results did not look right because they were greater than 1. The RNG should give numbers between 0-1.

Also I've written my program in such a way that using Enabling Index is the most simplest way and I like to make it work that way.

Thank you.

MC

Link to comment
Thank you Dan, but I don't think your program works the way I want it. The max and min results did not look right because they were greater than 1. The RNG should give numbers between 0-1.

Expand the indicator so you can see the whole number. You'll see that there's a E-x hidden there.

Edit:

Also I've written my program in such a way that using Enabling Index is the most simplest way and I like to make it work that way.

The advantage of doing it with the shift registers the way that Dan did is that it allows you to monitor (via plotting, probing, or statistics) your arrays as they are built. This helps quite a bit in debugging. It will, however, result in a performance hit if your arrays grow to be very large.

Gary

Link to comment
Admin Note: This is a great example of how to participate on the LAVA Forums! :thumbup:

Absolutely! The question is clear, the asker has already tried some stuff, and provided an example - and look at the results! People have really tried to help out :) Maybe we should link to this thread from a FAQ - how to ask a question...

Link to comment
Absolutely! The question is clear, the asker has already tried some stuff, and provided an example - and look at the results! People have really tried to help out :) Maybe we should link to this thread from a FAQ - how to ask a question...

Crelf, I don't know if you're being serious or not, but since I got chewed out by Mike for showing a messy VI, I've tried to ask simple questions and given clear examples. These simple things play big role in an application I am trying to develop. See, I write C++ and Java, so my boss thinks that I can write Labview and that's why I am assigned with some labview projects and not sent to any training course. So I appreciate any help I can get.

Dan, sorry for falsely accusing your VI not working. But I still think the Enabling Index will work better for me if I can make it work.

MC

Link to comment
Crelf, I don't know if you're being serious or not, but since I got chewed out by Mike for showing a messy VI, I've tried to ask simple questions and given clear examples.

I am completely serious - we've had a spate of threads where new users ask vague questions and/or expect everyone else to do the work for them without lifting a finger themselves. I agree with Mike: your post was refreshing and I really appreciate it! :thumbup:

Link to comment

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.