Go Down

Topic: Sleeping Servo using Photocell (Read 528 times) previous topic - next topic

james_scott74

Hi Guys,

I'm hoping somebody can help me with the code to put a servo to sleep during a set range of light using a photocell.

I'm using the servo to open a chicken coop door when the sun comes up and close when the sun goes down.

I followed the steps from:
https://duino4projects.com/arduino-tutorial-photocell/

I changed the degree of the servo to 0,90 so the servo only opens to 90 degrees. 
The circuit works perfectly however I found after 30minutes the MG995 servo is extremely hot.
I am purchasing some buck converters as I'm currently running it from a 7.2V RC Car battery via the Arduino uno and will be switching to a 12V battery (connected to a solar panel) but to conserve power I would like the servo to sleep when the light exceeds a certain level (after the door opens) and then wake (just prior to the door closing).


Would anybody be able to assist with the code for the sleep during these parameters?


Thank you

Paul_KD7HB

No such think as sleeping a servo.

I am guessing you use the servo to hold the door open. If you did "sleep" the servo, the door would close. Right?

Paul

james_scott74

Hi Paul,

Spot on.  I want the door to stay open.  If the servo is overheating now whilst running 5v of power from the Arduino, am I right in assuming the MP2307 buck converter will not solve the issue by drawing 5v directly from the 12v battery?

Is there any other way to resolve the issue of overheating?

jremington

#3
Feb 11, 2019, 02:10 am Last Edit: Feb 11, 2019, 02:11 am by jremington
You should NEVER attempt to power a servo from the Arduino 5V. That output is designed for sensors, not motors and servos. Always use a separate servo power supply and connect the grounds.

Make sure that you did not run the servo into an end stop, and that the load not too large for the servo.

james_scott74

Thanks Mark,

Yes I'm learning that as I go.  I followed the steps on the tutorial which used the Arduino 5v as a power source.  I have ordered some buck converters and will wire it up separately but I'm not sure if that will solve the issue of overheating.  The door will remain open for up to 14 hours in summer.  It's a long time for the servo to be in that state. 
I'm welcome to any other suggestions.  I have several stepper motors on hand if this is a better way to open and close a door. 

jremington

Quote
I followed the steps on the tutorial which used the Arduino 5v as a power source.
Obviously written by someone who has no idea what he/she is doing. Good luck!

Paul_KD7HB

Time to redesign your door open mechanism. The servo should rotate an arm that will go "over center" so the door will stay open when the servo has no power. Then power it up and rotate the other way to close the door. You surely don't continue to power the servo when the door is closed. Then why do it when the door is open?

Paul

james_scott74

As Jremington so bluntly said - I have no idea what I'm doing, hence looking at tutorials to learn.

Paul - what do you mean by over center?  I'm currently turning it 90 degrees to open the door.  I had the same issue when I had it set to 0, 179 for the 180 degree turn. 

jremington

#8
Feb 11, 2019, 03:39 am Last Edit: Feb 11, 2019, 03:45 am by jremington
Quote
As Jremington so bluntly said - I have no idea what I'm doing, hence looking at tutorials to learn.
Sorry, I was referring to the tutorial writer. About 95% of the servo problems reported on this forum are due to beginners trying to follow bad advice, such as using the 5V Arduino output to power a servo.

Hobby servos are not suitable for outdoor projects like chicken coops. Most people use worm gear motors or linear actuators for chicken coop doors, as they hold position even under load, when the power is off. You will need a suitable motor driver for those options, and a good motor power supply.

However, if the door is properly counterbalanced, no power is required to hold it open or closed.

Here is a description of a sturdy automated chicken coop featuring a linear actuator.

Paul_KD7HB

As Jremington so bluntly said - I have no idea what I'm doing, hence looking at tutorials to learn.

Paul - what do you mean by over center?  I'm currently turning it 90 degrees to open the door.  I had the same issue when I had it set to 0, 179 for the 180 degree turn. 
But, did you turn the power to the servo -off- when the door reached fully open? I guess I can't get a mental picture of your arrangement.

Paul

james_scott74

Hi Guys,

I see what you're getting at now.  No the power was not switched off to the servo when it was fully open at 180 degrees.  The way I have the door on a hinged swing system it cannot physically open to 180 degrees.  I used 180 during the test phase before I attached it to the door.


Just so Jremington can have a laugh I also made the mistake of following the tutorial and putting the LED near the photocell.  This of cause would send a message to the photocell to go onto the next bit of code and which was turn the LED off.  This little loop made it look like bad wiring when in fact it is just bad placement of components.  Took me a few hours as a newbie to figure out.



I also have access to a few Nema 17 stepper motors if that would be a better option.
I'm assuming the 28BYJ-48 isn't going to be suitable for this application either even in conjunction with some limiting switches to switch it on and off. 

Robin2

Paul - what do you mean by over center? 
Try this...

Get something heavy that you can easily hold in your hand - for example hold a hammer by its head.

Put your elbow on a table and hold  your arm extended so your hand (and the weight) is about about 2 inches above the table. It quickly gets very tiring.

Now lift your arm so your hand (and the weight) are vertically above your elbow. The load is now trivially easy to hold because there is no leverage pulling the weight down. Your arm is "over centre".

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

jremington

#12
Feb 11, 2019, 05:15 pm Last Edit: Feb 11, 2019, 05:16 pm by jremington
Quote
I also have access to a few Nema 17 stepper motors if that would be a better option.
Not a good idea. Steppers are very inefficient, and must be powered at all times to maintain position, unless heavily geared down.

Go Up