1
package com.sun.electric.tool.simulation.test;
5
* Copyright (c) 2004,2005 by Sun Microsystems, Inc.
7
* Created on Jul 19, 2004
11
* Class for setting a voltage level supplied by a single channel of an Instek
12
* PST-3202 programmable DC power supply, using the device-independent interface
13
* {@link PowerChannel}.
15
* This class should now be instantiated from a {@link Model#createPowerChannel(String, String, int, int, String)}
17
* @author Tom O'Neill (toneill)
19
public class Pst3202Channel extends PowerChannel {
22
* The Instek PST-3202 programmable DC power supply that provides the
23
* voltage level in question
25
private final Pst3202 supply;
27
/** Channel of power supply that supplies the voltage */
28
private final int channel;
31
* Creates an object to control a PST-3202 power supply using the methods of
32
* the device-independent PowerChannel abstract class.
34
* Instead of this, you should use
35
* {@link Model#createPowerChannel(String, String, int, int, String)}.
36
* I have left it public for backwards compatability.
39
* name of signal on this channel of the power supply
41
* <code>gpibconf</code> identifier for the power supply
43
* Channel of the supply to control
45
public Pst3202Channel(String channelName, String supplyName, int channel) {
46
Pst3202.checkChannel(channel);
47
this.name = channelName + " (" + supplyName + " channel " + channel
49
supply = new Pst3202(supplyName);
50
this.channel = channel;
51
logInit("Initialized Pst3202Channel " + this.name);
54
/** @return Returns the name of the Pst3202 */
55
public String getSupplyName() {
56
return supply.getName();
60
* @return Returns the channel number within the Pst3202 device.
62
public int getChannel() {
67
* Returns string indicating state of the channels
69
public String getState() {
70
return supply.getState(channel);
74
* Reads back the voltage provided by this channel of the power supply.
76
* @return voltage drawn over this channel, in Volts
78
public float readVoltage() {
79
logOther("Reading voltage on " + getName());
80
return this.supply.readVoltage(this.channel);
84
* Set the channel's voltage to the value provided
87
* new voltage for the channel, in Volts
89
public void setVoltageNoWait(float volts) {
90
logSet("Pst3202Channel setting voltage on " + getName() + " to "
92
if (this.supply.setVoltage(this.channel, volts) == false) {
93
try { Thread.sleep(1000); } catch (InterruptedException _) { }
94
if (this.supply.setVoltage(this.channel, volts) == false) {
95
Infrastructure.fatal(this.getName()
96
+ " power supply error setting voltage " + volts);
101
public void waitForVoltage(float setVolts) {
102
if (supply.isDisabled())
104
super.waitForVoltage(setVolts);
108
* Get the channel's voltage setpoint
110
* @return voltage setpoint for the channel, in Volts
112
public float getVoltageSetpoint() {
113
logOther("Reading voltage setpoint on " + getName());
114
return this.supply.getVoltageSetpoint(this.channel);
118
* Returns voltage resolution of power supply.
120
* @return voltage resolution of power supply
122
public float getVoltageResolution() {
123
logOther("Getting voltage resolution on " + getName());
124
return Pst3202.getVoltageResolution(this.channel);
128
* Reads back the current provided by this channel of the power supply.
130
* @return current drawn over this channel, in Amps
132
public float readCurrent() {
133
logOther("Reading current on " + getName());
134
return this.supply.readCurrent(this.channel);
138
* Set the channel's current limit to the value provided
141
* new current limit for the channel, in Amps
143
public void setCurrent(float amps) {
144
logSet("Setting current limit on " + getName() + " to " + amps);
145
supply.setCurrent(channel, amps);
149
* Get the channel's current setpoint
151
* @return current setpoint for the channel, in Amps
153
public float getCurrentSetpoint() {
154
logOther("Reading current setpoint on " + getName());
155
return supply.getCurrentSetpoint(this.channel);
159
* Unit tests, prints current as function of voltage for channel 1. Should
160
* disconnect supply from any chips before waiting.
165
public static void main(String[] args) {
166
Infrastructure.gpibControllers = new int[] { 1 };
167
Pst3202Channel channel1 = new Pst3202Channel("chan1", "hPst3202", 1);
168
Pst3202Channel channel2 = new Pst3202Channel("chan2", "hPst3202", 2);
169
Pst3202Channel channel3 = new Pst3202Channel("chan3", "hPst3202", 3);
171
System.out.println("Voltage setpoints: "
172
+ channel1.getVoltageSetpoint() + ", "
173
+ channel2.getVoltageSetpoint() + ", "
174
+ channel3.getVoltageSetpoint());
175
System.out.println("Voltages read: " + channel1.readVoltage() + ", "
176
+ channel2.readVoltage() + ", " + channel3.readVoltage());
177
System.out.println("Current limits: " + channel1.getCurrentSetpoint()
178
+ ", " + channel2.getCurrentSetpoint() + ", "
179
+ channel3.getCurrentSetpoint());
180
System.out.println("Currents read: " + channel1.readCurrent() + ", "
181
+ channel2.readCurrent() + ", " + channel3.readCurrent());
182
channel3.setCurrent(2.0f);
184
System.out.println("Chan 1 resolution: "
185
+ channel1.getVoltageResolution() + " V");
186
System.out.println("Chan 2 resolution: "
187
+ channel2.getVoltageResolution() + " V");
188
System.out.println("Chan 3 resolution: "
189
+ channel3.getVoltageResolution() + " V");
194
for (float volts = 1.0f; volts < 1.85f; volts += 0.01f) {
195
channel1.setVoltageNoWait(volts);
196
channel3.setVoltageWait(volts);
197
channel1.waitForVoltage(volts);
198
System.out.print(nsweep + ", " + volts + " V; ");
199
System.out.println(channel1.getState());