Tuesday, 24 July 2018

Modified Condition/Decision Coverage (MCDC) in depth tutorial - Condition coverage - Decision coverage


The Modified condition/decision coverage is one of the code coverage testing and can be categorized as white-box testing. It can bettered be explained with the help of a following code example:

if ((A && B) || C) then
{
 /* code statements */
}
else
{
 /* code statements */
}

For better understanding, shortly decision coverage testing and condition coverage testing will be discussed shortly:

In order to do 'Decision coverage' testing, the outcome of the logic condition needs to be tested for both True and False cases. Meaning, that condition variable can be set to such values that result in the output of the whole condition overall is True and false, each for once.

With, A = True, B = False, C = True   => Outcome of the condition = True
A = True, B = False, C = False  => Outcome of the condition = False

The above 2 set of inputs are enough to test the above piece of code with 'Decision coverage' test, instead of testing with whole truth table of A, B and C with 8 possible combination of values.

Then, comes the 'Condition coverage', in which each of the condition variables needs to be tested with both possible logic; True and False. So, the effect of each variable is observed when setting to both the logic; i.e. True and false.

A = True, B = False, C = True
A = False, B = True, C = False

With the above 2 set of input values, it would ensure 100% condition coverage test, as each of the variables is tested for both True and False.

However, both the Decision coverage and condition coverage tests are sometimes not enough to ensure the correctness of intended code flow. That is where Modified Condition/decision coverage test comes in. Which is often mandatory for safety-critical software to be performed on the code.

In Modified condition/decision coverage test, the effect of each condition variable on the overall outcome of the condition is tested. This is done by setting up input values of the condition, such as that each input variable is tested with True and False, with that affecting the overall outcome of the decision.

For example, for the same above example, let's set up set of input value for each of the condition variables, such as that the criteria is fulfilled:

1. A = True, B = False, C = True   => Outcome of the condition = True
2. A = True, B = False, C = False   => Outcome of the condition = False
3. A = True, B = True, C = False   => Outcome of the condition = True
4. A = False, B = True, C = False   => Outcome of the condition = False

So, if we look at the input value set no. 1 and 2, A and B are constant, but the value of C is changed. With C set to True, it results in an overall outcome of True and when C set to False, the overall outcome is also affected; changed to False. So, coverage for variable C is done. Similarly, B is tested in input values set no. 2 and 3. Where A and C are constant and with the change in the value of B, the outcome of the condition is changed. Also, same goes for input values set 3 and 4, in which variable A is tested, with variable B and C kept constant. In this way, as all variables have been tested and the effect on outcome observed, 100% MCDC is achieved.

It is worth mentioning that, for achieving 100% coverage for MCDC, only 
[no. variables in the condition]  +  1 
sets of input values/tests are necessary out of the total possible combination of all variables in the condition (2^3 = 8), as can also be seen in the above example.




Saturday, 21 July 2018

LED Dot Matrix Display Operation




How LED Screen displays an image

The flowchart below shows the sequence of processes that take place in order to display the desired image on a LED display.



So, overall, one row at a time is being displayed, but this process is done so fast, with speed much higher than human eye’s response time (which is >= 10ms) that all of the rows appear to be switched on / lit up. Hence, a complete image is formed on the display.






Larger the number of rows, higher the scan-time

As described earlier that one row of a display is switched-on at a time, so the Scan-rate of a display is the amount of time required to display data pixel on all the rows.

So, what if a LED display of resolution, e.g. 1024x768,768 rows. And the display controller starts from row 1 to row 768 to display one row at a time. The amount of time required for completing one-cycle, or more specifically the ‘Scan-time’, would increase very much and may get even higher than the Human eye’s response time. It would result in the rows of the display being noticed to be switching on & off. This effect can be termed as ‘flickering’. To compensate this increase in scan-time, one would suggest increasing the frequency at which data is clocked in, along with row selection. But this may lead to consequences in term of:

  • Increase in power consumption of the whole system, due to increase in frequency.
  • Increase in hardware cost, due to increase in power supply and components required with higher frequency response.
  • The brightness of the display might be affected by various undesired changes in other parameters.
  • The control card or driver that drives the LED display to display an image may have limitations on scanning frequency.
  • High scan time would lead to lower Frame-refresh rate.

