Jkutil18
Posts: 5
Joined: Fri Jul 11, 2014 12:20 pm

Observatory Shutter Opener

Fri Jul 11, 2014 12:28 pm

Hello,

I am a RPi beginner currently working on a project to use a raspberry pi to open the shutters (doors that slide out of the way so the telescope is open to the sky) in an observatory I work at. These shutters are presently opened and closed with a small motor. As these shutters are very similar to a garage door, I have used this Instructables post as a guideline: http://www.instructables.com/id/Web-Ena ... spberry-Pi . I have completed the .html aspect of the web site but am stuck in writing the .php code. The guide I'm using only has one button for open/close of a garage door while I am using three buttons: open, stop, and close. Could anyone tell me how to write the proper code for these processes?

Jkutil18
Posts: 5
Joined: Fri Jul 11, 2014 12:20 pm

Re: Observatory Shutter Opener

Fri Jul 11, 2014 12:36 pm

P.S. here is my html code:

Code: Select all

<html><body>
<h1 style="font-size:500%;text-align:center;">Tower 2 Controls<h1>
<form action>=”ShutterO.php” method=”get”>
<div style="text-align:center">
  <h4><input type="submit" value="OPEN SHUTTER" style="width:250px; height:50px;font-size:27px;color:white;border-radius: 25px; background-color: 0B243B;"><h4>
</div>
<form action>=”ShutterS.php” method=”get”>
<div style="text-align:center">
  <h4><b><input type="submit" value="STOP" style="width:150px; height:150px;font-size:50px;color:white;align:center;border-radius: 25px; background-color: red;"></b><h4>
<form action>=”ShutterC.php” method=”get”>
</div>
<div style="text-align:center">
  <h4><input type="submit" value="CLOSE SHUTTER" style="width:250px; height:50px;font-size:27px;color:white;border-radius: 25px; background-color: 0B243B;"><h4>
</div>
</form>
</body></html>

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Observatory Shutter Opener

Fri Jul 11, 2014 12:50 pm

Jkutil18 wrote:Hello,

I am a RPi beginner currently working on a project to use a raspberry pi to open the shutters (doors that slide out of the way so the telescope is open to the sky) in an observatory I work at. These shutters are presently opened and closed with a small motor. As these shutters are very similar to a garage door, I have used this Instructables post as a guideline: http://www.instructables.com/id/Web-Ena ... spberry-Pi . I have completed the .html aspect of the web site but am stuck in writing the .php code. The guide I'm using only has one button for open/close of a garage door while I am using three buttons: open, stop, and close. Could anyone tell me how to write the proper code for these processes?
Yes.

First, forget about HTML and PHP.

Do you have the hardware to control the shutters? Is it hooked up to the Pi? Can you use the command line or a simple Python script to open or close the shutters, and stop the process at any time?

Do you have detector switches at the open and closed shutter positions? Can you read the state with the Pi? Does your code detect the switch closures and turn off the motor power?

Do you also have limit switches connected to the motor that will safely stop the motor independently of the Pi? This is important if the Pi should crash or someone should deliberately or accidentally take control of the Pi and drive the motor.

You'll probably have two GPIOs in use for this project, controlling two relays. Either one for motor direction and one for motor on/off, or one each for two relays wired up so that they can reverse the motor.

You should also have a Big Red Switch to disconnect motor power inside the observatory. I guarantee that your smartphone web browser will crash just after you notice an obstacle in the path of the doors.

Anyway, once you have the relays wired up it's a simple matter of doing this:
Open: Set GPIOs to turn motor direction to open, turn motor on until open limit switch is actuated.
Close: Set GPIOs to turn motor direction to close, turn motor on until close limit switch is actuated.
Stop: Set GPIOs to turn motor off.

You can write 3 php routines for this, or a Python cgi script, or something.

Jkutil18
Posts: 5
Joined: Fri Jul 11, 2014 12:20 pm

Re: Observatory Shutter Opener

Fri Jul 11, 2014 1:30 pm

The Pi is my currently connected to the motor, it is at my house where I am trying to program it. The motor does have limit switches and it is fully capable of being operated apart from the pi. I have the hardware to set it up, but my problem is with the coding. I have never coded before in my life and I am lost on how to write the .php files as to complete these processes. It was easy to find the correct command terms for the .html document, but I am having a harder time finding the proper commands an syntax for these .php executions.

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

Re: Observatory Shutter Opener

Fri Jul 11, 2014 2:08 pm

I imagine from your previous replies that pushing and releasing the open button would cause the shutter to start to open, until stopped by either the motor end stop or you pushing the stop button? Pushing and releasing the close button would cause the shutter to move toward the close position until reaching the end stop position or stop button is pushed.

Assuming that to be the case you would need to wire up 3 relays as shown in the instructable, each with its own GPIO pin and create 3 (identical in all but name) PHP files (as shown in the example), 1 to open the shutter, 1 to close it and 1 to stop it at any point in its travel.
Doug.
Building Management Systems Engineer.

Jkutil18
Posts: 5
Joined: Fri Jul 11, 2014 12:20 pm

Re: Observatory Shutter Opener

Fri Jul 11, 2014 3:03 pm

Doug,

Thank you very much. How would I distinguish between gpio pin in the .php code?

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Observatory Shutter Opener

Sat Jul 12, 2014 12:51 pm

Jkutil18 wrote:Doug,

Thank you very much. How would I distinguish between gpio pin in the .php code?
Here is the code from the instructable:

Code: Select all

<?php
$on = 'gpio mode 0 out';
$off = 'gipo mode 0 in';
$command = 'gpio write 0 1';
$command2 = 'gpio write 0 0';
exec($on);
exec($command);
sleep(2);
exec($command2);
exec($off);
header ("Location: Garage.html");
?>
The gpio instruction contains the GPIO number, and the value to write (1 = on, 0 = off). As you can see, GPIO 0 is used for this example. If you wire your relays to different number GPIOs, change the first digit of the gpio command. You could make 3 different php routines with different IOs, called from different buttons on the web page.

Jkutil18
Posts: 5
Joined: Fri Jul 11, 2014 12:20 pm

Re: Observatory Shutter Opener

Mon Jul 14, 2014 2:24 am

Thank you

Return to “Automation, sensing and robotics”