go-api-bindings: github.com/Tinkerforge/go-api-bindings/industrial_dual_0_20ma_bricklet Index | Files

package industrial_dual_0_20ma_bricklet

import "github.com/Tinkerforge/go-api-bindings/industrial_dual_0_20ma_bricklet"

Measures two DC currents between 0mA and 20mA (IEC 60381-1).

See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/IndustrialDual020mA_Bricklet_Go.html.

Index

Package Files

industrial_dual_0_20ma_bricklet.go

Constants

const DeviceDisplayName = "Industrial Dual 0-20mA Bricklet"
const DeviceIdentifier = 228

type Function Uses

type Function = uint8
const (
    FunctionGetCurrent                  Function = 1
    FunctionSetCurrentCallbackPeriod    Function = 2
    FunctionGetCurrentCallbackPeriod    Function = 3
    FunctionSetCurrentCallbackThreshold Function = 4
    FunctionGetCurrentCallbackThreshold Function = 5
    FunctionSetDebouncePeriod           Function = 6
    FunctionGetDebouncePeriod           Function = 7
    FunctionSetSampleRate               Function = 8
    FunctionGetSampleRate               Function = 9
    FunctionGetIdentity                 Function = 255
    FunctionCallbackCurrent             Function = 10
    FunctionCallbackCurrentReached      Function = 11
)

type IndustrialDual020mABricklet Uses

type IndustrialDual020mABricklet struct {
    // contains filtered or unexported fields
}

func New Uses

func New(uid string, ipcon *ipconnection.IPConnection) (IndustrialDual020mABricklet, error)

Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.

func (*IndustrialDual020mABricklet) DeregisterCurrentCallback Uses

func (device *IndustrialDual020mABricklet) DeregisterCurrentCallback(registrationId uint64)

Remove a registered Current callback.

func (*IndustrialDual020mABricklet) DeregisterCurrentReachedCallback Uses

func (device *IndustrialDual020mABricklet) DeregisterCurrentReachedCallback(registrationId uint64)

Remove a registered Current Reached callback.

func (*IndustrialDual020mABricklet) GetAPIVersion Uses

func (device *IndustrialDual020mABricklet) GetAPIVersion() [3]uint8

Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.

func (*IndustrialDual020mABricklet) GetCurrent Uses

func (device *IndustrialDual020mABricklet) GetCurrent(sensor uint8) (current int32, err error)

Returns the current of the specified sensor.

It is possible to detect if an IEC 60381-1 compatible sensor is connected and if it works properly.

If the returned current is below 4mA, there is likely no sensor connected or the sensor may be defect. If the returned current is over 20mA, there might be a short circuit or the sensor may be defect.

If you want to get the current periodically, it is recommended to use the RegisterCurrentCallback callback and set the period with SetCurrentCallbackPeriod.

func (*IndustrialDual020mABricklet) GetCurrentCallbackPeriod Uses

func (device *IndustrialDual020mABricklet) GetCurrentCallbackPeriod(sensor uint8) (period uint32, err error)

Returns the period as set by SetCurrentCallbackPeriod.

func (*IndustrialDual020mABricklet) GetCurrentCallbackThreshold Uses

func (device *IndustrialDual020mABricklet) GetCurrentCallbackThreshold(sensor uint8) (option ThresholdOption, min int32, max int32, err error)

Returns the threshold as set by SetCurrentCallbackThreshold.

Associated constants:

* ThresholdOptionOff
* ThresholdOptionOutside
* ThresholdOptionInside
* ThresholdOptionSmaller
* ThresholdOptionGreater

func (*IndustrialDual020mABricklet) GetDebouncePeriod Uses

func (device *IndustrialDual020mABricklet) GetDebouncePeriod() (debounce uint32, err error)

Returns the debounce period as set by SetDebouncePeriod.

func (*IndustrialDual020mABricklet) GetIdentity Uses

func (device *IndustrialDual020mABricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, firmwareVersion [3]uint8, deviceIdentifier uint16, err error)

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet connected to an `Isolator Bricklet <isolator_bricklet>` is always as position 'z'.

The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|

func (*IndustrialDual020mABricklet) GetResponseExpected Uses

func (device *IndustrialDual020mABricklet) GetResponseExpected(functionID Function) (bool, error)

Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.

For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by SetResponseExpected. For setter functions it is disabled by default and can be enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

See SetResponseExpected for the list of function ID constants available for this function.

func (*IndustrialDual020mABricklet) GetSampleRate Uses

func (device *IndustrialDual020mABricklet) GetSampleRate() (rate SampleRate, err error)

