Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

This code example is a calibration function that can be used to improve the results of Current measurement, which are used in this example: Power Monitor - Reading Voltage and Current Samples. For this example code to work properly, the user must be programming with the XStream-Iso, or XStreamPro-Iso (black) adapters and no targets should be connected to the adapter.

This code sequence is taken from the LinuxCommandLineDemo installation directory for Linux, however, the same sequence of calls will work in other environments:

The code sequence is as follows:

  • Find adapters and perform initialization using F_OpenInstancesAndFPAs((char *)input.c_str()) and F_Initialization()

    • In this example, F_Set_FPA_index (0) is called, which means that all adapters will be initialized.

  • Select one adapter F_Set_FPA_index (1), in this case FPA-1, since the calibration function cannot be called on all adapters.

  • Perform a sequence of calibration steps, from 0 to 100, and print report messages.

    • F_XS_Current_zeroing( i, msg );the msg buffer is written into by the library with status messages. Msg can be printed to follow the calibration process.

  • This calibration sequence can take several minutes.

Demo code:

Code Block
languagecpp
#include <stdio.h>
#include <string>
#include <iostream>

#ifdef FLASHPROARMFLASHPROM
#include "../FlashProARMFlashProM-Dll.h"
#endif

#ifdef GANGPROARMGANGPROM
#include "../GangProARMGangProM-Dll.h"
#endif

using namespace std;

int main(int argc, char* argv[])
{
  int st;

  string input = "*# *";

  cout << "F_OpenInstancesAndFPAs : " << dec <<   F_OpenInstancesAndFPAs((char *)input.c_str()) << endl;
  cout << "F_Get_FPA_SN : " << F_Get_FPA_SN(1) << endl;
  cout << "F_Set_FPA_index : " << dec << F_Set_FPA_index (0) << endl;
  cout << "F_Initialization : " << dec << F_Initialization() << endl;
  cout << "API Version " << hex << (0xFFF & F_DLLTypeVer()) << endl;
  cout << "Multi Version " << hex << (0xFFF & F_Multi_DLLTypeVer()) << endl;
  F_Set_FPA_index(1);

  char msg[1000];
  for(int i=0; i<=100; i++)
  {
    cout << "Step: " << dec << i << " Result: ";
    cout.flush();
    F_XS_Current_zeroing( i, msg );
    cout << msg << endl;
  } 
  
  
  return 0;
}