General description

Communication protocol documentation for device IOFireBug with Firmware ver.:

Ver. 1.x

Communication protocol is binary (no text) with 8 data bits, 1 stop bit, without parity.

Communication is based on request – response principle. Master device (PC for example) sends a command and the slave device (IOFireBug Engine) will send a response. If the slave device didn’t understand the command or the command is invalid, there will not be any response.

 

USB interface communication:

IOFireBug Engine can communicate with a PC by USB interface. Engine is equipped with an FTDI USB to Serial converter. After connection with a PC there will be FTDI driver installed and a new COM port will be created.

If operating system didn’t install the driver automatically, you can download it at: http://www.ftdichip.com/Drivers/VCP.htm

 

RS485 / 422 interface communication:

IOFireBug Engine is equipped by galvanically isolated RS485 or RS422 bus (mode of bus can be configured by a jumper). In case of use RS485 you have to avoid periodic or on-change data sending by the Engine unit. In RS485 mode is the bus only HALF-DUPLEX. If possible, we recommend to use RS-422 always, which is FULL-DUPLEX.

IOFireBug Engine units can be interconnected by the serial bus. First unit can be connected to a PC by USB port and next units are interconnected by RS-485 / RS-422 interface. Each unit must have unique identification by the address set on DIP switch on the board.

General format of communication message:

Byte Name Meaning Value
0 PRE Starting characters 0x2A
1 PRE
2 LEN_HI Message length 2B 0x0007 to 0xFFFF
3 LEN_LO
4 ADDR Unit address 0x01 to 0x0E
5 SIG Message number 0x00 to 0xFF
6 INSTR Code of instruction See code list
7 ACK Confirmation See code list
8 DATAn Message data
8+n CRC_HI CRC16 – 2B 0x0000 to 0xFFFF
9+n CRC_LO
10+n CR Ending character 0x0D

LEN – message length from ADDR (including) until the end of message.

ADDR – unit address length is 4bits, which corresponds the range from 0x01 to 0x0E. Address 0x0F is reserved for broadcast. When devices have broadcast address you can send a command to all of them by one message. Address 0x00 is invalid, so if device has this address, will not respond on any incoming message.

SIG – this byte is used for message numbering. Master device set any value to this byte and slave will respond with the same number of message. Two following messages should have different message number (SIG).

INSTR – code of instruction, see the following table for details.

