Examples For Calculated Signals; Extracting Bits Or Bit Fields From An Integer; Calculating Rms - ETAS MDA V8.6 User Manual

Table of Contents

Advertisement

ETAS
4.3

Examples for Calculated Signals

4.3.1

Extracting Bits or Bit Fields from an Integer

To extract individual bits see "Extracting Bits from a Signal" on page 50.
You can perform the following actions:
To extract a single bit from an integer
To extract a bit field from a signal
4.3.2

Calculating RMS

For alternating current wave forms (e.g. sine wave) there are several ways of
characterizing the voltage. One is the RMS (root mean square) which is the
equivalent DC voltage that would have the same heating effect on a resistor.
The calculation of RMS involves taking the average voltage over some time
range. To generate a low noise result it is important to align these time ranges
with the cycles of the wave form. This can be achieved by the following cal-
culations.
An example sine wave (use periodic 100 ms raster):
l
voltage = sin(Master())
Detecting the zero crossings (used to finish the integral):
l
positive = voltage > 0
windowDetect = positive && !State_Register(positive,
!1)
Also provide the detected signal delayed by one sample (used to restart
l
the integral):
windowDetect2 = State_Register(windowDetect, !1)
Remember start of window on each crossing:
l
windowStart = Latch(Master(), windowDetect2)
MDA V8.6 – User Guide
"To extract a single bit from an integer" below
l
"To extract a bit field from a signal" below
l
1. Shift the integer such that the bit of interest is in the 0 position.
2. Apply a bit-wise AND with 1 to isolate the individual bit.
singleBit = (inputsignal >> BIT)& 1
1. Shift the input signal such that the least significant bit (LEAST_
SIGNIFICANT_BIT) of the bit field that you want to extract is in the
0 position.
2. Isolate the NUMBER_OF_BITS of the bit field by applying a bit-
wise AND with a bitmask.
bitfield = (inputsignal >> LEAST_SIGNIFICANT_
BIT) & ~(~0 << NUMBER_OF_BITS)
4 Calculated Signals
62

Advertisement

Table of Contents
loading

Table of Contents