SPRUJ26A September 2021 – April 2024
The DATALOG module stores the real-time values of two user selectable software variables in the data RAM provided on the C2000 MCU as shown in Figure 3-23. The two variables are selected by configuring the module inputs, iptr[0] and iptr[1] to the address of the two variables. The starting addresses of the two RAM buffer locations, where the data values are stored, are stored in datalogBuff1[0] and datalogBuff1[1]. These Datalog buffers are large arrays that contain value-triggered data that can then be displayed to a graph. The datalog prescalar is configurable, which will allow the dlog function to only log one out of every prescalar samples. The default prescalar is set to 10, but can be changed by modifying the value of the DATA_LOG_SCALE_FACTOR define in the datalogIF.h file. Direct Memory Access (DMA) is used to transfer the values of the selected software variables to the datalog buffer in RAM.
In order to enable the datalog functionality, the predefine symbol DATALOGF2_EN must be added in the project properties as shown in Figure 3-19.
The code below shows the declaration of one DATALOG object and handle. This code is located in the datalogIF.c file.
DATALOG_Obj datalog;
DATALOG_Handle datalogHandle; //!< the handle for the Datalog object
The code below shows the initialization and setting up of the datalog object, handle and parameters. This code is located in the sys_main.c file.
// Initialize Datalog
datalogHandle = DATALOGIF_init(&datalog, sizeof(datalog));
DATALOG_Obj *datalogObj = (DATALOG_Obj *)datalogHandle;
HAL_setupDMAforDLOG(halHandle, 0, &datalogBuff1[0], &datalogBuff1[1]);
HAL_setupDMAforDLOG(halHandle, 1, &datalogBuff2[0], &datalogBuff2[1]);
The code below shows the configuration of the two module inputs, iptr[0] and iptr[1], to point to the address of two variables. The datalog module inputs point to different system variables depending on the build level. This code is located in the sys_main.c file:
datalogObj->iptr[0] = &motorVars_M1.adcData.I_A.value[0];
datalogObj->iptr[1] = &motorVars_M1.adcData.I_A.value[1];
The code below shows the periodic updating of the datalog buffer with the new data during the execution of the motor1ctrlISR() interrupt. This code is located in the motor1_drive.c file.
if(DATALOGIF_enable(datalogHandle) == true)
{
DATALOGIF_updateWithDMA(datalogHandle);
// Force trig DMA channel to save the data
HAL_trigDMAforDLOG(halHandle, 0);
HAL_trigDMAforDLOG(halHandle, 1);
}
The datalog module is used with the graph tool, which provides a means to visually inspect the variables and judge system performance. The graph tool is available in CCS, which can display arrays of data in various graphical types. The arrays of data are stored in a device’s memory in various formats.
While the project is in debug mode, open and setup time graph windows to plot the data log buffers as shown in Figure 3-24. Alternatively, the user can import the graph configurations files that are located in the project folder. In order to import them, Click: Tools -> Graph -> DualTime… and select import and browse to the following location <install_location>\solutions\universal_motorcontrol_lab\common\debug and select motor_datalog_fp2.graphProp file. Hit OK, this should add the Graphs to your debug perspective. Click on Continuous Refresh button on the top left corner of the graph tab.