Value Name Meaning
Command for device identification
0xF0 INSTR_GET_DEV_NAME Request for device name
0xF1 INSTR_GET_FW_VER Request for FW version
0xF2 INSTR_GET_DEV_ID Request for ID of device
0xF3 INSTR_GET_SERIAL Request for serial number of device
Binary inputs commands
0xA0 INSTR_GET_INPUTS Request for state of binary inputs
0xA1 INSTR_GET_INPUTS_CNT Request for state of binary inputs counters
0xA2 INSTR_GET_INPUTS_CNT_RM Request for state of binary inputs counters including reset
0xA3 INSTR_SET_INPUTS_FNC Set function for binary inputs
0xA4 INSTR_GET_ROTARY_CNT Request for state of rotary encoders counters
0xA5 INSTR_GET_ROTARY_CNT_RM Request for state of rotary encoders counters including reset
Binary outputs commands
0xB0 INSTR_SET_OUTPUTS Binary outputs setting
0xB1 INSTR_SET_OUTPUTS_PWM Binary outputs PWM setting
0xB2 INSTR_GET_OUTPUTS Request for state of binary outputs
0xB3 INSTR_GET_OUTPUTS_PWM Request for state of PWM outputs
Analog inputs commands
0xC0 INSTR_GET_ANALOG Dotaz na stav analogových vstupů
0xC1 INSTR_SET_ANALOG_FNC Nastavení funkce analogových vstupů
Configuration commands
0xE0 INSTR_STORE_CFG Stores current configuration to a EEPROM
0xE1 INSTR_SET_CFG_ADC AD Converters configuration
0xE2 INSTR_SET_CFG_PWM1234 PWM outputs configuration for 1,2,3,4
0xE3 INSTR_SET_CFG_PWM56 PWM outputs configuration for 5,6
0xE4 INSTR_SET_CFG_PWM78 PWM outputs configuration for 7,8
0xE5 INSTR_SET_CFG_INPUTS Process binary inputs configuration
0xE6 INSTR_SET_CFG_FTDI Set baudrate for FTDI-USB converter
0xE7 INSTR_SET_CFG_RS4XX Set baudrate for RS485/422 interface
0xE8 INSTR_SET_CFG_EXP Expansion modules setting
0xE9 INSTR_SET_ADC_OFFSETS Starts offset calibration of analog inputs
0xEA INSTR_SET_OUTPUTS_DEFAULT Sets current digital output state as the default after unit starts
0xEE INSTR_RESET Invokes a restart of device, reading the last saved configuration from EEPROM
0xEF INSTR_CLEAR_EEPROM Clears the configuration memory (EEPROM)
Configuration states
0xD1 INSTR_GET_CFG_ADC AD converters configuration request
0xD2 INSTR_GET_CFG_PWM1234 PWM outputs 1,2,3,4 configuration request
0xD3 INSTR_GET_CFG_PWM56 PWM outputs 5,6 configuration request
0xD4 INSTR_GET_CFG_PWM78 PWM outputs 7,8 configuration request
0xD5 INSTR_GET_CFG_INPUTS Request to get a configuration of binary inputs process
0xD6 INSTR_GET_CFG_FTDI Request to get a FTDI – USB baudrate
0xD7 INSTR_GET_CFG_RS4XX Request to get a RS485/422 baudrate
0xD8 INSTR_GET_CFG_EXP Request to get expanding modules configuration

ACK – acknowledge byte

Value Name Meaning
0x00 ACK_OK Everything OK
0x01 ACK_ERR Another error
0x02 ACK_BAD_INSTR Unknown instruction
0x03 ACK_NODATA No data requested
0x04 ACK_DEV_ERR Device failure

CRC –CRC16 is calculated from all message bytes excluding the last byte CR. As an initial value is 0xFFFF used.

 

Request messages

Request messages are messages without data. These messages can be used by PC to get configuration parameters or device states (inputs etc.). IOFireBug Engine responses to these messages with according data values (as described below). These messages are identified by INSTR_GET_xxxxxx in the documentation.

Byte Name Meaning Value
0 PRE Starting characters 0x2A
1 PRE
2 LEN_HI Message length 2B 0x00
3 LEN_LO 0x07
4 ADDR Device address 0x01 to 0x0E
5 SIG Message number 0x00 to 0xFF
6 INSTR Code of instruction See code list
7 ACK 0x00
8 CRC_HI CRC16 – 2B 0x0000 to 0xFFFF
9 CRC_LO
10 CR Ending character 0x0D

 

Command messages

By these messages you can send some commands like save/delete internal EEPROM, unit reset etc. Unit will respond by acknowledgement to these messages.

Byte Name Meaning Value
0 PRE Starting characters 0x2A
1 PRE
2 LEN_HI Message length 2B 0x00
3 LEN_LO 0x07
4 ADDR Device address 0x01 to 0x0E
5 SIG Message number 0x00 to 0xFF
6 INSTR Code of instruction See code list
7 ACK 0x00
8 CRC_HI CRC16 – 2B 0x0000 to 0xFFFF
9 CRC_LO
10 CR Ending character 0x0D

 

Setting messages

By setting messages you can set configuration parameters, output states etc. These messages are identified by INSTR_SET_xxxxxx in the documentation. Response to these messages is an acknowledge message, which doesn’t contain any data.

Byte Name Meaning Value
0 PRE Starting characters 0x2A
1 PRE
2 LEN_HI Message length 2B Count of message bytes: 7 + count of data bytes
3 LEN_LO
4 ADDR Device address 0x01 to 0x0E
5 SIG Message number 0x00 to 0xFF
6 INSTR Code of instruction See code list
7 ACK 0x00
8 DATAn CRC16 – 2B 0xXX (see detail description of each message)
8+n CRC_HI 0x0000 to 0xFFFF
9+n CRC_LO Ending character
10+n CR 0x0D

 

