User Tools

Site Tools


getting_started:tutorials:oneaxis

This is an old revision of the document!


Control a Single Motor

This tutorial will show you how to control a single motor using EEROS. This example is located in a separate repository https://github.com/eeros-project/simple-motor-control.git. It will be downloaded and built automatically if you follow Getting the Sources with a Script.

Navigate to the directory simple-motor-control where you can find the code.

Theoretical Background

A motor position is measured by an encoder. After differentiating this signal we obtain the velocity. The input of the velocity controller is the difference between reference and measured velocity. Additionally, the feed forward velocity is added. The output of this controller is an acceleration. This value is then multiplied by the inertia and divided by the motor constant, in order to obtain a current reference value to control the motor.

Control loop

For a good dynamical stiffness we choose f0 = fs / 20 where fs is the sampling frequency. With fs = 1kHz we get f0 = 50Hz. With ω0 = 2·π·f0 the parameters for the position and velocity controller, kp and kv respectively, will be as follows:

kp = ω0 / 2·D and kv = 2·D·ω0

D is the damping factor and we choose it as 0.9.

Experimental Setup

A maxon motor controller (50V / 5A) delivers the necessary power. The motor we use has the following properties:

Properties Value Unit
Inertia 9.49 kgm2
Motor Constant 16.3 10-3 Nm/A
Encoder Pulses 500

We use three different platforms for running the Simple Motor Controller.

  • A regular PC (x86-64) together with a National Instrument card: PCIe - 6251 (M-Series). The card requires the comedi library together with the EEROS hardware wrapper, see comedi. In any case you have to install comedi separately.

Connect all the necessary signals according to your hardware configuration file, notably

  • analog output and enable signal to the motor controller
  • encoder outputs (A/B signals) to the decoder inputs
  • motor controller ready signal to a digital input
  • emergency button to a digital input

IMPORTANT On the beaglebone blue board, you don't need a motor controller. Hence, you do not need the enable signal. Tie the ready signal to logic one.

Build Application

  1. Install EEROS and necessary hardware libraries as described in Installation and Setup
  2. Build Compile, you already have the necessary libraries together with the application. If you use comedi navigate to the build directory of your simple motor control directory. If you use the cb20 board, follow the instruction in https://github.com/ntb-ch/cb20 to download the necessary files to the target.

Test Application

You will find different hardware configuration files depending on the hardware platform.

  • HalComedi.json
  • HalFlink.json
  • HalBBB.json

Start our application by choosing the appropriate configuration file, e.g.:

$ sudo ./simpleMotorControl -c HalBBB.json

Implementation

Control System

The control system declares in ControlSystem.hpp all the necessary blocks as given in the picture at the top of this page. Those blocks are then defined in ControlSystem.cpp, connected together, and added to a time domain. At last the time domain is added to the executor.

Safety System

Safety levels and events are declared in SMCSafetyProperties.hpp. SMCSafetyProperties.cpp initializes these objects, defines critical inputs and outputs, defines level actions, and adds the levels to the safety system. The levels and events causing transitions between those levels are shown in the next figure.

Safety levels and events

Two critical inputs are defined: “emergency” and “readySig1”. “enable” is a critical output. Critical inputs and outputs are checked and set by each safety level. For example “enable” is set to true as soon as the safety level is equal or higher than powerOn. “emergency” is unchecked for the two lowest levels and leads to level change to level emergency for higher levels.

Sequencer

The sequencer runs a sequence which turns the motor each second a tenth of a full turn.

getting_started/tutorials/oneaxis.1570784898.txt.gz · Last modified: 2019/10/11 11:08 by graf