LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using tab, relay module and datalog

Hello, people.
 
You can say I'm in desperate need for help with my VI. I'm an intern and got an assignment which include "writing" a new VI which they need to read the temperatures of lamps. So we've got NI-cards in our dataloggers, I got the VI that reads the data from the datalogger.
 
I got 2 cycles, both are made seperate from each other and should not interfere one another when running. When I press the "cyclus1" (cycle 1) button you should be reading the temperatures of the lamp you choose (that's why the checkboxes are for). The other buttons and string controllers are parameters that you change to your needs, but that's not important right now. Upon pressing the cycle 1 button, you get a box on screen that asks you to save the data, and you enter a name for it. This proces should happen again when pressing the cycle 2 button.
 
This does happen when the 2 cycles are seperated from each other, when they're NOT in a tab together. Once I've put them together in a tab, I started to get problems I couldn't fix. If I run the VI and press Cycle1, this wouldn't run (no saving data) but when I press Cycle2 this cycle will save data. This isn't always the same, if I close the VI and start it over again, it's possible that it's the other way around...
 
How can I make sure that while still using a tab, I can save both data? Or is this just not possible?
 
I've posted my VI below.
 
 
Another question I have, I bought a USB-9481 4-CH relay module
and I don't really have a good "program" to switch a relay on/off. I looked through the libs from the CD but couldn't found a basic one. Using switches on the computer to switch, relay 1, 2, 3 and/or 4. I used the DAQ assistent, but it refused to work properly in the tab. Just like the datalogging part.
 
It's a bit long, but I hope someone could help me or tell me with certainty that the datalogging I want can't work in a tab.
 
Thanks
 

Message Edited by HmanH on 09-07-2007 07:57 AM

Message Edited by HmanH on 09-07-2007 07:58 AM

0 Kudos
Message 1 of 13
(2,907 Views)
The reason that you are having trouble switching tabs is that the tab control terminal is outside any loop. Thus, it gets read as soon as the program begins executing and any changes after that are ignored because the program never comes back to the terminal. This is basic dataflow programming which is fundamental to LV. It might be worth you while to spend an hour or two with the tutorials which ship with LV.

Do you want to be able to start the Cyclus 1 process and while it is running switch to the Cyclus 2 tab and run that as well? Or does only one run until finished and then the user can start another?

Lynn
Message 2 of 13
(2,896 Views)
Cycle 1 and 2 have to be separate of each other. When Cycle 1 is running, I have to be able to switch cycle 2 on or off, vice versa.
This is also the first time I worked with tab, don't really know how to use it. And I don't even know where I can find the block... I just copied the tab block from another vi...
 
Where can I find these tutorials? I do have a student version of LV at home. Not sure if that'll be on the cd.
Gonna look at it again this weekend.
 
Thanks
0 Kudos
Message 3 of 13
(2,884 Views)
So if I just put a while loop around my tab control it should work fine?
I tested that, but still got the same problems.
0 Kudos
Message 4 of 13
(2,864 Views)

if you made this vi you already have some Lv programation knowledge - you should therefore know that a while loop will execute as long as not terminated.

in other words: what your program look like now is:

1- tab chosen

2- run while loop, where in each iteration some data will be created and saved.

3- the while loop will not stop until you press the stop (3 or 4) button. remark: stop 3 is hidden!, stop 4 is well below the rest of the front panel.

4- only then, the program will stop.

if you didnt do this vi, i strongly suggest you make one from scratch, and on a step by step approach design what you want to do. As Lynn proposed you better off doing some LV tutorial before.

so, to change what you have right now:

1- easiest is to let run all the data process in one big loop. since the tab is only an indicator, there is no need to connect it to any case structure, unless you have some operation that critically depend on which page is displayed.

2- put all saving option after the loop. as you press the stop button you will be asked to save.

keep posting, we'll try to help from here.

 

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
Message 5 of 13
(2,855 Views)
I did make this vi from scratch, the only thing I didn't make was a subvi I put in my subvi. In the past I had some Labview lessons in school, but that wasn't really interesting me. But I still managed to get a good grade for it. But now I have to build a program from scrath, and I'm relearning and learning a lot about LV.
 
But my basic knowledge about LV isn't that great. I never used a tab control and didn't knew of its existence until I stumbled upon it when searching for something on this forum. I don't have an idea how it really works.
 
So what you're basically saying is, that there is no need for a case structure when using tab control?
0 Kudos
Message 6 of 13
(2,851 Views)

keep posting, we'll try to help (dont forget to rate 🙂 (5 stars only pls))

when you post, make sure all subvis are uploaded. the easiest way to do so is to save your application as : save with options -> development distribution.
your application will then be saved in a library (.llb), with all relevent subvis. you can use your application like that and send the whole llb for use to look at.

about tab control: to my opinion it it best used in combination with an event structure, if operations on each pages is different when displayed than when not displayed.
this seems not to be the case in your application, however i am not really understanding the difference of the 2 cycles. maybe you can explain?

what version of LV do you have?

 

Message Edited by Gabi1 on 09-10-2007 12:28 PM

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
Message 7 of 13
(2,849 Views)
The saving under development distribution didn't really work, so I just zipped the subvi's that are needed.
 
Well, it's like this:
- 1 cycle can measure 5 lamps, the different temperatures and maybe voltage and current (haven't put it in yet)
- Both cycle do exactly the same, but only with different lamps (cycle 1 (lamp 1 to 5) and cycle 2 (lamp 6 to 10)
- The set-up (I don't really know if this is the correct word in English) is 10 lamps, both divided in 2 sections (cycles) which can be operated separatly so someone else can use the 2nd section. Thus needing 2 separate but identical cycles.
- A cycle must have the ability to save the logged data instantaneously, keep an eye on the data in real time using indicators and graphs
- When a cycle starts it must trigger a relay (type of relay was described in the first post) that allows the power to go to the lamps.
 
That's about it.
 
It seems like I have completed the tab control, just lose the case structure and place it open in the block diagram. It can save data from both cycles. But I do have a new problem with the relay. As you can see I used the DAQ assistent, and it should work fine. But the problem is that I can't use the boolean output from both the cycle to trigger the right relays.
 
I made the subVI "relaysturing" which does the following:
Cycle 1 ON, Cycle 2 OFF --> Only relay 1 triggers
Cycle 1 OFF, Cycle 2 ON --> Only relay 2 triggers
Cycle 1 and cycle 2 ON --> relay 1 and 2 triggers
Cycle 1 and 2 OFF --> no relay triggers thus no power (safety reason)
 
The problem is that the while loop won't let data through. I thought there was a way to avoid this.
 
 
Also, I use Labview version 7.1

Message Edited by HmanH on 09-10-2007 07:14 AM

Message Edited by HmanH on 09-10-2007 07:17 AM

0 Kudos
Message 8 of 13
(2,838 Views)
Got a new problem already.
As you can see in my vi, in the left lower corner of a while loop you see a few tick counts, these are necessary to give the cycle it's run time. You enter the hours you want the cycle running and after that the cycle will stop. Also given is the date and hour when the cycle stops, so the person knows when he has to come back to the set-up.
 
The problem is, you don't want to close the vi and run it again. You want to keep running it and when a cycle stops you want to start a new cycle. Now, the "End of cycle" time won't change, because it's outside the loop. It won't get updated which is the general purpose, else I couldn't realize the cycle time. But now I need to update the tick count outside the loop when I want. With a switch or some sort. So that the "time outside while loop" updates.
 
 
0 Kudos
Message 9 of 13
(2,816 Views)

Hey HmanH

your vi looks like you have 2 unrelated applications.

here is a very first approximation of what you are trying to do.

Yet, it seems to me like quite an effort and clutter to duplicate virtually all (!!) controls and indicators for the 2 cycles. why not use only one such panel, and just have a button for observing either the cycle 1 or cycle 2? from the programing point of vue it would just mean you can implement everything into subvis, that would get called one or 2 times depending on which cycle is on.

right now, you have inner loop for the cycle to perform, the cycle on-off button also serves to stop the inner loop. then an outher loop for each cycle, to allow multiple cycling.
the current configuration forces you to recommand the relays everytime one of the outer loop reiterate.

do you have event structures possibilities in your version of LV?

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
Message 10 of 13
(2,795 Views)