Feelix
  • Feelix Documentation
  • Getting started
    • Designing Effects
      • Torque Effects
      • Position Effects
      • Velocity Effects
      • (In)dependent Effects
    • Effect Library
    • Creating Collections
  • Create and edit
    • Edit tools
    • Effect Settings
    • Layers
    • Grid
    • Export Effects
    • TensorFlow
  • Connecting with Feelix
    • Setting up STM32
    • Setting up ESP32
    • Connect and Upload
    • Hardware Settings
    • Troubleshooting Feelix
  • Hardware support
    • Hardware
    • PCB pinout
    • Setup
    • Dependencies
    • FeelixEffect Docs
      • Functions and Parameters
      • Setup
      • Motor control
      • Import Effects
        • Import Haptic Effect
        • Import Velocity Effect
      • I2C communication
        • One Way Communication
        • Two Way Communication
  • Downloads
    • Feelix Design Tool
    • Feelix Arduino Library
    • 3D Models
    • Old Library Releases
Powered by GitBook
On this page

Was this helpful?

  1. Hardware support
  2. FeelixEffect Docs

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.

PreviousSetupNextImport Effects

Last updated 6 hours ago

Was this helpful?

This code works with the

You can use the functions specified in the documentation of the library.

Get motor angle and velocity


/* when feelix.run() and feelix.move_feelix() or feelix.bldc->loopFOC() 
 *  is called in the loop the angle can be directly accessed with: 
 */
float angle // Radians
float angleDeg // Degrees

/* the velocity can be directly accessed with: */
float velocity

/* read value magnetic rotary encoder without using feelix.run()
 * function is handled in feelix.run() no need to duplicate
 */
feelix.sensor->update();

feelix.sensor->getAngle();
feelix.sensor->getVelocity();

Control type options

/* motion control type can be updated at run time to alternate between different control types. 
You only need to control these settings when writing your own custom effects with SimpleFOC */
feelix.bldc->controller = MotionControlType::torque;
feelix.bldc->controller = MotionControlType::angle;
feelix.bldc->controller = MotionControlType::velocity;

Move the motor

/* SimpleFOC function - running the low level torque control loop
 * it sets the appropriate voltages to the phase pwm signals
 * the faster you can run it the better 
 */
feelix.bldc->loopFOC();

/* SimpleFOC function to update torque, velocity, or angle
 * depending on the set MotionControlType
 */
feelix.bldc->move(value);  
/* Set velocity PID settings */
feelix.bldc->PID_velocity.P = 0.5;
feelix.bldc->PID_velocity.I = 10.0;
feelix.bldc->PID_velocity.D = 0.0;

/* Set angle PID settings */
feelix.bldc->P_angle.P = 14.0;
feelix.bldc->P_angle.I = 0.0;
feelix.bldc->P_angle.D = 0.0;

Motor control functions in Feelix Library

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

/* function to let the motor move towards specific angle (blocking code)
 * angle: angle in degrees
 * speed: percentage 0.0 - 0.1 of max velocity
 * threshold: accuracy target position (degrees) 
 * default: stop within 0.2 degrees from target area 
 */
feelix.move_to(float angle, float speed, float threshold);

/* returns is set to TRUE while moving to desired positoin, 
 * and FALSE when position is reached
 */
feelix.MOVING; 

PID controller settings (more )

For all possibilities, check out the complete documentation at

Feelix Effect Arduino Library
simpleFOC
information
SimpleFOC.com