Confirmation messages

Byte Name Meaning Value
0 PRE Starting characters 0x2A
1 PRE
2 LEN_HI Message length 2B 0x00
3 LEN_LO 0x07
4 ADDR Device address Same as in setting or command message.
5 SIG Message number Same as in setting or command message.
6 INSTR Code of instruction Same as in setting or command message.
7 ACK See code list
8 CRC_HI CRC16 – 2B 0x0000 to 0xFFFF
9 CRC_LO
10 CR Ending character 0x0D

 

Device identification messages

0xf0 – Reading of device name– response data structure

Byte of data Name Meaning
0 DEVICE_NAME Text in ASCII format, length of text depends on message length
N

Note.:

Device IOFireBug Engine returns the name: „PLC-ENGINE“

 

0xf1 – Reading of device FW version – response data structure

Byte of data Name Meaning
0 FW_MAJOR uint8 number
1 FW_MINOR uint8 number

Note.:

Device IOFireBug Engine returns FW version in the following format: FW_MAJOR.FW_MINOR, for example: 1.0

 

0xf2 – Reading of device ID – response data structure

Byte of data Name Meaning
0 DEVICE_ID Unique identifier of device – uint16 number
1

Note.:

Device IOFireBug Engine returns id 0x1003 (year 16 = 0x10, month 03 = 0x03)

 

0xf3 – Reading of device serial number – response data structure

Byte of data Name Meaning
0 DEVICE_SERIAL Unique serial number of device (11 bytes)
..
10

Note:

Device IOFireBug Engine returns 0x0E05

 

Binary inputs messages

0xa0 – Reading of binary inputs states– response data structure

Byte of data Name Meaning
0 INPUTS uint8 number, MSB is input 8, LSB is input 1. Log1 means input active
1 EXP_BIN_INPUTS_1 uint16 number, MSB is input 16, LSB is input 1. Log1 means input active.
2
3 EXP_BIN_INPUTS_2 uint16 number, MSB is input 16, LSB is input 1. Log1 means input active.
4
n

Note:

Number of binary inputs depends on usage of extension modules Wagon. If IOFireBug is used independently then one byte is returned (eight binary inputs). If we for example use one Wagon 16I, the messages will contain 3 Bytes of data.

 

0xa1 – Reading of binary inputs counters – response data structure

Byte of data Name Meaning
0 INPUT_CNT0 State of counter number 1, uint16 number

 

1
2 INPUT_CNT1 State of counter number 2, uint16 number

 

3
14 INPUT_CNT7 State of counter number 8, uint16 number

 

15
16 EXP_INPUT_CNT8-31 Format of each counter uint16
47

0xa2 – Reading of binary inputs counters + resetting– response data structure is same as command 0xa1.

Note:

Number of binary inputs counters depends on usage of extension modules Wagon. If IOFireBug is used independently then 16 bytes is returned (eight binary inputs). If we for example use one Wagon 16I, the messages will contain 48 Bytes of data.

 

0xa3 – Functions of binary inputs – structure of message data

Byte of data Name Meaning
0 INPUTS_FNC 0x00 – default value, no function

0xff – automatic sending of input state (message 0xa1) on input change

0x01 – 0xfe – periodical sending of input state (message 0xa0) in miliseconds [ms] (1ms to 254ms)

1 INPUT_COUNTERS_FNC 0x00 – default value, no function

0xff – automatic sending of input counters state (message 0xa1) on counter change

0x01 – 0xfe – periodical sending of counter state (message 0xa1) in miliseconds [ms] (1ms to 254ms)

2 ROTARY_COUNTERS_FNC 0x00 – default value, no function

0xff – automatic sending of rotary encoder counters state (message 0xa1) on counter change

0x01 – 0xfe – periodical sending of rotary encoder counter state (message 0xa1) in miliseconds [ms] (1ms to 254ms)

 

