LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to program "If x < 6.4 FOR 10 second THEN "

I need to control a motor and im programming a jam control. If the current spike stays longer than lets say 10min i want the motor to go in reverse. My question is.. how do i program the statement:
If *variable of motor current" > 6.4 FOR 10 second THEN..
do i use the selecior? case structure? I would appreciate details. Thanks! 

0 Kudos
Message 1 of 11
(3,672 Views)

One of the way would be to acquire the current for 10 seconds (by putting it inside a while loop) and then comparing the values. (by averaging the values recorded during the acquire process)

Regards
Guru (CLA)
Message 2 of 11
(3,667 Views)

Hi Spaaw,

 

I have come up with 2 methods to solve this. Ya. The difference b/w them is only in the timing. If you need to monitor the line for a longer duration, method-II which uses wait function would be a better option. The code is real simple. If at any iteration, if the condition is not met, you will get the selection output (boolean) as false. you can use that for your subsequent operation.

 

Kudos are welcome,Smiley Happy

Satishsnippet 1.JPG

Message 3 of 11
(3,664 Views)

Guru,

 

Great idea. It makes it even simpler. But, there are chances of memory issues, when storing data for a real long period.

 

Just to make the code little smarter, I have made the looping to stop, if the condition is not met. This might not be possible in your method.

snippet 1.JPG

Message 4 of 11
(3,661 Views)

You are making this far too confusing. Wire a tick count into a shift register. Check if the voltage is greater than 6.4. Wire this boolean result into a select primitive. If it is greater, return the shift register value for tick count from the select function. If its not greater return the current tick count value. Then do a compare with the current tick count and the tick count returned from the select function. I'm on my phone but I didn't want to wait to put in my 2 cents because I feel there are simpler ways than some of the posted pictures are showing... Can someone draw this up for me?

0 Kudos
Message 5 of 11
(3,655 Views)

Here is what I was describing. Gosh pictures are easier; the timer resets if "Numeric" drops below 6 and starts counting again if it goes back over. Using this method you are not exiting any loops when ten seconds is up, but instead can do it all within the same loop. Also, the title of the post says < 6.4 and the post actually says > so you will have to modify code accordingly based on what you want.

 

Message 6 of 11
(3,649 Views)

@satish_21 wrote:

Guru,

 

Great idea. It makes it even simpler. But, there are chances of memory issues, when storing data for a real long period.

 

 


A double takes up the same amount of memory, no matter how long you store it Smiley Wink. I think you are referring to building arrays, but if averaging is done correctly with memory management in mind (using addition, a shift register, and a counter to keep track of the number of samples acquired), Guru's solution is more than acceptable and will have no memory issues. Unless of course the sum of the currents exceeds the maximum value for a double, which has something like 15 digits Smiley Very Happy

0 Kudos
Message 7 of 11
(3,641 Views)

 


Unless of course the sum of the currents exceeds the maximum value for a double, which has something like 15 digits :smileyvery-happy:


Smiley Very Happy

Regards
Guru (CLA)
0 Kudos
Message 8 of 11
(3,635 Views)

Guru and Greg,

 

Yes. I was referring to the array memory problem. I believe spaaw wants to check the condition through out the duration and not after averaging out for the duration. 

0 Kudos
Message 9 of 11
(3,626 Views)

Repeat after me, "Express VIs are awesome and should be used much more often!"  Ok, maybe one day too soon for that one, but the Elapsed Time Express VI is pretty useful.

 

ElapsedTimeExample.png

 

In a real application I would put this code in the timeout case of an event structure and set the timeout to 50-1000 msec depending on the time interval you are checking.

Message 10 of 11
(3,587 Views)