The below is the codes I am using for my TSP script
import java.io.*;
import java.net.Socket;
public class KeithleyControl {
public static void main(String[] args) {
String instrumentIP = "169.254.0.1";
int port = 5025;
try (Socket socket = new Socket(instrumentIP, port);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
// Configure Channel A to source 3.2V
out.println("SOURce1:FUNCtion VOLTage"); // Set function to voltage on Channel A
out.println("SOURce1:VOLTage 3.2"); // Set voltage level to 3.2V on Channel A
out.println("OUTPut1 ON"); // Turn on output on Channel A
// Configure Channel B to source 1.7V
out.println("SOURce2:FUNCtion VOLTage"); // Set function to voltage on Channel B
out.println("SOURce2:VOLTage 1.7"); // Set voltage level to 1.7V on Channel B
out.println("OUTPut2 ON"); // Turn on output on Channel B
// Measure current on Channel A
out.println("MEASure:CURRent? (@1)"); // Measure current on Channel A
String currentA = in.readLine(); // Read the response
System.out.println("Measured current on Channel A: " + currentA + " A");
// Measure current on Channel B
out.println("MEASure:CURRent? (@2)"); // Measure current on Channel B
String currentB = in.readLine(); // Read the response
System.out.println("Measured current on Channel B: " + currentB + " A");
// Turn off both channels
out.println("OUTPut1 OFF"); // Turn off output on Channel A
out.println("OUTPut2 OFF"); // Turn off output on Channel B
} catch (IOException e) {
e.printStackTrace();
}
}
}