LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

trying to use the TIMER to work out how many mS there are between triggers

Hasham622x_0-1725624012607.png

Hasham622x_1-1725624024587.png

Hi all,

 

First of all, sorry for disturbing.  I tried to use the TIMER to work out how many mS there are between triggers, but I don't think I did it correctly so have a look and could you please guide me. I'm trying to read the TIMER when the trigger occurs and to save the value as "prev time". When the next trigger occurs, I read the TIMER and subtract the "Prev time" to see how long it took.

I set 10 Hz frequency trigger signal. 

I also attached old version LV19 code.

Kind regards

 

Hasham

 

0 Kudos
Message 1 of 23
(392 Views)

@Hasham622x wrote:

Hasham622x_0-1725624012607.png

Hasham622x_1-1725624024587.png

Hi all,

 

First of all, sorry for disturbing.  I tried to use the TIMER to work out how many mS there are between triggers, but I don't think I did it correctly so have a look and could you please guide me. I'm trying to read the TIMER when the trigger occurs and to save the value as "prev time". When the next trigger occurs, I read the TIMER and subtract the "Prev time" to see how long it took.

I set 10 Hz frequency trigger signal. 

I also attached old version LV19 code.

Kind regards

 

Hasham

 


try using a shift register and the 'first call' Boolean instead of local variables, like this: 

 

snip.png

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 2 of 23
(368 Views)

@Jay14159265 wrote:
try using a shift register and the 'first call' Boolean instead of local variables, like this: 

... and if you would use a globally initialized feedback node instead , you could eliminate the "first call" complication. 😄

Message 3 of 23
(336 Views)

@altenbach wrote:

@Jay14159265 wrote:
try using a shift register and the 'first call' Boolean instead of local variables, like this: 

... and if you would use a globally initialized feedback node instead , you could eliminate the "first call" complication. 😄


 Hello @altenbach, well this was the best I could come up with for that. When I learned LabVIEW, I was taught to not use three things; Local variables, waits, and feedback nodes. Are feedback nodes really that bad? Maybe that was just the code style at that firm. 

snip.png

  

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 4 of 23
(327 Views)

The first iteration will be off, but simple after that. Can just stick in the while loop. Can move t0 outside the loop if the first point is important.

 

snip.png

0 Kudos
Message 5 of 23
(321 Views)

@mcduff wrote:

The first iteration will be off, but simple after that. Can just stick in the while loop. Can move t0 outside the loop if the first point is important.


 

The first point will be zero (not "off", whatever that means 😄 ), because no iteration has happened yet.

Message 6 of 23
(318 Views)

@altenbach wrote:

@mcduff wrote:

The first iteration will be off, but simple after that. Can just stick in the while loop. Can move t0 outside the loop if the first point is important.


 

The first point will be zero (not "off", whatever that means 😄 ), because no iteration has happened yet.


Off as in "Off the mark", not LED on/off. 🙂

 

From the dictionary

not accurate or correct : not achieving the desired result. Their estimates were completely off the mark.

0 Kudos
Message 7 of 23
(316 Views)

@mcduff wrote:

The first iteration will be off, but simple after that. Can just stick in the while loop. Can move t0 outside the loop if the first point is important.

 

snip.png


Nice, so is the preferred over the shift register or just less clicks to get the same code functionality. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 8 of 23
(300 Views)

@Jay14159265 wrote:

@mcduff wrote:

The first iteration will be off, but simple after that. Can just stick in the while loop. Can move t0 outside the loop if the first point is important.

 

snip.png


Nice, so is the preferred over the shift register or just less clicks to get the same code functionality. 


I think it is up to your preference, sometimes a shift register is easier, sometimes a feedback node is. The advantage of the feedback node in this case, is that the code can now fit on a "postage stamp". For some, that is preferable. 😉 

Message 9 of 23
(301 Views)

First of all, thanks for your reply. I tried this shift register option, and it gives some random numbers, not actual time ...

 

Kind regards

 

Hasham

0 Kudos
Message 10 of 23
(275 Views)