LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

software timed commands

Solved!
Go to solution

Hi

 

  • The program l have developed works correctly in all areas but one.
  • I cannot obtain consistent time period for the activation of the first command. The problem is best viewed after operating the program a number of times and pressing the data trigger button a number of times and viewing responses on the command data chart. You will see that command position 5  has a variable time step when compared to the other commands which are equally spaced in time.
  • If you view the For Loop indicator you will see that sometimes the counter displays a 1 instead of a zero when the data trigger is first pressed so command position 5 is nearly bypassed by command position 12.
  • I am after a solution to this problem.

 

  • Time loop is used to provide 100 mS to 1 minute time steps between each command.
  • You will see that the program automatically performs a ramp of commands 5 to 60 and when the ramp has finished the last value 60 remains.

 

Thank you

 

wetland

 

0 Kudos
Message 1 of 5
(2,208 Views)

First, let me talk about the several odd or Rube Goldberg constructs you have going on.

 

1.  There is no need for wiring the array size to the N of the for loop, and using index array inside the for loop tied to the i iteration counter.  Just auto index the tunnel for that array.

2.  Why the inner case structure?  "i" can never be less than zero.

 

3.  The reason you get a zero when the program ends is because that small while loop ends when the notifier yields an error when the notifier is destroyed.  There is no notification, just an error, so you wind up with the default value of the notifier which is zero.

 

Exactly what are you trying to synchronize your commands to?

 

When you use Wait until next msec multiple, you are not going to have consistent timing between iterations.  If you start your program late enough that it is in the last part of a 100 msec interval, and the loop execution finishes in that time, the next loop iteration will start right away.  That is why it looks like the 5 goes by right away.

 

Throw in the initial 1000 msec wait (which will wait exactly that line but has no correlation to any multiple of the PC clock).  Along with the  500 msec period on the timed loop, the 200 msec offset, and the 100 msec wait till next ms multiple, you have a lot of complicated interrelated things going on.

 

If you want to just have consistent delays between iterations, then use a regular wait, not wait until next msec multiple, and get rid of the timed loop which is really meant for real-time or FPGA operating systems, not windows.

0 Kudos
Message 2 of 5
(2,188 Views)

Hi RavensFan

 

A lot of comments but only one that addressed the problem and it indirectly provided the solution. So thanks for that. I read the line below and said to myself you idiot. The line below instantly gave me the idea to replace the wait next msec multiple with a wait and that fixed the problem straight away.

 

When you use Wait until next msec multiple, you are not going to have consistent timing between iterations.  If you start your program late enough that it is in the last part of a 100 msec interval, and the loop execution finishes in that time, the next loop iteration will start right away.  That is why it looks like the 5 goes by right away.

 

  • I had left all my last past attempts to fix the problem so that someone else may have a better idea.
  • I am using the timed loop because that is the only way l know to get a controlled time interval for each command below 1 second.

 

  • I am providing the code fix so that you can comment on the code for any other improvements.
  • I know this command code would probably go well with object oriented programing especially if l use a feedback loop but my problem with that type of programming l have not been able to reverse engineer examples up to this point. My problem is I prefer to have most of the code on the one page to get a good understanding of code.
  • I will leave the post for you to reply but after a day l will post a fix for the problem

 

So thanks RavenFan

 

 

0 Kudos
Message 3 of 5
(2,166 Views)

I enjoy a puzzle just as much as the next guy, so I took a look at your second code posting and asked myself the obvious question, "What (really) are you trying to do?".

 

The simple answer, based mostly on the text in your post, is that you want to deliver a series of Position Data information at precisely timed intervals (Period) beginning at the time you push the button Data Trigger.  There is an additional parameter, Number of Iterations, whose purpose is not clear.  If Position Data were the "1, 2, 3" and Number of Iterations were 2, would you want to give "1, 1, 2, 2, 3, 3" (which is what your code seems to imply, but doesn't make logical sense) or "1, 2, 3, 1, 2, 3"?  Your example shows this parameter as "1", in which case it doesn't matter, but leads me to ask "Do you really want/use this parameter?".

 

I'm not sure why you are using a Timed Loop -- you don't seem to be doing anything inside the loop.  If that is the case, the simplest way to run through your data points at evenly spaced periods would seem to be something like this:

Software Timed Loop.png

Note you can easily incorporate Number of Iterations (either model) by adding another For loop, either surrounding this For Loop (for the 1, 2, 3, 1, 2, 3 pattern) or inside the loop (for the 1, 1, 2, 2, 3, 3 pattern).

 

Similarly, there's a simple way to use Wait on Notifications and only get the "good" data -- simply ignore the data if the Error Line coming out of the Wait on Notification function shows an Error.  Here's an example collecting the Notifications in a loop -- we send 0 .. 4, and get back 0..4, without the additional 0 at the end.

Good Notifications.png

 

Hope these suggestions are helpful.

 

Bob Schor

Message 4 of 5
(2,139 Views)
Solution
Accepted by topic author wetland

Hi Bob

 

What (really) are you trying to do?”

  • To develop better code
  • I do not have all the ideas

 

  • As in the example below Software Timed Tigger_v2 you have shown me a simpler and better way to develop code. I now see l did not need the time loop however for me it was good anyway to see what l could do with the time loop.

 

  • Your send example was not dynamic in that you could not apply repeated commands however it did provide another way to code. I have not used that condition feature on a while loop before.
  • So what can this code be used for?
  • I do have a rotary stage which l have a number of small programs l have not put together as yet. This small program would be used for a stepper motor to turn the rotary stage. The time interval is the period where the camera performs an exposure.
  • To further develop the code l have an absolute position encoder so l am going to develop a feedback loop to see if commands have been obtained. When you have a flat battery the stage could at times not reach each location in time.
  • But l also see this small program could be used to control other items like a robot arm. Etc.  

 

  • I am very grateful for your input and your alternative ideas.
  • I now have enough solutions so l hope l can press the right button to end this post.

Regards

 

Wetland

Download All
Message 5 of 5
(2,091 Views)