user81470: so basically I am using 4 servo motors for our robotic arm and 1 l298n motor driver for 2 motor drive for base of the arm. when I individually tested robotic arm and controlled 4 servo motors, it worked perfectly fine, at the same time when i tested linear motion with motor driver individually it also worked fine. But when I combined them only servos are working but l298n doesn't. when I comment out servos.attach() line, then again motor driver works. Pins are different. That's why even I couldn't figure out why am i getting this issue.
#include <WiFi.h>
#include <WebServer.h>
#include <Robojax_L298N_DC_motor.h>
#include<Servo.h>

WebServer server(80);
Servo myservo,shoulder,elbow,wrist;
int grippos=0,shoulderpos=0,elbowpos=0,wristpos=0;



// motor 1 settings
#define CHA 0
#define ENA 19 // this pin must be PWM enabled pin if Arduino board is used
#define IN1 18
#define IN2 5

// motor 2 settings
#define IN3 15
#define IN4 2
#define ENB 4// this pin must be PWM enabled pin if Arduino board is used
#define CHB 1

const int CCW = 2; // do not change
const int CW  = 1; // do not change

#define motor1 1 // do not change
#define motor2 2 // do not change

String prev="";

Robojax_L298N_DC_motor robot(IN1, IN2, ENA, CHA,  IN3, IN4, ENB, CHB);

void gripopen()
{
  Serial.println("open");
  grippos+=30;
  if(grippos>180)
  {
    grippos=180;
  }
  myservo.write(grippos);
  
}

void gripclose()
{
  grippos-=30;
  Serial.println("close");

  if(grippos<0)
  {
    grippos=0;
  }
  myservo.write(grippos);
  
}

void wristleft()
{
  wristpos-=30;
  Serial.println("wristleft");
  if(wristpos<0)
  {
    wristpos=0;
  }
  wrist.write(wristpos);
}

void wristright()
{
  Serial.println("wristright");
  wristpos+=30;
  if(wristpos>180)
  {
    wristpos=180;
  }
  wrist.write(wristpos);
}

void elbowup()
{
  Serial.println("elbow up");
  elbowpos+=15;
  if(elbowpos>180)
  {
    elbowpos=180;
  }
  elbow.write(elbowpos);
}

void elbowdown()
{
  Serial.println("elbow down");
  elbowpos-=15;
  if(elbowpos<0)
  {
    elbowpos=0;
  }
  elbow.write(elbowpos);
}

void shoulderup()
{
  Serial.println("shoulder up");
  shoulderpos+=15;
  if(shoulderpos>180)
  {
    shoulderpos=180;
  }
  shoulder.write(shoulderpos);
}

void shoulderdown()
{
  Serial.println("shoulder down");
  shoulderpos-=15;
  if(shoulderpos<0)
  {
    shoulderpos=180;
  }
  shoulder.write(shoulderpos);
}

void forward()
{
    Serial.println("forward");
    robot.rotate(motor1,100,CW);
    robot.rotate(motor2,100,CCW);
  
Serial.println("end reached");
  
}

void backward()
{
    Serial.println("backward");
        robot.rotate(motor1,100,CCW);
    robot.rotate(motor2,100,CW);
  Serial.println("end reached");
  
}

void left()
{
    Serial.println("left");
        robot.rotate(motor1,100,CW);
    robot.rotate(motor2,100,CW);
Serial.println("end reached");
  
}

void right()
{
    Serial.println("right");
      robot.rotate(motor1,100,CCW);
    robot.rotate(motor2,100,CCW);
Serial.println("end reached");
  
}

void stopbot()
{
  Serial.println("stopbot");
  robot.brake(1);
  robot.brake(2);
  prev="";
  Serial.println("end reached");
}

void reset()
{
  myservo.write(0);
  shoulder.write(0);
  elbow.write(0);
  wrist.write(0);
}

void handleRoot() {
  server.send(200, "text/plain", "Ready");
}

