|
<< Click to Display Table of Contents >> 8.2 Waveform Equation Blocks for editable Analog waveforms |
![]() ![]()
|
Sine, Capacitor, Ramp and Exponential waveforms can be inserted into a waveform segment using a Waveform Equation Block. Unlike the State Label equations of the next section which append analog waveform segments onto the end of a signal, waveform equation blocks can edited after they are created. For this reason, it's often better to use a waveform equation block rather than a State Label equation.
Overview of steps to add a Waveform Equation Block to a Signal
|
|
|
|
|
|
|
|
Editing a Waveform Equation Block
|
|
|
|
Programming Waveform Equation Blocks
|
|
|
currentT is the current time for the event (e.g currentT will be startT + deltaT for the first event and startT + durationT for the last event in the block). startT is the start time for the block. deltaT is the sampling period for the block. durationT is the duration of the block. |
sampleT = currentT |
|
|
|
![]()
|
Advanced Waveform Equation Programming
Waveform Equation Blocks can access additional information about the timing diagram through our BtimPython module. While a Waveform Equation Block's code is executing, it can access the information about the waveform block through the global object currentWaveformBlock. From this object, you can navigate to objects representing the signal containing the block, the btim document, and other signals and event data in the document. This allows equations to generates state values based on either the event values of other signals or previous event values in the same signal.
There are several examples of equations which use the BtimPython API in the example file called waveform_block_equations.btim. The signals named from_text_file, product, and ramp_max_to_min demonstrate using the API to access the document's filename, get events from other signals, and access properties of the containing signal.
The full BtimPython API is documented in the file btim.html located in the SynaptiCAD/help directory. The BtimPython module is designed for use in stand-alone python programs as well as Waveform Equation Blocks. While all of the API functions can be called from a waveform equation block, many of the functions available in the module (such as creating new timing diagrams) will not be useful in this context.
Basing an Equation on the Preceding State Before the Waveform Block
It is often useful to define a waveform block equation so that it's waveform is a function of the state of the signal just before the waveform block begins. Two Python functions are available to get this preceding value, depending on whether the waveform block is generating analog (real values) or digital values:
|
The signals called uses_preceding_event and uses_preceding_digital in the waveform_block_equations.btim file contain waveform block equations that demonstrate usage of these two functions.
Formatting the Equation's Return Value for Digital Signals
When using Waveform Equation Blocks to generate analog equations, the python code fragment should return a python floating point value. Waveform Equation Blocks can also be used to generate digital signals. For digital signals, your Python code should return values as a strings of binary digits so that the signal's radix can post-process the value. For example, if you wish to return the hexadecimal value 'h71, you would want your python code to say: "return '1110001'". When the values are displayed to the user, they will be converted using the radix set in the Signal Properties dialog. For example, if the signal's radix is set to "hex" and the MSB:LSB is set to 15:0, that string will be formatted as 0071.
Two different ways of converting your digital values to binary strings are demonstrated in the signalsrandom and repeating_sequence in waveform_block_equations.btim. In the signal repeating_sequence, a decimal value is converted to a binary string using this python command:
valueAsBinary = '{0:b}'.format(value)