SimpleFOC and ESPAsyncWebServer are conflicting?
Posted: Wed Mar 20, 2024 1:41 am
As my title suggests, I am trying to run a BLDC motor at full speed in loop(), while at the same time I wish to run a server that updates a chart at some set inverval. However every time the chart updates, or a button is pressed, the motor skips/stutters. I've tried swapping the motor to Core 0, or vice versa but no luck. Here are some snippets of the test code, but it seems I am not understanding something happening in the background. Any help?
Code: Select all
#include <SimpleFOC.h>
#include <ESPAsyncWebServer.h>
void setup(){
// Route for root / web page
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/html", index_html, processor);
});
server.on("/pressure", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/plain", atmoshpere().c_str());
}); }
xTaskCreatePinnedToCore(
Task1code, //function name
"Task1", // name
10000, // stack size
NULL, // type
2, // priority
&Task1, // task handle
0 // core number
);
void loop(){
motor.move(target_velocity);
motor_i = motor_i +1;
if (motor_i>= 3000){
if (target_velocity<50){
target_velocity = target_velocity + .25;
}
motor_i = 0;
}
}