void handleGet() {
  if (server.hasArg("data")) {
    String data = server.arg("data");
    if(data=="gripper_open")
    {
      gripopen();
    }
    else if(data=="reset")
    {
      Serial.println("Reset");
    }
    else if(data=="Stop")
    {
      stopbot();
    }
    else if(data=="Forward")
    {
     // forward();
      if(prev!=data)
      {
        forward();
        prev=data;
      }
    }
    else if(data=="Backward")
    {
     // backward();
      if(prev!=data)
      {
        backward();
        prev=data;
      }
    }
    else if(data=="Left")
    {
      //left();
      if(prev!=data)
      {
        left();
        prev=data;
      }
    }
    else if(data=="Right")
    {
      //right();
      if(prev!=data)
      {
        right();
        prev=data;
      }
    }
    else if(data=="gripper_close")
    {
      gripclose();
    }
    else if(data=="elbow_up")
    {
      elbowup();
    }
    else if(data=="elbow_down")
    {
      elbowdown();
    }
    else if(data=="shoulder_up")
    {
      shoulderup();
    }
    else if(data=="shoulder_down")
    {
      shoulderdown();
    }
    else if(data=="Wrist_left")
    {
      wristleft();
    }
    else if(data=="Wrist_right")
    {
      wristright();
    }
    Serial.println("Data: " + data);
   
  }
  server.send(200, "text/plain", "Data Received");
}

void handlePost() {
    if (server.hasArg("data")) {
    String data = server.arg("data");
    Serial.println("Data: " + data);
  }
 // server.send(200, "text/plain", "Data Received");
  server.send(200, "text/plain", "Processing Data");
}

void handleUpload() {
  HTTPUpload& upload = server.upload();
  if (upload.status == UPLOAD_FILE_START) {
    Serial.println("Receiving data:");
  } else if (upload.status == UPLOAD_FILE_WRITE) {
    Serial.write(upload.buf, upload.currentSize);
  } else if (upload.status == UPLOAD_FILE_END) {
    server.send(200, "text/plain", "Data: ");
  }
}

void setup() {
  Serial.begin(9600);
  WiFi.softAP("ESP32");
  myservo.attach(13);
  shoulder.attach(12);
  elbow.attach(14);
  wrist.attach(27);
  
  
  myservo.write(0);
  shoulder.write(0);
  elbow.write(0);
  wrist.write(0);

  // motordriver pins
  robot.begin();
  
  server.on("/", handleRoot);
  server.on("/get", HTTP_GET, handleGet);
  server.on("/pot", HTTP_POST,handlePost);
  server.begin();
}

void loop() {
  server.handleClient();
}

I am receiving correct data from the app. That also I had cross-checked. If anyone can help with this or guide me how can i solve this issue.

user82299: Hi I have the same problem here, and everything is pointing the issue could be related with the channels shared for PWM. In the Robojax lib there is control of channels want to assign for each motor, but in the ESP32Servo the channels are assigned automatically by the library in consecutive order (see ESP32PWM.cpp). I would try use different channel when calling Robojax that doesn't make conflict with the amount of Servo controlled, maybe could help. For instance in my case I have one servo and 2 DC motors controlled by LN98. So the servo is using channel 0 for PWM, the other two motors on Robojax I will try CHA= 2 and CHB = 3. Maybe this could help.
There are timers shared is explained on the ESP32PWM.cpp, line 259, but I believe the channels conflicts is what is causing this issue.
I will try and let you know. Thanks
I already finished, and for me it is working now. Just need to change CHA and CHB to different PWM channel number (0-15), but > than the amount of servo you have. thanks

81470: <p>so basically I am using 4 servo motors for our robotic arm and 1 l298n motor driver for 2 motor drive for base of the arm. when I individually tested robotic arm and controlled 4 servo motors, it worked perfectly fine, at the same time when i tested linear motion with motor driver individually it also worked fine. But when I combined them only servos are working but l298n doesn't. when I comment out servos.attach() line, then again motor driver works. Pins are different. That's why even I couldn't figure out why am i getting this issue.</p>
<pre><code>#include &lt;WiFi.h&gt;
#include &lt;WebServer.h&gt;
#include &lt;Robojax_L298N_DC_motor.h&gt;
#include&lt;Servo.h&gt;