0xa4 – reading of rotary encoders counters state– structure of message data

Byte of data Name Meaning
0 ROT_CNT0 State of rotary encoder counter number 1, uint16 number
1
2 ROT_CNT1 State of rotary encoder counter number 2, uint16 number
3
6 ROT_CNT3 State of rotary encoder counter number 3, uint16 number
7
8 EXP_ROT_CNT4-11 Format of each counter uint16
23

Note:

Each rotary encoder uses two binary inputs. Rotary counter has two-byte size (16bit). Amount of data in the message depends on usage of extension modules Wagon. If IOFireBug Engine is used independently then 8 bytes is returned (4x encoder * 2 bytes). If we for example use one Wagon 16I, the messages will contain 24 Bytes of data (8bytes by Engine and 16 by Wagon).

 

0xa5 – reading of rotary encoders counters state + reset – structure of message data is same as command 0xa4.

 

Note:

Amount of data in the message depends on usage of extension modules Wagon. If IOFireBug Engine is used independently then 8 bytes is returned (4x encoder * 2 bytes, each encoder needs two inputs). If we for example use one Wagon 16I, the messages will contain 24 Bytes of data (8bytes by Engine and 16 by Wagon).

 

Binary output/PWM messages

0xb0 – Setting of binary outputs – structure of message data

Byte of data Name Meaning
0 OUTPUTS uint8 number, MSB is output 8, LSB is output 1. Log1 means active output (closed contact).
1 EXP_OUTPUTS_1 uint8 number, MSB is output 8, LSB is output 1. Log1 means active output (closed contact).
2 EXP_OUTPUTS_2 uint8 number, MSB is output 8, LSB is output 1. Log1 means active output (closed contact).

Note:

Number of binary outputs depends on usage of extension modules Wagon. If IOFireBug is used independently then 1 byte is returned (eight binary outputs). If we for example use one Wagon 8O, the messages will contain 2 Bytes of data.

 

0xb1 – Setting of PWM output generator – structure of message data

Byte of data Name Meaning
0 OUTPUT_PWM0 PWM value of output 1 – uint8 number. 0 – output disabled, 255 – output enabled.
1 OUTPUT_PWM1 PWM value of output 2
7 OUTPUT_PWM7 PWM value of output 8

Note:

It’s necessary to turn on PWM functionality to activate PWM generators. It can be done by PWM configuration messages.

 

0xb2 – Reading of digital output state – structure of message data

Byte of data Name Meaning
0 OUTPUTS uint8 number, MSB is output 8, LSB is output 1. Log1 means active output (closed contact).
1 EXP_OUTPUTS_1 uint8 number, MSB is output 8, LSB is output 1. Log1 means active output (closed contact).
2 EXP_OUTPUTS_2 uint8 number, MSB is output 8, LSB is output 1. Log1 means active output (closed contact).

 

0xb3 – Reading of PWM output generator state – structure of message data

Byte of data Name Meaning
0 OUTPUT_PWM0 PWM value of output 1 – uint8 number. 0 – output disabled, 255 – output enabled
1 OUTPUT_PWM1 PWM value of output 2
7 OUTPUT_PWM7 PWM value of output 8

 

Analog input messages

0xc0 – Reading of analog inputs – structure of message data

Byte of data Name Meaning
0 INPUT_ADC0 Value of analog input 1, uint16 number
1
2 INPUT_ADC1 Value of analog input 2, uint16 number
3
14 INPUT_ADC7 Value of analog input 8, uint16 number
15

 

0xc1 – Analog input functions– structure of message data

Byte of data Name Meaning
0 ADC_FNC 0x00 – default value, no function

0x01 – 0xff – periodical sending of analog inputs state (message 0xa1) in miliseconds [ms] (1ms to 255ms)

 

Configuration messages

0xe1 – Analog input and ADC configuration – structure of message data

Byte of data Name Meaning
0 ADC_ENABLE 0x00 – ADC Disabled

0x01 – ADC Enabled

1 ADC_RESOLUTION 0x08 – 8bit ADC resolution

