Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Using Constants in Fractional Notation (Blackfin, Embedded Module)

You cannot use a fixed-point decimal notation to directly express fractional data. You must specify constants in hexadecimal format.

Tip  Fractional constants must be greater than or equal to –1.0 and less than 1.0.

Complete the following steps to specify a constant in fractional notation.

  1. Express the value as a floating-point number.
    Example: 0.75
  2. Multiply the floating point number by 32,768.0 for a fract16 constant or 2,147,483,648.0 for a fract32 constant.
    Example: 0.75 * 32,768.0 = 24,576.0
  3. Truncate, or fix, the result to a 16-bit integer for a fract16 constant or a 32-bit signed integer for a fract32 constant.
    Example: FIX(0.75 * 32,768.0) = FIX(24,576.0) = 24,576
  4. Express the fixed-point number as a hexadecimal value.
    Example: FIX(0.75 * 32,768.0) = 24,576 = 0x6000

Entering Hexadecimal Constants in LabVIEW

You can create constants for the Blackfin Analysis Library and Blackfin Numeric VIs in two ways:

  • Use the fract16 and fract32 custom controls on the Fixed Point palette.
  • Right-click an input terminal of a VI and select Create»Constant from the shortcut menu.

Complete the following steps to specify a fixed-point constant as a hexadecimal value.

  1. Right-click a numeric constant and change the numeric representation to I16 if necessary.
  2. Right-click the constant and select Format and Precision from the shortcut menu to open the Numeric Constant Properties dialog box.
  3. Click the Format and Precision tab.
  4. Select the Advanced editing mode radio button.
  5. Enter 0x%04.4x in the Format string text box.
  6. Click the OK button to display the constant as a hexadecimal value.

Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit