Keeping your calculations in fixed point (that is, scaled integer operations) is important for getting maximum performance from a low-cost microcontroller. Performance can be sped up by a factor of 5 or more by using in-line fixed point vs. emulated floating point. VisSim/Fixed-Point lets you simulate and generate code for fixed-point algorithms. You can mix fixed-point algorithms like controllers or filters with floating-point plant models to validate system behavior.
When used in conjunction with VisSim/Embedded Controls Developer, VisSim/Fixed-Point produces highly efficient, fixed-point production code that works very well with targets like Texas Instruments C2000 microcontroller.
Simulation is Key to Debugging
The downside to fixed-point coding is the limited range and precision relative to floating point. The upside to model-based development is that you can easily simulate your model and debug it before you ever generate code. It can be very difficult to find overflow cases and maximize precision when hand coding, so the VisSim model-based paradigm is ideal for fixed-point algorithm development. VisSim/Fixed-Point makes fixed-point design easy by tracking minimum and maximum values during simulation. Any overflow causes an error and flags the block red.
Think in Floating Point, Simulate and Generate Code in Fixed Point
You enter floating point values in gains, parameters and constants. You choose the desired scaling (or let VisSim autoscale) and VisSim will perform bit true simulation. In simulation mode, values will be truncated and drop precision just like they will on the target hardware. VisSim makes it easy to adjust the radix point and word size on an operator basis. This is important to get optimal performance.
The fx Notation vs Q Notation
For ease of use and clarity, VisSim uses the "fx" format: fx<magnitude bits>.<word size>. For example, scaling with 8 bits of magnitude in a 16 bit word has format fx8.16. Texas Instruments uses the "Q" format. It only has one numeric value, the number of fractional bits. It is missing the word size, so it can be ambiguous. The fx8.16 is q8 in a 16 bit word or q24 in a 32 bit word. If you are doing fixed point intensive calculations that move between 16 and 32 bit word size, it is much easier to have the word size as a consistent field, and think in terms of available magnitude bits. The Q notation requires that you do a mental subtraction of the fractional bits from the implied word size to obtain the all important magnitude bit length. As you might expect, this is prone to error.
The "auto-scale" mode automatically sets the radix point on each auto-scale enabled fixed-point block to the optimal point. This point allows storage of the largest magnitude value seen during the simulation, while retaining the maximal fractional precision possible.
Tutorials and Interactive Help
VisSim/Fixed-Point provides comprehensive tutorials on fixed-point controller design, along with an example of converting a floating-point controller implementation to a fixed-point implementation. VisSim/Fixed-Point includes interactive Help.
High Level Fixed-Point Library
VisSim/Fixed-Point provides a toolbox of high level fixed-point operations like 16- and 32-bit PI and PID, digital integrators, up count, down count, ramp, rising/falling edge detect, cascadable counters, resettable one-shots, triangle wave generation, and toggle.
- Uses simpler 'fx' notation instead of 'q' notation
- Automatic radix point scaling of all fixed-point blocks and fixed-point operations to maximize dynamic range
- Efficient simulation and code generation for digital filters, sin, cos, arctan2, sqrt, interpolated table look-up
- Color highlighting at the block level for overflow alerts
- Use of high and low watermarks to determine headroom for radix point settings
- Master word length control that enables the fixed-point word length to be changed for the entire block diagram
- Choose any word size between 1 and 32
- Many blocks that become fixed- or floating-point based on the input data type
- Intuitive dialog boxes to configure fixed-point options