Thank you Olaf!
Yes, that’s correct, it is ATmel328p. I used ‘Arduino Pro or Pro mini’ for the board to flash it. After flashing, when i connect a motor with target_velocity of 0 it stays the position but gets very hot. When i do target velocity of 5, it is just vibrating the motor. So, I think you are right, it does not seem to work correctly. I will place this board in my Ali Express souvenir collection box.
By the way, I also tried this another board FOC bldc driver controller SimpleFOC Shield brushless motor engine board MKS ESP32 FOC Servo Drive Mechanical Robot Dog parts - AliExpress 7 which claims to be designed for ‘SimpleFOC’. When I flash it, It does rotate my BLDC motor as per the set target_velocity but as soon as i send a message through ‘Serial monitor’, it shows uart disconnected message to me. So, I thought it might be to do with Arduino IDE trying to do flashing and serial both from the same window. I tried out SimpleFOC Studio for serial connection which gives this error:
C:\Users\me\anaconda3\envs\simplefoc\lib\site-packages\serial\serialwin32.py", line 317, in write
raise SerialException(“WriteFile failed ({!r})”.format(ctypes.WinError()))
serial.serialutil.SerialException: WriteFile failed (PermissionError(13, ‘Access is denied.’, None, 5))
My assumption is that its the same error as Arduino IDE. The serial port is not available somehow for sending messages. After that, flashing also gives error 2. I then have to disconnect my motor, reset the board and it starts flashing again.
Here is my code…
/// MKS ESP32 FOC Open loop speed control example; Test Library:SimpleFOC 2.1.1 ; Tested hardware:MKS ESP32 FOC V1.0
/// Enter "T+number" in the serial port to set the speed of the two motors.For example, to set the motor to rotate at a speed of 10rad/s, input "T10"
/// When the motor is powered on, it will rotate at 5rad/s by default
/// When using your own motor, do remember to modify the default number of pole pairs, the value in BLDCMotor(7).
/// The default power supply voltage of the program is 12V.
/// Please remember to modify the voltage_power_supply , voltage_limit variable values when using other voltages for power supply
#include <SimpleFOC.h>
BLDCMotor motor = BLDCMotor(7); //According to the selected motor, modify the number of pole pairs here, the value in BLDCMotor()
BLDCDriver3PWM driver = BLDCDriver3PWM(32,33,25,22);
/// BLDC motor & driver instance
BLDCMotor motor1 = BLDCMotor(7); //Also modify the value in BLDCMotor() here
BLDCDriver3PWM driver1 = BLDCDriver3PWM(26,27,14,12);
/// Target Variable
float target_velocity = 5;
/// Serial Command Setting
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }
void setup() {
driver.voltage_power_supply = 12; //According to the supply voltage, modify the value of voltage_power_supply here
driver.init();
motor.linkDriver(&driver);
motor.voltage_limit = 1; // [V] //According to the supply voltage, modify the value of voltage_limit here
motor.velocity_limit = 40; // [rad/s]
driver1.voltage_power_supply = 12; //Also modify the value of voltage_power_supply here
driver1.init();
motor1.linkDriver(&driver1);
motor1.voltage_limit = 3; // [V] //Also modify the value of voltage_limit here
motor1.velocity_limit = 40; // [rad/s]
// Open Loop Control Mode Setting
motor.controller = MotionControlType::velocity_openloop;
motor1.controller = MotionControlType::velocity_openloop;
// Initialize the Hardware
motor.init();
motor1.init();
// Add T Command
// Enter "T+number" in the serial port to set the speed of the two motors.For example, to set the motor to rotate at a speed of 10rad/s, input "T10".
command.add('T', doTarget, "target velocity");
Serial.begin(115200);
Serial.println("Motor ready!");
Serial.println("Set target velocity [rad/s]");
_delay(1000);
}
void loop() {
motor.move(target_velocity); //When the motor is powered on, it will rotate at 5rad/s by default
motor1.move(target_velocity);
//User Newsletter
command.run();
}
I tried both 1 and 3 for target voltage. My motor is actually a 12v motor but it suggests to keep it way below its actual 1amp capacity.
No sensors - i am connecting the motor without any encoder sensors. Simply connecting 3 phase wires.
Any suggestion?
Disclaimer: I am a newbie, not an expert 