LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping motor after elapsed time

Solved!
Go to solution

Hi everyone,

 

I've recently inherited some code that I need to add some functionality to - one being making sure the motor and spray stop after the inputted time has elapsed. Unfortunately due to time and equipment restraints I don't have many opportunities to test this code before it is needed so I'd just like to check if I'm on the right track.

 

In the attached VI the changes I have made are to the stop condition in the bottom right while loop, changing it from just a stop button to also being dependent on the elapsed time. It does require the total test time to be entered twice though this is a rather minor inconvenience, albeit inelegant.

 

Does it look like the changes I have made will work?

 

Thank you for your help

0 Kudos
Message 1 of 5
(3,125 Views)
Solution
Accepted by topic author Neil_C

Hi Neil,

 

Does it look like the changes I have made will work?

It looks like it will work.

(It doesn't look like a nice cleaned up VI. And it doesn't look like a VI with some well-thought architecture…)

Why don't you use the "Time has Elapsed" output? Why do you need to compare time target and elapsed time on your own?

 

Unfortunately due to time and equipment restraints I don't have many opportunities to test this code before it is needed

Take the DAQmx part out of the loop nd replace it by a simple LED indicator (array). Then test your VI…

(Do you need to initialize the DAQmx task with each iteration? Why don't you clean up the task? Why is this subVI called "untitled"???)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(3,107 Views)

Hi GerdW,

 

Thank you for your reply - not just here but elsewhere as well, they've been really helpful for me.

I've changed to using the Time has Elapsed output as suggested. I agree with what you say about the VI, it's been a struggle to understand it!

 

These are the other two problems that I'm working on solving:

  • If any error occurs, Labview should turn off the valves and motor (“Spray Off” and “Motor Off”)
  • Rather than writing 1 huge TDMS file, it would be better to start a new TDMS file after 1GB of data or 1h of running time has elapsed.

I've seen quite a few threads about saving to a new file after a certain time/size/number of points, but have been struggling to apply them to the VI without interfering to much with it. Do you think any of these would be easier than the others to apply so that I can work on one before coming back with an attempted solution? Similarly any guidance towards a good resource for errors would be much appreciated.

 

Thank you

0 Kudos
Message 3 of 5
(3,089 Views)

Hi Neil,

 

If any error occurs, Labview should turn off the valves and motor (“Spray Off” and “Motor Off”)

Then you need to program this!

"IF error THEN turn off valves/motors"…

 

Rather than writing 1 huge TDMS file, it would be better to start a new TDMS file after 1

 GB of data or 1h of running time has elapsed.

Have a look at the "Write to measurement file" ExpressVI. Configure it as you need it, included file size limitation. Then open it to see how NI solves that problem…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(3,086 Views)

Hi GerdW,

 

Thanks for your help, I'll have a play around with them and see how I get on.

0 Kudos
Message 5 of 5
(3,082 Views)