5.2 Plot Graph In MPLAB® Data Visualizer
The MPLAB® Data Visualizer is a program used to process and visualize data from a running embedded target. The program may be accessed as an MPLAB X IDE plugin or a stand-alone program. In this assignment, the Data Visualizer will be configured to graph the input and output of OP0 received over USART. The configuration is done through a saved workspace, and the basics of how to display the data are explained. To find out how to set up your own workspace, a detailed guide can be found by clicking on the Documentation button in MPLAB Data Visualizer.
- Open the program and plug in an
already flashed device. Make sure the COM-port used for USART communication is not
already in use. The start screen will be similar to Figure 5-2.
- Load the workspace. Press the Load
Workspace button and add the workspace-file called Assignment3.json.
All the workspaces for this training can be found in
DataVisualizer
. Two axes appear in the graph. These can be configured on the panel on the right-hand side, as illustrated in Figure 5-3. - Choose the COM-port on the left-hand
side panel seen in Figure 5-3 to plot the data.
Make sure the Baud Rate is 115200 and press the Apply button to
set the baud rate. Press the Play button next to the COM field shown in Figure 2. Press the
Variable Streamers button to connect the decoder to the USART data
stream. Set the COM port as input to Decoder 1, as shown in Figure 3.
- Press Show Live Data to start plotting live data from the device.
void sine_wave_table_init(void) { for(uint16_t i = 0; i < SINE_WAVE_STEPS; i++) { sine_wave[i] = SINE_DC_OFFSET + SINE_AMPLITUDE * sin(i * M_2PI / SINE_WAVE_STEPS); } }
ISR(SINE_WAVE_TIMER_vect) {
volatile static uint16_t sine_wave_index = 0
data_stream.dacVal = sine_wave[sine_wave_index];
DAC0_setVal(data_stream.dacVal);
sine_wave_index++;
sine_wave_index = sine_wave_index % SINE_WAVE_STEPS;
/* Clear interrupt flag */
SINE_WAVE_TIMER.INTFLAGS = TCB_CAPT_bm;
}