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.