You need to test, we're here to help.

You need to test, we're here to help.

13 September 2021

Correlating Sensor and Serial Data in Complex Embedded Systems

Figure 1: Voltage output of a temperature sensor.
As the temperature rises, the output voltage falls. 
The microcontrollers/microprocessors in deeply embedded systems often are set up to monitor and control operational parameters.  Take, for example, a deeply embedded system where a microcontroller is used to control temperature that has been sensed by a temperature sensor.  The sensor is read through one of the microcontrollers analog interfaces.  As temperature changes are sensed, the microcontroller adjusts the speed of a cooling fan, which is driven by a pulse width modulated signal. The microcontroller uses a program algorithm to convert the DC level of the sensor into a PWM signal with an appropriate duty cycle to set the fan speed to correct any changes in temperature. 

Where it is possible to probe the temperature sensor, the output is a DC signal that changes very slowly over time.  Figure 1 shows a direct measurement of the temperature sensor using a heavily filtered oscilloscope channel to minimize noise pickup.

One thing to remember, though, is that in embedded systems, these temperature sensors are rarely accessible to probing. However, you may have access to the microcontroller, and it is usually easy to access the communication from the microcontroller to the fan controller. So, in this case, we have a method of monitoring the status of the device temperature via the I2C link from the microcontroller to the PWM controller controlling the fan.

Connecting oscilloscope probes to the clock and data lines of the I2C signal, we can acquire and decode the fan speed commands. The oscilloscope decoder interprets the signal based on the I2C protocol and displays the data content as a colored overlay on the electrical signal trace, while also listing each packet’s data content in a table (Figure 2).

Figure 2: Decoded I2C temperature control data.
Address 0x9a is the PWM fan speed controller.
The decoder table lists the packet number, trigger time of the acquisition, packet address length, address, read/write mode, data length in bytes, and the data payload in binary or hexadecimal format. (For some protocols, symbolic decoding is also available). In this system, address 0x9a is the device ID for the PWM controller. Byte 0—containing values 30, 40, or 50—selects one of three outputs of the PWM controller, with 40 indicating a fan speed control.

Therefore, if we want to track the fan speed as an indicator of temperature, we are only interested in packets addressed to 0x9a that contain data value 40 in Byte 0. Byte 1 is the actual data setting the fan speed. 

Figure 3: Table filtered for only data packets
with the 40 fan speed control value.
The decoder table is customizable, and we can filter out all payload data except for that containing 40, fan speed control data, as shown in Figure 3. At this point, the filtered data related only to fan speed control can be read as a sequence of fan speeds that correlate to the state of the temperature sensor.

If the decoder software is Measure/Graph enabled (options containing “ME” and “MP” in the name), these filtered serial data values can be converted to the corresponding analog values and plotted as a function of time. The decoder is a Digital to Analog converter! 

First, set up a parameter applying the Message to Value serial data measurement to the decoder results (Figure 4). As part of defining the Message to Value parameter, you specify what Data column bits to extract from each packet and the formula by which to convert it to analog values. In our example, the fan control data is contained in Byte 1, bits 7 through 0, so we tell the oscilloscope to start at bit 7 and take a total of 8 bits (7 to 0). This is scaled to fan motor speed by taking the value represented by those bits, multiplying it by 14.1 (in this case), and converting the result to the unit of rotational speed, revolutions per minute (RPM). Next, create a math function (F1) to plot the converted P1 measurement values as a Track graph, which acts like a strip chart recorder showing each analog value in sequence.

Figure 4: Measure/Graph-enabled decoders allow you to extract desired bits of serial data, perform a linear scaling to analog values, and graph converted data as a histogram, trend or track.

You can see from the I2C data plot (orange trace) that the RPM is ramping up slowly until it limits at maximum RPM. The fan speed correlates with device temperature: as temperature increases, speed increases. The fan’s effect is to cool the device, so as the temperature decreases, the fan speed also decreases. Note how the curve is inverse to the DC output of the temperature sensor, which drops with increase in temperature.

Any decoded bits of payload data can be extracted and converted in this fashion using Measure/Graph capability. This is a very powerful tool, because it lets you use the decoded contents of serial data streams, which are generally accessible, to “extract” data from sensors which may not be reachable for direct probing of their analog signals. 

Read more about our Measure/Graph & Eye Diagram (TDME) options.

Watch William Kaunds explain many facets of debugging embedded systems in the on-demand webinar, Debugging Complex Embedded Computing System Issues (Part 2).

Also see:

Debugging Complex Embedded Systems


No comments:

Post a Comment