Go Down

Topic: Should I use a transistor? (Read 1 time) previous topic - next topic

c131frdave

I'm working on a little project.  I have an arduino Uno (at the moment) controlling two servos that move a big Santa.  The Santa moves certain ways as you get closer to him.  Kinda creepy, I know... 

One of the servos moves his arm, but I noticed that when the arm is in the bottom position and resting against a physical stop, if you bump the arm, the servo starts making noise. I'm assuming that the "encoder" is sensing that the servo arm is a hair off, and is attempting to compensate.  It happens with my RC airplanes all the time- it goes away when you bump the control stick or it will just settle out on its own.  But in this case, the servo isn't settling out unless you cause the arm to "cycle" by standing in front of the sensor that controls the whole thing.  This could be dangerous if I leave it on unattended.  I'm worried that the servo will "come on" and burn up, possibly catching fire.

Would it make sense to put a transistor between the voltage regulator and servo wire?  Then I could have the arduino turn off the power output to the servo when it should be at rest.  I have absolutly zero experience with transistors- I just read about them in my "Getting Started with Arduino" book.  Are there transistors that can handle a 400ma 6V servo?  Thanks!

c131frdave

Wow, just went to Mouser and did a search for "transistor" and got smacked in the face.  I have no idea where to start... 

ash901226

wow you really are into hobby servos. if i am not mistaken you could do that in the software
using detach function
http://arduino.cc/en/Reference/ServoDetach
this function as to stop giving the servo pulse to continue holding that position.
then when you want to use that servo again use the attach function again
http://arduino.cc/en/Reference/ServoAttach
theres another function of servo that is attached. this is just to varify that the port is not use for servo and not other things.
http://arduino.cc/en/Reference/ServoAttached
so you might not need the transistor. Hope someone could verify this but i am certain that this might do the trick

c131frdave

I've been into RC airplanes for a long time and have about 100 of them sitting around.  Just out of curiosity, do you have a better solution?  The hobby servo just seems so convenient since it's already in a complete assembly and only has three wires, power, gnd, and signal. 

I'll try the detach thing and see if it works.  Thanks.

c131frdave

#4
Dec 06, 2012, 05:30 pm Last Edit: Dec 06, 2012, 05:33 pm by c131frdave Reason: 1
I got an error for some reason when I tried it.  The line of code is:

myservo.detach(9);

The Error is:

no matching function for call to 'Servo::detach(int)'
Win_program_draft.ino: In function 'void loop()':
Win_program_draft:128: error: no matching function for call to 'Servo::detach(int)'
C:\Users\Dave\Downloads\arduino-1.0.2\libraries\Servo/Servo.h:114: note: candidates are: void Servo::detach()

ash901226

sorry for my remark. i just saying this cause most of your post is about hobby servo. i have no expereince with hobby servo what so ever.

c131frdave

No need to be sorry.  If there's a better way, I'm more than eager to know it.   :D  Can't figure out the detach thing though. :(

ash901226

you dont have to specify the pin you want to detach, the name if that pin is enough
Code: [Select]
myservo.detach();

c131frdave

#8
Dec 06, 2012, 05:38 pm Last Edit: Dec 06, 2012, 05:40 pm by c131frdave Reason: 1
Awesome!  Worked perfectly.  Thanks!


Edit:  Spoke too soon.  When he moves his arm up and the servo shuts off, the arm drops.  lol  Nothing I can't fix in the code, but I thought it was kind of funny to watch.  lol

ash901226

IMHO, i am more or less leaning toward Dc motor,H bridge and an encoder/ pot if the angle is kinda not need to be continuous.

ash901226

welcome, just glad i could help

c131frdave

Got it!  Works exactly like I hoped.  Thanks pal!

ash901226

could you post all of your code, let me see if i could help you

Go Up