LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

hardware push button

I am trying to build an automated thermostat tester using labview. I'm going to try and test 6 t'stats at one time. I have most of it ready but I have a few doubts. I'm using Labview 8.5 on Windows 2000 with the NI PCI 6515 DAQ unit.
I am attaching my code here. As you can see it has  start and stop buttons (soft button). But this is not how it's supposed to be anymore. They want a push button in hardware now. So our design fixture has a big push button for start and stop (momentary switching not a proper switch) (hard start-stop).
I want to know how to edit this VI in order to not have these soft buttons but to tie them up to a hardware button. I know I will have to use the DAQ to sense the momentary change in state but I don't know how I can do that and how to edit this without having lots to do.
All you help will be highly appreciated.
Thanks,
Shreya
0 Kudos
Message 1 of 117
(6,191 Views)
Usual programming practice in LV is to keep the size of diagrams to one screen. Perhaps you are working in an IMAX theater! Really, it is very hard to tell what your VI is doing when it is necessary to scroll five screens each way to see the diagram.

1. Much of your code appears (at a glance) to be duplicated. Make subVIs of these parts. The Case structures for each Unit.
2. For what you want to do you will need to have an overall loop structure. I highly recommend that you look into state machine architectures. The VI will start to run when opened and will be idle except for a Digital Input from your DAQ card which will be read often enough to detect the button operation. Mechanical switches take 10s of milliseconds to operate and if it is a big industrial pushbutton, it will likely be closed for 100s of milliseconds, so 100 samples per second is probably fast enough to scan the digital inputs.
3. Once the button has been detected, go the the operating states of the program while watching the digital inputs for the stop button.
4. The Digital Input driver should probably run in a parallel loop which communicates the status of the Start and Stop buttons with the main program via queues or an Action Engine.
5. Look at the style guides. Overlapping wires and objects hidden behind others make it difficult to understand and debug.

Lynn
Message 2 of 117
(6,172 Views)

Yes I agree with all your comments. All the case structures are the same. But the lines I am reading and writing to are different. If you see the writes they are made as global variables using MAX. I could not think of any other way to do it. Any suggestion for improvement will be appreciated.



johnsold wrote:
2. For what you want to do you will need to have an overall loop structure. I highly recommend that you look into state machine architectures. The VI will start to run when opened and will be idle except for a Digital Input from your DAQ card which will be read often enough to detect the button operation. Mechanical switches take 10s of milliseconds to operate and if it is a big industrial pushbutton, it will likely be closed for 100s of milliseconds, so 100 samples per second is probably fast enough to scan the digital inputs.
Lynn

How exactly can I do that??
 


johnsold wrote:
3. Once the button has been detected, go the the operating states of the program while watching the digital inputs for the stop button.
Lynn

What exactly do you mean I should do with this?


johnsold wrote:
4. The Digital Input driver should probably run in a parallel loop which communicates the status of the Start and Stop buttons with the main program via queues or an Action Engine.

Action Engine is one thing I haven't followed. I tried reading it and trying to understand but I just couldn't.
I will be grateful if you could help me edit and simplify the code.
Thank You.

0 Kudos
Message 3 of 117
(6,166 Views)
Hi smm,

your vi really is a mess...

Before we can/should try to simplify the code it's your turn!
- clean up your code: use straight wires for the error cluster from left to right (much easier to follow!)
- put same structures into subvis (using just one additional input to select the needed DAQ channel)
- use just one type of delay: why do use express vis for simple delays, "wait (ms)" should do the same and you can even see the delay value!
- delete unneccessary frames (like the first one of the biggest sequence)
- make all structures as small as possible (no need for a 400×400 pixel big while loop just waiting for a start button)

When you have done this all, the we will be able to help you simplifying your vi!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 117
(6,140 Views)


GerdW wrote:
- put same structures into subvis (using just one additional input to select the needed DAQ channel)

I tried putting the structures in the sub vis, but it gives me a warning saying the functionality of the structure may change on doing so. That's why I didn't do it. Also if i do use a subvi how can I ensure that it reads and writes from accurate lines?
 


GerdW wrote:
- delete unneccessary frames (like the first one of the biggest sequence)

Which frame are you talking about?
0 Kudos
Message 5 of 117
(6,132 Views)
The reason you get the warning about changing functionality is that there are controls or indicators (Or local variables) inside the structure you are trying to convert to a subVI. Deselect them or move them outside the region you are trying to convert.

I saw some dataflow issues that you will need to address, but I do not have time now to point them out. Maybe later today.

Lynn
Message 6 of 117
(6,113 Views)
That'll be really great. Whenever you get the time. I tried the sub vi thing but it doesn't seem right.
0 Kudos
Message 7 of 117
(6,104 Views)
Look at the dataflow demo I have attached. If you cannot figure out what it is doing part of the time, try running it with execution highlighting on. (The light bulb on the diagram toolbar). Notice that parts Two and Three have the indicators outside the case structures and use shift registers so no local variables are needed. Part One does not update LED 1 or String 1 effectively because it has neither the shift registers nor local variables. Parts One and Two are similar to your Unit cases, except that in the demo they always execute the same case on each iteration. Part Three is similar except for the way it handles delays. See below for why this matters.

Part Three shows an alternate Wait method which works well with state machines and allows prompt response to user inputs (Stop) or errors.

The picture shows one case of your program. Suppose this case is called in Unit 1 and the Reset93 case is called in Unit 2 on iteration 50 of the while loop. A call to Reset93 writes to a digital line then calls Clear Tasks. Clear Tasks calls Power Off which writes to a different digital line and calls Stop. Stop tells the while loop to stop executing.

Question: When does PowerOff (Unit 2) happen and when does the while loop stop executing?
Answer: In iteration 53 at least 183 seconds later. Iteration 50 does not complete until all the case structures and all other nodes inside the while loop complete. Since Unit 1 Case Dialog1 has waits totaling 183 seconds, iteration 51 will not start for at least that long. If one of the other Unit cases has a longer delay or has a delay in iteration 51 or 52 those delays would extend the time before stopping.

Lynn
Download All
Message 8 of 117
(6,086 Views)

Hello,

The first post by johnsold is extremely helpful to the future structure of your program.  However, I also agree that the code needs to cleaned up and made to it can be viewed on one screen.  It seems you are currently having issues creating sub vis.

I would suggest using the LabVIEW Help to read the following articles.  Each of these titles is a “How-To” document so it should help you through the process.  Please note that the “Concept” articles will aisd the “How-To” pages.

Creating SubVIs from Selections

Avoiding SubVI Selections That Contain Front Panel Terminals

Icon and Connector Pane Overview

Selection a Connector Pane Pattern

Avoid SubVI Selections That Create Cycles

Samantha
National Instruments
Applications Engineer
Message 9 of 117
(6,080 Views)
I finally made the subvis and now my main Vi fits in one page. But I hope all the wires because if indicators are not a problem.
Coming back to my original question. Can someone tell me how I can replace the soft start and stop buttons with a hard start/stop button.  I want the mometary switch (hardware) on the interface unit to do what the soft start and stop does.
 
Download All
0 Kudos
Message 10 of 117
(5,985 Views)