Returns the sample rate as set by SetSampleRate.

Associated constants:

* SampleRate240SPS
* SampleRate60SPS
* SampleRate15SPS
* SampleRate4SPS

func (*IndustrialDual020mABricklet) RegisterCurrentCallback Uses

func (device *IndustrialDual020mABricklet) RegisterCurrentCallback(fn func(uint8, int32)) uint64

This callback is triggered periodically with the period that is set by SetCurrentCallbackPeriod. The parameter is the current of the sensor.

The RegisterCurrentCallback callback is only triggered if the current has changed since the last triggering.

func (*IndustrialDual020mABricklet) RegisterCurrentReachedCallback Uses

func (device *IndustrialDual020mABricklet) RegisterCurrentReachedCallback(fn func(uint8, int32)) uint64

This callback is triggered when the threshold as set by SetCurrentCallbackThreshold is reached. The parameter is the current of the sensor.

If the threshold keeps being reached, the callback is triggered periodically with the period as set by SetDebouncePeriod.

func (*IndustrialDual020mABricklet) SetCurrentCallbackPeriod Uses

func (device *IndustrialDual020mABricklet) SetCurrentCallbackPeriod(sensor uint8, period uint32) (err error)

Sets the period with which the RegisterCurrentCallback callback is triggered periodically for the given sensor. A value of 0 turns the callback off.

The RegisterCurrentCallback callback is only triggered if the current has changed since the last triggering.

func (*IndustrialDual020mABricklet) SetCurrentCallbackThreshold Uses

func (device *IndustrialDual020mABricklet) SetCurrentCallbackThreshold(sensor uint8, option ThresholdOption, min int32, max int32) (err error)

Sets the thresholds for the RegisterCurrentReachedCallback callback for the given sensor.

The following options are possible:

Option| Description
--- | ---
'x'|    Callback is turned off
'o'|    Callback is triggered when the current is *outside* the min and max values
'i'|    Callback is triggered when the current is *inside* the min and max values
'<'|    Callback is triggered when the current is smaller than the min value (max is ignored)
'>'|    Callback is triggered when the current is greater than the min value (max is ignored)

Associated constants:

* ThresholdOptionOff
* ThresholdOptionOutside
* ThresholdOptionInside
* ThresholdOptionSmaller
* ThresholdOptionGreater

func (*IndustrialDual020mABricklet) SetDebouncePeriod Uses

func (device *IndustrialDual020mABricklet) SetDebouncePeriod(debounce uint32) (err error)

Sets the period with which the threshold callback

* RegisterCurrentReachedCallback

is triggered, if the threshold

* SetCurrentCallbackThreshold

keeps being reached.

func (*IndustrialDual020mABricklet) SetResponseExpected Uses

func (device *IndustrialDual020mABricklet) SetResponseExpected(functionID Function, responseExpected bool) error

Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

func (*IndustrialDual020mABricklet) SetResponseExpectedAll Uses

func (device *IndustrialDual020mABricklet) SetResponseExpectedAll(responseExpected bool)

Changes the response expected flag for all setter and callback configuration functions of this device at once.

func (*IndustrialDual020mABricklet) SetSampleRate Uses

func (device *IndustrialDual020mABricklet) SetSampleRate(rate SampleRate) (err error)

Sets the sample rate to either 240, 60, 15 or 4 samples per second. The resolution for the rates is 12, 14, 16 and 18 bit respectively.

Value| Description
--- | ---
0|    240 samples per second| 12 bit resolution
1|    60 samples per second| 14 bit resolution
2|    15 samples per second| 16 bit resolution
3|    4 samples per second| 18 bit resolution

Associated constants:

* SampleRate240SPS
* SampleRate60SPS
* SampleRate15SPS
* SampleRate4SPS

type SampleRate Uses

type SampleRate = uint8
const (
    SampleRate240SPS SampleRate = 0
    SampleRate60SPS  SampleRate = 1
    SampleRate15SPS  SampleRate = 2
    SampleRate4SPS   SampleRate = 3
)

type ThresholdOption Uses

type ThresholdOption = rune
const (
    ThresholdOptionOff     ThresholdOption = 'x'
    ThresholdOptionOutside ThresholdOption = 'o'
    ThresholdOptionInside  ThresholdOption = 'i'
    ThresholdOptionSmaller ThresholdOption = '<'
    ThresholdOptionGreater ThresholdOption = '>'
)

Package industrial_dual_0_20ma_bricklet imports 5 packages (graph). Updated 2020-08-03. Refresh now. Tools for package owners.