LinuxCNC Documentation

SYNOPSIS

loadrt histobinstream [count=N|names=name1[,name2…​]] [keys=value[,value…​]]

keys

Stream shmem unique key for each instance

DESCRIPTION

Calculates a histogram of an input pin’s value. The histogram data is sent in a HAL stream for maximum transfer speed and to prevent any RT to non-RT data race conditions. This is the streaming counterpart to the histobins component.

Read the availablebins pin for the number of bins available. Set the minvalue, binsize and nbins pins and ensure nbins ≤ availablebins.

For nbins = N, the bins are numbered 0 …​ N-1. The value range covered is [minvalue …​ minvalue + N * binsize). Any input below minvalue is counted in the negative overflow (ntail). Any input at or above the upper edge is counted in the positive overflow (ptail).

The input used is selected based on pintype:

pintype inputpin

0

input

1

input-sint

2

input-uint

3

input-bool

Stream format and how to obtain the histogram data:

  • Set the stream pin to high.

  • Read the fifo data when it becomes available. The data streamed has the following sequence:

    • ntail bin[0] …​ bin[N-1] ptail

    • This gives nbins + 2 values streamed (all unsigned counts).

  • Read the statistics pins (input-min, input-max, mean, variance, nsamples) that reflect the values at the time when stream was asserted.

  • Set the stream pin to low.

The reset pin may be used to restart. Note that the reset pin is set to high at startup. You must set it to low before data collection begins.

The method input pin selects an alternate variance calculation (0: Welford incremental, 1: sum / sum-of-squares).

Maintainers note: hardcoded for MAXBINNUMBER==200

FUNCTIONS

histobinstream.N

PINS

histobinstream.N.pintype uint in

Select the input pin (0:input 1:input-sint 2:input-uint 3:input-bool).

histobinstream.N.input real in

Floating point input value (pintype 0).

histobinstream.N.input-sint sint in

Signed input value (pintype 1).

histobinstream.N.input-uint uint in

Unsigned input value (pintype 2).

histobinstream.N.input-bool bool in

Bit input value (pintype 3).

histobinstream.N.nbins uint in (default: 20)

Number of active bins N (0 …​ N-1).

histobinstream.N.binsize real in (default: 1)

Width of one bin in input units.

histobinstream.N.minvalue real in (default: 0)

Lower edge of bin 0.

histobinstream.N.reset bool in (default: 1)

Reset state and bins.

histobinstream.N.stream bool in (default: 0)

Set to high to stream all bins and tails on rising edge.

histobinstream.N.method bool in (default: 0)

Variance method (0:Welford incremental, 1:sum of squares).

histobinstream.N.stream-error bool out

Set if the data stream did not fit and was never sent.

histobinstream.N.input-error bool out

Set when input rules are violated; updates are invalid until fixed and a reset.

histobinstream.N.input-min real out

Minimum input value seen (latched on stream rising edge).

histobinstream.N.input-max real out

Maximum input value seen (latched on stream rising edge).

histobinstream.N.nsamples uint out

Number of samples accumulated (latched on stream rising edge).

histobinstream.N.variance real out

Variance of the input (latched on stream rising edge).

histobinstream.N.mean real out

Mean of the input (latched on stream rising edge).

histobinstream.N.stream-time sint out

The time it took for the stream data to be pushed out in nanoseconds (ns).

histobinstream.N.availablebins sint out (default: 200)

AUTHOR

Dewey Garrett, B.Stultiens, LinuxCNC contributors

LICENSE

GPL