Servo Data Line Noise?

Brento
Posts: 21
Joined: Mon Apr 20, 2020 10:02 am

Servo Data Line Noise?

Postby Brento » Thu Jun 10, 2021 4:55 am

I am having a really bizarre issue with an MG996R servo, controlled by an ESP32-D2WD.

Completely intermittently (once or twice a day, running all day), and without making a call to any Servo class methods, it will jump around. AFAIK know, the power is stable. But, I am wondering if perhaps some noise on the data pin is causing it. It's a very LARGE software application, so, I won't include the dozens of files here. Included is the simplest version. That said, I can tell you none directly share this pin, but, I do have a timer, serial, other PWM and TFT software running here. None, however access the Servo pin.

Code: Select all

#include <ESP32Servo.h>
#define GATE_PIN				13
#define GATE_CHANNEL			5
Servo _Gate;
..
void setup()
{
	..other stuff..

	ESP32PWM::allocateTimer(GATE_CHANNEL);
	_Gate.setPeriodHertz(50);
}

void loop()
{
	..other stuff..

	//This code is the ONLY thing that SHOULD make it move
	//However, once every few hours or so, it'll move anyways (usually to 0 degree angle)
	if ( false )
	{
		_Gate.attach(GATE_PIN);
		_Gate.write(_someAngle);
		delay(500);
		_Gate.detach();
	}
	
	delay(5000);
}

Perhaps I need to use another pin? Or, maybe it's related to the channel I am using? Nothing else is using this channel, unless 5 is reserved in some internal library somewhere. Can PWM or other things be inducing noise on the Servo pin?

Who is online

Users browsing this forum: No registered users and 52 guests