Using Comparator Subsystem (CMPSS) for Voltage Compare
This example shows how to use the Comparator Subsystem (CMPSS) to compare the analog voltage signals for Texas Instruments™ C2000™ processors and monitor the status output. Using this example, you can:
Configure the CMPSS module to generate the digital output when there is a voltage difference on the input pins
Configure Digital Filter to generate filtered output for CMPSS
The CMPSS consists of two modules, Comparator High (COMPH) and Comparator Low (COMPL). Each module generates a high digital output when the voltage on the first input pin (positive input) is greater than the voltage on the second input pin (negative input). Vice versa it generates low digital output when the voltage on the first input pin (positive input) is less than the voltage on the second input pin (negative input).
The second input pin can either be the external pin or the internal CMPSS DAC module.
To run this example, you can use either TI Piccolo F280049C LaunchPad or TI Delfino F28379D LaunchPad. For your convenience, a preconfigured model for
TI Delfino F28379D LaunchPad is used in this example.
1. DAC- A is connected to the positive input of the CMPSS1H comparator (COMPH of CMPSS1).
2. Configure the negative input to the internal DAC of CMPSS1(DACH).
3. COMPH actively compares the input voltages on its input pins and provides the STS output.
1. DAC- B is connected to the positive input of the CMPSS2L comparator (COMPL of CMPSS2).
2. Configure the negative input to the internal DAC of CMPSS2(DACL).
3. This COMPL actively compares the input voltages on its input pins and provides the STS output.
Connect the launchpad header pins for TI Delfino F28379D LaunchPad as listed below.
Using CMPSS Module for Voltage Compare Model
To open the model, type the following command in the MATLAB® prompt:
Configure the Model
1. Open the
Using CMPSS Module for Voltage Compare Model model. This model is configured for TI Delfino F28379D LaunchPad hardware.
2. To run the model on other TI C2000 processors, press Ctrl+E to open the Configuration Parameters dialog box and select the required hardware board by navigating to Hardware Implementation > Hardware board.
3. The following are the comparator configurations performed in the model. Ensure that the specified parameter values are the same if you want to run this example for other hardware board.
Configure CMPSS1 with COMPH
Configure CMPSS2 with COMPL
CMPSS Block Configurations
Following are the CMPSS block configurations done for this model. Double-click on the blocks to open block parameter configurations. Ensure the specified parameter values are the same if you want to run this example for other hardware board
Run the Model
1. Open Hardware tab and click Monitor & Tune.
2. Use the diagnostic viewer to follow the build progress and wait until the code loads and runs on the target hardware.
3. Observe the logged data on the Scope block.
Analysis of DAC and CMPSS output signals
This section explains how to interpret the DAC-A and COMPH for CMPSS1.
DAC-A voltage value ranges from 0-4095 which gives a Ramp voltage(0-3.3v) on the DAC-A pin. This voltage is fed to positive input of the CMPSS1 COMPH comparator.
The internal DAC (DACH) of the CMPSS1 is configured to output a constant voltage of 2048(1.65v).
The model is configured to run at a step time of 10ms. It will take 10ms * 4095 = 40.950 seconds for the DAC-A output to reach from 0 to 3.3V.
The COMPH outputs 0 for the first half as the voltage on the positive input is less than the constant voltage (1.65v) on negative input. It then outputs 1 for second half as the voltage on the positive input is now more than the constant voltage (1.65v) on negative input.
Similar interpretation can be done for DAC-B and CMPSS2 from the below Scope plot.
Other things to try
Run the example on the
TI Delfino F280049C LaunchPadhardware board.
Connect the launchpad header pins for TI Delfino F280049C LaunchPad as listed below.