0

Servo Driver Board Twitches Servos on Startup
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Servo Driver Board Twitches Servos on Startup

by JackTheSE on Sun Jan 06, 2019 11:20 am

I'm a newbie with a project to make LEGO train switches remote controlled. The pic shows the final hardware, consisting of a Nano, an AdaFruit Servo Driver, some NeoPixels to show switch direction, and an IR remote. Everything works perfectly, with one minor exception: When the system is powered on, any servo not in the full clockwise position twitches a bit. I designed the program to save the state of each switch in EEPROM, and load that info at startup. That worked perfectly when I had the servos attached directly to the Nano, using the Arduino servo library. But with the Servo Driver board and the AdaFruit servo library, I get the twitching. Apparently the library sends a command to the servos to go to their clockwise stops, as part of the library initialization. Is there any way to prevent this from happening?

IMG_0461.jpg
IMG_0461.jpg (279.65 KiB) Viewed 95 times

JackTheSE
 
Posts: 12
Joined: Wed Jan 02, 2019 8:34 pm

Re: Servo Driver Board Twitches Servos on Startup

by adafruit_support_bill on Sun Jan 06, 2019 6:47 pm

Apparently the library sends a command to the servos to go to their clockwise stops, as part of the library initialization.

The only thing the library sets during initialization is the PWM frequency.

It is not unusual for servos to twitch a little on power-up - even when not connected to any controller. You can try pulling the OE pin low until your program has a chance to initialize the PWM channels to the desired pulse width.

adafruit_support_bill
 
Posts: 71779
Joined: Sat Feb 07, 2009 10:11 am

Re: Servo Driver Board Twitches Servos on Startup

by JackTheSE on Sun Jan 06, 2019 9:30 pm

Hey, thanks for the instantaneous reply, on a Sunday yet!

Just to clarify a bit, my servos upon shutdown are in one of two states: full CCW, or full CW. Upon subsequent startup, if they are in full CW position they never twitch (pulsewidth=450 uSecs for my servos). If in full CCW position (2210 uSec) they always twitch.

So, I don't have anything connected to the OE pin, so I assume the default value is LOW, meaning output is enabled, in accordance with your discussion of Driver Board use that I read on the AdaFruit website. Sounds like I need to...
(1) connect the OE pin to one of my open digital pins on the NANO, call it, say, OEPin = 3,
(2) make it an output pin, using pinMode(OEPin,OUTPUT);
(3) pull that pin HIGH using digitalWrite(OEPin, HIGH); to disable output from the Servo Board,
(4) set all my servo positions using legoDr.setPWM(iServom1,0,initialServoPositionTics[iServom1]);
(5) pull the OE pin Low using digitalWrite(IEPin,LOW);, to enable output.

Since I'm already soldered up, I can't try this easily at the breadboard level, so that's why I'm asking. I'm certainly willing to try it, thanks...Jack

JackTheSE
 
Posts: 12
Joined: Wed Jan 02, 2019 8:34 pm

Re: Servo Driver Board Twitches Servos on Startup

by adafruit_support_bill on Sun Jan 06, 2019 10:35 pm

That sounds right. The OE pin is pulled LOW be default.

adafruit_support_bill
 
Posts: 71779
Joined: Sat Feb 07, 2009 10:11 am

Re: Servo Driver Board Twitches Servos on Startup

by JackTheSE on Mon Jan 07, 2019 4:14 am

I was able to put in a temporary jumper to the D4 pin and connect it to the OE pin on the driver board. With the code additions I outlined above, it worked. All servos are now totally quiet upon power up, no matter their initial position. They operate normally thereafter. I'll now disassemble and put in permanent wiring for OE.

So mark this problem as solved. Thanks very much for your suggestion--it was key to solving this problem...Jack

JackTheSE
 
Posts: 12
Joined: Wed Jan 02, 2019 8:34 pm

Re: Servo Driver Board Twitches Servos on Startup

by adafruit_support_bill on Mon Jan 07, 2019 7:37 am

Good to hear that is working for you. Thanks for the follow-up.

adafruit_support_bill
 
Posts: 71779
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.