REM 14 Sensor Demo

In this document

The purpose of this app is showing the use of the REM 14 Sensor Module with Position Feedback Module. For that, it implements a simple app that reads the output of a REM 14 sensor and shows over XScope the read velocity and position. It also displays the status of the sensor for debugging.

  • Min. Nr. of cores: 2
  • Min. Nr. of tiles: 1

Quick How-to

  1. Assemble your SOMANET device.
  2. Wire up your device. Check how at your specific hardware documentation. Connect your sensor, power supply cable, and XTAG. Power up!
  3. Set up your XMOS development tools.
  4. Download and import in your workspace the SOMANET Motor Control Library and its dependencies.
  5. Open the main.xc within the app. Include the board-support file according to your device. Also set the appropriate target in your Makefile.

Important

Make sure the SOMANET Motor Control Library supports your SOMANET device. For that, check the Hardware compatibility section of the library.

  1. Again in your main.xc, set the configuration for the Position feedback Service and you sensor.

    on tile[IFM_TILE]:
    /* Position feedback service */
    {
        PositionFeedbackConfig position_feedback_config;
        position_feedback_config.sensor_type = REM_14_SENSOR;
        position_feedback_config.resolution  = REM_14_SENSOR_RESOLUTION;
        position_feedback_config.velocity_compute_period = REM_14_SENSOR_VELOCITY_COMPUTE_PERIOD;
        position_feedback_config.polarity    = NORMAL_POLARITY;
        position_feedback_config.pole_pairs  = POLE_PAIRS;
        position_feedback_config.ifm_usec    = IFM_TILE_USEC;
        position_feedback_config.max_ticks   = SENSOR_MAX_TICKS;
        position_feedback_config.offset      = 0;
        position_feedback_config.sensor_function = SENSOR_FUNCTION_COMMUTATION_AND_MOTION_CONTROL;
    
        position_feedback_config.rem_14_config.hysteresis     = REM_14_SENSOR_HYSTERESIS ;
        position_feedback_config.rem_14_config.noise_setting  = REM_14_SENSOR_NOISE;
        position_feedback_config.rem_14_config.dyn_angle_comp = REM_14_SENSOR_DAE;
        position_feedback_config.rem_14_config.abi_resolution = REM_14_SENSOR_ABI_RES;
    
        position_feedback_service(null, null, null, spi_ports, gpio_port_0, gpio_port_1, gpio_port_2, gpio_port_3,
                position_feedback_config, i_shared_memory[0], i_position_feedback,
                null, null, null);
    }
    
  2. In parallel, the position/velocity and others status info are displayed with XScope.

    on tile[APP_TILE]:
    {
        int count = 0;
        int velocity = 0;
        int position = 0;
        int angle = 0;
        timer t;
        unsigned int start_time, end_time, time;
    
    
        while(1) {
            /* get position from REM_14 Sensor */
            {count, position, void } = i_position_feedback.get_position();
    
            /* get angle from REM_14 Sensor */
            angle = i_position_feedback.get_angle();
    
            /* get velocity from REM_14 Sensor */
            velocity = i_position_feedback.get_velocity();
    
            t :> start_time;
            if (!isnull(i_shared_memory)) {
                UpstreamControlData upstream_control_data = i_shared_memory.read();
                angle = upstream_control_data.angle;
                count = upstream_control_data.position;
                velocity = upstream_control_data.velocity;
            }
            t :> end_time;
    
            xscope_int(COUNT, count);
            xscope_int(POSITION, position);
            xscope_int(ANGLE, angle);
            xscope_int(VELOCITY, velocity);
            xscope_int(TIME, (end_time-start_time)/USEC_STD);   //time to get the data in microseconds
            xscope_int(TIME_INTERNAL, time);   //time to get the data in microseconds
    
            delay_milliseconds(1);
        }
    }
    
  3. Run the application enabling XScope.

See also

Did everything go well? If you need further support please check out our forum.