Control virtual analog inputs with the convenience of a knob.
Knobs can be added to a host to manually control analog inputs.
To use a knob, drag and drop it from the Virtuoso Components control group onto the schematic, or right-click the schematic area and type “knob” and select the knob from the drop-down.
The knob has a single KnobValue double precision output port.
The knob’s properties are shown below.
The Component ID is generated randomly when the knob instance is created.
The Mechanically Limited checkbox sets whether the knob should spin freely without limitation, or should be “mechanically” limited on the low and high end.
When mechanically limited, the Minimum and Maximum Knob Values indicate the range of values the knob will output. The Minimum and Maximum Knob Rotation specifies the mechanical range that the knob will move. The angle is specified with 0° at the top, and positive angles corresponding to a clockwise direction.
If Mechanically Limited is unchecked, the property window changes, and the only input that must be specified is the Value Change Per Degree input. This value defines the relationship between knob movement in degrees and value change. If Value Change Per Degree is set to 10, then for every degree of rotation in the clockwise direction, the knob’s output value will increase by 10.
The Is Value Visible checkbox indicates whether the numerical value of the knob’s value should be displayed at the center of the knob, as shown below.
The Display Name is shown beneath the knob at runtime as shown below.
To easily see how the knob works, connect a gauge to display the knob’s value as shown below. Both the knob and gauge can have a range of 0 to 100. When you run the host, you will be able to control the gauge value by moving the knob. Since the knob and the gauge are both double precision ports, conversion isn’t needed, however if the knob is connected to another port type, like a 32-bit integer, the knob’s value will be converted to an integer by the port connection snippet metadata.
The XAML code emitted for the knob and gauge for a C# WPF host are as shown below, with the data context for each binding to their respective view models.
The emitted base view model code regions are shown below. The knob and gauge view model properties are declared
They are then initialized in the initialization section based on their configurations:
The port connection results in the Knob value’s change notification causing the gauge value to be updated with the knob value.