LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Count the time that the output is active

I have made a program with a state machine, but I have one problem. I don't know how I can count the time that the output is active. I have tried several things, but the timer doesnt do what I want. The one time it counts up, also when the output is not active, or it starts counting again (start at 0) everytime its active.

 

Furthermore I have made a delay before the output is active and a delay when a other output is active. The first time it runs it works, but the next time it also doenst work. I think the source of this problem is the same as the one from the counter but I dont know for sure.

 

Can anybody help me with this? See the attachment for my VI. The counter is in case "pump up 10".

0 Kudos
Message 1 of 10
(2,604 Views)

Hi MarkVBA,

  What is type of output(boolean or integer)?

  Use TickCount(ms) function to calculate the time elapsed.

 

regards,

SrikrishnaNF

 

 

Regards,
Srikrishna


0 Kudos
Message 2 of 10
(2,602 Views)

Hi SrikrishnaNF,

 

Thanks for your reply. The output now is a boolean, but after I finished my program it will be a output from the NI 9481.

0 Kudos
Message 3 of 10
(2,597 Views)

I just have tried the tick count. Maybe I am doing something wrong, but this also do not work. It is still counting when the output is not active. You cannot see that it is counting when the output is not active, but when it becomes active again, you can see that on the background it have been counting, because the timer jumps from (for example) 7450 to 7480. It also starts with a strange time, it doesnt begin at 0 seconds. Am I doing something wrong?

0 Kudos
Message 4 of 10
(2,595 Views)

What is the sequence yo are trying to achieve.

 

1. Start exceution ..

2.check Pressure. If it goes above 5, then turn on the digital line and waits for 'x ' secs

3.After x secs switch off Pump5

4.Check if pressure exceeds 9 and turn on pump 10 for y secs..

5.after y secs turn off pump 10 

6. Stop the execution.

 

Is this what you are trying ?

0 Kudos
Message 5 of 10
(2,593 Views)

Hi Frabto,

 

It goes something like that. What I am trying to do is the following:

 

  1. Start -> check pressure, if it is between -0.3 and 0.3 then go tho the next case otherwise open the valve, so the pressure drops
  2. Pump up the pressure with the use of the compressor and stop if the pressure is 4 bar ( it must be 5, but i dont know what the overshoot is when it stops, so I now used 4)
  3. Wait x seconds and pump up the pressure till 9 bar (it must be 10, and there is 9, because the reason above)
  4. Wait x seconds and open the valve until the pressure is 6 bar (it must be 5, but for the same reason as above it is now 6)
  5. The execution must stop when the compressor running time is over y seconds.
0 Kudos
Message 6 of 10
(2,589 Views)

 

 

You are not reseting the timer . Wire true to auro reset so that it resets after counting the pre-defined time.

 

With hardware, this digital line( for compresor and ventiel) would be set using a DAQ. You are repeatedly wrting the Digital line in while loop. Its sufficient set the digital line when there is a logic state change.

 

 

0 Kudos
Message 7 of 10
(2,583 Views)

Hi Frabto,

 

I have put an True before auto reset, but this do not work. The timer still counts on, also when the boolean (compressor) is not active. Try it and you see what I mean. I have put the new VI in the attachment.

 

The problem is, I only want to count when the boolean (compressor) is high.

 

Regarding the digital lines in the while loop. Is this a problem and do I need to change this?

0 Kudos
Message 8 of 10
(2,574 Views)

I have made a quick draft copy .You can further implement additional logic.

Download All
0 Kudos
Message 9 of 10
(2,569 Views)

Thanks Frabto,

 

I don't understand completely what this does, but I am now going to look at this and see if I can understand it.

0 Kudos
Message 10 of 10
(2,565 Views)