WebServer server(80);
Servo myservo,shoulder,elbow,wrist;
int grippos=0,shoulderpos=0,elbowpos=0,wristpos=0;



// motor 1 settings
#define CHA 0
#define ENA 19 // this pin must be PWM enabled pin if Arduino board is used
#define IN1 18
#define IN2 5

// motor 2 settings
#define IN3 15
#define IN4 2
#define ENB 4// this pin must be PWM enabled pin if Arduino board is used
#define CHB 1

const int CCW = 2; // do not change
const int CW  = 1; // do not change

#define motor1 1 // do not change
#define motor2 2 // do not change

String prev=&quot;&quot;;

Robojax_L298N_DC_motor robot(IN1, IN2, ENA, CHA,  IN3, IN4, ENB, CHB);

void gripopen()
{
  Serial.println(&quot;open&quot;);
  grippos+=30;
  if(grippos&gt;180)
  {
    grippos=180;
  }
  myservo.write(grippos);
  
}

void gripclose()
{
  grippos-=30;
  Serial.println(&quot;close&quot;);

  if(grippos&lt;0)
  {
    grippos=0;
  }
  myservo.write(grippos);
  
}

void wristleft()
{
  wristpos-=30;
  Serial.println(&quot;wristleft&quot;);
  if(wristpos&lt;0)
  {
    wristpos=0;
  }
  wrist.write(wristpos);
}

void wristright()
{
  Serial.println(&quot;wristright&quot;);
  wristpos+=30;
  if(wristpos&gt;180)
  {
    wristpos=180;
  }
  wrist.write(wristpos);
}

void elbowup()
{
  Serial.println(&quot;elbow up&quot;);
  elbowpos+=15;
  if(elbowpos&gt;180)
  {
    elbowpos=180;
  }
  elbow.write(elbowpos);
}

void elbowdown()
{
  Serial.println(&quot;elbow down&quot;);
  elbowpos-=15;
  if(elbowpos&lt;0)
  {
    elbowpos=0;
  }
  elbow.write(elbowpos);
}

void shoulderup()
{
  Serial.println(&quot;shoulder up&quot;);
  shoulderpos+=15;
  if(shoulderpos&gt;180)
  {
    shoulderpos=180;
  }
  shoulder.write(shoulderpos);
}

void shoulderdown()
{
  Serial.println(&quot;shoulder down&quot;);
  shoulderpos-=15;
  if(shoulderpos&lt;0)
  {
    shoulderpos=180;
  }
  shoulder.write(shoulderpos);
}

void forward()
{
    Serial.println(&quot;forward&quot;);
    robot.rotate(motor1,100,CW);
    robot.rotate(motor2,100,CCW);
  
Serial.println(&quot;end reached&quot;);
  
}

void backward()
{
    Serial.println(&quot;backward&quot;);
        robot.rotate(motor1,100,CCW);
    robot.rotate(motor2,100,CW);
  Serial.println(&quot;end reached&quot;);
  
}

void left()
{
    Serial.println(&quot;left&quot;);
        robot.rotate(motor1,100,CW);
    robot.rotate(motor2,100,CW);
Serial.println(&quot;end reached&quot;);
  
}

void right()
{
    Serial.println(&quot;right&quot;);
      robot.rotate(motor1,100,CCW);
    robot.rotate(motor2,100,CCW);
Serial.println(&quot;end reached&quot;);
  
}

void stopbot()
{
  Serial.println(&quot;stopbot&quot;);
  robot.brake(1);
  robot.brake(2);
  prev=&quot;&quot;;
  Serial.println(&quot;end reached&quot;);
}

void reset()
{
  myservo.write(0);
  shoulder.write(0);
  elbow.write(0);
  wrist.write(0);
}

void handleRoot() {
  server.send(200, &quot;text/plain&quot;, &quot;Ready&quot;);
}

