Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/hal/components.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ To search in the man pages, use the UNIX tool `apropos`.
| link:../man/man9/counter.9.html[counter] |Counts input pulses (deprecated). Use the <<sec:encoder,encoder>> component. | |
| link:../man/man9/ddt.9.html[ddt] |Computes the derivative of the input function. ||
| link:../man/man9/deadzone.9.html[deadzone] |Returns the center if within the threshold. ||
| link:../man/man9/demux_generic.9.html[demux_generic] | Routes a single input signal to one of multiple outputs. ||
| link:../man/man9/div2.9.html[div2] |Quotient of two floating point inputs. ||
| link:../man/man9/hypot.9.html[hypot] |Three-input hypotenuse (Euclidean distance) calculator. ||
| link:../man/man9/ilowpass.9.html[ilowpass] |Low-pass filter with integer inputs and outputs ||
Expand Down
108 changes: 108 additions & 0 deletions docs/src/man/man9/demux_generic.9.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
= demux_generic(9)

== NAME

demux_generic - routes a single input signal to one of multiple outputs

== SYNOPSIS

**loadrt demux_generic config="**__<input_type><output_type><size>__[,__<input_type><output_type><size>__],...**"**

Types: **b** = bit, **f** = float, **s** = signed integer, **u** = unsigned integer

Example:
**loadrt demux_generic config="**bb8,fu12**"**


== FUNCTIONS

**demux-gen.**_NN_ Depending on the data types can run in either a floating point or non-floating point thread.

== PINS

demux-gen.NN.sel-bit-00 ───────────────────┐
... ─────────────────┐ │
demux-gen.NN.sel-bit-BB ───────────────┐ │ │
demux-gen.NN.sel-int ─────────────┐ │ │ │
┌───────┴─┴─┴─┴───────┐
│ / o───── ├───── demux-gen.NN.out-[bit/float/s32/u32]-00
demux-gen.NN.in-[bit/float/s32/u32] ─────┤ ─────o o───── ├───── ...
│ o───── ├───── demux-gen.NN.out-[bit/float/s32/u32]-MM
demux-gen.NN.suppress-no-input ─────┤ │
demux-gen.NN.debounce-us ─────┤ │
└─────────────────────┘

**demux-gen**.__N__.**suppress-no-input** bit in::
This suppresses changing the output if all select lines are false.
This stops unwanted jumps in output between transitions of input but makes in00 unavailable.
**demux-gen**.__N__.**debounce-us** unsigned in::
sets debounce time in microseconds, e.g. 100000 = a tenth of a second.
The selection inputs must be stable this long before the output
changes. This helps to ignore 'noisy' switches.
**demux-gen**.__N__.**sel-bit-**__BB__ bit in (BB=0..bit width of _size_)::
**demux-gen**.__N__.**sel-int** unsigned in::
The sel-bit pins are only created when the size of the demux_gen
component is an integer power of two.
Together, these determine to which **out**-__MM__ the **in** value is forwarded.
The bit pins are interpreted as binary bits, and the result is simply
added on to the integer pin input. It is expected that either one or
the other would normally be used. However, the possibility exists to
use a higher-order bit to "shift" the values set by the integer pin.
**demux-gen**.__N__.**in-**[**bit**/**float**/**s32**/**u32**] variable-type in::
The input value which is routed to an output depending on the selection pins.
**demux-gen**.__N__.**out-**[**bit**/**float**/**s32**/**u32**]**-**__MM__ variable-type out (M=0..size-1)::
According to the selection bits and/or the selection number, the selected output
follows the **in** value. The other outputs retain the values they had before
resp. zero if they have not been selected yet. Values will be
converted/truncated according to standard C rules. This means, for
example that a float input greater than 2147483647 will give an S32
output of -2147483648.

== PARAMETERS

**demux-gen**.__N__.**elapsed** float r::
Current value of the internal debounce timer for debugging.
**demux-gen**.__N__.**selected** s32 r::
Current value of the internal selection variable after conversion for debugging.
Possibly useful for setting up gray-code switches.

== DESCRIPTION

This component is a general demultiplexer component.
It allows the creation of arbitrary-size demultiplexers (up to
1024 entries) and also supports differing data types on the input and
output pins. The configuration string is a comma-separated list of
code-letters and numbers, such as "bb4,fu12". This would create a
4-element bit-to-bit demux and a 12-element float-to-unsigned demux.
The code letters are:

**b** = bit,
**f** = float,
**s** = signed integer and
**u** = unsigned integer.

The first letter code is the input type, the second is the
output type. The codes are not case-sensitive. The order of the letters
is significant but the position in the string is not. Do not insert any
spaces in the config string. Any non-zero float value will be converted
to a "true" output in bit form. Be wary that float datatypes can be
very, very, close to zero and not actually be equal to zero.

Each demux has its own HAL function and must be added to a thread
separately. If neither input nor output is of type float then the
function is base-thread (non floating-point) safe. Any demux_generic with
a floating point input or output can only be added to a floating-point
thread.

== SEE ALSO

mux_generic(9)

== AUTHOR

Hans Unzner

== LICENSE

GPL

3 changes: 3 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,8 @@ obj-$(CONFIG_BOSS_PLC) += boss_plc.o
boss_plc-objs := hal/components/boss_plc.o $(MATHSTUB)
obj-$(CONFIG_DEBOUNCE) += debounce.o
debounce-objs := hal/components/debounce.o $(MATHSTUB)
obj-$(CONFIG_DEMUX_GENERIC) += demux_generic.o
demux_generic-objs := hal/components/demux_generic.o $(MATHSTUB)
obj-$(CONFIG_ENCODER) += encoder.o
encoder-objs := hal/components/encoder.o $(MATHSTUB)
obj-$(CONFIG_ENUM) += enum.o
Expand Down Expand Up @@ -1303,6 +1305,7 @@ endif
../rtlib/classicladder_rt$(MODULE_EXT): $(addprefix objects/rt,$(classicladder_rt-objs))
../rtlib/boss_plc$(MODULE_EXT): $(addprefix objects/rt,$(boss_plc-objs))
../rtlib/debounce$(MODULE_EXT): $(addprefix objects/rt,$(debounce-objs))
../rtlib/demux_generic$(MODULE_EXT): $(addprefix objects/rt,$(demux_generic-objs))
../rtlib/encoder$(MODULE_EXT): $(addprefix objects/rt,$(encoder-objs))
../rtlib/enum$(MODULE_EXT): $(addprefix objects/rt,$(enum-objs))
../rtlib/counter$(MODULE_EXT): $(addprefix objects/rt,$(counter-objs))
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ CONFIG_MOTMOD=m
CONFIG_BLOCKS=m
CONFIG_BOSS_PLC=m
CONFIG_DEBOUNCE=m
CONFIG_DEMUX_GENERIC=m
CONFIG_ENCODER=m
CONFIG_ENUM=m
CONFIG_COUNTER=m
Expand Down
Loading
Loading