Created
May 22, 2021 15:23
-
-
Save mlodzianck/27a73a54b40c83d6ef6b59437cf80781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Open loop motor control example | |
#include <SimpleFOC.h> | |
// BLDC motor & driver instance | |
// BLDCMotor( pp number , phase resistance) | |
BLDCMotor motor = BLDCMotor(11 , 0.6); | |
BLDCDriver3PWM driver = BLDCDriver3PWM(25,26,27); | |
//target variable | |
float target_velocity = 2; // rad/s | |
// instantiate the commander | |
//Commander command = Commander(Serial); | |
void setup() { | |
// driver config | |
// power supply voltage [V] | |
driver.voltage_power_supply = 12; | |
driver.init(); | |
// link the motor and the driver | |
motor.linkDriver(&driver); | |
// limiting motor current (provided resistance) | |
motor.current_limit = 12; // [Amps] | |
// open loop control config | |
motor.controller = MotionControlType::velocity_openloop; | |
// init motor hardware | |
motor.init(); | |
// add target command T | |
Serial.begin(115200); | |
Serial.println("Motor ready!"); | |
Serial.println("Set target velocity [rad/s]"); | |
_delay(1000); | |
} | |
void loop() { | |
// open loop velocity movement | |
// using motor.current_limit and motor.velocity_limit | |
motor.move(2); | |
// user communication | |
// command.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment