<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[RemoteXY community — Проблема с сервоприводом MG945 ESP32]]></title>
		<link>https://forum.remotexy.com/viewtopic.php?id=1836</link>
		<atom:link href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1836&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Проблема с сервоприводом MG945 ESP32.]]></description>
		<lastBuildDate>Thu, 15 Aug 2024 07:54:25 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Проблема с сервоприводом MG945 ESP32]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=5644#p5644</link>
			<description><![CDATA[<p>Возможно вы добавили в код какую то вещь которая конфликтует с библиотекой Servo.<br />Вижу что в коде RemoteXY у вас есть следующая строка в функции Setup. Возможно есть какой либо конфликт по прерываниям.<br /></p><div class="codebox"><pre><code> attachInterrupt(digitalPinToInterrupt(BTN), handleButtonPress, CHANGE);</code></pre></div><p>Ну и попробуйте убрать все лишнее что не относится к серве:<br /></p><div class="codebox"><pre><code>//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// определение режима соединения и подключение библиотеки RemoteXY
#define REMOTEXY_MODE__WIFI_POINT

#include &lt;WiFi.h&gt;
#include &lt;ESP32Servo.h&gt;

Servo myservo;

// настройки соединения
#define REMOTEXY_WIFI_SSID &quot;HummerBot1&quot;
#define REMOTEXY_WIFI_PASSWORD &quot;HummerBot1&quot;
#define REMOTEXY_SERVER_PORT 6377


#include &lt;RemoteXY.h&gt;

// конфигурация интерфейса RemoteXY
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =  // 45 bytes
  { 255, 3, 0, 0, 0, 38, 0, 17, 0, 0, 0, 31, 1, 200, 84, 1, 1, 2, 0, 5,
    19, 10, 60, 60, 32, 16, 28, 31, 1, 140, 27, 24, 24, 1, 16, 1, 208, 163, 208, 180,
    208, 176, 209, 128, 0 };

// структура определяет все переменные и события вашего интерфейса управления
struct {

  // input variables
  int8_t stick_x;  // oт -100 до 100
  int8_t stick_y;  // oт -100 до 100
  uint8_t hummer;  // =1 если кнопка нажата, иначе =0

  // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

int servoPin = 18;

void setup() {
  Serial.begin(115200);

  myservo.setPeriodHertz(50);// Standard 50hz servo
  myservo.attach(servoPin, 1000, 2000); //MG945

  RemoteXY_Init();
}

void loop() {
  /* обработчик событий модуля RemoteXY */
  RemoteXY_Handler();

  if(RemoteXY.hummer == 1){
    Serial.println(&quot;Серво запускается...&quot;);
    myservo.write(0);
    RemoteXY_delay(1000);
    Serial.println(&quot;Серво Выключается...&quot;);
    myservo.write(180);
    RemoteXY_delay(1000);
  }

}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (remotexy)]]></author>
			<pubDate>Thu, 15 Aug 2024 07:54:25 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=5644#p5644</guid>
		</item>
		<item>
			<title><![CDATA[Re: Проблема с сервоприводом MG945 ESP32]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=5640#p5640</link>
			<description><![CDATA[<p>Запитан сервопривод от аккумуляторов 18650(2шт). Сигнал да напрямую от esp32. Без RemoteXY все работает штатно.</p><br /><p>// Include the ESP32 Arduino Servo Library instead of the original Arduino Servo Library<br />#include &lt;ESP32Servo.h&gt;</p><p>Servo myservo;&nbsp; // create servo object to control a servo</p><p>// Possible PWM GPIO pins on the ESP32: 0(used by on-board button),2,4,5(used by on-board LED),12-19,21-23,25-27,32-33<br />// Possible PWM GPIO pins on the ESP32-S2: 0(used by on-board button),1-17,18(used by on-board LED),19-21,26,33-42<br />// Possible PWM GPIO pins on the ESP32-S3: 0(used by on-board button),1-21,35-45,47,48(used by on-board LED)<br />// Possible PWM GPIO pins on the ESP32-C3: 0(used by on-board button),1-7,8(used by on-board LED),9-10,18-21<br />int servoPin = 18;&nbsp; // GPIO pin used to connect the servo control (digital out)</p><p>int ADC_Max = 4096;&nbsp; // This is the default ADC max value on the ESP32 (12 bit ADC width);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// this width can be set (in low-level oode) from 9-12 bits, for a<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// a range of max values of 512-4096<br />#define BTN 23<br />void setup() {<br />&nbsp; // Allow allocation of all timers<br />&nbsp; ESP32PWM::allocateTimer(0);<br />&nbsp; ESP32PWM::allocateTimer(1);<br />&nbsp; ESP32PWM::allocateTimer(2);<br />&nbsp; ESP32PWM::allocateTimer(3);<br />&nbsp; myservo.setPeriodHertz(50);<br />&nbsp; myservo.attach(servoPin, 300, 2600);<br />&nbsp; Serial.begin(115200);<br />}</p><p>void loop() {<br />&nbsp; &nbsp; Serial.println(&quot;Серво запускается...&quot;);<br />&nbsp; &nbsp; myservo.write(0);&nbsp; &nbsp;// set the servo position according to the scaled value<br />&nbsp; &nbsp; delay(2000);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// wait for the servo to get there<br />&nbsp; &nbsp; Serial.println(&quot;Серво выключается...&quot;);<br />&nbsp; &nbsp; myservo.write(180);&nbsp; // set the servo position according to the scaled value<br />&nbsp; &nbsp; delay(2000);<br />}</p><br /><br /><p>Вот с этой программой все работает.</p>]]></description>
			<author><![CDATA[null@example.com (canvova)]]></author>
			<pubDate>Mon, 12 Aug 2024 10:58:39 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=5640#p5640</guid>
		</item>
		<item>
			<title><![CDATA[Re: Проблема с сервоприводом MG945 ESP32]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=5637#p5637</link>
			<description><![CDATA[<p>Судя по коду все в порядке.<br />1. Если вы подаете сигнал управления напрямую на сервопривод, то возможно сервопривод не может работать с логикой 3.3 В.<br />2. Если у вас такой большой сервопривод подключен к питанию 5В от платы контроллера то это работать не будет. Сервопривод потребляет достаточно большой ток что бы сбрасывать контроллер при попытке движения. Для этого сервопривода желательно отдельный источник питания.</p><p>Проверьте как работает сервопривод на каком либо простом примере только для сервопривода, без RemoteXY. Возможно что то напутали с выбором пина. Либо не туда подключили либо этот пин не поддерживается библиотекой Servo.</p>]]></description>
			<author><![CDATA[null@example.com (remotexy)]]></author>
			<pubDate>Mon, 12 Aug 2024 05:01:55 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=5637#p5637</guid>
		</item>
		<item>
			<title><![CDATA[Проблема с сервоприводом MG945 ESP32]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=5635#p5635</link>
			<description><![CDATA[<p>//////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; RemoteXY include library&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />//////////////////////////////////////////////<br />volatile bool buttonPressed = false;</p><p>// определение режима соединения и подключение библиотеки RemoteXY<br />#define REMOTEXY_MODE__WIFI_POINT</p><p>#include &lt;WiFi.h&gt;<br />#include &lt;ESP32Servo.h&gt; </p><p>Servo myservo;</p><p>// настройки соединения<br />#define REMOTEXY_WIFI_SSID &quot;HummerBot1&quot;<br />#define REMOTEXY_WIFI_PASSWORD &quot;HummerBot1&quot;<br />#define REMOTEXY_SERVER_PORT 6377</p><br /><p>#include &lt;RemoteXY.h&gt;</p><p>// конфигурация интерфейса RemoteXY<br />#pragma pack(push, 1)<br />uint8_t RemoteXY_CONF[] =&nbsp; // 45 bytes<br />&nbsp; { 255, 3, 0, 0, 0, 38, 0, 17, 0, 0, 0, 31, 1, 200, 84, 1, 1, 2, 0, 5,<br />&nbsp; &nbsp; 19, 10, 60, 60, 32, 16, 28, 31, 1, 140, 27, 24, 24, 1, 16, 1, 208, 163, 208, 180,<br />&nbsp; &nbsp; 208, 176, 209, 128, 0 };</p><p>// структура определяет все переменные и события вашего интерфейса управления<br />struct {</p><p>&nbsp; // input variables<br />&nbsp; int8_t stick_x;&nbsp; // oт -100 до 100<br />&nbsp; int8_t stick_y;&nbsp; // oт -100 до 100<br />&nbsp; uint8_t hummer;&nbsp; // =1 если кнопка нажата, иначе =0</p><p>&nbsp; // other variable<br />&nbsp; uint8_t connect_flag;&nbsp; // =1 if wire connected, else =0</p><p>} RemoteXY;<br />#pragma pack(pop)</p><p>/////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END RemoteXY include&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />/////////////////////////////////////////////<br />#define LED 27<br />#define BTN 23<br />int servoPin = 18;<br />int ADC_Max = 4096; </p><p>/* определяем пины управления правым мотором */<br />#define RIGHT_UP 32<br />#define RIGHT_DN 33<br />#define PIN_MOTOR_RIGHT_SPEED 10</p><p>/* определяем пины управления левым мотором */<br />#define LEFT_UP 26<br />#define LEFT_DN 25<br />#define PIN_MOTOR_LEFT_SPEED 10</p><p>/* определяем два массива с перечислением пинов для каждого мотора */<br />unsigned char RightMotor[3] = { RIGHT_UP, RIGHT_DN, PIN_MOTOR_RIGHT_SPEED };<br />unsigned char LeftMotor[3] = { LEFT_UP, LEFT_DN, PIN_MOTOR_LEFT_SPEED };</p><p>/*<br />&nbsp; &nbsp;управление скоростью мотора<br />&nbsp; &nbsp;motor - ссылка на массив пинов<br />&nbsp; &nbsp;v - скорость мотора, может принимать значения от -100 до 100<br />*/<br />void Wheel(unsigned char* motor, int v) {<br />&nbsp; if (v &gt; 100) v = 100;<br />&nbsp; if (v &lt; -100) v = -100;<br />&nbsp; if (v &gt; 0) {<br />&nbsp; &nbsp; digitalWrite(motor[0], HIGH);<br />&nbsp; &nbsp; digitalWrite(motor[1], LOW);<br />&nbsp; &nbsp; analogWrite(motor[2], v * 2.55);<br />&nbsp; } else if (v &lt; 0) {<br />&nbsp; &nbsp; digitalWrite(motor[0], LOW);<br />&nbsp; &nbsp; digitalWrite(motor[1], HIGH);<br />&nbsp; &nbsp; analogWrite(motor[2], (-v) * 2.55);<br />&nbsp; } else {<br />&nbsp; &nbsp; digitalWrite(motor[0], LOW);<br />&nbsp; &nbsp; digitalWrite(motor[1], LOW);<br />&nbsp; &nbsp; analogWrite(motor[2], 0);<br />&nbsp; }<br />}</p><p>void setup() {<br />&nbsp; Serial.begin(115200);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; ESP32PWM::allocateTimer(0);<br />&nbsp; &nbsp; &nbsp; &nbsp; ESP32PWM::allocateTimer(1);<br />&nbsp; &nbsp; ESP32PWM::allocateTimer(2);<br />&nbsp; &nbsp; ESP32PWM::allocateTimer(3);<br />&nbsp; myservo.setPeriodHertz(50);// Standard 50hz servo<br />&nbsp; myservo.attach(servoPin, 1000, 2000); //MG945</p><p>&nbsp; /* инициализация пинов */<br />&nbsp; pinMode(RIGHT_UP, OUTPUT);<br />&nbsp; pinMode(RIGHT_DN, OUTPUT);<br />&nbsp; pinMode(LEFT_UP, OUTPUT);<br />&nbsp; pinMode(LEFT_DN, OUTPUT);<br />&nbsp; pinMode(BTN, INPUT_PULLUP);<br />&nbsp; pinMode(LED, OUTPUT);<br />&nbsp; attachInterrupt(digitalPinToInterrupt(BTN), handleButtonPress, CHANGE);</p><p>&nbsp; /* инициализация модуля RemoteXY */<br />&nbsp; RemoteXY_Init();<br />}</p><p>void loop() {<br />&nbsp; /* обработчик событий модуля RemoteXY */<br />&nbsp; RemoteXY_Handler(); </p><p>&nbsp; if(RemoteXY.hummer == 1){<br />&nbsp; &nbsp; Serial.println(&quot;Серво запускается...&quot;);<br />&nbsp; &nbsp; myservo.write(0);<br />&nbsp; &nbsp; RemoteXY_delay(1000);<br />&nbsp; &nbsp; Serial.println(&quot;Серво Выключается...&quot;);<br />&nbsp; &nbsp; myservo.write(180);<br />&nbsp; &nbsp; RemoteXY_delay(1000);<br />&nbsp; }</p><p>&nbsp; if (buttonPressed) {<br />&nbsp; &nbsp; digitalWrite(LED, HIGH);<br />&nbsp; &nbsp; RemoteXY_delay(5000);<br />&nbsp; &nbsp; digitalWrite(LED, LOW);<br />&nbsp; &nbsp; buttonPressed = false;<br />&nbsp; }<br />&nbsp; <br />&nbsp; Wheel(RightMotor, RemoteXY.stick_y - RemoteXY.stick_x);<br />&nbsp; Wheel(LeftMotor, RemoteXY.stick_y + RemoteXY.stick_x);<br />}</p><p>void handleButtonPress() {<br />&nbsp; buttonPressed = true;&nbsp; // Устанавливаем флаг нажатия кнопки в true<br />}</p><br /><br /><br /><br /><br /><br /><p>Моторы двигаются а сервопривод нет.<br />Я загружаю нажимаю на кнопку serial принт выводит что серва вкл после выкл но при этом никаких действий что делать помогите второй день решаю??</p>]]></description>
			<author><![CDATA[null@example.com (canvova)]]></author>
			<pubDate>Sun, 11 Aug 2024 16:27:58 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=5635#p5635</guid>
		</item>
	</channel>
</rss>
