.. _io-can: CAN Communication ================= You can find the command set at :ref:`io-command-set`. Addresses --------- The base address to receive messages is set to ``0x100`` by default. The addresses used by the IOBoard are calculated from the base address by adding the following offsets. ======================= ======= Offset to base address Message ======================= ======= ``+0`` Receive commands ``+1`` Answer to ``CMD_IOBOARD_CONNECT`` ``+2`` Answer to ``CMD_IOBOARD_GETDIGIN`` ``+3`` Answer to ``CMD_IOBOARD_GETANALOGIN`` ======================= ======= Commands -------- In the following, the CAN IDs are given as an offset to the base address, so ``+3`` means base address plus 3. CMD_IOBOARD_CONNECT ******************* Use this command to test the connection to the IOBoard. Command ID: ``+0`` =============== = = = = = = = ``CMD_CONNECT`` 0 0 0 0 0 0 0 =============== = = = = = = = Answer ID: ``+1`` =============== = = = = = = = ``CMD_CONNECT`` 1 2 3 4 5 6 7 =============== = = = = = = = CMD_IOBOARD_GETDIGIN ******************** The command requests data from all digital inputs. Command ID: ``+0`` ======================== = = = = = = = ``CMD_IOBOARD_GETDIGIN`` 0 0 0 0 0 0 0 ======================== = = = = = = = Answer ID: ``+2`` ======================== ========= ======== = = = = = ``CMD_IOBOARD_GETDIGIN`` Bits 8-15 Bits 0-7 0 0 0 0 0 ======================== ========= ======== = = = = = Note that for electrical reasons the digital inputs are flipped: A value of ``1`` means that the respective input is low, a value of ``0`` means it is high. CMD_IOBOARD_SETDIGOUT ********************* The command sets all digital outputs. The outputs are organized as follows: ====== ======================= Port D 8 x optocoupler outputs Port G 4 x optocoupler outputs Port B 4 x relay outputs ====== ======================= Command ID: ``+0`` ========================= = ====== ==================================== = = = = ``CMD_IOBOARD_SETDIGOUT`` 0 Port D Port G (Bits 4-7), Port B (Bits 0-3) 0 0 0 0 ========================= = ====== ==================================== = = = = Answer No answer. CMD_IOBOARD_GETANALOGIN *********************** The command requests data from analogue inputs. Command ID: ``+0`` =========================== = = = = = = = ``CMD_IOBOARD_GETANALOGIN`` 0 0 0 0 0 0 0 =========================== = = = = = = = Answer ID: ``+3`` =========================== ========== ========== ========== ========== ========= = = ``CMD_IOBOARD_GETANALOGIN`` low bits 1 low bits 2 low bits 3 low bits 4 high bits 0 0 =========================== ========== ========== ========== ========== ========= = = The `high bits` byte contains the high two bits for each channel, in ascending order (Bits 0-1 for channel 1 and so on). CMD_IOBOARD_GETALLDATA ********************** The command requests data from both the digital and the analog inputs. It has the same effect as requesting the digital and analog inputs separately. Command ID: ``+0`` ========================== = = = = = = = ``CMD_IOBOARD_GETALLDATA`` 0 0 0 0 0 0 0 ========================== = = = = = = = Answer The answer consists of two CAN frames that are identical to the answer frames to the commands ``CMD_IOBOARD_GETDIGIN`` and ``CMD_IOBOARD_GETANALOGIN``.