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: | Object |
---|
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: | Error |
---|---|
› 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: | Index |
---|---|
› Default: | AnalogInput.Invalid |
› Signal: | indexChanged() |
› Attributes: | Writable |
mode¶
This property holds the mode of the input. This property has to be set to work properly.
› Type: | Mode |
---|---|
› Default: | AnalogInput.ModeInvalid |
› 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.
Signals¶
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 |
---|---|---|
AnalogInput.NoError |
0 |
No error occurred or was detected. |
AnalogInput.InvalidMode |
1 |
None or invalid mode set. |
AnalogInput.HardwareDriverNotAvailable |
2 |
No hardware driver available for the current platform. |
Index¶
This enumeration describes the supported analog input indexes.
Name | Value | Description |
---|---|---|
AnalogInput.Invalid |
0 |
No index assigned. |
AnalogInput.AIN1 |
1 |
The first analog input. |
AnalogInput.AIN2 |
2 |
The second analog input. |
AnalogInput.AIN3 |
3 |
The third analog input. |
AnalogInput.AIN4 |
4 |
The fourth analog input. |
Mode¶
This enumeration describes supported modes for an analog input interface.
Name | Value | Description |
---|---|---|
AnalogInput.ModeInvalid |
0 |
No mode assigned. |
AnalogInput.Mode5V |
1 |
Measure an input voltage in the range [0..5V] (only HUB-GM100). |
AnalogInput.Mode10V |
2 |
Measure an input voltage in the range [0..10V]. |
AnalogInput.Mode20V |
3 |
Measure an input voltage in the range [0..20V] (only HUB-GM100). |
AnalogInput.Mode20mA |
4 |
Measure an input current in the range [4..20mA]. |
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)
}
}