The solution is to limit the scanning to a specific number of rows.  Commonly 1~16 rows in a matrix display are scanned. For additional sets of rows, additional ‘data group’ lines from the controller or LED display driver are connected to shift-in the data in parallel.


LED Dot Matrix Display



LED Display Basic Hardware organization

The LED dot matrix display is made up of a combination of LEDs in dot-matrix configuration, which makes the configuration for large numbers of LEDs to be easily multiplexed. By multiplexing (more on multiplexing and how actually the LED dot matrix operation is explained in this post, click here), the number of IOs required to switch on LED is reduced.



LED Matrix

The dot matrix configuration of the LEDs is made in combination like 8x8, 16x8 or 16x16. The first connections of the LED, usually Anode, in the columns are made common i.e. connected together. And the other remaining pins, usually cathode, of LEDs in the rows are made common.

So, if a positive voltage is applied to any of the pins of the column and negative polarity to any of the row, then the dot or pixel or the LED intersection the row and column will light up. In that way, for an 8x8 matrix, we can control all 64 (8x8=64 LEDs in a matrix) LEDs with 8+8=16 wires.




Serial shift register

Even if for 8x8=64 LEDs, 1/4th of the pins (16) are required for controlling all the LEDs, but for displays with 800x800 pixels/LEDs, the total number of 8x8 matrices formed would be 100, meaning 100x16 (pins for each matrix)= 1600 pins/IOs required to operate the whole display.

Even if this huge number of IOs can be available from display controller or microprocessor, the wire connections to each of the matrix would make a huge mess, along with inflexible or non-customizable hardware.

So, to transport the data to each of the Matrix or LED, serial-in-serial & parallel-out shift registers are used, like 74HC595 (8-bit register), MBI5024 (16bit register), MAX6679(16 bit with special LED drivers with fault detection) etc.

With serial shift register for each matrix, only 1 wire for data, 1 wire for clock, 1 wire for latching data & 1 wire for Output enable would be required to drive the whole row. And the serial out data, from each of the shift register of a matrix, can be inputted to the neighboring matrix’s shift register.



Row Decoding

For columns, the shift registers reduced the required IO count to IOs just required to derive a single shift register, the same technique can be applied to connect to all of the row side pins of the matrices. Or more often, for simplicity of software to derive the display and also for fast processing, 3-8 decoders (74HC138) are commonly used for selecting and enabling a row of the display. With 3-inputs to 74HC138 8 rows of an 8x8 matrix can be selected. And for 16 rows selection, 2 x74HC138 can be multiplexed using ‘enable’ pins to form 4-16 decoder and so on for more rows.





Current sourcing and sinking of LEDs

By enabling the row means that allowing the circuit of LED to be completed. That is, if shift register provided 5V to the Anode of LED when data of binary ‘1’ is shifted-in, the ground or negative polarity to the cathode of LED is provided by ‘row enabler’, that is 3-8 decoder output pin.

As 1 row at a time is enabled by the 3-8 decoder, it means that the sum of the current for all 8 LEDs will pass through 3-8 decoder’s single output pin. That current can be way higher than the maximum current that the 3-8 decoder’s output pin can source or sink. So, for that, power drivers like simple power MOSFETs or BJTs can be used to source/sink display’s single row current, where the 3-8 decoder output would be switching On and Off those drivers.






Signal Buffering

It is a good practice to buffer the display data signal and control signals, like clock, output-enable, latch and row decoding selection. Buffers should be placed at the input side and also at the output stage, i.e. for cascading. In that way, the display module can be added & cascaded to form a wall as many as required without worrying about the fan-out etc.





Display Basic module


A basic display module of a display wall/screen is the one with which, the whole wall/screen is composed of. A basic display module is cascaded in series to form a row and several rows of cascaded basic display modules are stacked to form a display wall.





The basic display module pixel size should be kept such as that most of the common size display walls can be made by cascading it.



Next: LED Dot Matrix Display Operation