10-24-2014 02:58 PM
Hi, guys.
I have a VI where I have 8 different xy graphs going, but I only want to show 4 at a time and have them cycle every minute, so I included 4 of them on a tab and 4 on another one and I have a while loop cycling through every minute. However, I would like to include a bit more functionality to these tabs and I'm not sure how to go about it. I want to be able to select a tab during runtime and view it. Currently, the tabs cycle between "mid" and "exit" every minute smoothly, but when I click on any other tab, nothing happens.
I have attached the VI. Thank you!
10-24-2014 03:08 PM - edited 10-24-2014 03:22 PM
First, make your tab control a control again rather than an indicator. That way the person can control it.
I would use an event structure with a timeout value to determine when to switch pages. Use a local variable to write the new page you are changing to.
Other things.
1. Your code on the right doesn't have any loops around it. It will only execute once.
2. Why are you using Array to Cluster, then unbundle to get the individual waveforms out of the array? That is what Index Array is for. What you have made is a Rube Goldberg. Also see it at http://forums.ni.com/t5/LabVIEW/How-to-mean-2D-continuous-data/m-p/1949545#M648401
3. You are also building twice as many arrays as you need to. You have two identical sets of shift registers where you are building waveforms onto the end of the arrays for each channel. For that matter, you are also building 8 arrays of the i iteration value that are all identical. So you can eliminate 7 more shift registers right there.
4. You are rewriting the text file on every iteration of the while loop. That is just going to keep slowing down the loop. Save the data after the loop is done. Or use a producer/consumer architecture to send the new data to another loop for writing the the file.
10-24-2014 03:10 PM - edited 10-24-2014 03:11 PM
OK, you mis-stated something there, Thats a Tab Indicator! Make it a control and "Bob's yer uncle!" Use a local variable to write the value every minute.
Better yet, change that long long cycle while loop to an event case with a 1 minute time out
EDIT: Bill types faster than me
10-27-2014 12:34 PM - edited 10-27-2014 12:35 PM
RavensFan wrote:
First, make your tab control a control again rather than an indicator. That way the person can control it.
I would use an event structure with a timeout value to determine when to switch pages. Use a local variable to write the new page you are changing to.
Other things.
1. Your code on the right doesn't have any loops around it. It will only execute once.
2. Why are you using Array to Cluster, then unbundle to get the individual waveforms out of the array? That is what Index Array is for. What you have made is a Rube Goldberg. Also see it at http://forums.ni.com/t5/LabVIEW/How-to-mean-2D-continuous-data/m-p/1949545#M648401
3. You are also building twice as many arrays as you need to. You have two identical sets of shift registers where you are building waveforms onto the end of the arrays for each channel. For that matter, you are also building 8 arrays of the i iteration value that are all identical. So you can eliminate 7 more shift registers right there.
4. You are rewriting the text file on every iteration of the while loop. That is just going to keep slowing down the loop. Save the data after the loop is done. Or use a producer/consumer architecture to send the new data to another loop for writing the the file.
I am somewhat clueless on how the timeout event structure works. I attempted something quick just because I really don't know how else I would go about it, but I have posted it. I understand that when the timeout hits the millisecond constant entered in the top left corner, that it will execute what is inside the event structure border, but how would I go about switching between the two tabs from within the event structure?
1. I copied and pasted that from another VI that I was working on before this and have not put a loop around it yet because I haven't been sure whether I would need to include it inside of one giant while loop for my entire VI or if I should just have a while loop around that certain portion of code.
2. I will read up on your link and try to adjust it accordingly.
3. I'm not sure how I could go about fixing that or removing the shift registers?
4. I am rewriting the text file on every iteration because I kept receiving a buffer error when I had it placed outside of the loop and writing at the end. It was also very inconsistent where sometimes it would write to file and sometimes it would not, so somebody advised me to place it inside of my loop and that it would also help out because this code will be running for a few hours and in case of any sort of error, I would lose all of the data up to that point.
Thank you for all of your suggestions!
10-27-2014 01:13 PM - edited 10-27-2014 01:14 PM
It looks like you've only attempted the change to making the tab back to a control!
When you have multiple shift registers doing the same thing, get rid of the extra copies. Branch the wire coming out of your Build Arrays and send that to the different areas of the code. Right now you are just branching the new data and sending that to different Build Arrays and thus different shift registers.
See the attached VI where I cleaned that up.
I also put an event case in your first loop to handle the stop button. Right now you can only stop your code by using the Abort button. Not a good idea, expecially if your program is in the middle of writing to the file when you do.
I didn't mess with the master while or anything with the file writing.
10-27-2014 02:05 PM
@RavensFan wrote:
It looks like you've only attempted the change to making the tab back to a control!
When you have multiple shift registers doing the same thing, get rid of the extra copies. Branch the wire coming out of your Build Arrays and send that to the different areas of the code. Right now you are just branching the new data and sending that to different Build Arrays and thus different shift registers.
See the attached VI where I cleaned that up.
I also put an event case in your first loop to handle the stop button. Right now you can only stop your code by using the Abort button. Not a good idea, expecially if your program is in the middle of writing to the file when you do.
I didn't mess with the master while or anything with the file writing.
Yes, I changed the tab back to a control, put it into the event structure for a timeout event, and I wired the "exit" constant to the tab local variable. I can't think of a way to make it switch between the two tabs within the timeout event structure. And as far as the vi that you sent back to me, I believe that you sent me the same vi that I posted by mistake because there haven't been any changes made.
10-27-2014 02:13 PM
Look at the middle while loop and how much smaller it is.
You had the switching working in your original VI. Just do the same thing.
10-27-2014 03:20 PM
@RavensFan wrote:
Look at the middle while loop and how much smaller it is.
You had the switching working in your original VI. Just do the same thing.
For some reason, I thought that what I originally had wouldn't work with an event structure but I included it and now it's working the way I would like it to, so thank you very much. However, I was wondering if you knew of another way to get the switching done? For instance, when the front panel has just recently switched to "exit" and I would like to view mid and click on that tab, it switches to that tab right away. However, it doesn't reset the timer. I would like to be able to click on to either mid or exit, and then have the timer reset to 60 seconds to switch to the other tab. The way it is now set up, if I click on "mid" after it has been on "exit" for 10 seconds, it will wait for 50 more seconds before it switches to "mid" (even though it is already on "mid") and then it will wait 60 more seconds to go back to "exit". I would like to be able to click on "mid" after x amount of seconds into "exit", then have the timer reset so that after 60 seconds, it will switch back to "exit". This isn't a huge problem, but it would be nice to be able to do this.
10-27-2014 03:36 PM
Add another event case that is for the Tab control :Value Change. You don't have to do anything in it. But when it executes, it will reset the timeout timer.
10-27-2014 04:59 PM
@RavensFan wrote:
Add another event case that is for the Tab control :Value Change. You don't have to do anything in it. But when it executes, it will reset the timeout timer.
Thank you very much! That worked perfectly. I'm sorry, I know I have a lot of questions, but I can't seem to find answers anywhere else... do you know why the time on my x-axis is incorrect? Everywhere else that I have looked has said that the time should be on the x-axis in terms of seconds since some specific date and time, which I believe was in 1901? Anyway, I right clicked the xy graph and went to properties and for the x-axis i chose the format of absolute time and I did not get that, nor did I get an accurate time. It kept saying 4:00pm and gave me an incorrect date as well. I had no idea how to edit the date/time or if there was something that I was missing?