AnalogInput
Description
The AnalogInput object allows measuring voltages or currents. The underlying hardware works with a 12 bit ADC so measured values are always in the range [0..4095].
- › Inherits:
Overview
Properties
Methods
Signals
Enumerations
Properties
analogFault
This property holds the current state of the Analog Fault pin (HUB-GM200 only).
This property was introduced in InCore 2.1.
- › Type:
Boolean
- › Signal:
analogFaultChanged()
- › Attributes:
Readonly, Requires Polling
current
This property holds the current calculated from value if mode is set to AnalogInput.Mode20mA. Otherwise 0 will be returned. The current is be updated whenver the valueChanged() signal is emitted, so you have to poll value to read a valid current.
This property was introduced in InCore 2.2.
- › Type:
Double
- › Signal:
currentChanged()
- › Attributes:
Readonly
error
This property holds the most recently occurred error or AnalogInput.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.
- › Type:
- › Signal:
errorChanged()
- › Attributes:
Readonly
errorString
This property holds the current human readable error string corresponding to the current value in the error property. It may include additional information such as failure reasons or locations.
- › Type:
String
- › Signal:
errorStringChanged()
- › Attributes:
Readonly
index
This property holds the index of the input. This property has to be set to work properly.
- › Type:
- › Default:
- › Signal:
indexChanged()
- › Attributes:
Writable
mode
This property holds the mode of the input. This property has to be set to work properly.
- › Type:
- › Default:
- › Signal:
modeChanged()
- › Attributes:
Writable
value
This property holds the current value of the measured current or voltage in digits.
- › Type:
SignedInteger
- › Signal:
valueChanged()
- › Attributes:
Readonly, Requires Polling
voltage
This property holds the voltage calculated from value if mode is set to AnalogInput.Mode5V, AnalogInput.Mode10V or AnalogInput.Mode20V. Otherwise 0 will be returned. The voltage is updated whenever the valueChanged() signal is emitted, so you have to poll value to read a valid voltage.
This property was introduced in InCore 2.2.
- › Type:
Double
- › Signal:
voltageChanged()
- › Attributes:
Readonly
Methods
pollAnalogFault()
This method polls the analogFault property. It is called automatically when using a Polling property modifier on this property and usually does not have to be called manually.
pollValue()
This method polls the value property. It is called automatically when using a Polling property modifier on this property and usually does not have to be called manually.
Signals
errorOccurred()
This signal is emitted whenever an error has occurred, regardless of whether the error property has changed or not. In contrast to the change notification signal of the error property this signal is also emitted several times if a certain error occurs several times in succession.
Enumerations
Error
This enumeration describes all errors which can occur in AnalogInput objects. The most recently occurred error is stored in the error property.
Name |
Value |
Description |
|---|---|---|
|
|
No error occurred or was detected. |
|
|
None or invalid mode set. |
|
|
No hardware driver available for this device. |
Index
This enumeration describes the supported analog input indexes.
Name |
Value |
Description |
|---|---|---|
|
|
No index assigned. |
|
|
The first analog input. |
|
|
The second analog input. |
|
|
The third analog input. |
|
|
The fourth analog input. |
Mode
This enumeration describes supported modes for an analog input interface.
Name |
Value |
Description |
|---|---|---|
|
|
No mode assigned. |
|
|
Measure an input voltage in the range [0..5V] (only HUB-GM100). |
|
|
Measure an input voltage in the range [0..10V]. |
|
|
Measure an input voltage in the range [0..20V] (only HUB-GM100). |
|
|
Measure an input current in the range [4..20mA]. |
|
|
Measure an input current in the range [0..24V]. |
Example
import InCore.Foundation 2.5
import InCore.IO 2.5
Application {
AnalogInput {
index: AnalogInput.AIN1
mode: AnalogInput.Mode10V
Polling on value { interval: 100 }
onValueChanged: console.log("Current ADC value is", value)
onVoltageChanged: console.log("Current voltage is", voltage)
}
}