BiSS Encoder Module

This module provides functions to read data transmitted using the BiSS protocol and process the data coming from a BiSS Encoder into position data.

BiSS is an open source digital interface for sensors and actuators. BiSS is hardware compatible to the industrial standard SSI (Serial Synchronous Interface). The standardization process is coordinated on biss-interface.com.

Those functions are used in Serial Encoder Module itself used by Position Feedback Module to create a service for reading a BiSS encoder.

The BiSS functions should always run over an IFM Tile so it can access the ports to your SOMANET IFM device.

How to use

Important

We assume that you are using SOMANET Base and your app includes the required board support files for your SOMANET device.

See also

You might find useful the BiSS Sensor Demo, which illustrates the use of this module.

  1. First, add all the SOMANET Motor Control modules to your app Makefile.

    USED_MODULES = configuration_parameters module_adc module_biss_encoder lib_bldc_torque_control module_board-support module_hall_sensor module_utils module_position_feedback module_pwm module_incremental_encoder module_encoder_rem_14 module_encoder_rem_16mt module_serial_encoder module_shared_memory module_spi_master module_watchdog
    

    Note

    Not all modules will be required, but when using a library it is recommended to include always all the contained modules. This will help solving internal dependency issues.

  2. Include the BiSS Service header biss_service.h in your app.

  3. Instantiate the ports for the BiSS.

    BiSS needs a clock output port, a data input port and a clock block. The ports structures are defined in position_feedback_service.h. The clock block is taken for the SPI ports sturcture. Depending on the BiSS configuration the output clock port is taken from hall_enc_select_port or from a GPIO port and the data input port is taken from qei_hall_port 1 or 2. The functions take pointers for parameters, so you need to pass the addresses of the port structures. If qei_hall_ports are used the hall_enc_select_config parameter also needs to be set to configure the ports in differential mode.

  4. Fill up the BiSS configuration structure.

  5. At your IFM tile, You can use the functions to read BiSS data and process it into position data.
    #include <CORE_C22-rev-a.bsp>   //Board Support file for SOMANET Core C22 device
    #include <IFM_DC100-rev-b.bsp>  //Board Support file for SOMANET IFM DC100 device
                                    //(select your board support files according to your device)
    
    // 2. Include the BiSS Service header **biss_service.h** in your app.
    #include <biss_service.h>
    
    // 3.Instantiate the ports for the BiSS.
    SPIPorts spi_ports = SOMANET_IFM_SPI_PORTS;
    QEIHallPort qei_hall_port_1 = SOMANET_IFM_HALL_PORTS;
    QEIHallPort qei_hall_port_2 = SOMANET_IFM_QEI_PORTS;
    HallEncSelectPort hall_enc_select_port = SOMANET_IFM_QEI_PORT_INPUT_MODE_SELECTION;
    port ?gpio_port_2 = SOMANET_IFM_GPIO_D2;
    
    int main(void)
    {
        par
        {
            on tile[IFM_TILE]:
            {
                // 4. Fill up the BiSS configuration structure.
                BiSSConfig biss_config;
                biss_config.multiturn_resolution = BISS_MULTITURN_RESOLUTION;
                biss_config.filling_bits = BISS_FILLING_BITS;
                biss_config.crc_poly = BISS_CRC_POLY;
                biss_config.clock_frequency = BISS_CLOCK_FREQUENCY;
                biss_config.timeout = BISS_TIMEOUT;
                biss_config.busy = BISS_BUSY;
                biss_config.clock_port_config = BISS_CLOCK_PORT;
                biss_config.data_port_number = BISS_DATA_PORT_NUMBER;
    
                // 5. Use the functions to read BiSS data and process it into position data.
                // read BiSS data
                int data[BISS_FRAME_BYTES]; // array of 32 bit bytes to store the data. The size needs to be enough to store all the data bits.
                int hall_enc_select_config = 0b0011; //to configure qei_hall_ports in differential mode
                int error = read_biss_sensor_data(&qei_hall_port_1, &qei_hall_port_2, &hall_enc_select_port, hall_enc_select_config, &gpio_port_2, biss_config, data);
                // process data
                int count, position, status;
                { count, position, status } = biss_encoder(data, biss_config);
            }
        }
    
        return 0;
    }
    

API

Definitions

BISS_FRAME_BYTES

Number of 32 bit bytes needed to save the BiSS frame before processing.

It must be large enough to hold: CDS bit + multiturn and singleturn data with filling bits + error and warning bits and the crc (6) 2 bytes should be enough for a sensor up to 55 bits of position data (1 + 55 + 2 + 6 = 64)

BISS_DATA_PORT_BIT

Bit number (0 = rightmost bit) when inputing from a multibit port.

BISS_STATUS_BITS

Number of bits used for status data (usually 2)

Types

BISSConfig

Structure type to define the BiSS sensor configuration.

Structure Members:

int multiturn_resolution

