Analogue Testing

The example up to this point has demonstrated how the XJIO board can be used to extend the digital testing of a UUT. This section provides an example of extending the testing of the XJDemo board by using the DAC on the XJIO board to stimulate the ADC inputs on the XJDemo board.

Hardware configuration

The DAC outputs on the XJIO board are routed to CN5. This is a 16-way header which provides eight DAC outputs and eight ground signals. Four of the ADC inputs on the XJDemo board are routed to CN2.

  • Use an 8-to-16-way ribbon cable (supplied with the XJIO board) to connect CN5 on the XJIO board to P4 on the XJDemo board. XJIO board pin CN5.1 should be connected to XJDemo board pin P4.1, leaving pins 9-16 of CN5 on the XJIO board unconnected.

XJEase configuration

Having made the physical connection between the analogue ports on the XJIO board and the XJDemo board it is now necessary to create an XJEase test to drive signals out of the DAC and read them back on the ADC.

The Test_DAC_ADC function in CircuitTest.xje for the XJIO Board is designed to use a 16-way cable between CN4 and CN5 to test the DAC and ADC during board manufacture. As the ADC on the XJIO board and the XJDemo board are the same device we can use the function to implement this test. Below is a copy of the three functions.

On the Circuit Code Files screen:

  • Click New... and create a new Circuit Code file called CircuitTest.xje.
  • Delete the example Test function from the newly created file.
  • Copy and paste the code below into the file.
// DAC & ADC reference voltage (mV)
CONST INT REF_VOLTAGE_EXTERNAL := 3300;

// Potential variation in the datasheet is 60mv + 3 times the value of the LSB
CONST INT VARIANCE := ((REF_VOLTAGE_EXTERNAL/1024)*3 + 60);

GLOBAL Test_DAC_ADC()(INT result)
  INT key;
  PRINT("Attach cable between ");
  PRINT_DEVICE_LINK("XJIO Board.CN5");
  PRINT(" and ");
  PRINT_DEVICE_LINK("XJDemo.P4");
  PRINT(".\nPress key to continue...\n");
  key := WAITKEY();
  CALL("DAC1", "Init")()();
  SetDACTestValues(0, 3)();
  CheckADC(0, 4, 4)(result);
  CALL("DAC1", "ResetDAC")()();
END;

SetDACTestValues(INT firstBit, INT lastBit)()
  INT i, value, mV;

  // Set each of the DAC outputs to a different value that we can read back via an ADC
  // The DAC fitted is 10 bit therefore we will split the values equally across this range
  FOR i := firstBit TO lastBit
    value := ((i + 1) * 128) - 1;
    mV := (REF_VOLTAGE_EXTERNAL * value ) / 1023;
    PRINT("DAC channel ", i, " set to ", value, "(", mV, "mV).\n");
    CALL("DAC1", "SetDAC")(i, value)();
  END;
  CALL("DAC1", "ToggleLDAC")()();
END;

CheckADC(INT firstBitDac, INT firstBitAdc, INT channels)(INT result)
  INT i, value, I2Cfail, mV;
  INT channelDac, channelAdc;
  result := RESULT_PASS;

  FOR i := 0 FOR channels
    channelDac := firstBitDac + i;
    channelAdc := firstBitAdc + i;
    CALL("XJDemo.U11", "ReadADC")(channelAdc, 1, 2500)(mV, I2Cfail);
    IF I2Cfail THEN result := RESULT_FAIL; RETURN; END;
    // Calculate the reference value. Use same equation as was used to set DAC output
    value := (REF_VOLTAGE_EXTERNAL * (((channelDac + 1)  * 128) - 1)) / 1023;

    IF (value + VARIANCE < mV ||? mV < value - VARIANCE) THEN
      result := RESULT_FAIL;
      PRINT("ADC channel ", channelAdc); PRINT_FORMAT("color=red", " failed "); PRINT("with a reading of ", mV, "mV.\n");
    ELSE
      PRINT("ADC channel ", channelAdc); PRINT_FORMAT("color=Green", " passed "); PRINT("with a reading of ", mV, "mV.\n");
    END;
  END;
END;

Some minor changes need to be made to make the test only use the top four channels of the DAC on the XJIO board.

Running the Test

Having created the XJEase function to implement analogue testing between the XJIO board and the XJDemo board you now need to add the test to the XJRunner Test List.

On the XJRunner Setup screen:

  • Click the Add Group... button at the bottom of the XJRunner Tests pane.
  • Enter ADC Tests as the name and click the Add Global Function button.
  • Select the Test_DAC_ADC function, and click OK.

On the Run Tests screen:

  • Run all the tests.

The output from the new test will show something similar to:

Attach cable between XJIO Board.CN5 and XJDemo.P4.

Press key to continue...

DAC channel 0 set to 127(409mV).

DAC channel 1 set to 255(822mV).

DAC channel 2 set to 383(1235mV).

DAC channel 3 set to 511(1648mV).

ADC channel 4 passed with a reading of 411mV.

ADC channel 5 passed with a reading of 833mV.

ADC channel 6 passed with a reading of 1235mV.

ADC channel 7 passed with a reading of 1627mV.

Test_DAC_ADC passed - ran in default profile (All chains)

>>>> PASSED <<<<