Difference between revisions of "Component: Scale (DSP)"

From Flowcode Help
Jump to navigationJump to search
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
+
{| style="width:50%"
 
 
{| width="50%"
 
 
|-
 
|-
| width="20%" style="color: gray;" | Author
+
| width="20%" style="color:gray;" | Author
 
| Matrix Ltd
 
| Matrix Ltd
 
|-
 
|-
| width="20%" style="color: gray;" | Version
+
| width="20%" style="color:gray;" | Version
| 1.1 (Release)
+
| 1.1
 
|-
 
|-
| width="20%" style="color: gray;" | Category
+
| width="20%" style="color:gray;" | Category
 
| DSP
 
| DSP
 
|}
 
|}
  
  
 +
==Scale component==
 +
Allows the values in a single buffer to be scaled uniformly. Functions include: Multiply, Divide, LeftShift, RightShift, Float Multiply, Float Divide
  
==[[File:Component Icon f1af5256_1dee_491c_b43f_fdc8f33279fb.png|Image]] Scale component==
+
==Component Pack==
Allows the values in a single buffer to be scaled uniformly.
 
Functions include: AddOffset, Divide, LeftShift, Multiply, RightShift, Subtract, ScaleReal
 
  
==Examples==
+
DSP
  
Here is a basic example showing various aspects of the DSP scale component.
+
==Detailed description==
  
{{Fcfile|Scale.fcfx|Scale}}
 
  
  
The RightShift macro is a very efficient means of performing a division but only for values which are a power of 2.
 
  
The LeftShift macro is a very efficient means of performing a multiplication but only for values which are a power of 2.
 
  
  
LeftShift(1) = Multiply by 2 / RightShift(1) = Divide by 2
 
  
LeftShift(2) = Multiply by 4 / RightShift(2) = Divide by 4
 
  
LeftShift(3) = Multiply by 8 / RightShift(3) = Divide by 8
 
  
LeftShift(4) = Multiply by 16 / RightShift(4) = Divide by 16
 
  
  
Here is an example which demonstrates multiplication and division and then compares to the shift macros.
+
''No detailed description exists yet for this component''
  
[[File:DSPScale.jpg]]
+
==Examples==
  
  
Note that the maths for the scale function will not take roll overs into account, this is why the multiply and left shift traces wrap back to zero when the input is above the mid point level.
 
  
128 x 2 = 256
 
  
256 & 0xFF = 0
 
  
==Downloadable macro reference==
 
  
===<span style="font-weight: normal;"><u><tt>DivideTick</tt></u></span>===
 
Allows a integer divide to be assigned to the current index position within the buffer.
 
  
'''Parameters'''
 
  
:[[Variable Types|UINT]] ''Scaler''
 
  
  
'''Return value'''
 
  
:''This call does not return a value''
 
  
 +
Here is an example which demonstrates variable scaling based on an analogue input.
  
===<span style="font-weight: normal;"><u><tt>LeftShift</tt></u></span>===
+
{{Fcfile|Scale.fcfx|Scale}}
Allows a highly efficient multiply to be assigned to every value within the buffer.
 
  
'''Parameters'''
+
Here are the traces as seen on the data recorder window.
  
:[[Variable Types|BYTE]] ''Scaler''
+
[[File:DSPScale.jpg]]
  
  
'''Return value'''
+
The RightShift macro is a very efficient means of performing a division but only for values which are a power of 2.
  
:''This call does not return a value''
+
The LeftShift macro is a very efficient means of performing a multiplication but only for values which are a power of 2.
  
  
===<span style="font-weight: normal;"><u><tt>MultiplyTick</tt></u></span>===
+
LeftShift(1) = Multiply by 2 / RightShift(1) = Divide by 2
Allows a less efficient but more flexible multiply to be assigned to the current index position within the buffer.
 
  
'''Parameters'''
+
LeftShift(2) = Multiply by 4 / RightShift(2) = Divide by 4
  
:[[Variable Types|UINT]] ''Scaler''
+
LeftShift(3) = Multiply by 8 / RightShift(3) = Divide by 8
  
 +
LeftShift(4) = Multiply by 16 / RightShift(4) = Divide by 16
  
'''Return value'''
+
==Downloadable macro reference==
  
:''This call does not return a value''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetScalerFloat'''
 +
|-
 +
| colspan="2" | Sets the Float scaler to be used when calling the calculate function.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 +
| width="90%" | Scaler
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
===<span style="font-weight: normal;"><u><tt>ScaleReal</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Scales the value based on a floating point number.
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetScalerInteger'''
 +
|-
 +
| colspan="2" | Sets the Integer scaler to be used when calling the calculate function.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
 +
| width="90%" | Scaler
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
'''Parameters'''
 
  
:[[Variable Types|FLOAT]] ''Scaler''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Value to set the floating point scale
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Calculate'''
 +
|-
 +
| colspan="2" | Performs the selected scaling on a value from the input buffer and passes to the output buffer.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
'''Return value'''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
:''This call does not return a value''
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CalculateArray'''
 
+
|-
===<span style="font-weight: normal;"><u><tt>ScaleRealTick</tt></u></span>===
+
| colspan="2" | Performs the selected scaling on an entire buffer.&nbsp;
Scales the value based on a floating point number.
+
|-
 
+
|-
'''Parameters'''
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
+
| width="90%" style="border-top: 2px solid #000;" | ''Return''
:[[Variable Types|FLOAT]] ''Scaler''
+
|}
::Value to set the floating point scale
 
 
 
 
 
'''Return value'''
 
 
 
:''This call does not return a value''
 
 
 
 
 
===<span style="font-weight: normal;"><u><tt>SubtractOffset</tt></u></span>===
 
Allows a integer offset to be subtracted from every value within the buffer.
 
 
 
