06-20-2015 07:50 PM
Hi
Thank you
wetland
Solved! Go to Solution.
06-20-2015 09:15 PM
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.
06-21-2015 01:06 AM
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.
So thanks RavenFan
06-21-2015 09:23 AM
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:
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.
Hope these suggestions are helpful.
Bob Schor
06-22-2015 06:17 AM
Hi Bob
What (really) are you trying to do?”
Regards
Wetland