3.2.2 Graph Configuration Example

This chapter gives an example on how to configure the Graph module to be used with a target application implementing a Night mode switch with a light sensor. Although this example utilizes only some of the data sources available in the Data Visualizer, the procedure will be the same for all data sources. The target code used in this example and a description of the hardware setup can be found in the Graph Example Code chapter. The first part of the configuration example uses the code found in the first subsection of the Graph Example Code chapter (Basic Graph). When changes to the target application code are required as the example progress a link to the corresponding code listing will be provided.

Todo: Select correct tool in the DGI Control Panel.
Todo: Click Connect to make a connection to the DGI on the selected tool.
Todo:
  • Click the SPI checkbox
  • Open the SPI Configuration dialog by clicking the Gear button next to the SPI checkbox
Todo:
  • Open the configuration panel
  • Add a Graph module to the Data Visualizer
  • Drag the source connector from the interface in the DGI Control Panel into the sink marked New plot to make a connection to a new plot
Todo:
  • Push Start in DGI Control Panel
The data will be plotted in the Graph module. It could look something like the picture below when hovering a hand above the light sensor.

The light sensor data can be used to switch between Day and Night mode. For the Night mode switch to be useful, the threshold when switching between the modes are important. The Graph module contains a useful feature called Band to mark when the plot data is within a certain range. This can be used to simplify the selection of the mode switch threshold.

Todo:
  • Drag the interface source to the New band sink

To see that the Night mode switch is actually working and switching at the right threshold, the string marker feature of the Graph module is useful. In this example, the CDC USART interface of the target board is used to send a string each time the mode is switched. These messages can then be shown in the graph as string markers. The target application source code for this part of the configuration example can be found in Adding String Markers.

Todo:
  • Open the Serial Port Control panel found under External Connection in the Modules section of the Configuration tab in Data Visualizer
Todo:
  • Select the correct COM port corresponding to the connected kit
  • Set the serial port parameters according to the application code
  • Make sure the Open Terminal option is not checked
Todo:
  • Drag the serial port source to the New string sink
  • Click Connect in the Serial Port Control Panel
String markers will appear as vertical lines with a square on top. By double-clicking the square the string text will be shown. Note that there will naturally be some delay from the ADC data values crosses the threshold until the string message reaches the host computer. In addition, the timestamping of the data is added on the host computer and the two serial interfaces are not synchronized. This results in a misalignment of the string markers compared to the ADC values. DGI includes timestamping functionality on the EDBG on the Xplained Pro and this can be enabled in the DGI Control Panel at a performance cost, but CDC includes no time stamping functionality.
Tip: In this example, a separate serial interface was used for the string marker data. If the number of serial interfaces available are constrained, the same interface could be used to stream both the ADC data and the string marker data by using the Atmel Data Protocol (ADP). For more information, see the Atmel Data Protocol.

So far, the Graph module of the Data Visualizer has been used to show the data generated by the light sensor and to show when the Night mode switch toggles between the two modes. The Graph module can also be used to interact with the target application while it is running. In this example, the Night mode threshold can be adjusted dynamically by using a horizontal cursor.

The target application source code for this part of the configuration example can be found in Using Horizontal Cursor Code.

Todo:
  • First, remove the band from the graph as it is of no use when the Night mode threshold is dynamic
  • Click Add Horiz. Cursor to add a horizontal cursor to the graph
  • Drag the Horizontal Cursor source to the sink in the Serial Port Control Panel
To move the horizontal cursor either drag it or change the value by typing a new value in the Value field in the configuration. Note that the value will not be updated until the Value text box is not in focus, i.e. click somewhere else in the GUI after typing in a value. Every time the cursor is moved the Data Visualizer sends a new float value to the serial port the cursor is connected to.
Tip: Turn off Auto-scroll and Automatically fit Y to more closely examine a plot while it is still running.