Add project files.

This commit is contained in:
Wesley Hofman
2025-08-29 18:17:48 +02:00
parent 31eaf9e5f7
commit a0d5f3b21b
23 changed files with 2144 additions and 0 deletions

78
HTOLHAST/Keithley6485.cs Normal file
View File

@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HTOLHAST
{
public class Keithley6485 : SCPIInstrument
{
public Keithley6485(string resourceString) : base(resourceString) { }
public void PerformZeroCheck()
{
try
{
// Step 1. Reset
// Step 2. Enable zero check
// step 3. Perform zero correction
// step 4. Select AUTO range
// step 5. Connect current to be measured
// step 6. Disable zero check
WriteCommand("*RST"); // Reset Instrument
WriteCommand("SYST:ZCH ON"); // Enable zero check
WriteCommand("RANG 2E-9"); // Set lowest range
WriteCommand("INIT"); // Trigger reading to be used as zero correction
WriteCommand("SYST:ZCOR:ACQ"); // Use last reading taken as zero correct value.
WriteCommand("SYST:ZCOR ON"); // Perform zero correction
WriteCommand("RANG:AUTO ON"); // Enable AUTO range
WriteCommand("SYST:ZCH OFF"); // Disable zero check
Console.WriteLine("ZeroCheck Performed");
}
catch (Exception e)
{
throw new InvalidOperationException("ZeroCheck operation failed.", e);
}
}
private void InitiateRead()
{
WriteCommand("SYST:ZCH OFF"); // Enable zero check
WriteCommand("INIT"); // Trigger reading to be used as zero correction
WriteCommand("RANG:AUTO ON"); // Enable AUTO range
WriteCommand("READ?"); // trigger and return one reading
Console.WriteLine("Read Command Initiated");
}
public string MeasureDCCurrent()
{
InitiateRead();
string response = ReadResponse();
CreateSample(response);
return response;
}
public override Sample CreateSample(string response)
{
string Response = response;
// Parse the Keithley output
string[] parts = Response.Split(',');
if (parts.Length >= 1 && double.TryParse(parts[0].Replace("A", ""), out double current))
{
Keithley6485Sample sample = new Keithley6485Sample(DateTime.Now, current, "A");
// Optionally, store or process the sample here
Console.WriteLine($"[Keithley] Sample Created, Value: {sample.Value} {sample.Unit}");
return sample;
}
throw new InvalidOperationException("Unsupported instrument type.");
}
// Add more specific methods for Keithley 6485 as needed
}
}