Download Moisture Controlled Watering System

Document related concepts
no text concepts found
Transcript
UNIVERSITY OF LOUISVILLE
Two and Three Electrode
Potentiostats Appendix
Final Report
Josh Geiman, Kyle Bloomer, and Lucas Bennett
With Ben Williams
Project Manager: Dr. Andrew Dozier
Project Customer: Dr. Cindy Harnett
This is the Appendix for the Final Report for the Two and Three Electrode Potentiostat project which is the
ECE Capstone project for Lucas Bennett, Kyle Bloomer and Joshua Geiman.
Two and Three Electrode Potentiostat Appendix
0.2 Table of Contents
0.2 Table of Contents .................................................................................................................................... 2
1.0 Appendix 1: Ardustat.java ....................................................................................................................... 3
2.0 Appendix 2: Cheapstat Information ...................................................................................................... 53
3.0 CheapStat Testing ................................................................................................................................. 63
4.0 Two Electrode Potentiostat Technical Manual ..................................................................................... 64
5.0 Two Electrode Potentiostat Material List ............................................................................................. 65
6.0 Three Electrode Assembly and Programming………………………………………………………………………………….66
2
Two and Three Electrode Potentiostat Appendix
1.0 Appendix 1: Ardustat.java
/*
* RefCellArduinoInterface.java
*
* Created on July 22, 2006, 9:31 AM
*/
/**
*
* @author dan
*
*
*/
//import com.sun.org.apache.bcel.internal.verifier.statics.DOUBLE_Upper;
import gnu.io.*;
import java.io.*;
import java.util.*;
import java.lang.reflect.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.FileReader;
import javax.swing.JFrame;
public class Ardustat extends javax.swing.JFrame implements SerialPortEventListener {
// 7/27/07 a poor attempt to tell you what these all mean:
String appendDate;
long logtimer = System.currentTimeMillis();
//Generally for RS232 Communications via RXTXComm or Javax.comm
double timelogstart;
static Enumeration portListing; //To Deal with Serial Port Listing
static CommPortIdentifier portId; //Serial Port Place Holder
static String messageString = "Hello, world!\n"; //Message Placeholder
static InputStream inputStream; //Serial Port Input
static OutputStream outputStream; //Serial Port Output
int counter = 0;
int cyclecounter = 0;
static SerialPort serialPort;
byte buffer[] = new byte[32768];
int bufferIndex;
int bufferLast;
int bufferSize = 1; // how big before reset or event firing
boolean bufferUntil;
int bufferUntilByte;
//Variables for dealing with data thinning on a change basis
double changeFinder = 0;
int changeInterval = 1;
3
Two and Three Electrode Potentiostat Appendix
double voltageholder = 0;
double currentholder = 0;
//Attached to Log File Things
long timein;
long timeout;
int enroute = 0;
String temp;
boolean logit = false;
boolean logcyc = true;
boolean logstartline = true;
double vccCalib = 4.99;
double mRCalib = 0.218;
double bRCalib = 0.184;
double vLim = .9;
double iLim = .0006;
String gstring;
String dataFile;
String dataFile2;
String infFile;
// ArdustatNew Control
String whatIWant;
int lastMode;
int lastSetting;
//Calibration Section
boolean calibrationMode = false;
double res[] = new double[256];
//Cycling Section
boolean advanced = false;
String[] advancedparts;
int advancedstep;
boolean fresh = true;
boolean advancedtimed;
double advancedtimestart;
long nowtime;
double advancedtimestop;
long connectime;
String TimeString;
int holdtime;
int currentmodetimeinterval;
double Voltage;
4
Two and Three Electrode Potentiostat Appendix
boolean cycleset;
double Current;
boolean gstep1 = false;
boolean gstep2 = false;
boolean leaveout = false;
/** Creates new form RefCellArduinoInterface */
public Ardustat() {
initComponents();
jPanel14.setVisible(true);
jPanel25.setVisible(true);
jPanel26.setVisible(false);
jPanel27.setVisible(false);
jPanel28.setVisible(false);
jMenuItem2.setVisible(false);
portList.removeAllItems();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
logButtonGroup = new javax.swing.ButtonGroup();
jPanel7 = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
adcField = new javax.swing.JTextField();
currentField = new javax.swing.JTextField();
dacField = new javax.swing.JTextField();
ohmField = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
modeField = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
settingField = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
dacField1 = new javax.swing.JTextField();
dacField2 = new javax.swing.JTextField();
TimeField = new javax.swing.JTextField();
jLabel18 = new javax.swing.JLabel();
wattField = new javax.swing.JTextField();
5
Two and Three Electrode Potentiostat Appendix
jLabel22 = new javax.swing.JLabel();
jRadioButton1 = new javax.swing.JRadioButton();
logToggle = new javax.swing.JRadioButton();
cellResField = new javax.swing.JTextField();
jLabel27 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
fileField = new javax.swing.JTextField();
logButton = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
jPanel30 = new javax.swing.JPanel();
jPanel14 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
portList = new javax.swing.JComboBox();
portButton = new javax.swing.JButton();
connectButton = new javax.swing.JButton();
jLabel7 = new javax.swing.JLabel();
jPanel15 = new javax.swing.JPanel();
jRadioButton2 = new javax.swing.JRadioButton();
jLabel30 = new javax.swing.JLabel();
jLabel31 = new javax.swing.JLabel();
jLabel32 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
jPanel24 = new javax.swing.JPanel();
jPanel25 = new javax.swing.JPanel();
jScrollPane9 = new javax.swing.JScrollPane();
jTextPane5 = new javax.swing.JTextPane();
jPanel26 = new javax.swing.JPanel();
jScrollPane10 = new javax.swing.JScrollPane();
jTextPane6 = new javax.swing.JTextPane();
jPanel27 = new javax.swing.JPanel();
jScrollPane11 = new javax.swing.JScrollPane();
jTextPane7 = new javax.swing.JTextPane();
jPanel28 = new javax.swing.JPanel();
jScrollPane12 = new javax.swing.JScrollPane();
jTextPane8 = new javax.swing.JTextPane();
jPanel31 = new javax.swing.JPanel();
jPanel8 = new javax.swing.JPanel();
setactionField = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
pstatRadio = new javax.swing.JRadioButton();
gstatRadio = new javax.swing.JRadioButton();
resRadio = new javax.swing.JRadioButton();
manRadio = new javax.swing.JRadioButton();
actionButton = new javax.swing.JButton();
ocvButton = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
sendField = new javax.swing.JTextField();
sendButton = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
6
Two and Three Electrode Potentiostat Appendix
whatIWantField = new javax.swing.JTextField();
checkSendBox = new javax.swing.JCheckBox();
jPanel1 = new javax.swing.JPanel();
jPanel6 = new javax.swing.JPanel();
vccField = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
mRField = new javax.swing.JTextField();
bRField = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
calibButton = new javax.swing.JButton();
vLimitField = new javax.swing.JTextField();
iLimitField = new javax.swing.JTextField();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
r10kButton = new javax.swing.JRadioButton();
r50kButton = new javax.swing.JRadioButton();
rFixedButton = new javax.swing.JRadioButton();
rFixedField = new javax.swing.JTextField();
jLabel23 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
initialVField = new javax.swing.JTextField();
jLabel28 = new javax.swing.JLabel();
r100kButton = new javax.swing.JRadioButton();
saveSettingsButton = new javax.swing.JButton();
loadSettingsButton = new javax.swing.JButton();
resCheckButton = new javax.swing.JButton();
potCalButton = new javax.swing.JButton();
fixedResCalField = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem3 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Ardustat");
setResizable(false);
org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 286, Short.MAX_VALUE)
);
jPanel7Layout.setVerticalGroup(
7
Two and Three Electrode Potentiostat Appendix
jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 0, Short.MAX_VALUE)
);
jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
adcField.setText("0");
adcField.setMaximumSize(new java.awt.Dimension(8, 22));
currentField.setText("0");
currentField.setMaximumSize(new java.awt.Dimension(8, 22));
dacField.setText("0");
dacField.setMaximumSize(new java.awt.Dimension(8, 22));
ohmField.setText("0");
ohmField.setMaximumSize(new java.awt.Dimension(8, 22));
jLabel1.setText("Readings");
jLabel2.setText("V (Cell)");
jLabel3.setText("mA");
jLabel4.setText("V (DAC)");
jLabel5.setText("k? (setting)");
modeField.setText("0");
modeField.setMaximumSize(new java.awt.Dimension(8, 22));
jLabel9.setText("Mode");
settingField.setText("0");
settingField.setMaximumSize(new java.awt.Dimension(8, 22));
settingField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
settingFieldActionPerformed(evt);
}
});
jLabel11.setText("Setting");
dacField1.setText("0");
dacField1.setMaximumSize(new java.awt.Dimension(8, 22));
dacField2.setText("0");
dacField2.setMaximumSize(new java.awt.Dimension(8, 22));
TimeField.setEditable(false);
TimeField.setText("0");
TimeField.setMaximumSize(new java.awt.Dimension(8, 22));
TimeField.addActionListener(new java.awt.event.ActionListener() {
8
Two and Three Electrode Potentiostat Appendix
public void actionPerformed(java.awt.event.ActionEvent evt) {
TimeFieldActionPerformed(evt);
}
});
jLabel18.setText("Time (s)");
wattField.setText("0");
wattField.setMaximumSize(new java.awt.Dimension(8, 22));
jLabel22.setText("W");
cellResField.setText("0");
cellResField.setMaximumSize(new java.awt.Dimension(8, 22));
jLabel27.setText("k? (cell)");
jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
fileField.setText("testlog");
logButton.setText("Start Log");
logButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
logButtonActionPerformed(evt);
}
});
jLabel8.setText("Log File");
org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel3Layout.createSequentialGroup()
.add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel8)
.add(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.add(logButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 107,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.add(fileField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 147,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel3Layout.createSequentialGroup()
.add(jLabel8)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
9
Two and Three Electrode Potentiostat Appendix
.add(fileField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(logButton)
.addContainerGap(48, Short.MAX_VALUE))
);
org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel5Layout.createSequentialGroup()
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel5Layout.createSequentialGroup()
.add(8, 8, 8)
.add(jLabel1)
.add(15, 15, 15)
.add(jRadioButton1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(logToggle))
.add(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(modeField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(ohmField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(dacField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(adcField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
.add(currentField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 74,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.add(jLabel4)
.add(jLabel3)
.add(jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)))
.add(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, TimeField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, dacField2,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, dacField1,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
10
Two and Three Electrode Potentiostat Appendix
.add(org.jdesktop.layout.GroupLayout.LEADING, settingField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jLabel11, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jLabel18, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(24, 24, 24))
.add(jPanel5Layout.createSequentialGroup()
.add(wattField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel22)))
.add(11, 11, 11))
.add(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.add(cellResField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel27))
.add(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 235,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel5Layout.createSequentialGroup()
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(logToggle)
.add(jRadioButton1))
.add(7, 7, 7)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(adcField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel5Layout.createSequentialGroup()
.add(currentField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(dacField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel4))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(ohmField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
11
Two and Three Electrode Potentiostat Appendix
.add(jLabel5)))
.add(jLabel3))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel9)
.add(modeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(settingField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel11))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(dacField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(dacField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(TimeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel18))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(wattField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel22))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(cellResField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel27))
.add(26, 26, 26)
.add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(77, Short.MAX_VALUE))
);
jPanel30.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel30.setLayout(new java.awt.CardLayout());
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
portList.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item
4" }));
portList.setMaximumSize(new java.awt.Dimension(80, 27));
portButton.setText("Get Ports");
portButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
portButtonActionPerformed(evt);
}
12
Two and Three Electrode Potentiostat Appendix
});
connectButton.setText("Connect");
connectButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectButtonActionPerformed(evt);
}
});
jLabel7.setText("Connection");
org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
.add(10, 10, 10)
.add(jLabel7))
.add(portList, 0, 255, Short.MAX_VALUE)
.add(connectButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.TRAILING, portButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
.add(jLabel7)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(portList, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 14, Short.MAX_VALUE)
.add(portButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(connectButton))
);
jPanel15.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jRadioButton2.setSelected(true);
jRadioButton2.setText("Cyclic Voltammetry");
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton2ActionPerformed(evt);
}
});
jLabel30.setText("Mode:");
jLabel31.setText("Input1:");
13
Two and Three Electrode Potentiostat Appendix
jLabel32.setText("Input2:");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mode 0", "Mode 1", "Mode
2", "Mode 3" }));
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
jButton2.setText("Run");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout jPanel15Layout = new org.jdesktop.layout.GroupLayout(jPanel15);
jPanel15.setLayout(jPanel15Layout);
jPanel15Layout.setHorizontalGroup(
jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel15Layout.createSequentialGroup()
.add(19, 19, 19)
.add(jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jRadioButton2)
.add(jPanel15Layout.createSequentialGroup()
.add(jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel30)
.add(jLabel31)
.add(jLabel32))
.add(18, 18, 18)
.add(jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jTextField2)
.add(jTextField1)
.add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 82,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(18, 18, 18)
.add(jButton2)))
.addContainerGap(39, Short.MAX_VALUE))
);
jPanel15Layout.setVerticalGroup(
jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel15Layout.createSequentialGroup()
.add(9, 9, 9)
.add(jRadioButton2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel30))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
14
Two and Three Electrode Potentiostat Appendix
.add(jLabel31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel15Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel32)
.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jButton2))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel24.setLayout(new java.awt.CardLayout());
jTextPane5.setText("Set current to Input1 (mA) until potential reaches Input2 (V) ");
jScrollPane9.setViewportView(jTextPane5);
org.jdesktop.layout.GroupLayout jPanel25Layout = new org.jdesktop.layout.GroupLayout(jPanel25);
jPanel25.setLayout(jPanel25Layout);
jPanel25Layout.setHorizontalGroup(
jPanel25Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel25Layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
.addContainerGap())
);
jPanel25Layout.setVerticalGroup(
jPanel25Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel25Layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
.addContainerGap())
);
jPanel24.add(jPanel25, "card2");
jTextPane6.setText("Set current to Input1 (mA) for Input2 seconds");
jScrollPane10.setViewportView(jTextPane6);
org.jdesktop.layout.GroupLayout jPanel26Layout = new org.jdesktop.layout.GroupLayout(jPanel26);
jPanel26.setLayout(jPanel26Layout);
jPanel26Layout.setHorizontalGroup(
jPanel26Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 221, Short.MAX_VALUE)
.add(jPanel26Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel26Layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane10, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
.addContainerGap()))
);
jPanel26Layout.setVerticalGroup(
jPanel26Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
15
Two and Three Electrode Potentiostat Appendix
.add(0, 128, Short.MAX_VALUE)
.add(jPanel26Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel26Layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane10, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
.addContainerGap()))
);
jPanel24.add(jPanel26, "card3");
jTextPane7.setText(" Set potential to Input1 (V) until current reaches Input2 (mA) ");
jScrollPane11.setViewportView(jTextPane7);
org.jdesktop.layout.GroupLayout jPanel27Layout = new org.jdesktop.layout.GroupLayout(jPanel27);
jPanel27.setLayout(jPanel27Layout);
jPanel27Layout.setHorizontalGroup(
jPanel27Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel27Layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane11, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
.addContainerGap())
);
jPanel27Layout.setVerticalGroup(
jPanel27Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel27Layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane11, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
.addContainerGap())
);
jPanel24.add(jPanel27, "card4");
jTextPane8.setText("Set potential to Input1 (V) for Input2 seconds");
jScrollPane12.setViewportView(jTextPane8);
org.jdesktop.layout.GroupLayout jPanel28Layout = new org.jdesktop.layout.GroupLayout(jPanel28);
jPanel28.setLayout(jPanel28Layout);
jPanel28Layout.setHorizontalGroup(
jPanel28Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel28Layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane12, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
.addContainerGap())
);
jPanel28Layout.setVerticalGroup(
jPanel28Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel28Layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane12, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
.addContainerGap())
);
jPanel24.add(jPanel28, "card5");
16
Two and Three Electrode Potentiostat Appendix
org.jdesktop.layout.GroupLayout jPanel14Layout = new org.jdesktop.layout.GroupLayout(jPanel14);
jPanel14.setLayout(jPanel14Layout);
jPanel14Layout.setHorizontalGroup(
jPanel14Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel14Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel14Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(jPanel15, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel14Layout.createSequentialGroup()
.add(jPanel24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(31, 31, 31))
.add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(19, Short.MAX_VALUE))
);
jPanel14Layout.setVerticalGroup(
jPanel14Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel14Layout.createSequentialGroup()
.add(18, 18, 18)
.add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(jPanel15, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(18, 18, 18)
.add(jPanel24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(117, 117, 117))
);
jPanel30.add(jPanel14, "card2");
jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());
setactionField.setText("4.99");
jLabel15.setText("Actions");
jLabel16.setText("Setting (k?/mA/V)");
buttonGroup1.add(pstatRadio);
pstatRadio.setText("pstat");
pstatRadio.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pstatRadioActionPerformed(evt);
}
});
buttonGroup1.add(gstatRadio);
gstatRadio.setText("gstat");
17
Two and Three Electrode Potentiostat Appendix
buttonGroup1.add(resRadio);
resRadio.setText("res set");
buttonGroup1.add(manRadio);
manRadio.setText("manual V");
actionButton.setText("Set");
actionButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
actionButtonActionPerformed(evt);
}
});
ocvButton.setText("OCV");
ocvButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ocvButtonActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout jPanel8Layout = new org.jdesktop.layout.GroupLayout(jPanel8);
jPanel8.setLayout(jPanel8Layout);
jPanel8Layout.setHorizontalGroup(
jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel8Layout.createSequentialGroup()
.add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel15)
.add(jPanel8Layout.createSequentialGroup()
.addContainerGap()
.add(setactionField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel16))
.add(jPanel8Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(pstatRadio)
.add(gstatRadio)
.add(resRadio)
.add(manRadio)))
.add(jPanel8Layout.createSequentialGroup()
.addContainerGap()
.add(actionButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(ocvButton)))
.addContainerGap(61, Short.MAX_VALUE))
);
jPanel8Layout.setVerticalGroup(
jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel8Layout.createSequentialGroup()
.add(jLabel15)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
18
Two and Three Electrode Potentiostat Appendix
.add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(setactionField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 34,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(12, 12, 12)
.add(pstatRadio)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(gstatRadio)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(resRadio)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(manRadio)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(actionButton)
.add(ocvButton))
.addContainerGap(94, Short.MAX_VALUE))
);
jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendButtonActionPerformed(evt);
}
});
jLabel6.setText("Manual Action");
checkSendBox.setSelected(true);
checkSendBox.setText("Check Send");
org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel4Layout.createSequentialGroup()
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel6)
.add(jPanel4Layout.createSequentialGroup()
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel4Layout.createSequentialGroup()
.add(12, 12, 12)
.add(sendField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 113,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.add(sendButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 94,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
19
Two and Three Electrode Potentiostat Appendix
.add(checkSendBox)
.add(whatIWantField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 113,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel4Layout.createSequentialGroup()
.add(jLabel6)
.add(18, 18, 18)
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(sendField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(whatIWantField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(sendButton)
.add(checkSendBox))
.addContainerGap(37, Short.MAX_VALUE))
);
org.jdesktop.layout.GroupLayout jPanel31Layout = new org.jdesktop.layout.GroupLayout(jPanel31);
jPanel31.setLayout(jPanel31Layout);
jPanel31Layout.setHorizontalGroup(
jPanel31Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel31Layout.createSequentialGroup()
.add(67, 67, 67)
.add(jPanel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel31Layout.createSequentialGroup()
.addContainerGap(30, Short.MAX_VALUE)
.add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel31Layout.setVerticalGroup(
jPanel31Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel31Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(18, 18, 18)
.add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(103, Short.MAX_VALUE))
);
jPanel30.add(jPanel31, "card3");
jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());
20
Two and Three Electrode Potentiostat Appendix
vccField.setText("4.99");
vccField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
vccFieldActionPerformed(evt);
}
});
jLabel10.setText("Calibrate");
mRField.setText("0.03843");
mRField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mRFieldActionPerformed(evt);
}
});
bRField.setText("0.04485");
jLabel12.setText("VCC");
jLabel13.setText("R slope");
jLabel14.setText("R offset");
calibButton.setText("Set");
calibButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
calibButtonActionPerformed(evt);
}
});
vLimitField.setText("5");
iLimitField.setText("20");
jLabel19.setText("V lim");
jLabel20.setText("I lim");
buttonGroup2.add(r10kButton);
r10kButton.setText("10 K set");
r10kButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
r10kButtonActionPerformed(evt);
}
});
buttonGroup2.add(r50kButton);
r50kButton.setSelected(true);
r50kButton.setText("50 K Set");
r50kButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
r50kButtonActionPerformed(evt);
21
Two and Three Electrode Potentiostat Appendix
}
});
buttonGroup2.add(rFixedButton);
rFixedButton.setText("Fixed");
rFixedButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rFixedButtonActionPerformed(evt);
}
});
rFixedField.setText("1000000");
jLabel23.setText("Fixed k?");
jButton1.setText("Find Me!");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
initialVField.setText("0.1");
jLabel28.setText("Initial ?V");
buttonGroup2.add(r100kButton);
r100kButton.setText("100 K Set");
r100kButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
r100kButtonActionPerformed(evt);
}
});
saveSettingsButton.setText("Save Settings");
saveSettingsButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveSettingsButtonActionPerformed(evt);
}
});
loadSettingsButton.setText("Load Settings");
resCheckButton.setText("Start Res Check");
resCheckButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
resCheckButtonActionPerformed(evt);
}
});
potCalButton.setText("Pot Cal");
potCalButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
22
Two and Three Electrode Potentiostat Appendix
potCalButtonActionPerformed(evt);
}
});
fixedResCalField.setText("10");
fixedResCalField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fixedResCalFieldActionPerformed(evt);
}
});
jLabel17.setText("kOhm");
org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel6Layout.createSequentialGroup()
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel10)
.add(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel6Layout.createSequentialGroup()
.add(vccField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel12))
.add(jPanel6Layout.createSequentialGroup()
.add(mRField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel13))
.add(jPanel6Layout.createSequentialGroup()
.add(bRField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel14))
.add(jPanel6Layout.createSequentialGroup()
.add(rFixedField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel23))
.add(jPanel6Layout.createSequentialGroup()
.add(initialVField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel28)))
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel6Layout.createSequentialGroup()
.add(19, 19, 19)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, iLimitField)
23
Two and Three Electrode Potentiostat Appendix
.add(org.jdesktop.layout.GroupLayout.LEADING, vLimitField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel20)
.add(jLabel19)))
.add(jPanel6Layout.createSequentialGroup()
.add(18, 18, 18)
.add(r10kButton))
.add(jPanel6Layout.createSequentialGroup()
.add(18, 18, 18)
.add(r50kButton))
.add(jPanel6Layout.createSequentialGroup()
.add(39, 39, 39)
.add(jLabel17))
.add(jPanel6Layout.createSequentialGroup()
.add(18, 18, 18)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(rFixedButton)
.add(r100kButton)))))
.add(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(saveSettingsButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel6Layout.createSequentialGroup()
.add(calibButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 93,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(jButton1))
.add(loadSettingsButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(resCheckButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.add(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.add(potCalButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(fixedResCalField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel6Layout.createSequentialGroup()
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel6Layout.createSequentialGroup()
.add(jLabel10)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel12)
.add(vLimitField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
24
Two and Three Electrode Potentiostat Appendix
.add(vccField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel19))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(mRField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel13)
.add(iLimitField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel20))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel6Layout.createSequentialGroup()
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(bRField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel14))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(rFixedField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel23)))
.add(jPanel6Layout.createSequentialGroup()
.add(r10kButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(r50kButton))))
.add(jPanel6Layout.createSequentialGroup()
.addContainerGap(146, Short.MAX_VALUE)
.add(r100kButton)
.add(2, 2, 2)))
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel6Layout.createSequentialGroup()
.add(7, 7, 7)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(initialVField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel28)))
.add(jPanel6Layout.createSequentialGroup()
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(rFixedButton)))
.add(19, 19, 19)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1)
.add(calibButton))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(saveSettingsButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(loadSettingsButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(resCheckButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
25
Two and Three Electrode Potentiostat Appendix
.add(potCalButton)
.add(jLabel17)
.add(fixedResCalField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(41, 41, 41))
);
jLabel21.setText("Settings");
jButton3.setText("Close Settings");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel21)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jButton3)
.add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(45, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(7, 7, 7)
.add(jLabel21)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(27, 27, 27)
.add(jButton3)
.addContainerGap(52, Short.MAX_VALUE))
);
jPanel30.add(jPanel1, "card4");
jMenu1.setText("File");
jMenuItem3.setText("Exit");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
26
Two and Three Electrode Potentiostat Appendix
jMenu1.add(jMenuItem3);
jMenuBar1.add(jMenu1);
jMenu2.setText("Edit");
jMenuItem4.setText("Settings");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem4);
jMenuBar1.add(jMenu2);
jMenu3.setText("Debug");
jMenuItem1.setText("Debug Mode");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem1);
jMenuItem2.setText("Exit Debug Mode");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem2);
jMenuBar1.add(jMenu3);
setJMenuBar(jMenuBar1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(21, 21, 21)
.add(jPanel30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 302,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(18, 18, 18)
.add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(jPanel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
27
Two and Three Electrode Potentiostat Appendix
.addContainerGap(52, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jPanel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel5,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel30,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addContainerGap(50, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void TimeFieldActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_TimeFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_TimeFieldActionPerformed
public void nextStepAnnounce()
{
System.out.println("inside of nextStepAnnounce()");
String output = "";
String parts[] = advancedparts[advancedstep].split(" ");
int model = Integer.parseInt(parts[0]);
double setting = Double.parseDouble(parts[1]);
double cutoff = Double.parseDouble(parts[2]);
if (model == 0)
{
gstatGo(setting);
output = output + "Set current to " + String.valueOf(setting) + " mA until potential reaches " +
String.valueOf(cutoff) + " V";
}
else if (model == 1)
{
gstatGo(setting);
output = output + "Set current to " + String.valueOf(setting) + " mA for " + String.valueOf(cutoff) + "
seconds";
}
else if (model == 2)
{
pstatGo(setting);
output = output + "Set potential to " + String.valueOf(setting) + " V until current reaches " +
String.valueOf(cutoff) + " mA";
}
28
Two and Three Electrode Potentiostat Appendix
else if (model == 3)
{
pstatGo(setting);
output = output + "Set potential to " + String.valueOf(setting) + " V for " + String.valueOf(cutoff) + "
seconds";
}
output = "Now: " +output+"\n";
System.out.println(output);
//announceText.setText(output);
}
public void parseAdvanced(String input)
{
String output = "";
input = input+"\n" +"1 0 0";
String[] lines = input.split("\n");
advancedparts = lines;
advancedstep = 0;
System.out.println(lines.length);
for (int i = 0; i < lines.length; i++)
{
String parts[] = lines[i].split(" ");
int model = Integer.parseInt(parts[0]);
double setting = Double.parseDouble(parts[1]);
double cutoff = Double.parseDouble(parts[2]);
if (model == 0) output = output + "Set current to " + String.valueOf(setting) + " mA until potential reaches " +
String.valueOf(cutoff) + " V";
else if (model == 1) output = output + "Set current to " + String.valueOf(setting) + " mA for " +
String.valueOf(cutoff) + " seconds";
else if (model == 2) output = output + "Set potential to " + String.valueOf(setting) + " V until current reaches
" + String.valueOf(cutoff) + " mA";
else if (model == 3) output = output + "Set potential to " + String.valueOf(setting) + " V for " +
String.valueOf(cutoff) + " seconds";
output = output+"\n";
}
System.out.println(output);
//confirmText.setText(output);
}
private void ocvButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_ocvButtonActionPerformed
toArd("-0000");
}//GEN-LAST:event_ocvButtonActionPerformed
private void actionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_actionButtonActionPerformed
System.out.println("The set button was pressed");
try {
if (pstatRadio.isSelected()) pstatGo(Double.parseDouble(setactionField.getText()));
29
Two and Three Electrode Potentiostat Appendix
else if (resRadio.isSelected()) resGo(Double.parseDouble(setactionField.getText()));
else if (manRadio.isSelected()) manualGo(Double.parseDouble(setactionField.getText()));
else if (gstatRadio.isSelected()) gstatGo(Double.parseDouble(setactionField.getText()));
}
catch (Exception e)
{
}
}//GEN-LAST:event_actionButtonActionPerformed
private void pstatRadioActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_pstatRadioActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_pstatRadioActionPerformed
private void settingFieldActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_settingFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_settingFieldActionPerformed
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_sendButtonActionPerformed
System.out.println("Send button action performed");
System.out.println("To be sent: " + sendField.getText());
try
{
toArd(sendField.getText());
}
catch (Exception e)
{
}
}//GEN-LAST:event_sendButtonActionPerformed
void LogStuff(String data)
{
logToggle.setSelected(!logToggle.isSelected());
try{
FileWriter fw = new FileWriter(dataFile,true);
fw.write(data);
fw.close();
FileWriter fw2 = new FileWriter(dataFile2,true);
fw2.write(data);
fw2.close();
}
catch(Exception fwerror)
{
30
Two and Three Electrode Potentiostat Appendix
}
}
private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_connectButtonActionPerformed
try{
if (connectButton.getText() == "Connect" )
{
calibrate();
connectime = System.currentTimeMillis();
Enumeration whosits = portId.getPortIdentifiers();
while (whosits.hasMoreElements())
{
portId = (CommPortIdentifier) whosits.nextElement();
System.out.println(portList.getSelectedItem().toString());
System.out.println(portId.getName());
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(portList.getSelectedItem().toString()))
{
try {
//serialPort = (SerialPort) portId.open("test",100);
serialPort = (SerialPort) portId.open("serial",50);
} catch (PortInUseException e) {
e.printStackTrace();
}
try {
outputStream = serialPort.getOutputStream();
inputStream = serialPort.getInputStream();
} catch (IOException e) {}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {e.printStackTrace();}
serialPort.notifyOnDataAvailable(true);
try {
serialPort.setSerialPortParams(57600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {e.printStackTrace();}
toArd("-0000");
31
Two and Three Electrode Potentiostat Appendix
}
}
}
portList.setEnabled(false);
connectButton.setText( "Disconnect");
}
else
{
serialPort.close();
connectButton.setText("Connect");
portList.setEnabled(true);
}
}
catch (Exception e) {}
}//GEN-LAST:event_connectButtonActionPerformed
private void portButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_portButtonActionPerformed
portList.removeAllItems();
Enumeration whosits = portId.getPortIdentifiers();
while (whosits.hasMoreElements())
{
portId = (CommPortIdentifier) whosits.nextElement();
System.out.println(portId.getName());
portList.addItem(portId.getName());
}
}//GEN-LAST:event_portButtonActionPerformed
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jRadioButton2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jRadioButton2ActionPerformed
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jComboBox1ActionPerformed
// TODO add your handling code here:
if(jComboBox1.getSelectedIndex() == 0) {
jPanel25.setVisible(true);
jPanel26.setVisible(false);
jPanel27.setVisible(false);
jPanel28.setVisible(false);
} else if(jComboBox1.getSelectedIndex() == 1) {
jPanel25.setVisible(false);
jPanel26.setVisible(true);
jPanel27.setVisible(false);
jPanel28.setVisible(false);
} else if(jComboBox1.getSelectedIndex() == 2) {
jPanel25.setVisible(false);
jPanel26.setVisible(false);
jPanel27.setVisible(true);
32
Two and Three Electrode Potentiostat Appendix
jPanel28.setVisible(false);
} else if(jComboBox1.getSelectedIndex() == 3) {
jPanel25.setVisible(false);
jPanel26.setVisible(false);
jPanel27.setVisible(false);
jPanel28.setVisible(true);
}
}//GEN-LAST:event_jComboBox1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
System.out.println("we got here!");
if(jTextField1.getText().isEmpty() || jTextField2.getText().isEmpty()) {
return ;
}
if(jButton2.getText().equalsIgnoreCase("Run")) {
jButton2.setText("Stop");
} else {
jButton2.setText("Run");
}
int mode = jComboBox1.getSelectedIndex();
double maxValue = Double.valueOf(jTextField1.getText());
double time = Double.valueOf(jTextField2.getText());
System.out.println("mode is:" + mode);
System.out.println("maxValue is:" + maxValue);
System.out.println("time is:" + time);
String output = "";
String advancedPartsString = "";
advancedPartsString = advancedPartsString + mode + " " + maxValue + " " + time + "\n" + "1 0 0";
String[] lines = advancedPartsString.split("\n");
advancedparts = lines;
advancedstep = 0;
System.out.println("line is: " + advancedparts[advancedstep]);
//System.out.println(lines.length);
int model = mode;
double setting = maxValue;
double cutoff = time;
if (model == 0) output = output + "Set current to " + String.valueOf(setting) + " mA until potential reaches " +
String.valueOf(cutoff) + " V";
else if (model == 1) output = output + "Set current to " + String.valueOf(setting) + " mA for " +
String.valueOf(cutoff) + " seconds";
else if (model == 2) output = output + "Set potential to " + String.valueOf(setting) + " V until current reaches "
+ String.valueOf(cutoff) + " mA";
33
Two and Three Electrode Potentiostat Appendix
else if (model == 3) output = output + "Set potential to " + String.valueOf(setting) + " V for " +
String.valueOf(cutoff) + " seconds";
output = output+"\n";
System.out.println(output);
//confirmText.setText(output);
System.out.println("we got to this line of code");
System.out.println("advanced: " + advanced);
if (advanced) {
advanced = false;
advancedtimed = false;
advancedstep = 0;
//advancedButton.setText("Go!");
//confirmText.setText("");
//announceText.setText("");
//advancedButton.setEnabled(false);
cycleset = false;
toArd("-0000");
if (logit)
{
try
{
FileWriter fw = new FileWriter(infFile,true);
fw.write("Changed cycle behavior at "+String.valueOf(System.currentTimeMillis())+"\n");
//fw.write(advancedText.getText()+"\n");
//fw.write(confirmText.getText()+"\n");
//if (nthCycleCheckBox.isEnabled()) fw.write("Logging every "+nthCycleTextField.getText()+" cycle\n");
fw.close();
}
catch (Exception e){}
}
//repeatCheckBox.setEnabled(true);
//repeatCheckBox.setSelected(false);
nthCycleLoggingEnable();
} else {
advanced = true;
advancedtimed = false;
//advancedButton.setText("Stop!");
nextStepAnnounce();
cycleset = false;
//repeatCheckBox.setEnabled(false);
//nthCycleCheckBox.setEnabled(false);
//nthCycleTextField.setEnabled(false);
}
}//GEN-LAST:event_jButton2ActionPerformed
34
Two and Three Electrode Potentiostat Appendix
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jMenuItem1ActionPerformed
// TODO add your handling code here:
jPanel31.setVisible(true);
jPanel14.setVisible(false);
jMenuItem2.setVisible(true);
jMenuItem1.setVisible(false);
}//GEN-LAST:event_jMenuItem1ActionPerformed
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jMenuItem2ActionPerformed
// TODO add your handling code here:
jPanel31.setVisible(false);
jPanel14.setVisible(true);
jMenuItem2.setVisible(false);
jMenuItem1.setVisible(true);
}//GEN-LAST:event_jMenuItem2ActionPerformed
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jMenuItem3ActionPerformed
// TODO add your handling code here:
if(serialPort != null)
{
System.out.println("turning serial off");
serialPort.close();
}
System.exit(0);
}//GEN-LAST:event_jMenuItem3ActionPerformed
private void logButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_logButtonActionPerformed
if(logButton.getText()=="Start Log") {
logButton.setText("Stop Log");
fileField.setEditable(false);
logit = true;
timelogstart = ((double)System.currentTimeMillis())/1000;
appendDate = Long.toString(System.currentTimeMillis());
dataFile = fileField.getText()+"-"+appendDate+".dat";
dataFile2 = fileField.getText()+"-"+appendDate+".csv";
infFile = fileField.getText()+"-"+appendDate+".inf";
String header = "Unix Time,Mode,Resistance Calibration Offset,Resistance Calibration Slope,Vcc
Calibration,"
+ "ADC Potential,DAC Potential(V),Potentiometer Resistance,Current(mA),RAW Data,RAW Data,RAW
Data,"
+ "RAW Data,RAW Data,RAW Data,Time(s)" + "\n";
try {
FileWriter fw = new FileWriter(dataFile,true);
fw.write(header);
fw.close();
FileWriter fw2 = new FileWriter(dataFile2,true);
fw2.write(header);
fw2.close();
35
Two and Three Electrode Potentiostat Appendix
} catch (Exception e){};
setTitle( "Ardustat - " + fileField.getText());
} else {
logButton.setText("Start Log");
fileField.setEditable(true);
logit = false;
setTitle( "Ardustat");
}
}//GEN-LAST:event_logButtonActionPerformed
private void resCheckButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_resCheckButtonActionPerformed
if (checkSendBox.isSelected()) {
checkSendBox.setSelected(false);
toArd("R");
resCheckButton.setText("Stop Res Check");
} else {
toArd("-0000");
checkSendBox.setSelected(true);
resCheckButton.setText("Start Res Check");
}
}//GEN-LAST:event_resCheckButtonActionPerformed
private void saveSettingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_saveSettingsButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_saveSettingsButtonActionPerformed
private void r100kButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_r100kButtonActionPerformed
mRField.setText("0.00252264");
bRField.setText("0.37997267");
}//GEN-LAST:event_r100kButtonActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton1ActionPerformed
try {
String outie = " ";
outputStream.write(outie.getBytes());
leaveout = true;
} catch (Exception e) {
}
}//GEN-LAST:event_jButton1ActionPerformed
private void rFixedButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_rFixedButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_rFixedButtonActionPerformed
36
Two and Three Electrode Potentiostat Appendix
private void r50kButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_r50kButtonActionPerformed
mRField.setText("0.2136");
bRField.setText("0.02682");
// mRField.setText("0.2166");
// bRField.setText("0.2405");
}//GEN-LAST:event_r50kButtonActionPerformed
private void r10kButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_r10kButtonActionPerformed
mRField.setText("0.03843");
bRField.setText("0.04485");
//Old values (pre V-board 1.5)
//0.0397
//0.0455
}//GEN-LAST:event_r10kButtonActionPerformed
private void calibButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_calibButtonActionPerformed
calibrate();
}//GEN-LAST:event_calibButtonActionPerformed
private void mRFieldActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_mRFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_mRFieldActionPerformed
private void vccFieldActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_vccFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_vccFieldActionPerformed
private void potCalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_potCalButtonActionPerformed
if (checkSendBox.isSelected()) {
checkSendBox.setSelected(false);
toArd("R");
resCheckButton.setText("Stop");
} else {
toArd("-0000");
checkSendBox.setSelected(true);
resCheckButton.setText("Start Res Check");
}
}//GEN-LAST:event_potCalButtonActionPerformed
private void fixedResCalFieldActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_fixedResCalFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_fixedResCalFieldActionPerformed
37
Two and Three Electrode Potentiostat Appendix
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jMenuItem4ActionPerformed
// TODO add your handling code here:
jPanel31.setVisible(false);
jPanel14.setVisible(false);
jPanel1.setVisible(true);
}//GEN-LAST:event_jMenuItem4ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
jPanel31.setVisible(false);
jPanel1.setVisible(false);
jPanel14.setVisible(true);
}//GEN-LAST:event_jButton3ActionPerformed
public void nthCycleLoggingEnable()
{
/*if (repeatCheckBox.isSelected())
{
nthCycleCheckBox.setEnabled(true);
//nthCycleTextField.setEnabled(true);
}
else
{
nthCycleCheckBox.setEnabled(false);
nthCycleCheckBox.setSelected(false);
//nthCycleTextField.setEnabled(false);
logcyc = true;
}*/
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Ardustat().setVisible(true);
}
});
}
public void serialEvent(SerialPortEvent event)
{
38
Two and Three Electrode Potentiostat Appendix
try {
//
byte[] readBuffer = new byte[16];
while (inputStream.available() > 0)
{
buffer[counter] = (byte) inputStream.read();
byte tempbyte = buffer[counter];
if (tempbyte == 10)
{
timein = System.currentTimeMillis() - timeout;
byte oof[] = new byte[counter];
for (int i = 0; i < counter; i++)
{
oof[i] = buffer[i];
}
//System.out.println(new String(oof));
parseData(new String(oof));
counter = 0;
}
else
{
counter++;
}
}
}
catch (Exception e) {}
//System.out.print(counter);
}
public void parseData(String input)
{
System.out.println("inside parsedata()");
System.out.println("input into parsedata(): " + input);
//Get the current time in milliseconds
nowtime = System.currentTimeMillis();
TimeString = String.valueOf((nowtime-connectime)/1000);
String stringdata[] = input.split(",");
39
Two and Three Electrode Potentiostat Appendix
try{
//Funny functions round stuff
double DAC = Math.round(1000*(vccCalib*Double.parseDouble(stringdata[3])/1023));
DAC = DAC/1000;
double ADC = Math.round(1000*vccCalib*Double.parseDouble(stringdata[2])/1023);
ADC = ADC/1000;
double R = Math.round(1000*((mRCalib*Double.parseDouble(stringdata[4]))+ bRCalib));
R = R/1000;
//if (rFixedButton.isSelected()) R = Double.parseDouble(rFixedField.getText());
double I = Math.round(1000*(DAC-ADC)/(R));
I = I/1000;
//if (rFixedButton.isSelected()) I = (DAC-ADC)/(R);
Voltage = ADC;
Current = I;
//BLink if processed
//if (jRadioButton1.isSelected()) jRadioButton1.setSelected(false);
//
else jRadioButton1.setSelected(true);
//if (rFixedButton.isSelected()) R = Double.valueOf(rFixedField.getText());
adcField.setText(Double.toString(ADC));
dacField.setText(Double.toString(DAC));
dacField1.setText(stringdata[3]);
dacField2.setText(stringdata[1]);
ohmField.setText(Double.toString(R));
TimeField.setText(TimeString);
String mode ="";
String m ="";
if (Double.parseDouble(stringdata[6]) == 0)
{
mode = "man";
m = "+";
}
else if (Double.parseDouble(stringdata[6]) == 1)
{
mode = "OCV";
m = "-";
}
else if (Double.parseDouble(stringdata[6]) == 2)
{
mode = "pstat";
m = "p";
}
else if (Double.parseDouble(stringdata[6]) == 3)
{
mode = "gstat";
m="g";
}
else if (Double.parseDouble(stringdata[6]) == 4)
{
mode = "dactest";
40
Two and Three Electrode Potentiostat Appendix
m="P";
}
whatIWantField.setText(stringdata[7]);
modeField.setText(mode);
settingField.setText(stringdata[5]);
if ((checkSendBox.isSelected())&&(leaveout==false))
{
if (whatIWant.equals(stringdata[7])&& gstep1)
{
System.out.println("toArd(" +gstring+ ")");
toArd(gstring);
gstep1 = false;
gstep2 = true;
}
else if (whatIWant.equals(stringdata[7]) && gstep2)
{
System.out.println("inside step 2");
gstep2 = false;
}
else if (whatIWant.equals(stringdata[7])) holder();
else
{
System.out.println("toArd(whatIwant)");
toArd(whatIWant);
//System.out.println(whatIWant);
}
/* if ((Voltage > vLim) || (Math.abs(Current) > iLim))
{
System.out.println("toArd(-1000)");
toArd("-0000");
advanced = false;
// advancedButton.setText("Go!");
}
*/
}
else if ((checkSendBox.isSelected()))
{
leaveout = false;
}
if (mode =="OCV")
{
Current = 0;
}
double rout = 0;
currentField.setText(Double.toString(Current));
double Watts = .001*Current*Voltage;
41
Two and Three Electrode Potentiostat Appendix
wattField.setText(Double.toString(Math.abs(Watts)));
if (Current != 0)
{
rout = (ADC)/(Current);
}
else rout = 0;
cellResField.setText(Double.toString(rout));
//reportArea.setText(output);
//double data[] = new double[stringdata.length];
// for (int i = 0; i < data.length; i++)
//{
// data[i] = 5*Double.parseDouble(stringdata[i])/1023;
// }
if (advanced)
{
System.out.println("advanced is true --- entering cycleControl");
cycleControl();
}
if (logit && logcyc)
{
System.out.println("logit and logcyc are true");
double timelog = ((double)System.currentTimeMillis())/1000;
String data = Long.toString(System.currentTimeMillis())+","+
stringdata[6]+","+
Double.toString(bRCalib)+","+
Double.toString(mRCalib)+","+
Double.toString(vccCalib)+","+
Double.toString(ADC)+","+
Double.toString(DAC)+","+
Double.toString(R)+","+
Double.toString(Current)+","+
stringdata[1]+","+
stringdata[2]+","+
stringdata[3]+","+
stringdata[4]+","+
stringdata[5]+ ","+
stringdata[6]+","+
Double.toString(timelog-timelogstart)+
"\n";
//double VDiff = Math.abs((Voltage-voltageholder)/Voltage)*100;
42
Two and Three Electrode Potentiostat Appendix
//double IDiff = Math.abs((Current-currentholder)/Current)*100;
//double DiffThreshold = Double.parseDouble(changeTextField.getText());
double VDiff = Math.abs((Voltage-voltageholder));
double IDiff = Math.abs((Current-currentholder));
//double Icheck = Double.parseDouble(changeIField.getText());
//double Vcheck = Double.parseDouble(changeVField.getText());
//int StaticTrigger = Integer.parseInt(changeCounterTextField.getText());
/*if (adaptLogRadio.isSelected())
{
if ( VDiff > Vcheck || IDiff > Icheck || changeInterval >= StaticTrigger)
{
LogStuff(data);
changeInterval = 0;
}
changeInterval++;
voltageholder = Voltage;
currentholder = Current;
}
else if (timedLogRadio.isSelected())
{
Long timenow = System.currentTimeMillis();
Long timewait = Long.parseLong(timelogTextField.getText());
if (timenow > (timewait*1000+logtimer))
{
logtimer = timenow;
LogStuff(data);
}
}
else if (everyLogRadio.isSelected())
{
LogStuff(data);
}*/
LogStuff(data);
}
//Calibration Stuff
if (calibrationMode)
{
System.out.println("Calibration is true");
//wait for 0 then start counting
int ardres = Integer.parseInt(stringdata[4]);
if (counter == 4)
{
//calibrationModeOff();
43
Two and Three Electrode Potentiostat Appendix
}
else
{
}
}
}
catch (Exception E)
{
System.out.println("Parse Data Error" +E.getMessage());
}
}
public void holder()
{
}
public void gstatGo(double setcurrent)
{
if (setcurrent != 0)
{
//find maximum R
double maxR = mRCalib*(255)+bRCalib;
//determine best R for selected current
double x = 0;
double tres = 0;
String stringout ="";
double initialV = Double.parseDouble(initialVField.getText());
tres = initialV/Math.abs(setcurrent);
// Check to see if we can do this
if (tres > maxR) tres = maxR;
if (tres < .150) tres = .150;
// Account for rounding errors
x = Math.round((tres-bRCalib)/mRCalib);
double tres2 = (mRCalib*x) + bRCalib;
if (rFixedButton.isSelected()) tres2 = Double.parseDouble(rFixedField.getText());
//Figure out deltaV for given R and set current
double deltaV = (tres2)*setcurrent;
int sendtoard = (int)Math.round(deltaV*1023/vccCalib);
if (sendtoard < 0) sendtoard = Math.abs(sendtoard)+2000;
//format for ardustat
if (sendtoard < 10) stringout = "g000"+Integer.toString(sendtoard);
44
Two and Three Electrode Potentiostat Appendix
else if (sendtoard < 100) stringout = "g00"+Integer.toString(sendtoard);
else if (sendtoard < 1000) stringout = "g0"+Integer.toString(sendtoard);
else stringout = "g"+Integer.toString(sendtoard);
gstring = stringout;
System.out.println("gstring is: " + gstring);
//set current
if (rFixedButton.isSelected()==false) resGo(tres);
//get gString to step up later
gstep1 = true;
}
else
toArd("-0000");
}
public void pstatGo(double setpotential)
{
String stringout ="";
int sendtoard = (int) Math.round(setpotential*1023/vccCalib);
if (sendtoard > 1023) sendtoard = 1023;
if (sendtoard < 0) sendtoard = 0;
if (sendtoard < 10) stringout = "p000"+Integer.toString(sendtoard);
else if (sendtoard < 100) stringout = "p00"+Integer.toString(sendtoard);
else if (sendtoard < 1000) stringout = "p0"+Integer.toString(sendtoard);
else stringout = "p"+Integer.toString(sendtoard);
toArd(stringout);
}
public void manualGo(double setpotential)
{
String stringout ="";
int sendtoard = (int) Math.round(setpotential*1023/vccCalib);
if (sendtoard > 1023) sendtoard = 1023;
if (sendtoard < 0) sendtoard = 0;
if (sendtoard < 10) stringout = "+000"+Integer.toString(sendtoard);
else if (sendtoard < 100) stringout = "+00"+Integer.toString(sendtoard);
else if (sendtoard < 1000) stringout = "+0"+Integer.toString(sendtoard);
else stringout = "+"+Integer.toString(sendtoard);
toArd(stringout);
}
public void resGo(double setresistance)
{
String ardstring;
int x = (int) Math.round((setresistance-bRCalib)/mRCalib);
if (x > 255) x = 255;
if (x < 0) x = 0;
45
Two and Three Electrode Potentiostat Appendix
if (x < 10) ardstring = "r000"+Integer.toString(x);
else if (x < 100) ardstring = "r00"+Integer.toString(x);
else ardstring = "r0"+Integer.toString(x);
toArd(ardstring);
}
public void calibrate()
{
vccCalib = Double.parseDouble(vccField.getText());
mRCalib = Double.parseDouble(mRField.getText());
bRCalib = Double.parseDouble(bRField.getText());
vLim = Double.parseDouble(vLimitField.getText());
iLim = Double.parseDouble(iLimitField.getText());
}
//More Variables
double tempres[][] = new double [4][256];
int autoCalibrateCounter = 0;
/*public void voltageDivider(int round, int number)
{
//Set Fixed Things
double fixedResistor = Double.parseDouble(fixedResCalField.getText());
double DAC = Double.parseDouble(dacField.getText());
double ADC = Double.parseDouble(adcField.getText());
//Match Stuff
tempres[round][number] = (fixedResistor/ADC - fixedResistor/DAC)*DAC;
}*/
public void autoCalibrate()
{
for (int j = 0; j < 256; j++)
{
for (int i = 0; i < 4; i++)
{
}
}
}
/*Begin Advanced Section*/
public void cycleControl()
{
if (advanced)
{
if(advancedstep < advancedparts.length - 1)
{
String parts[] = advancedparts[advancedstep].split(" ");
46
Two and Three Electrode Potentiostat Appendix
int mode = Integer.parseInt(parts[0]);
double setting = Double.parseDouble(parts[1]);
double cutoff = Double.parseDouble(parts[2]);
if ((mode == 1 || mode ==3)&&(advancedtimed == false))
{
advancedtimed = true;
advancedtimestop = Double.parseDouble(TimeString)+cutoff;
}
if (mode == 0)//Constant Current until a cutoff potential
{
//NEED TO ADD 0 current clause
if ((((setting <= 0) && (Voltage > cutoff))||((setting > 0) && (Voltage < cutoff)))&&(cycleset==false))
//Check to see if Discharge condition is met
{
if (setting == 0) toArd("-0000");
else gstatGo(setting);
cycleset = true;
}
else if (((setting <= 0) && (Voltage > cutoff))||((setting > 0) && (Voltage < cutoff))) //Check to see if
condition is met
{
holder();
}
else
{
cycleset = false;
advancedstep ++;
holdtime = 0;
advancedtimed = false; //If done move on to the next step;
nextStepAnnounce();
}
}
if (mode == 1)//Constant Current until a cutoff time
{
if ((Double.parseDouble(TimeString) < advancedtimestop)&&(cycleset==false)) //Check to see if Discharge
condition is met
{
if (setting == 0)
{
toArd("-0000");
}
else
{
gstatGo(setting);
47
Two and Three Electrode Potentiostat Appendix
}
cycleset = true;
}
else if (Double.parseDouble(TimeString) < advancedtimestop) //Check to see if Discharge condition is met
{
holder();
}
else
{
advancedstep ++;
cycleset = false;
holdtime = 0;
advancedtimed = false; //If done move on to the next step;
nextStepAnnounce();
}
}
if (mode == 2)
{
if((((setting < Voltage)&&(Current > cutoff))||((setting > Voltage)&&(Current < cutoff)))&&(cycleset ==
false) )
{
pstatGo(setting);
cycleset = true;
}
else if(((setting < Voltage)&&(Current > cutoff))||((setting > Voltage)&&(Current < cutoff)))
{
holder();
}
else
{
advancedstep ++;
cycleset = false;
advancedtimed = false; //If done move on to the next step;
nextStepAnnounce();
}
}
if (mode == 3)
{
if((Double.parseDouble(TimeString) < advancedtimestop)&&(cycleset==false))
{
48
Two and Three Electrode Potentiostat Appendix
pstatGo(setting);
cycleset = true;
}
else if((Double.parseDouble(TimeString) < advancedtimestop))
{
holder();
}
else
{
//SetCurrentField.setText(String.valueOf("0"));
advancedstep ++;
System.out.println(advancedstep);
cycleset = false;
advancedtimed = false; //If done move on to the next step;
nextStepAnnounce();
}
}
}
else
{
advancedstep = 0;
toArd("-0000");
advanced = false;
//advancedButton.setText("Go!");
//confirmText.setText("");
//announceText.setText("");
advancedtimed = false;
cycleset = false;
//repeatCheckBox.setEnabled(true);
//advancedButton.setEnabled(false);
logcyc = true;
}
}
}
/* End Advanced Section */
public void toArd(String outie)
{
try
{
outputStream.write(outie.getBytes());
whatIWant = outie;
sendField.setText(outie);
}
catch (Exception e)
{
49
Two and Three Electrode Potentiostat Appendix
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField TimeField;
private javax.swing.JButton actionButton;
private javax.swing.JTextField adcField;
private javax.swing.JTextField bRField;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.JButton calibButton;
private javax.swing.JTextField cellResField;
private javax.swing.JCheckBox checkSendBox;
private javax.swing.JButton connectButton;
private javax.swing.JTextField currentField;
private javax.swing.JTextField dacField;
private javax.swing.JTextField dacField1;
private javax.swing.JTextField dacField2;
private javax.swing.JTextField fileField;
private javax.swing.JTextField fixedResCalField;
private javax.swing.JRadioButton gstatRadio;
private javax.swing.JTextField iLimitField;
private javax.swing.JTextField initialVField;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel28;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel30;
private javax.swing.JLabel jLabel31;
private javax.swing.JLabel jLabel32;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
50
Two and Three Electrode Potentiostat Appendix
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel14;
private javax.swing.JPanel jPanel15;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel24;
private javax.swing.JPanel jPanel25;
private javax.swing.JPanel jPanel26;
private javax.swing.JPanel jPanel27;
private javax.swing.JPanel jPanel28;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel30;
private javax.swing.JPanel jPanel31;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JScrollPane jScrollPane10;
private javax.swing.JScrollPane jScrollPane11;
private javax.swing.JScrollPane jScrollPane12;
private javax.swing.JScrollPane jScrollPane9;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextPane jTextPane5;
private javax.swing.JTextPane jTextPane6;
private javax.swing.JTextPane jTextPane7;
private javax.swing.JTextPane jTextPane8;
private javax.swing.JButton loadSettingsButton;
private javax.swing.JButton logButton;
private javax.swing.ButtonGroup logButtonGroup;
private javax.swing.JRadioButton logToggle;
private javax.swing.JTextField mRField;
private javax.swing.JRadioButton manRadio;
private javax.swing.JTextField modeField;
private javax.swing.JButton ocvButton;
private javax.swing.JTextField ohmField;
private javax.swing.JButton portButton;
private javax.swing.JComboBox portList;
private javax.swing.JButton potCalButton;
private javax.swing.JRadioButton pstatRadio;
51
Two and Three Electrode Potentiostat Appendix
private javax.swing.JRadioButton r100kButton;
private javax.swing.JRadioButton r10kButton;
private javax.swing.JRadioButton r50kButton;
private javax.swing.JRadioButton rFixedButton;
private javax.swing.JTextField rFixedField;
private javax.swing.JButton resCheckButton;
private javax.swing.JRadioButton resRadio;
private javax.swing.JButton saveSettingsButton;
private javax.swing.JButton sendButton;
private javax.swing.JTextField sendField;
private javax.swing.JTextField setactionField;
private javax.swing.JTextField settingField;
private javax.swing.JTextField vLimitField;
private javax.swing.JTextField vccField;
private javax.swing.JTextField wattField;
private javax.swing.JTextField whatIWantField;
// End of variables declaration//GEN-END:variables
}
52
Two and Three Electrode Potentiostat Appendix
2.0 Appendix 2: Cheapstat Information
General Instructions for building a CheapStat portable potentiostat.
1// Circuit Board
Send the Gerber files to a printed circuit board manufacturer, and order one or more of the CheapStat
printed circuit boards. The gerber files are available as supporting information, and updated versions
may be found on our website.
2// Parts List
Order the parts from a vendor such as digikey or Mouser electronics. See table S1 for a full list of parts.
Some of these components may be substituted or omitted. For instance, this device can function with a
wide variety of different flash chips.
3// Soldering
Solder all of the components onto the printed circuit board as indicated in figure S1. You can zoom in on
this schematic, or look at the gerber files and the photos below (S2 and S3) for further clarification. If
you do not have the appropraite soldering equipment, contract circuit assembly firms such as Sandberg
Industries (Santa Ana, California) can do it for you for a reasonable fee. Be sure to wear an antistatic
wrist strap when handling the components.
4// Mounting the board.
You will need to cut several holes in the enclosure (Fig S2 and S7) to handle the LCD display, USB port,
and control switch. This can be done with a dremmel rotary tool.
5// Programming the microcontroller.
On the circuit board, there are a set of six pins that can be plugged into a microcontroller programmer.
First, attach the cheapstat to a USB power source. Then, attach the microcontroller programmer. Finally,
upload the firmware files to the microcontroller (available in supporting information). This process
should take a few minutes. This is the final step of the assembly process.
6// Using the cheapstat
With the CheapStat plugged into the USB port of a computer, start the control software program. Use
the four way switch on the CheapStat to select an experiment mode such as Square Wave Voltammetry,
change the parameters, and run an experiment. Be sure that the control software is set to the correct
COM port.
7// Handling Data
Data from the cheapstat can be copied directly into Microsoft Excel, Open Office, or other spreadsheet
programs.
53
Two and Three Electrode Potentiostat Appendix
Figure S1 – Board layout. An Atmel XMEGA microcontroller containing a DAC and an ADC with precision
sufficient for voltage waveform generation and current quantification. An RS-232 chip provides an
interface between this microcontroller and a data analysis computer via a USB port. An op amp
feedback system sets the voltage across the electrochemical cell and supplies the voltage needed to
drive the electrochemical reaction.
54
Two and Three Electrode Potentiostat Appendix
Figure S2 – The front side of the circuit board has a mix of surface mount and through-hole solder
connections. Many of the components have a fine pitch, meaning that the electrical contacts are very
close together. Nevertheless, all of the components were placed by hand and soldered without the
assistance of a reflow oven.
55
Two and Three Electrode Potentiostat Appendix
Figure S3 – The reverse of the circuit board supports a three-line LCD display and a joystick, which is
used to select an experiment protocol, change its parameters, and initiate experiments.
56
Two and Three Electrode Potentiostat Appendix
Figure S4 – A block diagram shows the relationship between the microcontroller and other components.
57
Two and Three Electrode Potentiostat Appendix
Figure S5 – A circuit schematic, detailing the connections between each of the main components. Zoom
in to see the details.
58
Two and Three Electrode Potentiostat Appendix
Figure S6 – Screen shot of the control software in action. Data can be copied to the computer clipboard
with a single mouse click or saved into a new file within seconds.
59
Two and Three Electrode Potentiostat Appendix
Figure S7 – Key features of the device. The red wire should be attached to a counter electrode. The
green wire can be attached to a working electrode. The white wire can be attached to a reference. The
device is controlled with a four way switch, and there is a USB port on the side, which supplies power
and an interface with any netbook, laptop, or desktop computer.
60
Two and Three Electrode Potentiostat Appendix
Table S1 -- Cheapstat Version 2.0
Complete Parts List
61
Two and Three Electrode Potentiostat Appendix
Key Features of the CheapStat
Square Wave Voltammetry
Alternating Current Voltammetry
Linear Sweep Voltammetry
Constant Potential Mode
Frequency Range: 1-1000Hz
Voltage Range: -990 to 990mV
Current Range: ~100nA to ~10µA
Note for Early Adopters
For information demonstrating proper use of the CheapStat, as well as updates to this design, circuit
board layout, and source code, can be found on the website of Professor Kevin Plaxco, where it is
available free of charge.
http://www.plaxcolab.com/cheapstat
or
http://www.chem.ucsb.edu/~kwp/cheapstat/
Feel free to email us with questions. We’re friendly!
We welcome design suggestions and code.
62
Two and Three Electrode Potentiostat Appendix
3.0 CheapStat Testing
Refer to ojlead.pdf
63
Two and Three Electrode Potentiostat Appendix
4.0 Two Electrode Potentiostat Technical Manual
Refer to Two Electrode Potentiostat Technical Manual
64
Two and Three Electrode Potentiostat Appendix
5.0 Two Electrode Potentiostat Material List
Arduino Uno
Starter Kit
MAX5250
36.9
9
14.8
8
MCP4261
0.86
R56-1D.5-6
Plastic
Enclosure Box
6.61
5.35
http://www.amazon.com/Arduino-Uno-Starter---SolderlessBreadBoard/dp/B0051QHPJM/ref=sr_1_5?ie=UTF8&qid=1323571211&sr=85
http://www.mouser.com/search/ProductDetail.aspx?qs=9Cj2FLRihcO32hKM
H%2fwmCw%3d%3d&amp;cm_mmc=findchips-_-na-_-na-_-na
http://avnetexpress.avnet.com/store/em/EMController/DigitalPotentiometer/Microchip/MCP4261-503E-P/_/R-6421288/A-6421288/An0?action=part&catalogId=500201&langId=-1&storeId=500201&listIndex=-1
http://mouser.com/search/ProductDetail.aspx?qs=mF0e053UjDARDkAnUfVf
1Q%3d%3d&amp;cm_mmc=findchips-_-na-_-na-_-na
http://www.mouser.com/ProductDetail/Hammond/1593YGY/?qs=%252bn8
HNu1qIod%252bFVQzTwjEdA%3d%3d
65
Two and Three Electrode Potentiostat Appendix
Cheapstat PCB Assembly, Programming,
and Use
Authored by Kyle Bloomer
University of Louisville ECE Capstone Fall 2011
66
Two and Three Electrode Potentiostat Appendix
Table of Contents
PCB Assembly .............................................................................................................................................. 68
Order PCB ................................................................................................................................................ 68
Assemble PCB.......................................................................................................................................... 68
PCB Programming ....................................................................................................................................... 69
Download Atmel Development Environment......................................................................................... 69
Installing Development Environment ..................................................................................................... 69
67
Two and Three Electrode Potentiostat Appendix
PCB Assembly
Order PCB
Blank PCBs were ordered from PCBexpress.com. After registering, select the quantity of boards desired,
with two layer fabrication, and upload the Gerber files that are included in the Cheapstat zip file. For
prototyping, a leaded solder mask was selected, however if the boards will be assembled by students
with little training in soldering technique and safety, a ROHS compliant PCB would be desired and
recommended.
Assemble PCB
EagleCAD can be used to display the schematic and layout (.SCH and .BRD files, respectively). Using
these two views, determine part placement on the PCB, it is also helpful to toggle PCB layers in
EagleCAD to make part placement and values easier to determine. See below for reference.
The Below view was generated by showing only the Top, Dimension, tPlace, tNames, and tValues layers.
The prototype PCB was built using leaded solder and flux, however for student assembly, lead free
(ROHS compliant) solder and flux is recommended.
68
Two and Three Electrode Potentiostat Appendix
PCB Programming
Download Atmel Development Environment
The ATXMEGA microcontroller development environment can be downloaded from Atmel’s website at
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=17212&source=avr_5_studio_overview.
After registering, select the download link labeled “AVR Studio 5 installer (includes VSS and .NET)”, the
current version of this software at time of this documents authoring is rev5.0.1223, subsequent versions
may vary in use from this version.
Installing Development Environment
Once downloaded, run the as5installer-full-5.0.1223.exe application.
Figure 1 - Click Run
Make sure that the AVR Jungo USB Driver installs as well, as these are some of the driver necessary to
use with the AVRISP mkII in circuit programmer (programmer).
69
Two and Three Electrode Potentiostat Appendix
Figure 2 - Click Install
Figure 3 - Click Next
70
Two and Three Electrode Potentiostat Appendix
Figure 4 - Accept Terms and Click Next
Figure 5 - Select Full Install and Click Install
71
Two and Three Electrode Potentiostat Appendix
Figure 6 - Click Finish
After the initial install is complete, you will be prompted to complete the installation of the Jungo USB
drivers.
72
Two and Three Electrode Potentiostat Appendix
Figure 7 - Click Next
Figure 8 - If Prompted, Click Install
73
Two and Three Electrode Potentiostat Appendix
Figure 9 - Click Finish
After the drivers are installed, AVR Studio 5.0 will launch. On first startup, AVR Studio will go through an
initial setup.
Figure 10 - Click Next
74
Two and Three Electrode Potentiostat Appendix
Figure 11 - Accept Terms and Click Next
Figure 12 - Click Next
75
Two and Three Electrode Potentiostat Appendix
Figure 13 - Click Next
76
Two and Three Electrode Potentiostat Appendix
Figure 14 - Accept Terms and Click Next
Figure 15 - Click Next
77
Two and Three Electrode Potentiostat Appendix
Figure 16 - Verify Location and Click OK
Figure 17 - Click Finish and Run AVR Studio 5
To program the circuit, first connect the AVRIPS mkII programmer to the PC via USB 2.0 port; do not
connect the leads from the programmer to the Cheapstat yet. Install two standard AA batteries in the
battery holder. On the power supply jumper on the Cheapstat PCB, select battery power by attaching a
jumper across the ‘BAT’ AND ‘VCC’ pins. To proceed with programing of a Cheapstat PCB, open AVR
Studio 5, click Tools, and select AVR Programming
78
Two and Three Electrode Potentiostat Appendix
Figure 18 - Click Tools and Select AVR Programming
NOTE: When a factory new AVRISP mkII is used for the first time it will require a firmware update, and
will prompt the user when the user attempts to use it for the first time.
After all firmware updates are performed, the user can select the correct programmer that is connect to
the PC via the “Tool” dropdown box, as pictured below. The serial number of the programmer should
also be listed as another means to verify the correct unit being selected, in the even that multiple
programmers are connected to the same PC.
After the correct programmer is selected, the device dropdown box will allow the user to select the
micro that they desire to program. Select ATXMEGA32A4 from the list
79
Two and Three Electrode Potentiostat Appendix
Figure 19 - Select the AVRISP mkII Tool and ATxmega32A4 Device, Click Apply
To test and verify successful connection to the microcontroller, click read in the Device ID and Target
Voltage fields. You should get a hexadecimal ID in the Device ID field, and a DC voltage of 2.8 to 3.5
VDC.
Figure 20 - Click Read Device ID and Target Voltage
To program the Flash and EEPROM on the PCB, select the “Memories” menu on the left.
80
Two and Three Electrode Potentiostat Appendix
Figure 21 - Select Memories Menu
Select the appropriate .HEX files, which can be found in the Cheapstat zip file under mcu->
CheapStat_111810.hex (flash hex file) and mcu-> CheapStat_111810_EEPROM.hex (EEPROM hex file).
These files are selected by pressing the ellipse (…) button to the left of the input field for the Flash and
EEPROM files, respectively.
Figure 22 - Select Appropriate HEX Files by Browsing
81
Two and Three Electrode Potentiostat Appendix
Click Program under the flash field first, then click program under the EEPROM field. Your device is now
programmed, and the Programming window can be closed by clicking close in the lower right. You may
now exit AVR Studio 5 by going to File->Exit.
82
Two and Three Electrode Potentiostat Appendix
83
Related documents