Motor control

These functions provide motor control without using effects from Feelix and are based on the SimpleFOC library. Visit simplefoc.com for more details.

These functions can be used in combination with the 'lite' version of the library designed to work with effects imported from Feelix.

Initialization


/* initialize motor BLDCMotor(pole-pairs) */
BLDCMotor _bldc = BLDCMotor(7);

/* for STM32F401 v1.1 boards */
BLDCDriver3PWM _driver = BLDCDriver3PWM(PC8, PC7, PC6, PB15);
/* uncomment for Teensy controlled motors */
/* BLDCDriver3PWM _driver = BLDCDriver3PWM(21, 22, 23, 20); */

/* initializing the encoder */
MagneticSensorSPI _sensor = MagneticSensorSPI(CS_MAGNETIC_SENSOR_PIN, 14, CS_MAGNETIC_SENSOR_ADDRESS);

/* initialize Feelix */
Feelix feelix = Feelix(&_bldc, &_driver, &_sensor);

Control functions

You can use the functions specified in the documentation of the simpleFOC library. The initialization is handled in feelix.init(). To access the bldc, sensor and driver in the loop use: feelix.bldc-> (BLDCMoter object), feelix.driver-> (BLDCDriver3PWM object), feelix.sensor-> (MagneticSensorSPI object).

These are a few examples:

Get motor angle

/* accessing angle and velocity using SimpleFOC library  */
volatile float angle = feelix.bldc->shaft_angle();
volatile float velocity = feelix.bldc->shaft_velocity();

/* when feelix.run() is called in the loop  */
/* the angle can be directly accessed with: */
feelix.angle
/* the velocity can be directly accessed with: */
feelix.velocity

Control type options

feelix.bldc->controller = MotionControlType::torque;
feelix.bldc->controller = MotionControlType::angle;
feelix.bldc->controller = MotionControlType::velocity;

Move the motor

feelix.bldc->loopFOC();
feelix.bldc->move(value);

For all possibilities, check out the complete documentation at SimpleFOC.com

Motor control functions in Feelix Library

Move the motor to a specific position, speed value is optional.

/* angle (deg), speed (rad/s) */
feelix.move_to(float angle, float speed (optional));

/* returns true when motor is rotating, false when position is reached */
feelix.movingToAngle(); 

Last updated