-->
Page 1 of 1

Servo's and ESPs?

PostPosted: Tue Jul 12, 2016 2:15 am
by Zach Bellay
Hello everyone!

I'm working on making an automated door closer for my dorm room. Currently, I have a NodeMCU ESP running Lua and am trying to get a servo to work on this thing.

I have an outside power source, have tested the servo multiple times to ensure that it works, and have tested just about everything else. I have narrowed it to the PWM in my Lua code, but can't seem to figure out what the problem is. Here is my current, albeit lame, setup.Image

Here is the code I am executing through Lua Uploader:
Code: Select allpwm.setup(1, 544, 512)
pwm.start(1)
print("sup")
tmr.delay(5000000)
gpio.write(1, 1)


Obviously the LED is in the place of the signal input of the servo motor. I've looked at the servo library of the Arduino and ESP and both have the following constants defined.
Code: Select all#define MIN_PULSE_WIDTH       544     // the shortest pulse sent to a servo 
#define MAX_PULSE_WIDTH      2400     // the longest pulse sent to a servo
#define DEFAULT_PULSE_WIDTH  1500     // default pulse width when servo is attached


I've been trying to figure this out for months now, and I've finally decided to post on this forum. Please help!

Re: Servo's and ESPs?

PostPosted: Sat Jul 16, 2016 11:44 pm
by RaspberryPiThree
I want the servo to rotate one revolution clockwise, delay and rotate one revolution counterclockwise. What are pwm commands to do that?

Thanks

Re: Servo's and ESPs?

PostPosted: Tue Aug 02, 2016 7:55 am
by Morgan Stewart
Servos only have 180 degrees of rotation so you will not get a full revolution. Also, the PWM in your arduino code might not be correct for your specific servo, as when a servo is manually adjusted by force it could mess up the set PWM. Best way to find the max and minimum PWM to control your servo from 0 degrees to 180 degrees is to connect control wire of servo to function generator and increment/decrement the duty cycle of a square wave to find the percentage at which it reaches 0 degrees and 180 degrees.