Documentation ¶
Overview ¶
Measures two DC voltages between -35V and +35V with 24bit resolution each.
See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/IndustrialDualAnalogIn_Bricklet_Go.html.
Index ¶
- Constants
- type Function
- type IndustrialDualAnalogInBricklet
- func (device *IndustrialDualAnalogInBricklet) DeregisterVoltageCallback(registrationId uint64)
- func (device *IndustrialDualAnalogInBricklet) DeregisterVoltageReachedCallback(registrationId uint64)
- func (device *IndustrialDualAnalogInBricklet) GetADCValues() (value [2]int32, err error)
- func (device *IndustrialDualAnalogInBricklet) GetAPIVersion() [3]uint8
- func (device *IndustrialDualAnalogInBricklet) GetCalibration() (offset [2]int32, gain [2]int32, err error)
- func (device *IndustrialDualAnalogInBricklet) GetDebouncePeriod() (debounce uint32, err error)
- func (device *IndustrialDualAnalogInBricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, ...)
- func (device *IndustrialDualAnalogInBricklet) GetResponseExpected(functionID Function) (bool, error)
- func (device *IndustrialDualAnalogInBricklet) GetSampleRate() (rate SampleRate, err error)
- func (device *IndustrialDualAnalogInBricklet) GetVoltage(channel uint8) (voltage int32, err error)
- func (device *IndustrialDualAnalogInBricklet) GetVoltageCallbackPeriod(channel uint8) (period uint32, err error)
- func (device *IndustrialDualAnalogInBricklet) GetVoltageCallbackThreshold(channel uint8) (option ThresholdOption, min int32, max int32, err error)
- func (device *IndustrialDualAnalogInBricklet) RegisterVoltageCallback(fn func(uint8, int32)) uint64
- func (device *IndustrialDualAnalogInBricklet) RegisterVoltageReachedCallback(fn func(uint8, int32)) uint64
- func (device *IndustrialDualAnalogInBricklet) SetCalibration(offset [2]int32, gain [2]int32) (err error)
- func (device *IndustrialDualAnalogInBricklet) SetDebouncePeriod(debounce uint32) (err error)
- func (device *IndustrialDualAnalogInBricklet) SetResponseExpected(functionID Function, responseExpected bool) error
- func (device *IndustrialDualAnalogInBricklet) SetResponseExpectedAll(responseExpected bool)
- func (device *IndustrialDualAnalogInBricklet) SetSampleRate(rate SampleRate) (err error)
- func (device *IndustrialDualAnalogInBricklet) SetVoltageCallbackPeriod(channel uint8, period uint32) (err error)
- func (device *IndustrialDualAnalogInBricklet) SetVoltageCallbackThreshold(channel uint8, option ThresholdOption, min int32, max int32) (err error)
- type SampleRate
- type ThresholdOption
Constants ¶
const DeviceDisplayName = "Industrial Dual Analog In Bricklet"
const DeviceIdentifier = 249
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Function ¶
type Function = uint8
const ( FunctionGetVoltage Function = 1 FunctionSetVoltageCallbackPeriod Function = 2 FunctionGetVoltageCallbackPeriod Function = 3 FunctionSetVoltageCallbackThreshold Function = 4 FunctionGetVoltageCallbackThreshold Function = 5 FunctionSetDebouncePeriod Function = 6 FunctionGetDebouncePeriod Function = 7 FunctionSetSampleRate Function = 8 FunctionGetSampleRate Function = 9 FunctionSetCalibration Function = 10 FunctionGetCalibration Function = 11 FunctionGetADCValues Function = 12 FunctionGetIdentity Function = 255 FunctionCallbackVoltage Function = 13 FunctionCallbackVoltageReached Function = 14 )
type IndustrialDualAnalogInBricklet ¶
type IndustrialDualAnalogInBricklet struct {
// contains filtered or unexported fields
}
func New ¶
func New(uid string, ipcon *ipconnection.IPConnection) (IndustrialDualAnalogInBricklet, error)
Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.
func (*IndustrialDualAnalogInBricklet) DeregisterVoltageCallback ¶
func (device *IndustrialDualAnalogInBricklet) DeregisterVoltageCallback(registrationId uint64)
Remove a registered Voltage callback.
func (*IndustrialDualAnalogInBricklet) DeregisterVoltageReachedCallback ¶
func (device *IndustrialDualAnalogInBricklet) DeregisterVoltageReachedCallback(registrationId uint64)
Remove a registered Voltage Reached callback.
func (*IndustrialDualAnalogInBricklet) GetADCValues ¶
func (device *IndustrialDualAnalogInBricklet) GetADCValues() (value [2]int32, err error)
Returns the ADC values as given by the MCP3911 IC. This function is needed for proper calibration, see SetCalibration.
func (*IndustrialDualAnalogInBricklet) GetAPIVersion ¶
func (device *IndustrialDualAnalogInBricklet) 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 (*IndustrialDualAnalogInBricklet) GetCalibration ¶
func (device *IndustrialDualAnalogInBricklet) GetCalibration() (offset [2]int32, gain [2]int32, err error)
Returns the calibration as set by SetCalibration.
func (*IndustrialDualAnalogInBricklet) GetDebouncePeriod ¶
func (device *IndustrialDualAnalogInBricklet) GetDebouncePeriod() (debounce uint32, err error)
Returns the debounce period as set by SetDebouncePeriod.
func (*IndustrialDualAnalogInBricklet) GetIdentity ¶
func (device *IndustrialDualAnalogInBricklet) 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). A Bricklet connected to an `Isolator Bricklet <isolator_bricklet>` is always at position 'z'.
The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|
func (*IndustrialDualAnalogInBricklet) GetResponseExpected ¶
func (device *IndustrialDualAnalogInBricklet) 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 (*IndustrialDualAnalogInBricklet) GetSampleRate ¶
func (device *IndustrialDualAnalogInBricklet) GetSampleRate() (rate SampleRate, err error)
Returns the sample rate as set by SetSampleRate.
Associated constants:
- SampleRate976SPS
- SampleRate488SPS
- SampleRate244SPS
- SampleRate122SPS
- SampleRate61SPS
- SampleRate4SPS
- SampleRate2SPS
- SampleRate1SPS
func (*IndustrialDualAnalogInBricklet) GetVoltage ¶
func (device *IndustrialDualAnalogInBricklet) GetVoltage(channel uint8) (voltage int32, err error)
Returns the voltage for the given channel.
If you want to get the voltage periodically, it is recommended to use the RegisterVoltageCallback callback and set the period with SetVoltageCallbackPeriod.
func (*IndustrialDualAnalogInBricklet) GetVoltageCallbackPeriod ¶
func (device *IndustrialDualAnalogInBricklet) GetVoltageCallbackPeriod(channel uint8) (period uint32, err error)
Returns the period as set by SetVoltageCallbackPeriod.
func (*IndustrialDualAnalogInBricklet) GetVoltageCallbackThreshold ¶
func (device *IndustrialDualAnalogInBricklet) GetVoltageCallbackThreshold(channel uint8) (option ThresholdOption, min int32, max int32, err error)
Returns the threshold as set by SetVoltageCallbackThreshold.
Associated constants:
- ThresholdOptionOff
- ThresholdOptionOutside
- ThresholdOptionInside
- ThresholdOptionSmaller
- ThresholdOptionGreater
func (*IndustrialDualAnalogInBricklet) RegisterVoltageCallback ¶
func (device *IndustrialDualAnalogInBricklet) RegisterVoltageCallback(fn func(uint8, int32)) uint64
This callback is triggered periodically with the period that is set by SetVoltageCallbackPeriod. The parameter is the voltage of the channel.
The RegisterVoltageCallback callback is only triggered if the voltage has changed since the last triggering.
func (*IndustrialDualAnalogInBricklet) RegisterVoltageReachedCallback ¶
func (device *IndustrialDualAnalogInBricklet) RegisterVoltageReachedCallback(fn func(uint8, int32)) uint64
This callback is triggered when the threshold as set by SetVoltageCallbackThreshold is reached. The parameter is the voltage of the channel.
If the threshold keeps being reached, the callback is triggered periodically with the period as set by SetDebouncePeriod.
func (*IndustrialDualAnalogInBricklet) SetCalibration ¶
func (device *IndustrialDualAnalogInBricklet) SetCalibration(offset [2]int32, gain [2]int32) (err error)
Sets offset and gain of MCP3911 internal calibration registers.
See MCP3911 datasheet 7.7 and 7.8. The Industrial Dual Analog In Bricklet is already factory calibrated by Tinkerforge. It should not be necessary for you to use this function
func (*IndustrialDualAnalogInBricklet) SetDebouncePeriod ¶
func (device *IndustrialDualAnalogInBricklet) SetDebouncePeriod(debounce uint32) (err error)
Sets the period with which the threshold callback
* RegisterVoltageReachedCallback
is triggered, if the threshold
* SetVoltageCallbackThreshold
keeps being reached.
func (*IndustrialDualAnalogInBricklet) SetResponseExpected ¶
func (device *IndustrialDualAnalogInBricklet) 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 (*IndustrialDualAnalogInBricklet) SetResponseExpectedAll ¶
func (device *IndustrialDualAnalogInBricklet) SetResponseExpectedAll(responseExpected bool)
Changes the response expected flag for all setter and callback configuration functions of this device at once.
func (*IndustrialDualAnalogInBricklet) SetSampleRate ¶
func (device *IndustrialDualAnalogInBricklet) SetSampleRate(rate SampleRate) (err error)
Sets the sample rate. The sample rate can be between 1 sample per second and 976 samples per second. Decreasing the sample rate will also decrease the noise on the data.
Associated constants:
- SampleRate976SPS
- SampleRate488SPS
- SampleRate244SPS
- SampleRate122SPS
- SampleRate61SPS
- SampleRate4SPS
- SampleRate2SPS
- SampleRate1SPS
func (*IndustrialDualAnalogInBricklet) SetVoltageCallbackPeriod ¶
func (device *IndustrialDualAnalogInBricklet) SetVoltageCallbackPeriod(channel uint8, period uint32) (err error)
Sets the period with which the RegisterVoltageCallback callback is triggered periodically for the given channel. A value of 0 turns the callback off.
The RegisterVoltageCallback callback is only triggered if the voltage has changed since the last triggering.
func (*IndustrialDualAnalogInBricklet) SetVoltageCallbackThreshold ¶
func (device *IndustrialDualAnalogInBricklet) SetVoltageCallbackThreshold(channel uint8, option ThresholdOption, min int32, max int32) (err error)
Sets the thresholds for the RegisterVoltageReachedCallback callback for the given channel.
The following options are possible:
Option| Description --- | --- 'x'| Callback is turned off 'o'| Callback is triggered when the voltage is *outside* the min and max values 'i'| Callback is triggered when the voltage is *inside* the min and max values '<'| Callback is triggered when the voltage is smaller than the min value (max is ignored) '>'| Callback is triggered when the voltage is greater than the min value (max is ignored)
Associated constants:
- ThresholdOptionOff
- ThresholdOptionOutside
- ThresholdOptionInside
- ThresholdOptionSmaller
- ThresholdOptionGreater
type SampleRate ¶
type SampleRate = uint8
const ( SampleRate976SPS SampleRate = 0 SampleRate488SPS SampleRate = 1 SampleRate244SPS SampleRate = 2 SampleRate122SPS SampleRate = 3 SampleRate61SPS SampleRate = 4 SampleRate4SPS SampleRate = 5 SampleRate2SPS SampleRate = 6 SampleRate1SPS SampleRate = 7 )
type ThresholdOption ¶
type ThresholdOption = rune
const ( ThresholdOptionOff ThresholdOption = 'x' ThresholdOptionOutside ThresholdOption = 'o' ThresholdOptionInside ThresholdOption = 'i' ThresholdOptionSmaller ThresholdOption = '<' ThresholdOptionGreater ThresholdOption = '>' )