BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

Yes, these day "real benchmarkers" use "high resolution relative seconds", but for those still using tick count differences in a loop with a wait here's a tip to measure and verify the loop time (e.g. to ensure that the code can keep up!). The wait primitives give you a tick count output, no need for all that extra code!

 

 

ticker.png

 

(Nobody but me seems to ever use that! A similar tick output is also from the "time" event data node available in all (or most?) events. Useful!)

 

(see also)

 

 

Message 2001 of 2,571
(10,804 Views)

I use feedback nodes so seldom compared to a shift register.  But of the times I use a feedback node 90% of the time it is for simple timing like the example you gave.

0 Kudos
Message 2002 of 2,571
(10,797 Views)

@altenbach wrote:

The wait primitives give you a tick count output, no need for all that extra code!

 

 (Nobody but me seems to ever use that! A similar tick output is also from the "time" event data node available in all (or most?) events. Useful!)

 

(see also)

 

 

Awesome info!

 


 

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 2003 of 2,571
(10,762 Views)

Of course there are build in functions for getting the derivative.

 

Loop Timer.png

 

And it keeps working if the iteration time exceeds 49.7 days! (Smiley Indifferent)

 

Btw. time to make those PtByPt's a .vim.

0 Kudos
Message 2004 of 2,571
(10,749 Views)

wiebe@CARYA wrote:

Of course there are build in functions for getting the derivative.

 

 


Getting date/time is more expensive and if you look inside the ptbypt deriv, it's a bit ugly, containing an obsolete VI just to get error information on init (validity of dt and initial condition values). Then it has three shift registers. compared to one. 😄 It also does not follow modern guidelines on terminal placement, having some deep inside structures. All terminals belong on the toplevel diagram here. (e.g. "error" should be kept explicitly in a SR, not carried in a stale indicator. IMHO)

 


wiebe@CARYA wrote:

 

And it keeps working if the iteration time exceeds 49.7 days! (Smiley Indifferent)

 


That's why I typically use "high resolution relative seconds" I think it's more lightweight, not sure. It also does not need that lossy conversion from timestamp (128bits) to DBL (64bits). 😉 I don't think you need the "=0" because it inits unconditionally on first call anyway. You also need to wire the time to the initial condition, else you get garbage values for the first two iterations.

 


wiebe@CARYA wrote:

 

Btw. time to make those PtByPt's a .vim.


.Agreed. At the same time the code should be cleaned up a bit. 😄

 

 

0 Kudos
Message 2005 of 2,571
(10,715 Views)

In case you did not know how to create a simple 1D boolean array, here's one way I don't really recommend. 😄

 

MergeDynamic.png

 

(seen here)

0 Kudos
Message 2006 of 2,571
(10,705 Views)

Especially the conversions in the two case structures which (I think?) take a boolean, coerce it to dynamic data to then cast it to a boolean array, then back to dynamic data, merge it with other signals and back to a boolean array.

 

I also strongly dislike dynamic data because what even is the expected output of a double casted to dynamic data then casted to a boolean array.

Matt J | National Instruments | CLA
Message 2007 of 2,571
(10,701 Views)

@altenbach wrote:

In case you did not know how to create a simple 1D boolean array, here's one way I don't really recommend. 😄

 



Prime example of why "Express VIs" shouldn't even be there and "Dynamic Data" should be introduced at a much higher level.

 

NI is doing a huge disservice to new programmers with their "Just take these Express VI's and connect them with Dynamic Data wires so you don't have to worry (or think) about data types, how to properly handle them, or what you are doing.", beginner tutorials.

========================
=== Engineer Ambiguously ===
========================
Message 2008 of 2,571
(10,696 Views)

@altenbach wrote:

In case you did not know how to create a simple 1D boolean array, here's one way I don't really recommend. 😄

 

MergeDynamic.png

 

(seen here)


I THINK There is a clue to the poster's thought process in the boolean control labels.  We don't really need to ask, " What have you been smoking?" do we....


"Should be" isn't "Is" -Jay
Message 2009 of 2,571
(10,688 Views)

@Jacobson-ni wrote:

....

I also strongly dislike dynamic data because what even is the expected output of a double casted to dynamic data then casted to a boolean array.


My office is temporarily offline for movies but,  aren't the block diagrams unlocked.  WARNING: some content my offend some viewers.  Discretion is advised. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 2010 of 2,571
(10,680 Views)