Slodge123
Posts: 3
Joined: Sun Jan 18, 2015 5:20 pm

Motor Control issues

Sun Jan 18, 2015 5:27 pm

I'm using the instructions here http://computers.tutsplus.com/tutorials ... -cms-20051 to drive a motor to open and close a chicken coop door. It is simply a door on a piece of string which the motor winds up and down.

The issue I have is the door goes further down after 10 seconds than up in the same 10 seconds. This means ever time the door cycles it gets lower and lower until it doesn't open at all.

Is there something obvious I'm missing??

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12585
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Motor Control issues

Sun Jan 18, 2015 6:22 pm

You should add feedback to the PI in the form of switches that sense if the door is completely open, or completely closed so you can shut off the motor when it is completely open or closed.

Meaning don't rely only on motor running time!

You could suffice with only one switch, for example when it is completely close, and use timing for the opening of the door, that would usually suffice.

Slodge123
Posts: 3
Joined: Sun Jan 18, 2015 5:20 pm

Re: Motor Control issues

Sun Jan 18, 2015 9:04 pm

Ah ok, is the timing usually bad?

I would have expected it to be quite accurate?

As i'm very new to anything like this does anyone have any suggestions regarding the type of switch for feedback? possibly any advice for the wiring etc?

Thanks for any help given.

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Motor Control issues

Sun Jan 18, 2015 9:36 pm

If the door is opening upwards (against gravity) & downwards (with gravity) then, just like you or me, the motor has an easier time closing than opening.

You may get away with separate motor-on & motor-off timings which you can find by trial & error, at least for a few cycles of open/close. But even that will drift over time with other factors coming in to play, like wind, or whether the birds get to ride the gate as it moves.

For best results, as Mahjong says, employ a switch at the limit of the door's travel (open or closed, whichever has a hard mechanical stop which would otherwise strain the motor if left running). That way on each opening/closing cycle, the door will be sync'd to a known reference point.

Roller-switches are usually used in these limit-switching applications. They are usually fitted with a soft spring & a roller to minimize the activation force & any friction as the surfaces come together.

rgrbic
Posts: 128
Joined: Thu Jun 12, 2014 1:07 pm
Contact: Website

Re: Motor Control issues

Mon Jan 19, 2015 8:59 am

As mahjongg said, you don't have feedback regarding motor position. you can use mechanical swithc or reed switch for sensing open/closed door position.
At 127.0.0.1
Twitter: @rgrbic
IoT-projects.com

Slodge123
Posts: 3
Joined: Sun Jan 18, 2015 5:20 pm

Re: Motor Control issues

Sun Feb 08, 2015 8:00 pm

So I now have two scripts, doordown.py and doorup.py they work a treat and doorup.py uses a switch to stop the door. doordown.py just uses time to release the door.

The next thing I want to do is somehow call these scripts from a webpage. A simple up button and down button would be adequate for now but as ever nothing is as simple as it sounds.

How can I call the scripts from within a webpage?

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Motor Control issues

Mon Feb 09, 2015 1:34 pm

Slodge123 wrote:So I now have two scripts, doordown.py and doorup.py they work a treat and doorup.py uses a switch to stop the door. doordown.py just uses time to release the door.

The next thing I want to do is somehow call these scripts from a webpage. A simple up button and down button would be adequate for now but as ever nothing is as simple as it sounds.

How can I call the scripts from within a webpage?
have you installed the webserver yet?

I wrote up how I installed a webserver on my Pi for controlling my dalek.


This is how I would did do it:
create a php file called doordown.php and link to it in hour home web page (change the final line from home.html to whatever your home page is called).

Code: Select all

<?php
$command = "doordown.py ";

exec($command);

header ("Location: home.html");
?>
Doug.
Building Management Systems Engineer.

Return to “Automation, sensing and robotics”