无法用WEMOS D1 MINI和30A ESC使用A2212(1000KV)电动机
#include <Servo.h>
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
Servo bldc;
double roll,pitch,yaw,thr;
char packet[255];
struct __attribute__((packed)) JoyStick {
double yaw;
double thr;
double pitch;
double roll;
int32_t mode;
double array[9];
};
#define WIFI_SSID "K.G.F - 2"
#define WIFI_PASS "assafkhan92786"
#define UDP_PORT 4210
//----------------------------------------
WiFiUDP UDP;
void setup() {
Serial.begin(115200); //115200
//-----------------------------
WiFi.begin(WIFI_SSID, WIFI_PASS);
Serial.print("Connecting to ");
Serial.print(WIFI_SSID);
while (WiFi.status() != WL_CONNECTED)
{
delay(100);
Serial.print(".");
}
// Connected to WiFi
Serial.println();
Serial.print("Connected! IP address: ");
Serial.println(WiFi.localIP());
// Begin listening to UDP port
UDP.begin(UDP_PORT);
Serial.print("Listening on UDP port ");
Serial.println(UDP_PORT);
//----------------------------
bldc.attach(D5,1000,2000);
}
void udp_rcv()
{
int packetSize = UDP.parsePacket();
JoyStick myJoystick;
if (packetSize) {
//Serial.printf("Received %d bytes\n", packetSize);
if (UDP.read(packet, packetSize) > 0) {
memcpy(&myJoystick, packet, packetSize); //copy packet array to the a struct
//Serial.print(myJoystick.roll,HEX);
yaw=myJoystick.yaw;
thr=myJoystick.thr;
pitch=myJoystick.pitch;
roll=myJoystick.roll;
}
}
}
void loop()
{
udp_rcv();
Serial.println(thr);// the received values are in range from 0 to 1023
bldc.writeMicroseconds(thr);
}
我正在尝试使用ESP8266使用30A ESC控制1000kV BLDC电机(A2212),但我完全迷失了,尽管我正在通过UDP从笔记本电脑那里收回输入,但我无法武装电动机并控制电机,请指导我,如何使用ESP8266(WEMOS D1 MINI)控制其速度,我也使用了Wemos_d1_mini中的D5和D6 PIN,所以请让我知道我可以使用哪些其他引脚。
#include <Servo.h>
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
Servo bldc;
double roll,pitch,yaw,thr;
char packet[255];
struct __attribute__((packed)) JoyStick {
double yaw;
double thr;
double pitch;
double roll;
int32_t mode;
double array[9];
};
#define WIFI_SSID "K.G.F - 2"
#define WIFI_PASS "assafkhan92786"
#define UDP_PORT 4210
//----------------------------------------
WiFiUDP UDP;
void setup() {
Serial.begin(115200); //115200
//-----------------------------
WiFi.begin(WIFI_SSID, WIFI_PASS);
Serial.print("Connecting to ");
Serial.print(WIFI_SSID);
while (WiFi.status() != WL_CONNECTED)
{
delay(100);
Serial.print(".");
}
// Connected to WiFi
Serial.println();
Serial.print("Connected! IP address: ");
Serial.println(WiFi.localIP());
// Begin listening to UDP port
UDP.begin(UDP_PORT);
Serial.print("Listening on UDP port ");
Serial.println(UDP_PORT);
//----------------------------
bldc.attach(D5,1000,2000);
}
void udp_rcv()
{
int packetSize = UDP.parsePacket();
JoyStick myJoystick;
if (packetSize) {
//Serial.printf("Received %d bytes\n", packetSize);
if (UDP.read(packet, packetSize) > 0) {
memcpy(&myJoystick, packet, packetSize); //copy packet array to the a struct
//Serial.print(myJoystick.roll,HEX);
yaw=myJoystick.yaw;
thr=myJoystick.thr;
pitch=myJoystick.pitch;
roll=myJoystick.roll;
}
}
}
void loop()
{
udp_rcv();
Serial.println(thr);// the received values are in range from 0 to 1023
bldc.writeMicroseconds(thr);
}
I am trying to controll a 1000kv bldc motor(A2212) with a 30A ESC using esp8266, but I am completely lost, and I am unable to ARM the motor and controll it, although I am reciving the input from my laptop via UDP, please guide me, on how to ARM the ESC/MOTOR, and controll its speed using ESP8266 (wemos D1 mini) also I have used the d5 and d6 pin in wemos_d1_mini, so please let me know which other pins i can use.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该解决方案对我来说很好,最后我想出了这一点,似乎很容易,您只需要发送最小的油门等待2秒钟,然后发送最大油门(Pulse)即可。 Boom ESC现在已经校准。
This solution works fine for me, at last i figured it out, seems it was very easy, you just need to send the min throttle wait for 2 seconds and then send the max throttle (pulse); boom ESC is calibrated now.