'''Parameters'''
 
 
 
:[[Variable Types|UINT]] ''Offset''
 
 
 
 
 
'''Return value'''
 
 
 
:''This call does not return a value''
 
 
 
 
 
===<span style="font-weight: normal;"><u><tt>Divide</tt></u></span>===
 
Allows a integer divide to be assigned to every value within the buffer.
 
 
 
'''Parameters'''
 
  
:[[Variable Types|UINT]] ''Scaler''
 
  
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>LeftShiftTick</tt></u></span>===
 
Allows a highly efficient multiply to be assigned to the current index position within the buffer.
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Scaler''
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>Multiply</tt></u></span>===
 
Allows a less efficient but more flexible multiply to be assigned to every value within the buffer.
 
 
'''Parameters'''
 
 
:[[Variable Types|UINT]] ''Scaler''
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>RightShift</tt></u></span>===
 
Allows a highly efficient divideto be assigned to every value within the buffer.
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Scaler''
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>RightShiftTick</tt></u></span>===
 
Allows a highly efficient divide to be assigned to the current index position within the buffer.
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Scaler''
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>AddOffsetTick</tt></u></span>===
 
Allows a integer offset to be added to the current index position within the buffer.
 
 
'''Parameters'''
 
 
:[[Variable Types|UINT]] ''Offset''
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>SubtractOffsetTick</tt></u></span>===
 
Allows a integer offset to be subtracted from a single index value within the buffer.
 
 
'''Parameters'''
 
 
:[[Variable Types|UINT]] ''Offset''
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>AddOffset</tt></u></span>===
 
Allows a integer offset to be added to every value within the buffer.
 
 
'''Parameters'''
 
 
:[[Variable Types|UINT]] ''Offset''
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
 
==Simulation macro reference==
 
 
''This component does not contain any simulation macros''
 
  
  
 
==Property reference==
 
==Property reference==
<span style="font-weight: normal;"><u>Buffer Manager</u></span>
 
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''buffer_manager''.
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
Reference to DSP system buffer manager component.
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
<span style="font-weight: normal;"><u>Input</u></span>
+
|-
 
+
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''input_a''.
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Connect To
Buffer assigned to input channel
+
|-
 
+
| colspan="2" | DSP component with output buffer to collect our data from.&nbsp;
<span style="font-weight: normal;"><u>Output</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''output_c''.
+
| width="90%" | Buffer Size
 
+
|-
Buffer assigned to output channel
+
| colspan="2" | Number of individual elements the buffer can store, default 1.&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | Buffer Type
 +
|-
 +
| colspan="2" | Sets the buffer data type.&nbsp;
 +
|-
 +
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Scaling
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | Scale Type
 +
|-
 +
| colspan="2" | Defines the type of calculation performed on the input buffer to obtain the output value. A left shift is essentially an optimised multiply with the multiplier being the 2^scaler A right shift is essentially an optimised divide with the divider being the 2^scaler &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 +
| width="90%" | Rollover
 +
|-
 +
| colspan="2" | Allow the output buffer to rollover. For example 128 * 2 = 256 which would equate to 0 using an 8-bit buffer with rollover enabled. With rollover disabled the output would be set to 255 which is the max representable value.&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 +
| width="90%" | Initial Integer Scaler
 +
|-
 +
| colspan="2" | &nbsp;
 +
|}

Latest revision as of 17:19, 9 November 2022

Author Matrix Ltd
Version 1.1
Category DSP


Scale component

Allows the values in a single buffer to be scaled uniformly. Functions include: Multiply, Divide, LeftShift, RightShift, Float Multiply, Float Divide

Component Pack

DSP

Detailed description

No detailed description exists yet for this component

Examples

Here is an example which demonstrates variable scaling based on an analogue input.

FC6 Icon.png Scale

Here are the traces as seen on the data recorder window.

DSPScale.jpg


The RightShift macro is a very efficient means of performing a division but only for values which are a power of 2.

The LeftShift macro is a very efficient means of performing a multiplication but only for values which are a power of 2.


LeftShift(1) = Multiply by 2 / RightShift(1) = Divide by 2

LeftShift(2) = Multiply by 4 / RightShift(2) = Divide by 4

LeftShift(3) = Multiply by 8 / RightShift(3) = Divide by 8

LeftShift(4) = Multiply by 16 / RightShift(4) = Divide by 16

Downloadable macro reference

Fc9-comp-macro.png SetScalerFloat
Sets the Float scaler to be used when calling the calculate function. 
Fc9-f32-icon.png - FLOAT Scaler
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png SetScalerInteger
Sets the Integer scaler to be used when calling the calculate function. 
Fc9-s16-icon.png - INT Scaler
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Calculate
Performs the selected scaling on a value from the input buffer and passes to the output buffer. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png CalculateArray
Performs the selected scaling on an entire buffer. 
Fc9-void-icon.png - VOID Return



Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png Connect To
DSP component with output buffer to collect our data from. 
Fc9-type-21-icon.png Buffer Size
Number of individual elements the buffer can store, default 1. 
Fc9-type-16-icon.png Buffer Type
Sets the buffer data type. 
Fc9-conn-icon.png Scaling
Fc9-type-16-icon.png Scale Type
Defines the type of calculation performed on the input buffer to obtain the output value. A left shift is essentially an optimised multiply with the multiplier being the 2^scaler A right shift is essentially an optimised divide with the divider being the 2^scaler  
Fc9-type-7-icon.png Rollover
Allow the output buffer to rollover. For example 128 * 2 = 256 which would equate to 0 using an 8-bit buffer with rollover enabled. With rollover disabled the output would be set to 255 which is the max representable value. 
Fc9-type-14-icon.png Initial Integer Scaler