Posted Wed, 21 Aug 2024 08:59:17 GMT by ng, emma
Hello everyone, just checking if we want to control channel A and B for the source meter 2604B with updated firmware. We will need to write the codes inside of the TSP Script ( as shown in the picture below right ? ) also, does anyone know why am i facing errors like what is typed below ? 
TSP> TSP? -2.85000e+02    TSP Syntax error at line 1: `=' expected near `java'    2.00000e+01    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to index global `CODES' (a nil value)    0.00000e+00    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to call global `CODES' (a nil value)    0.00000e+00    1.00000e+00
TSP? -2.85000e+02    TSP Syntax error at line 1: `=' expected near `java'    2.00000e+01    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to index global `CODES' (a nil value)    0.00000e+00    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to call global `CODES' (a nil value)    0.00000e+00    1.00000e+00
TSP? -2.85000e+02    TSP Syntax error at line 1: `=' expected near `java'    2.00000e+01    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to index global `CODES' (a nil value)    0.00000e+00    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to call global `CODES' (a nil value)    0.00000e+00    1.00000e+00
TSP? -2.85000e+02    TSP Syntax error at line 1: `=' expected near `java'    2.00000e+01    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to index global `CODES' (a nil value)    0.00000e+00    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to call global `CODES' (a nil value)    0.00000e+00    1.00000e+00
TSP? -2.85000e+02    TSP Syntax error at line 1: `=' expected near `java'    2.00000e+01    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to index global `CODES' (a nil value)    0.00000e+00    1.00000e+00
TSP? -2.86000e+02    TSP Runtime error at line 1: attempt to call global `CODES' (a nil value)    0.00000e+00    1.00000e+00

 
Posted Wed, 21 Aug 2024 09:00:33 GMT by ng, emma
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();
        }
    }
}


 

You must be signed in to post in this forum.