..
 #############################################################
 # This file was automatically generated on 2015-05-08.      #
 #                                                           #
 # If you have a bugfix for this file and want to commit it, #
 # please fix the bug in the generator. You can find a link  #
 # to the generators git repository on tinkerforge.com       #
 #############################################################

:orphan:
:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-tcpip">Software</a> / TCP/IP - Industrial Dual Analog In Bricklet

.. |device_identifier_constant| unicode:: 0xA0
   :trim:

.. _industrial_dual_analog_in_bricklet_tcpip:

TCP/IP - Industrial Dual Analog In Bricklet
===========================================

.. note::
 This Bricklet is currently in the prototype stage and the software/hardware
 as well as the documentation is in an incomplete state.


This is the description of the :ref:`TCP/IP protocol <llproto_tcpip>` for the :ref:`Industrial Dual Analog In Bricklet <industrial_dual_analog_in_bricklet>`. General information and technical
specifications for the Industrial Dual Analog In Bricklet are summarized in its :ref:`hardware description
<industrial_dual_analog_in_bricklet_description>`.

.. _industrial_dual_analog_in_bricklet_tcpip_api:

API
---

A general description of the TCP/IP protocol structure can be found
:ref:`here <llproto_tcpip>`.


The Bricklet has two input channel. Functions that are related
directly to a channel have a ``channel`` parameter to specify one of the two
channels. Valid values for the ``channel`` parameter are 0 and 1.



Basic Functions
^^^^^^^^^^^^^^^



.. tcpip:function:: BrickletIndustrialDualAnalogIn.get_voltage

 :functionid: 1
 :request channel: uint8

 :response voltage: int32

 Returns the voltage for the given channel in mV.
 
 If you want to get the voltage periodically, it is recommended to use the
 callback :tcpip:func:`CALLBACK_VOLTAGE <BrickletIndustrialDualAnalogIn.CALLBACK_VOLTAGE>` and set the period with 
 :tcpip:func:`set_voltage_callback_period <BrickletIndustrialDualAnalogIn.set_voltage_callback_period>`.
 


Advanced Functions
^^^^^^^^^^^^^^^^^^

.. tcpip:function:: BrickletIndustrialDualAnalogIn.set_sample_rate

 :functionid: 8
 :request rate: uint8

 :noresponse: no response

 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.
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.get_sample_rate

 :functionid: 9
 :emptyrequest: empty payload

 :response rate: uint8

 Returns the sample rate as set by :tcpip:func:`set_sample_rate <BrickletIndustrialDualAnalogIn.set_sample_rate>`.
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.set_calibration

 :functionid: 10
 :request offset: int32[2]
 :request gain: int32[2]

 :noresponse: no response

 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
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.get_calibration

 :functionid: 11
 :emptyrequest: empty payload

 :response offset: int32[2]
 :response gain: int32[2]

 Returns the calibration as set by :tcpip:func:`set_calibration <BrickletIndustrialDualAnalogIn.set_calibration>`.
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.get_adc_values

 :functionid: 12
 :emptyrequest: empty payload

 :response value: int32[2]

 Returns the ADC values as given by the MCP3911 IC. This function
 is needed for proper calibration, see :tcpip:func:`set_calibration <BrickletIndustrialDualAnalogIn.set_calibration>`.
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.get_identity

 :functionid: 255
 :emptyrequest: empty payload

 :response uid: char[8]
 :response connected_uid: char[8]
 :response position: char
 :response hardware_version: uint8[3]
 :response firmware_version: uint8[3]
 :response device_identifier: uint16

 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' or 'd'.
 
 The device identifier numbers can be found :ref:`here <device_identifier>`.
 |device_identifier_constant|
 


Callback Configuration Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



.. tcpip:function:: BrickletIndustrialDualAnalogIn.set_voltage_callback_period

 :functionid: 2
 :request channel: uint8
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_VOLTAGE <BrickletIndustrialDualAnalogIn.CALLBACK_VOLTAGE>` callback is triggered
 periodically for the given channel. A value of 0 turns the callback off.
 
 :tcpip:func:`CALLBACK_VOLTAGE <BrickletIndustrialDualAnalogIn.CALLBACK_VOLTAGE>` is only triggered if the voltage has changed since the
 last triggering.
 
 The default value is 0.
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.get_voltage_callback_period

 :functionid: 3
 :request channel: uint8

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_voltage_callback_period <BrickletIndustrialDualAnalogIn.set_voltage_callback_period>`.
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.set_voltage_callback_threshold

 :functionid: 4
 :request channel: uint8
 :request option: char
 :request min: int32
 :request max: int32

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_VOLTAGE_REACHED <BrickletIndustrialDualAnalogIn.CALLBACK_VOLTAGE_REACHED>` callback for the given
 channel.
 
 The following options are possible:
 
 .. csv-table::
  :header: "Option", "Description"
  :widths: 10, 100
 
  "'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)"
 
 The default value is ('x', 0, 0).
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.get_voltage_callback_threshold

 :functionid: 5
 :request channel: uint8

 :response option: char
 :response min: int32
 :response max: int32

 Returns the threshold as set by :tcpip:func:`set_voltage_callback_threshold <BrickletIndustrialDualAnalogIn.set_voltage_callback_threshold>`.
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.set_debounce_period

 :functionid: 6
 :request debounce: uint32

 :noresponse: no response

 Sets the period in ms with which the threshold callback
 
 * :tcpip:func:`CALLBACK_VOLTAGE_REACHED <BrickletIndustrialDualAnalogIn.CALLBACK_VOLTAGE_REACHED>`
 
 is triggered, if the threshold
 
 * :tcpip:func:`set_voltage_callback_threshold <BrickletIndustrialDualAnalogIn.set_voltage_callback_threshold>`
 
 keeps being reached.
 
 The default value is 100.
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.get_debounce_period

 :functionid: 7
 :emptyrequest: empty payload

 :response debounce: uint32

 Returns the debounce period as set by :tcpip:func:`set_debounce_period <BrickletIndustrialDualAnalogIn.set_debounce_period>`.
 


.. _industrial_dual_analog_in_bricklet_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickletIndustrialDualAnalogIn.CALLBACK_VOLTAGE

 :functionid: 13

 :response channel: uint8
 :response voltage: int32


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_voltage_callback_period <BrickletIndustrialDualAnalogIn.set_voltage_callback_period>`. The response value is the voltage of the
 channel.
 
 :tcpip:func:`CALLBACK_VOLTAGE <BrickletIndustrialDualAnalogIn.CALLBACK_VOLTAGE>` is only triggered if the voltage has changed since the
 last triggering.
 
.. tcpip:function:: BrickletIndustrialDualAnalogIn.CALLBACK_VOLTAGE_REACHED

 :functionid: 14

 :response channel: uint8
 :response voltage: int32


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_voltage_callback_threshold <BrickletIndustrialDualAnalogIn.set_voltage_callback_threshold>` is reached.
 The response value is the voltage of the channel.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :tcpip:func:`set_debounce_period <BrickletIndustrialDualAnalogIn.set_debounce_period>`.
 