0x0c – 12bit ADC resolution

2 ADC_INPUT_FROM Index of first sampled analog input – 0 to 7
3 ADC_INPUT_TO Index of last sampled analog input – 0 to 7
4 ADZ_HZ AD converter frequency [Hz], uint32 number
5
6
7
8 ADC_AVERAGES Averaging of samples setting

0 – invalid value

1 – no averaging

2,4,8,16,32 – allowed values for averaging

9 ADC_RIGHT_ZEROS Count of right zero bits (ignores less significant bits) setting

0, 1, 2, 3, 4 – allowed values

Note:

Parameters ADC_INPUT_FROM / TO allows only to use requested analog inputs

ADC configuration take effect after device restart. It can be done by reset command or by power supply of the device.

 

0xe2 – PWM generator configuration for digital outputs 1 to 4 – structure of message data

Byte of data Name Meaning
0 PWM_ENABLE 0x00 – generator disabled

0x01 – generator enabled

1 PWM_HZ PWM generator frequency [Hz], uint16 number
2

Note:

If PWM generator is active on selected outputs, then digital output function is ignored for these outputs. This configuration takes effect after device restart. It can be done by reset command or by power supply of the device.

 

0xe3 – PWM generator configuration for digital outputs 5 to 6 – structure of message data

Byte of data Name Meaning
0 PWM_ENABLE 0x00 – generator disabled

0x01 – generator enabled

1 PWM_HZ PWM generator frequency [Hz], uint16 number
2

Note:

If PWM generator is active on selected outputs, then digital output function is ignored for these outputs. This configuration takes effect after device restart. It can be done by reset command or by power supply of the device.

 

0xe4 – PWM generator configuration for digital outputs 7 to 8 – structure of message data

Byte of data Name Meaning
0 PWM_ENABLE 0x00 – generator disabled

0x01 – generator enabled

1 PWM_HZ PWM generator frequency [Hz], uint16 number
2

Note:

If PWM generator is active on selected outputs, then digital output function is ignored for these outputs. This configuration takes effect after device restart. It can be done by reset command or by power supply of the device.

 

0xe5 – Binary input configuration– structure of message data

Byte of data Name Meaning
0 SAMPLE_PERIOD Setting of sample rate ratio for binary inputs. Base step is 1 ms. Value 1 to 65535 (from 1ms to 65535ms).
1
2 FILTER_LENGTH Binary input filter length setting. This value defines how much samples of same log. value must be taken to evaluate as log. value.

Value can be set from 0 to 15 (1 to 16 samples).

Note:

This configuration takes effect immediately, no need to restart the device.

 

0xe6 – Configuration of FTDI – USB baundrate – structure of message data

Byte of data Name Meaning
0 FTDI_BAUDRATE uint32 number
1
2
3

Note:

This configuration takes effect after device restart. It can be done by reset command or by power supply of the device.

 

0xe7 – Configuration of RS4XX baundrate – structure of message data

Byte of data Name Meaning
0 RS4XX_BAUDRATE uint32 number
1
2
3

Note:

This configuration takes effect after device restart. It can be done by reset command or by power supply of the device.

 

0xe8 – Configuration of extension modules (Wagons) – structure of message data

Byte of data Name Meaning
0 EXP_TYPE Type of first extension module
1 EXP_TYPE Type of second extension module
2 EXP_TYPE Type of third extension module
n (max. 7) EXP_TYPE Type of n-th extension module

Expansion modules types:

EXP_TYPE   Popis
0x00 WAGON_NONE Not used
0x01 WAGON_16 Wagon 16I (16xInput)
0x02 WAGON_8O Wagon 8O (8xOutput)
0x03 WAGON_8RELAY Wagon 8Op+ (8xRelay)
0x04 WAGON_16IO Wagon TTL 16IO (16xInput/Output)

Note:

Expansion modules (Wagons) must be connected in the same order as configured. The last expansion module must have jumper END closed for SPI bus termination. Number of expansion modules is limited to eight. Connection is made by a flat cable delivered with each expansion module.