Tutorial C code

 

Send comments on this topic

 

 10-JUL-2025  SPM V7.13.0 and higher

 

Below code extract is without error handling,

detailed error handling to be found in the installed example code.

 

// Starts the SPM Server in the given functional mode.

ErrorCode = SPM_Server_Start ();

 

// Connects to the SPM Server. This has to be done first to be able to use other API functions.          

ErrorCode = SPM_Client_Connect ();

 

// Opens a SPM Project from the specified file path.          

ErrorCode = SPM_Project_Open ("C:\\Users\\Public\\Documents\\Pickering Interfaces Ltd\\Switch Path Manager\\Projects\\Tutorial\\Tutorial.switchproj");

 

// Boots the Test System with the active System Setup into Driver Online State.

// This initializes all Device Drivers. This requires the System Hardware to be connected to the computer and be powered on.

ErrorCode = SPM_System_BootOnline ();

 

// Resets all switching modules to their initial state.

// If the Test System is booted in Online Mode this will be applied to the hardware.

ErrorCode = SPM_System_ResetFull ();

 

// based on the Tutorial Program the following scenario takes place

// SCENARIO WITH CONTROLLED Y-BUS USE

 

// 1. Connect Power Supply to PS+/PS-

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("bus2", "PS+, UUT_PS+"); // controlled route via bus2

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("bus3", "GND, UUT_PS-"); // controlled route via bus3

 

// 2. Pull Down CTRL Pin (GND)

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("bus3", "GND, UUT_PS-, CTRL"); // controlled route via bus3

 

// 3. Connect and Measure UUT1/UUT2 with Scope at the same time using ch1, ch2

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("UUT1", "ScopeCH1");

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("UUT2", "ScopeCH2");

Mux SubUnit 1   SubUnit2

 

// MEASURE HERE

 

ErrorCode = SPM_Switch_DisconnectEndpointsCsv ("UUT1", "ScopeCH1");

ErrorCode = SPM_Switch_DisconnectEndpointsCsv ("UUT2", "ScopeCH2");

 

// 4. Pull Up CTRL Pin (PS+)

ErrorCode = SPM_Switch_DisconnectEndpointsCsv ("bus3", "CTRL");                         // controlled route via bus3

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("bus2", "PS+, UUT_PS+, CTRL");  // controlled route via bus2

 

// 5. Connect and Measure UUT3/UUT4 with Scope at the same time using ch1, ch2

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("UUT3", "ScopeCH1");

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("UUT4", "ScopeCH2");

 

// MEASURE HERE

 

// 6. Disconnect All

ErrorCode = SPM_System_ResetFull ();

 

 

// based on the Tutorial Program the following scenario takes place

// SCENARIO WITH UNCONTROLLED USE OF Y-BUS (auto selection of Y1 and Y2 for the first 2 routes)

 

// 1. Connect Power Supply to PS+/PS-

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("PS+", "UUT_PS+");

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("GND", "UUT_PS-");

 

// 2. Pull Down CTRL Pin (GND)

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("GND", "UUT_PS-, CTRL");

 

// 3. Connect and Measure UUT1/UUT2 with Scope at the same time using ch1, ch2

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("UUT1", "ScopeCH1");

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("UUT2", "ScopeCH2");

Mux SubUnit 1   SubUnit2

 

// MEASURE HERE

 

ErrorCode = SPM_Switch_DisconnectEndpointsCsv ("UUT1", "ScopeCH1");

ErrorCode = SPM_Switch_DisconnectEndpointsCsv ("UUT2", "ScopeCH2");

// 4. Pull Up CTRL Pin (PS+)

ErrorCode = SPM_Switch_DisconnectEndpointsCsv ("GND", "CTRL");

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("PS+", "UUT_PS+, CTRL");

 

// 5. Connect and Measure UUT3/UUT4 with Scope at the same time using ch1, ch2

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("UUT3", "ScopeCH1");

ErrorCode = SPM_Switch_ConnectEndpointsCsv ("UUT4", "ScopeCH2");

 

// MEASURE HERE

 

// Stops the SPM Server, if no other clients are connected.          

ErrorCode = SPM_Server_Stop ();

 

 

Copyright © 2014-2024 Pickering Interfaces