Number of bits of multiturn resolution.

int singleturn_resolution

Number of bits of singleturn resolution.

int filling_bits

Number of filling bits between the singleturn data status data.

int crc_poly

CRC polynom in reverse representation: x^0 + x^1 + x^6 is 0b110000.

int clock_frequency

BiSS output clock frequency in kHz, supported frequencies depend on IFM Tile frequency.

int timeout

Timeout after a BiSS read in microseconds.

int busy

maximum number of bits to read before the start bit (= maximum duration of ACK bit)

BISSClockPortConfig clock_port_config

Configure of the biss clock port (GPIO or hall_enc_select_port)

EncoderPortNumber data_port_number

Configure which port is used for the biss input data.

SensorError

Type for Sensor Error.

Enum Values:

SENSOR_NO_ERROR
SENSOR_REM_16MT_WEAK_MAG_FIELD_ERROR
SENSOR_REM_16MT_MT_COUNTER_ERROR
SENSOR_REM_16MT_ST_CORDIC_ERROR
SENSOR_REM_16MT_MT_SPEED_OVERLOW_ERROR
SENSOR_REM_16MT_FILTER_CONFIG_ERROR
SENSOR_REM_16MT_FILTER_SPEED_OVERLOW_ERROR
SENSOR_REM_16MT_UNKNOWN_CMD_ERROR
SENSOR_REM_16MT_CONFIG_ERROR
SENSOR_BISS_ERROR_BIT_ERROR
SENSOR_BISS_WARNING_BIT_ERROR
SENSOR_BISS_ERROR_AND_WARNING_BIT_ERROR
SENSOR_BISS_NO_ACK_BIT_ERROR
SENSOR_BISS_NO_START_BIT_ERROR
SENSOR_CHECKSUM_ERROR
EncoderPortNumber

Type for Encoder Port.

There are two identical encoder ports which can be used for Hall, QEI and BiSS.

Enum Values:

ENCODER_PORT_1

Encoder port 1 (value should be 0)

ENCODER_PORT_2

Encoder port 0 (value should be 1)

QEIHallPort

Structure for Hall/QEI input ports (can also be used for BiSS)

Structure Members:

in port p_qei_hall

4-bit Port for Encoder, BiSS or Hall signals input.

HallEncSelectPort

Structure for the hall_enc_select port used to select the mode (differential or not) of Hall/qei ports.

Also used for the BiSS clock output

Structure Members:

out port p_hall_enc_select

[Nullable] Port to control the signal input circuitry (if applicable in your SOMANET device).

Also used for the BiSS clock output

SPIPorts

Structure for SPI ports and clock blocks.

Structure Members:

spi_master_class spi_class
port *movable slave_select

Functions

SensorError read_biss_sensor_data(QEIHallPort *qei_hall_port_1, QEIHallPort *qei_hall_port_2, HallEncSelectPort *hall_enc_select_port, int hall_enc_select_config, port *biss_clock_port, BISSConfig &biss_config, unsigned int data[])

Read generic BiSS sensor data.

Parameters:
  • qei_hall_port_1 – BiSS input port 1
  • qei_hall_port_2 – BiSS input port 2
  • hall_enc_select_port – port used to select the mode (differential or not) of Hall/qei ports and optionally output the BiSS clock
  • hall_enc_select_config – config to select the mode (differential or not) of Hall/qei ports
  • biss_clock_port – port used to optionally output the BiSS clock
  • biss_config – Configuration of the BiSS sensor (data lengths, crc polynomial, etc)
  • data – Array to store the read bits, should be large enough to store all the data bits + crc bits
Returns:

error status (No Error, CRC Error, No Ack, No Start Bit)

{ int, unsigned int, SensorError } b biss_encoder(unsigned int data[], BISSConfig biss_config)

Extract position data from a BiSS encoder raw sensor data.

Parameters:
  • data – BiSS raw sensor data
  • biss_config – structure definition for the BiSS encoder data lengths
Returns:

absolute count

Returns:

position in the range [0 - (2^singleturn_resolution - 1)]

Returns:

status (error and warning bits)

unsigned int biss_crc(unsigned int data[], unsigned int data_length, unsigned int crc_poly)

Compute a crc for BiSS data.

Parameters:
  • data – BiSS data
  • data_length – length of data in bits
  • crc_poly – crc polynomial in reverse representation with high exponent omitted: x^0 + x^1 + x^6 is 0b110000
Returns:

inverted crc for BiSS

void biss_crc_correct(unsigned int data[], unsigned int data_length, static const unsigned int frame_bytes, unsigned int crc_received, unsigned int crc_poly)

Try 1-bit error correction for BiSS data.

Parameters:
  • data – BiSS data
  • data_length – length of data in bits
  • frame_bytes – number of 32 bit bytes of data
  • crc_received – crc received with the data
  • crc_poly – crc polynomial in reverse representation: x^0 + x^1 + x^4 is 0b1100