03-24-2011 10:17 PM - edited 03-24-2011 10:19 PM
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!
03-24-2011 10:37 PM
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)
03-24-2011 10:52 PM - edited 03-24-2011 10:53 PM
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,
Satish
03-24-2011 11:02 PM
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.
03-24-2011 11:56 PM - edited 03-25-2011 12:05 AM
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?
03-25-2011 12:13 AM - edited 03-25-2011 12:16 AM
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.
03-25-2011 12:23 AM - edited 03-25-2011 12:24 AM
@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 . 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
03-25-2011 12:41 AM
Unless of course the sum of the currents exceeds the maximum value for a double, which has something like 15 digits
03-25-2011 02:07 AM
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.
03-31-2011 03:08 PM
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.
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.