..
 #############################################################
 # 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       #
 #############################################################


:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-modbus">Software</a> / Modbus - Hall Effect Bricklet

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

.. _hall_effect_bricklet_modbus:

Modbus - Hall Effect Bricklet
=============================

This is the description of the :ref:`Modbus protocol <llproto_modbus>` for the :ref:`Hall Effect Bricklet <hall_effect_bricklet>`. General information and technical
specifications for the Hall Effect Bricklet are summarized in its :ref:`hardware description
<hall_effect_bricklet_description>`.

.. _hall_effect_bricklet_modbus_api:

API
---

A general description of the Modbus protocol structure can be found
:ref:`here <llproto_modbus>`.




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



.. modbus:function:: BrickletHallEffect.get_value

 :functionid: 1
 :emptyrequest: empty payload

 :response value: bool

 Returns *true* if a magnetic field of 35 Gauss (3.5mT) or greater is detected.
 
.. modbus:function:: BrickletHallEffect.get_edge_count

 :functionid: 2
 :request reset_counter: bool

 :response count: uint32

 Returns the current value of the edge counter. You can configure
 edge type (rising, falling, both) that is counted with
 :modbus:func:`set_edge_count_config <BrickletHallEffect.set_edge_count_config>`.
 
 If you set the reset counter to *true*, the count is set back to 0
 directly after it is read.
 


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

.. modbus:function:: BrickletHallEffect.set_edge_count_config

 :functionid: 3
 :request edge_type: uint8
 :request debounce: uint8

 :noresponse: no response

 The edge type parameter configures if rising edges, falling edges or 
 both are counted. Possible edge types are:
 
 * 0 = rising (default)
 * 1 = falling
 * 2 = both
 
 A magnetic field of 35 Gauss (3.5mT) or greater causes a falling edge and a
 magnetic field of 25 Gauss (2.5mT) or smaller causes a rising edge.
 
 If a magnet comes near the Bricklet the signal goes low (falling edge), if
 a magnet is removed from the vicinity the signal goes high (rising edge).
 
 The debounce time is given in ms.
 
 Configuring an edge counter resets its value to 0.
 
 If you don't know what any of this means, just leave it at default. The
 default configuration is very likely OK for you.
 
 Default values: 0 (edge type) and 100ms (debounce time)
 
.. modbus:function:: BrickletHallEffect.get_edge_count_config

 :functionid: 4
 :emptyrequest: empty payload

 :response edge_type: uint8
 :response debounce: uint8

 Returns the edge type and debounce time as set by :modbus:func:`set_edge_count_config <BrickletHallEffect.set_edge_count_config>`.
 
.. modbus:function:: BrickletHallEffect.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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



.. modbus:function:: BrickletHallEffect.set_edge_interrupt

 :functionid: 5
 :request edges: uint32

 :noresponse: no response

 Sets the number of edges until an interrupt is invoked.
 
 If *edges* is set to n, an interrupt is invoked for every n-th detected edge.
 
 If *edges* is set to 0, the interrupt is disabled.
 
 Default value is 0.
 
.. modbus:function:: BrickletHallEffect.get_edge_interrupt

 :functionid: 6
 :emptyrequest: empty payload

 :response edges: uint32

 Returns the edges as set by :modbus:func:`set_edge_interrupt <BrickletHallEffect.set_edge_interrupt>`.
 
.. modbus:function:: BrickletHallEffect.set_edge_count_callback_period

 :functionid: 7
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :modbus:func:`CALLBACK_EDGE_COUNT <BrickletHallEffect.CALLBACK_EDGE_COUNT>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :modbus:func:`CALLBACK_EDGE_COUNT <BrickletHallEffect.CALLBACK_EDGE_COUNT>` is only triggered if the edge count has changed since the
 last triggering.
 
 The default value is 0.
 
.. modbus:function:: BrickletHallEffect.get_edge_count_callback_period

 :functionid: 8
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :modbus:func:`set_edge_count_callback_period <BrickletHallEffect.set_edge_count_callback_period>`.
 


.. _hall_effect_bricklet_modbus_callbacks:

Callbacks
^^^^^^^^^

.. modbus:function:: BrickletHallEffect.CALLBACK_EDGE_COUNT

 :functionid: 10

 :response count: uint32
 :response value: bool


 This callback is triggered periodically with the period that is set by
 :modbus:func:`set_edge_count_callback_period <BrickletHallEffect.set_edge_count_callback_period>`. The response values are the
 current count and the current value (see :modbus:func:`get_value <BrickletHallEffect.get_value>` and :modbus:func:`get_edge_count <BrickletHallEffect.get_edge_count>`).
 
 :modbus:func:`CALLBACK_EDGE_COUNT <BrickletHallEffect.CALLBACK_EDGE_COUNT>` is only triggered if the count or value changed since the
 last triggering.
 


