Loop

From SweepMe! Wiki
Jump to navigation Jump to search

Loop allows you to do repetitions during your measurement and thus behaves like a for-loop. It can also be used to create a while-loop by using the nonstop mode.

Properties

  • Double-click Loop in the sequencer to open its settings.
  • Enter a positive integer number in the field "Repetitions" to define the number of repetitions. The parameter syntax {...} can be used as well.
  • Loop returns the variable "Index". The first index is 1.
  • Enter 0, "nonstop", or "endless" to use the nonstop mode with a never-ending iteration. The words "nonstop" and "endless" are accepted from SweepMe! 1.5.8.3.

Nonstop mode

  • Entering 0, "nonstop", or "endless" as repetitions enables the nonstop mode.
  • The nonstop mode can be stopped at any time using the button "Stop".
  • Furthermore, the nonstop mode can be stopped by using Condition.
  • If your measurement runs basically forever with no planned end, please consider using the reduction mode.

Reduction mode

If a measurement creates a large number of measurement points, a memory error could occur because the RAM is full. Furthermore plotting a large number of points can slow down the program and can lead to freezing the program. To prevent this, Loop comes with a reduction mode that can be enabled with the toggle "Use reduction" to set a maximum number of points that are stored by SweepMe! before measurement points are discarded. Data that is saved by MakeFile to a file is not affected.

Most important is to define the maximum number of points that should be kept in the data manager of SweepMe! using the field "Maximum points" (default 10000). Further one can change the way how data is discarded with the field "Reduction mode": Linear, Quadratic (default), Cubic, or Square root. Linear reduction means that data is thinned out evenly over the entire measurement time. Quadratic reduction means that data points are discarded with a quadratic weight regarding the time distance between two neighboring points such that more recent points remain. As a consequence, points that are more back in time are more likely to be discarded. Cubic reduction makes this effect even stronger, while Square root reduction does the opposite and keeps relatively more of the older points. Additionally, one can define a percentage of the latest measurement points that are always kept using the field "Keep last points [%]" (default 10). These points are not thinned out until they do not belong any more the defined percentage of last points. This way one can keep points that have been recently measured completely. Keeping 100% of the latest points means that always the oldest measurement point is discarded.

Applications

  • Log sensor data over time and use Loop to create a permanent repetition of the measurement.
  • Combine Loop with Delay to get measurement points that are evenly spaced in time.
  • Repeat the measurement of certain value to average later or to check whether the measurement value is stable.