Skip to content

Commit

Permalink
Remove \n in e36xx and fix readVoltageCurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewrankin committed Apr 11, 2024
1 parent 577a9e5 commit f6e483e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
15 changes: 9 additions & 6 deletions dcpwr/keysight/e36xx/basechannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (ch *Channel) CurrentLimit() (float64, error) {
// Attribute Current Limit described in Section 4.2.1 of IVI-4.4: IviDCPwr
// Class Specification.
func (ch *Channel) SetCurrentLimit(limit float64) error {
return ivi.Set(ch.inst, "INST %s;:CURR %f\n", ch.name, limit)
return ch.inst.Command("INST %s;:CURR %f", ch.name, limit)
}

// CurrentLimitBehavior determines the behavior of the power supply when the
Expand Down Expand Up @@ -77,7 +77,7 @@ func (ch *Channel) SetCurrentLimitBehavior(behavior dcpwr.CurrentLimitBehavior)
// OutputEnabled is the getter for the read-write IviDCPwrBase Attribute Output
// Enabled described in Section 4.2.3 of IVI-4.4: IviDCPwr Class Specification.
func (ch *Channel) OutputEnabled() (bool, error) {
return query.Bool(ch.inst, "OUTP?\n")
return query.Bool(ch.inst, "OUTP?")
}

// SetOutputEnabled sets all three output channels to enabled or disabled.
Expand All @@ -87,9 +87,9 @@ func (ch *Channel) OutputEnabled() (bool, error) {
// Specification.
func (ch *Channel) SetOutputEnabled(v bool) error {
if v {
return ivi.Set(ch.inst, "OUTP ON\n")
return ch.inst.Command("OUTP ON")
}
return ivi.Set(ch.inst, "OUTP OFF\n")
return ch.inst.Command("OUTP OFF")
}

// DisableOutput is a convenience function for setting the Output Enabled
Expand Down Expand Up @@ -168,7 +168,7 @@ func (ch *Channel) VoltageLevel() (float64, error) {
// Voltage Level described in Section 4.2.6 of IVI-4.4: IviDCPwr Class
// Specification.
func (ch *Channel) SetVoltageLevel(amp float64) error {
return ivi.Set(ch.inst, "APPL %s, %f\n", ch.name, amp)
return ch.inst.Command("inst %s; volt %.2f", ch.name, amp)
}

// ConfigureCurrentLimit configures the current limit. It specifies the output
Expand Down Expand Up @@ -279,10 +279,13 @@ func (ch *Channel) MeasureCurrent() (float64, error) {
// is the voltage limit value and the second number 1.000000 is the current
// limit value for the specified output.
func (ch *Channel) readVoltageCurrent() (float64, float64, error) {
s, err := query.Stringf(ch.inst, "APPL? %s", ch)
s, err := query.Stringf(ch.inst, "appl? %s", ch.name)
if err != nil {
return 0.0, 0.0, err
}
// The E3631A returns the voltage and current inside double quotes, separated
// by a comma, so we need to strip those.
s = convert.StripDoubleQuotes(s)
floats, err := convert.StringToNFloats(s, ",", 2)
if err != nil {
return 0.0, 0.0, err
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/gotmc/ivi
go 1.21

require (
github.com/gotmc/convert v0.2.0
github.com/gotmc/query v0.5.0
github.com/gotmc/convert v0.4.0
github.com/gotmc/query v0.5.1
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github.com/gotmc/convert v0.2.0 h1:aWOTiy1PfaXoyPcqHyinGKkHgrdENTybUvrH7AOZLS0=
github.com/gotmc/convert v0.2.0/go.mod h1:ZuXbN0TaRi0AStPHR7iz2h2kgr1wlxYo2kTTNxwA1QU=
github.com/gotmc/query v0.5.0 h1:3du4felYwincLk1iFN26hkTv+yPajI3AxIwsEpdqRdc=
github.com/gotmc/query v0.5.0/go.mod h1:5Fe+Q3az2zfXXa4pdvQ95mgieY6Bf/XFEOyMtdKjukE=
github.com/gotmc/convert v0.4.0 h1:RI7J96V99HsQDGRMVOUdwczd7tDAk4FVttqOuLcBEwE=
github.com/gotmc/convert v0.4.0/go.mod h1:ClVdnU/ZcOFgUQWXgHexlLqE9/AFEeo5uZDf9kkAtyw=
github.com/gotmc/query v0.5.1 h1:bPa09woaMPDGwzvLHrPL89Vd2+hjbz7BNq8ccMdV0Ds=
github.com/gotmc/query v0.5.1/go.mod h1:5Fe+Q3az2zfXXa4pdvQ95mgieY6Bf/XFEOyMtdKjukE=
3 changes: 0 additions & 3 deletions inherent.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package ivi
import (
"errors"
"fmt"
"log"
"strings"
"time"

Expand Down Expand Up @@ -72,7 +71,6 @@ func (inherent *Inherent) InstrumentManufacturer() (string, error) {
// attribute Instrument Model described in Section 5.20 of IVI-3.2: Inherent
// Capabilities Specification.
func (inherent *Inherent) InstrumentModel() (string, error) {
log.Print("Executing InstrumentModel() IVI query")
return inherent.queryIdentification(modelID)
}

Expand All @@ -84,7 +82,6 @@ func (inherent *Inherent) InstrumentSerialNumber() (string, error) {

// Reset resets the instrument.
func (inherent *Inherent) Reset() error {
log.Println("Sending inherent Reset() command.")
err := inherent.inst.Command("*rst")
// Need to wait until the device resets.
// FIXME: The duration should be device dependent instead of hard coded.
Expand Down
2 changes: 1 addition & 1 deletion ivi.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ type Querier interface {
}

type Commander interface {
Command(format string, a ...interface{}) error
Command(format string, a ...any) error
}

0 comments on commit f6e483e

Please sign in to comment.