Now you know the next question..
any chance to upload this VC project on a github or even as an attachment here ?
Thanks! I'm all up for sharing, problem being its part of a form project and linked up with so many other stuff (LCR sweep & bin, oscilloscope, DMM data acquisition, arb waves, scales, etc etc). I'd need a day to pull a standalone/functional app out of this lot. Got the DMM and a LCR over serial com port, the rest over LAN. Pretty messy...
The primary function (method?) you see on the visual is what drives it all really, and pretty much the same what others have done already. PM me if you need any particular code or help with your own code and I'll happily help out, certainly will try my best anyway.
EDIT: here goes the full method. Good enough to get an idea I'm guessing. Nothing as elaborate and high quality as what Garrett already did. Below just put up the cal data in the DP832 and, that's all. Used Microsoft Visual Studio 2019, free Community edition (.NET Windows Form, buttons and all that good stuff).
using System.IO;
using System.IO.Ports;
using System.Net.Sockets;
using System.Threading;
string DP832IP = "192.168.100.111";
int DP832port = 5555;
string cmd_runtime;
// Array example CH1
string[] VDAC = new string[] { "0.842", "0.843", "0.845","0.85","0.9", "1", "1.2", "1.8", "2", "2.4", "2.7", "3", "3.3", "3.6", "4", "4.2", "4.5", "4.7",
"5", "5.5", "6", "6.5", "7", "7.5", "8", "8.5", "9", "9.5", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32" };
string[] VADC = new string[] { "0v", "0.001v", "0.005v", "0.05v", "0.1v", "0.5v", "1v", "5v", "10v", "12.8v", "20v", "30v", "32v" };
//CH1, CH2 & CH3 iADC
string[] iDAC = new string[] { "0.001A", "0.002A", "0.005A", "0.01A", "0.02A", "0.03A", "0.04A", "0.05A", "0.06A", "0.07A", "0.08A", "0.09A", "0.1A",
"0.2A", "0.3A", "0.4A", "0.5A", "0.6A", "0.7A", "0.8A", "0.9A", "1A", "1.2A", "1.5A", "1.7A", "2A", "2.2A", "2.5A",
"2.7A", "3A", "3.2A" };
string[] iADC = new string[] { "0A", "0.1A", "0.5A", "1A", "2A", "3A", "3.2A" };
private void btn_v_Click(object sender, EventArgs e)
{
Calibrate("CH3", "V");
}
private void btn_c_Click(object sender, EventArgs e)
{
Calibrate("CH3", "C");
}
private void Calibrate(string ch, string type)
{
int SCPIdelay = 1000;
int DMMdelay = 3000;
double DMMval = 0.00;
using (var client = new TcpClient(DP832IP, DP832port))
using (var networkStream = client.GetStream())
using (var writer = new StreamWriter(networkStream))
{
writer.Write(":CAL:Start 11111," + ch + "\r\n");
Thread.Sleep(SCPIdelay);
writer.Write(":CALibration:Clear "+ch+",v\r\n");
Thread.Sleep(SCPIdelay);
writer.Write("*RST\r\n");
Thread.Sleep(SCPIdelay);
writer.Write(":OUTPUT " + ch + ",ON\r\n");
Thread.Sleep(SCPIdelay);
if (type == "V")
{
cmd_runtime = "MEAS:VOLT:DC?";
Console.WriteLine("VDAC:");
for (int i = 0; i < VDAC.Length; i++)
{
writer.Write(":CAL:Set " + ch + "," + type + ", " + i + "," + VDAC[i] + ",1\r\n");
Thread.Sleep(DMMdelay);
DMMval = MEAS.Measure(cmd_runtime); // <-- DMM Get reading here
if (DMMval > 0)
{
Console.WriteLine(VDAC[i]);
writer.Write(":CAL:MEAS " + ch + "," + type + "," + i + "," + DMMval + ",1\r\n");
}
Thread.Sleep(SCPIdelay);
}
Console.WriteLine("VADC:");
for (int i = 0; i < VADC.Length; i++)
{
writer.Write(":CAL:Set " + ch + "," + type + "," + i + "," + VADC[i] + ",0\r\n");
Thread.Sleep(DMMdelay);
DMMval = MEAS.Measure(cmd_runtime); // <-- DMM Get reading here
if (DMMval > 0)
{
writer.Write(":CAL:MEAS " + ch + "," + type + "," + i + "," + DMMval + ",0\r\n");
Console.WriteLine(VADC[i]);
}
Thread.Sleep(SCPIdelay);
}
}
else
{
cmd_runtime = "MEAS:CURR:DC?";
Console.WriteLine("iDAC:");
for (int i = 0; i < iDAC.Length; i++)
{
writer.Write(":CAL:Set " + ch + "," + type + ", " + i + "," + iDAC[i] + ",1\r\n");
Thread.Sleep(DMMdelay);
DMMval = MEAS.Measure(cmd_runtime); //+0.0003; //CH2 add 0.0003 offset to comp mA
if (DMMval > 0)
{
Console.WriteLine(iDAC[i]);
writer.Write(":CAL:MEAS " + ch + "," + type + "," + i + "," + DMMval + ",1\r\n");
}
Thread.Sleep(SCPIdelay);
}
Console.WriteLine("iADC:");
for (int i = 0; i < iADC.Length; i++)
{
writer.Write(":CAL:Set " + ch + "," + type + "," + i + "," + iADC[i] + ",0\r\n");
Thread.Sleep(DMMdelay);
DMMval = MEAS.Measure(cmd_runtime);
if (DMMval > 0)
{
writer.Write(":CAL:MEAS " + ch + "," + type + "," + i + "," + DMMval + ",0\r\n");
Console.WriteLine(iADC[i]);
}
Thread.Sleep(SCPIdelay);
}
}
writer.Write(":OUTPUT " + ch + ",OFF\r\n"); Console.WriteLine(":OUTPUT " + ch + ",OFF");
Thread.Sleep(SCPIdelay);
writer.Write(":CAL:End 07/16/2020," + ch + "\r\n"); Console.WriteLine(":CAL:End 07/16/2020," + ch + "\n");
Thread.Sleep(SCPIdelay);
}
}
///// Public Class for the DMM's double val (over serial though)
class MEAS
{
public static double Measure(string message)
{
double data = 0.0;
try
{
Form1.port.Write(message + "\r\n");// Thread.Sleep(1);
data = Convert.ToDouble(Form1.port.ReadLine());
}
catch (Exception ex)
{
Console.WriteLine("Error in MEAS.cs (Measure() method): " + ex.Message);
}
return data;
}
}