void handleGet() {
  if (server.hasArg(&quot;data&quot;)) {
    String data = server.arg(&quot;data&quot;);
    if(data==&quot;gripper_open&quot;)
    {
      gripopen();
    }
    else if(data==&quot;reset&quot;)
    {
      Serial.println(&quot;Reset&quot;);
    }
    else if(data==&quot;Stop&quot;)
    {
      stopbot();
    }
    else if(data==&quot;Forward&quot;)
    {
     // forward();
      if(prev!=data)
      {
        forward();
        prev=data;
      }
    }
    else if(data==&quot;Backward&quot;)
    {
     // backward();
      if(prev!=data)
      {
        backward();
        prev=data;
      }
    }
    else if(data==&quot;Left&quot;)
    {
      //left();
      if(prev!=data)
      {
        left();
        prev=data;
      }
    }
    else if(data==&quot;Right&quot;)
    {
      //right();
      if(prev!=data)
      {
        right();
        prev=data;
      }
    }
    else if(data==&quot;gripper_close&quot;)
    {
      gripclose();
    }
    else if(data==&quot;elbow_up&quot;)
    {
      elbowup();
    }
    else if(data==&quot;elbow_down&quot;)
    {
      elbowdown();
    }
    else if(data==&quot;shoulder_up&quot;)
    {
      shoulderup();
    }
    else if(data==&quot;shoulder_down&quot;)
    {
      shoulderdown();
    }
    else if(data==&quot;Wrist_left&quot;)
    {
      wristleft();
    }
    else if(data==&quot;Wrist_right&quot;)
    {
      wristright();
    }
    Serial.println(&quot;Data: &quot; + data);
   
  }
  server.send(200, &quot;text/plain&quot;, &quot;Data Received&quot;);
}

void handlePost() {
    if (server.hasArg(&quot;data&quot;)) {
    String data = server.arg(&quot;data&quot;);
    Serial.println(&quot;Data: &quot; + data);
  }
 // server.send(200, &quot;text/plain&quot;, &quot;Data Received&quot;);
  server.send(200, &quot;text/plain&quot;, &quot;Processing Data&quot;);
}

void handleUpload() {
  HTTPUpload&amp; upload = server.upload();
  if (upload.status == UPLOAD_FILE_START) {
    Serial.println(&quot;Receiving data:&quot;);
  } else if (upload.status == UPLOAD_FILE_WRITE) {
    Serial.write(upload.buf, upload.currentSize);
  } else if (upload.status == UPLOAD_FILE_END) {
    server.send(200, &quot;text/plain&quot;, &quot;Data: &quot;);
  }
}

void setup() {
  Serial.begin(9600);
  WiFi.softAP(&quot;ESP32&quot;);
  myservo.attach(13);
  shoulder.attach(12);
  elbow.attach(14);
  wrist.attach(27);
  
  
  myservo.write(0);
  shoulder.write(0);
  elbow.write(0);
  wrist.write(0);

  // motordriver pins
  robot.begin();
  
  server.on(&quot;/&quot;, handleRoot);
  server.on(&quot;/get&quot;, HTTP_GET, handleGet);
  server.on(&quot;/pot&quot;, HTTP_POST,handlePost);
  server.begin();
}

void loop() {
  server.handleClient();
}
</code></pre>
<p>I am receiving correct data from the app. That also I had cross-checked. If anyone can help with this or guide me how can i solve this issue.</p>
 82299: <p>Hi I have the same problem here, and everything is pointing the issue could be related with the channels shared for PWM. In the Robojax lib there is control of channels want to assign for each motor, but in the ESP32Servo the channels are assigned automatically by the library in consecutive order (see ESP32PWM.cpp). I would try use different channel when calling Robojax that doesn't make conflict with the amount of Servo controlled, maybe could help. For instance in my case I have one servo and 2 DC motors controlled by LN98. So the servo is using channel 0 for PWM, the other two motors on Robojax I will try CHA= 2 and CHB = 3. Maybe this could help.</p>
<p>There are timers shared is explained on the ESP32PWM.cpp, line 259, but I believe the channels conflicts is what is causing this issue.</p>
<p>I will try and let you know. Thanks</p>
<p>I already finished, and for me it is working now. Just need to change CHA and CHB to different PWM channel number (0-15), but &gt; than the amount of servo you have. thanks</p>
