In the past, I have created and used a simple Labview VI (later built in to an exe) that continuously quarry and chart on a graph the current consumption used by devices I power with my HP66312A power supply.
This tool is useful in identifying an issue when troubleshooting power-on failures etc. attached1 is a screen shot of the Block diagram of my Labview program. When I run it, the output looks like attached 2.
I am trying to convert this application to a pure C# application. I was able to use the Agilent Command Expert to build the commands I needed and ended up with this code:
(not the most elegant code, but bear with me since this is a first pass at writing/reading the power supply)
private void button1_Click(object sender, EventArgs e)
{
foreach (var series in chart1.Series)
{
series.Points.Clear();
}
double IMeasure;
int Sample = 0;
int Voltage = Convert.ToInt16(NVoltage.Value);
int Current = Convert.ToInt16(NCurrent.Value);
string GPIO = Convert.ToString(NGPIO.Value);
Ag66xx v6612C = new Ag66xx("GPIB0::"+ GPIO +"::INSTR");
v6612C.SCPI.SOURce.CURRent.LEVel.IMMediate.AMPLitude.Command(Current, "A");
v6612C.SCPI.SOURce.VOLTage.LEVel.IMMediate.AMPLitude.Command(Voltage, "V");
v6612C.SCPI.OUTPut.STATe.Command(true);
Ag66xxx v66312A = new Ag66xxx("GPIB0::1::INSTR");
Sample = Convert.ToInt16(NSpan.Value);
for (int i = 1; i < Sample; i++)
{
v66312A.SCPI.MEASure.SCALar.CURRent.DC.Query(out IMeasure);
chart1.Series["Current"].Points.AddXY(i, IMeasure);
}
}
It uses a given time set by NSpan to quarry the bus and store it in an array then it pars the results onto a graph. attached3 is what my output looks like. This works well to record a triggered style analysis, but I want to be able to do this in real time.
The problem I have is that I don’t know how to use C# to continuously quarry the current and chart it in real time the way I do using Labview. every time I try to use a while or a do loop to read current, my program hangs.
Any help will be much appreciated.
Thanks,
This tool is useful in identifying an issue when troubleshooting power-on failures etc. attached1 is a screen shot of the Block diagram of my Labview program. When I run it, the output looks like attached 2.
I am trying to convert this application to a pure C# application. I was able to use the Agilent Command Expert to build the commands I needed and ended up with this code:
(not the most elegant code, but bear with me since this is a first pass at writing/reading the power supply)
private void button1_Click(object sender, EventArgs e)
{
foreach (var series in chart1.Series)
{
series.Points.Clear();
}
double IMeasure;
int Sample = 0;
int Voltage = Convert.ToInt16(NVoltage.Value);
int Current = Convert.ToInt16(NCurrent.Value);
string GPIO = Convert.ToString(NGPIO.Value);
Ag66xx v6612C = new Ag66xx("GPIB0::"+ GPIO +"::INSTR");
v6612C.SCPI.SOURce.CURRent.LEVel.IMMediate.AMPLitude.Command(Current, "A");
v6612C.SCPI.SOURce.VOLTage.LEVel.IMMediate.AMPLitude.Command(Voltage, "V");
v6612C.SCPI.OUTPut.STATe.Command(true);
Ag66xxx v66312A = new Ag66xxx("GPIB0::1::INSTR");
Sample = Convert.ToInt16(NSpan.Value);
for (int i = 1; i < Sample; i++)
{
v66312A.SCPI.MEASure.SCALar.CURRent.DC.Query(out IMeasure);
chart1.Series["Current"].Points.AddXY(i, IMeasure);
}
}
It uses a given time set by NSpan to quarry the bus and store it in an array then it pars the results onto a graph. attached3 is what my output looks like. This works well to record a triggered style analysis, but I want to be able to do this in real time.
The problem I have is that I don’t know how to use C# to continuously quarry the current and chart it in real time the way I do using Labview. every time I try to use a while or a do loop to read current, my program hangs.
Any help will be much appreciated.
Thanks,
I do not see your attachments for some reason.
If you do a single iteration doing the current query (no looping), do you get a result? If so how long does it take to do the readback?