03-10-2010 07:39 PM
aeastet wrote:
This vi should work for you
03-11-2010 06:46 AM
03-11-2010 06:57 AM - edited 03-11-2010 07:05 AM
Altenbach forgot to mention the slight abusive use of unnecessary Local Variables.
The medical term for this abuse is "Localitis". There is a cure..
Wiring directly would have eliminated 2 indicators and 2 Locals plus eliminated the need for a Flat Sequence Structure... An added bonus would have been cleaner code.
03-11-2010 07:13 AM - edited 03-11-2010 07:20 AM
Here's a snippet without Locals.
The reason for 2 iterations is to initialize t = 0. Actually, depending on the rest of your code, you would not even need the loop. I'll do another snippet.
This one below is probably more appropriate since the above was simply a self executing example and not how you would implement it.
03-11-2010 07:17 AM
Will
It is blowing my mind that this code worked for you. You didnt have to take into account the sampling rate of your digital I/O?
Chill
03-11-2010 07:18 AM
03-11-2010 07:21 AM
aeastet
This is my take on your code with a while loop. Still blows my mind that this worked for Will.
03-11-2010 07:25 AM
aeastet wrote:
How would you have done this with a fore loop? You do not know when the boolean value will change so you will only get one event at a time. The boolean will only change state once. I would love to see what you can do?
Sorry about that..
In my haste, I missed the boolean, which is an important part of this.. Also the trouble with jumping intoa thread from an external link..
Can't delete my useless posts. 😮 😞
I'll go back and try to understand the initial post.
03-11-2010 07:29 AM
Will
It is blowing my mind that this code worked for you. You didn't have to take into account the sampling rate of your digital I/O?
Chill
03-11-2010 07:34 AM
aeastet wrote:I am not sure why you are having trouble with it. I made the code independent of timing. That is the whole reason that I did it the way I did. I look to see when the Boolean changes and recorded the time and when it changes again I recorded the time and do the calculation. I does not matter how fast the loop is going for something this slow.
I still would like to see how Will is getting his data from the digitial IO. In my mind for this code to kinda work the data would have to be streaming real time.