Jump to content

1564402927_Comet2021Banner.jpg.a8d9e102cd65f969b635e8061096d211.jpg

Gina's Observatory Roll-Off-Roof Automation


Gina
 Share

Recommended Posts

Corresponding RPi GPIO lines :-

int rpiClosePin = A3; // Remote Close -- RPi GPIO 24
int rpiStopPin = A4;  // Remote Stop  -- RPi GPIO 23
int rpiOpenPin = A5;  // Remote Open  -- RPi GPIO 22
//
int limClosedPin = A6; // Closed Limit Switch -- RPi GPIO 3
int limOpenPin = A7;   // Open Limit Switch   -- RPi GPIO 2
//
int rpiFaultPin = 13;  // Remote Fault Sense  -- RPi GPIO 5
Edited by Gina
Link to comment
Share on other sites

I have yet to decide whether to test the Arduino local control first then disconnect and bring the control box back indoors to continue or whether to write the RPi code first and test that indoors before taking the unit out to the observatory.  One point is that some of the resting logic levels in the Arduino rely on the RPi so maybe that needs writing before any hardware testing.

Edited by Gina
Link to comment
Share on other sites

Modus Operandi of the RPi control panel will be (3 buttons with lights) :-

  1. Button to OPEN the roof - Inactive : Grey - Roof opening : Yellow - Roof Open : Green - Fault when opening RED
  2. Button to CLOSE the roof - Inactive : Grey - Roof closing : Yellow - Roof Closed : Green - Fault when closing RED
  3. Emergency STOP button - Inactive : Grey - Motor Stopped : Green
Edited by Gina
Link to comment
Share on other sites

The easiest way of remote controlling the RPi for the ROR is to use a minor sub-set of the KStars/Ekos/INDI system separate from the astro imaging, though I may find out how to combine them later and stop an imaging run if rain is detected, as well as closing the roof.  The Astroberry Board INDI driver is easily altered to provide the functionality to control the roof.

Link to comment
Share on other sites

Working on the RPi INDI driver code.  The standard Astroberry Board driver simply turns relays on and off with two buttons for each.  For this project I need something slightly different.  The ROR motor electronic relay has three states OFF, OPENING, CLOSING.  The ROR control could be implemented in a few ways :-

  1. One light and 3 buttons in a row.  Buttons for CLOSE, OPEN, STOP/ABORT - Light :- Closed, Open, Moving, Fault
  2. Three rows of lights each with one button.  My original idea.
  3. Three rows of lights each with two buttons.  (3 of the 4 standard Astroberry Board relay controls)
  4. Two rows of lights each with two buttons.

Option 1. would work but in the event of a fault there is no indication of whether the roof was opening or closing when the fault occurred.  OTOH a fault would need human intervention in the observatory and the LEDs on the control panel would show which way the roof was moving.  Also, if I had just operated the remote control I would know whether I was opening or closing the roof.  If the Ekos Control panel works as I think with this setup, I think it would be quite adequate as well as nice and simple.  (Less is more.)

Edited by Gina
Link to comment
Share on other sites

The way the RPi will drive the Arduino using the control buttons above means some small changes are required in the Arduino sketch.  The three buttons and hence the three data states will be mutually exclusive - 1 of 3 on.  In fact the number of control lines could be reduced but since the hardware is already built I shan't bother.

Th upshot is that the sketch will need to detect the rising edge of the GPIO line and then ignore the high level once detected.  The motor drive will be terminated by the appropriate limit switch, timeout or the STOP/ABORT signal from either push button or RPi.  The Ekos button will retain it's state from operator action with the Light indicating the result of the roof operation.

Link to comment
Share on other sites

  • 2 months later...

Update to the Arduino sketch.

// Filename :- ROR_Control_2020-02-07
//
bool roofOpen = false; 
bool roofOpening = false; 
bool roofClosing = false;
bool timerRunning = false;
int time = 0;
//
int Threshold = 400;     // 2v analog to digital threshold - 1023 = 5v
int currentLimit = 115;  // Motor current sense output gives 140mv per Amp  4A = 140x1024x4/5000 = 115
                         // (100 corresponds to 3.5A)
int timoutCount = 180;   //  Timout in seconds - amount of time alloweed to open or close roof

int pbClosePin = 3;  // Close Push Button
int pbStopPin = 4;   // Stop Push Button
int pbOpenPin = 5;   // Open Push Button
int detRainPin = 6;  // Rain detector
//
int MotorInAPin = 7;  // Motor In A
int MotorInBPin = 8;  // Motor In B
//
int MotorCSPin = A2;  // Motor Current Sense
//
int rpiClosePin = A3; // Remote Close
int rpiStopPin = A4;  // Remote Stop
int rpiOpenPin = A5;  // Remote Open
//
int limClosedPin = A6; // Closed Limit Switch
int limOpenPin = A7;   // Open Limit Switch
//
int rpiFaultPin = 13;  // Remote Fault Sense
//
//
void setup() {
  pinMode(pbClosePin,INPUT_PULLUP);   //  Close Push Button
  pinMode(pbStopPin,INPUT_PULLUP);    //  Stop Push Button
  pinMode(pbOpenPin,INPUT_PULLUP);    //  Open Push Button
  pinMode(detRainPin,INPUT_PULLUP);   //  Rain detector
//  
  pinMode(MotorInAPin, OUTPUT);
  pinMode(MotorInBPin, OUTPUT);
  pinMode(rpiFaultPin, OUTPUT);
 }
//
//

void StartTimer();
  timerRunning = true;
  }

void OpenRoof() {
  MotorInAPin = HIGH;
  roofOpening = true;
  StartTimer;
  }
//
void CloseRoof() {
  MotorInBPin = HIGH;
  roofClosing = true;
  StartTimer;
  }
//  
void StopMotor() {
  MotorInAPin = LOW;
  MotorInBPin = LOW;

  }
//
void LimitReached() {
  StopMotor;
  timerRunning = false;
  }
//
void MotorStalled() {
  StopMotor;
  rpiFaultPin = HIGH;
  timerRunning = false;
  }
//
void timeOut() {
  StopMotor;
  rpiFaultPin = HIGH;
  timerRunning = false;
  }
//
// Test all buttons, inputs and rain detector for change
//
void loop(){
  if (timerRunning) { time++; if (time > timoutCount) { timeOut;} }
  if (digitalRead(pbOpenPin) == LOW) { OpenRoof; };
  if (digitalRead(pbClosePin) == LOW) { CloseRoof; };
  if (digitalRead(pbStopPin) == LOW) { StopMotor; };
  if (digitalRead(detRainPin) == LOW) { CloseRoof; };
//  
  if ((analogRead(rpiOpenPin) > Threshold) && (!roofOpening) ) { OpenRoof; };
  if ((analogRead(rpiClosePin) > Threshold)) && (!roofClosing)  { CloseRoof; };
  if ((analogRead(rpiStopPin) > Threshold)) { StopMotor; };
//
  if ((analogRead(limClosedPin) > Threshold)) { LimitReached; };
  if ((analogRead(limOpenPin) > Threshold)) { LimitReached; };
  
//
  if ((analogRead(MotorCSPin) > currentLimit)) { MotorStalled; };
}
// End

 

Edited by Gina
Link to comment
Share on other sites

Now looking at the RPi coding.  The amount of code involved in the roof control is quite small - a lot more is required to maintain protocols.  My other RPi systems do vastly more.  It could be said that this is using a sledgehammer to crack a nut but it means that the roof control can be integrated with the rest of the astro systems and maybe a weather station.

The control is simply one light and 3 buttons in a row.  Buttons for CLOSE, OPEN, STOP - Light :- Closed, Open, Moving, Fault

Link to comment
Share on other sites

Once either OPEN or CLOSE has been chosen the other will be disabled, with STOP as the only option, until a limit switch is detected and the roof stopped by the Arduino. 

Edited by Gina
Link to comment
Share on other sites

Clicking on a button will set the appropriate output line to ON.  This ON state will show the button as Down using LoadLines.

LoadLines will also read the levels of the inputs. 

  1. isClosed will set the Property (light) to IPS_IDLE
  2. isOpen will set the Property to IPS_OK
  3. isFault will set the Property to IPS_ALERT
  4. else Property is set to IPS_BUSY
Edited by Gina
Link to comment
Share on other sites

  • 2 weeks later...

The test rig is to emulate the roof with drive motor and limit switches.  I shall power it from a bench PSU.  I have a 12v DC motor/gearbox with 8mm shaft (with 1mm flat) and I have some microswitches to use as limit switches.  The motor shaft rotates at around 15 rpm - 4s per revolution, so I shall wan't some 3D printed gears to increase the time emulating the opening and closing of the roof plus a base to hold it all together.

Edited by Gina
Link to comment
Share on other sites

Arduino sketch syntax adjusted, compiled and uploaded to Arduino Nano so that's ready for testing.

// Filename :- ROR_Control_2020-02-07
//
bool roofOpen = false; 
bool roofOpening = false; 
bool roofClosing = false;
bool timerRunning = false;
int time = 0;
//
int Threshold = 400;     // 2v analog to digital threshold - 1023 = 5v
int currentLimit = 115;  // Motor current sense output gives 140mv per Amp  4A = 140x1024x4/5000 = 115
                         // (100 corresponds to 3.5A)
int timoutCount = 180;   //  Timout in seconds - amount of time alloweed to open or close roof

int pbClosePin = 3;  // Close Push Button
int pbStopPin = 4;   // Stop Push Button
int pbOpenPin = 5;   // Open Push Button
int detRainPin = 6;  // Rain detector
//
int MotorInAPin = 7;  // Motor In A
int MotorInBPin = 8;  // Motor In B
//
int MotorCSPin = A2;  // Motor Current Sense
//
int rpiClosePin = A3; // Remote Close
int rpiStopPin = A4;  // Remote Stop
int rpiOpenPin = A5;  // Remote Open
//
int limClosedPin = A6; // Closed Limit Switch
int limOpenPin = A7;   // Open Limit Switch
//
int rpiFaultPin = 13;  // Remote Fault Sense
//
//
void setup() {
  pinMode(pbClosePin,INPUT_PULLUP);   //  Close Push Button
  pinMode(pbStopPin,INPUT_PULLUP);    //  Stop Push Button
  pinMode(pbOpenPin,INPUT_PULLUP);    //  Open Push Button
  pinMode(detRainPin,INPUT_PULLUP);   //  Rain detector
//  
  pinMode(MotorInAPin, OUTPUT);
  pinMode(MotorInBPin, OUTPUT);
  pinMode(rpiFaultPin, OUTPUT);
 }
//
//

void StartTimer() {
  timerRunning = true;
  }

void OpenRoof() {
  MotorInAPin = HIGH;
  roofOpening = true;
  StartTimer;
  }
//
void CloseRoof() {
  MotorInBPin = HIGH;
  roofClosing = true;
  StartTimer;
  }
//  
void StopMotor() {
  MotorInAPin = LOW;
  MotorInBPin = LOW;

  }
//
void LimitReached() {
  StopMotor;
  timerRunning = false;
  }
//
void MotorStalled() {
  StopMotor;
  rpiFaultPin = HIGH;
  timerRunning = false;
  }
//
void timeOut() {
  StopMotor;
  rpiFaultPin = HIGH;
  timerRunning = false;
  }
//
// Test all buttons, inputs and rain detector for change
//
void loop(){
  if (timerRunning) { time++; if (time > timoutCount) { timeOut;} }
  if (digitalRead(pbOpenPin) == LOW) { OpenRoof; };
  if (digitalRead(pbClosePin) == LOW) { CloseRoof; };
  if (digitalRead(pbStopPin) == LOW) { StopMotor; };
  if (digitalRead(detRainPin) == LOW) { CloseRoof; };
//  
  if (analogRead(rpiOpenPin) > Threshold) { if (!roofOpening) { OpenRoof; }};
  if (analogRead(rpiClosePin) > Threshold) { if (!roofClosing)  { CloseRoof; }};
  if ((analogRead(rpiStopPin) > Threshold)) { StopMotor; };
//
  if ((analogRead(limClosedPin) > Threshold)) { LimitReached; };
  if ((analogRead(limOpenPin) > Threshold)) { LimitReached; };
  
//
  if ((analogRead(MotorCSPin) > currentLimit)) { MotorStalled; };
}
// End

 

Link to comment
Share on other sites

Looking at the hardware, I see I haven't yet added a connector for the rain detector.  One 4 pin connector to add - 2 for power 2 for relay contacts.

Roof Control 16.png

Edited by Gina
  • Like 2
Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...
12 hours ago, sloz1664 said:

Hi Gina

The  NodeMCU Module ESP8266 ESP-12E WiFi devices look good and nice and cheap. How are you going to incorporate these into your design?

steve

Here's a first revised block/circuit diagram.

1197801483_RoofControl04a.thumb.png.4b3c181da5f68f8f75bd255bcdca93a0.png

Link to comment
Share on other sites

  • 1 month later...

Unfortunately, this project has taken a step backwards.  There is a serious problem with the large chain pulley and its cover.  The cover has broken and the bearing arrangement for the pulley needs improving.  This has been causing the roof to jam so I have had to remove the chain and pulley.  This is not a problem at the moment since I've been opening and closing the roof manually anyway but before I can complete the project I shall need to print a new pulley cover and sort out the bearing.

  • Sad 1
Link to comment
Share on other sites

So far I've been using the ESP32 to read and send data to a browser but now I want for an ESP to receive data from the browser (or something else) and control the motor that will operate the observatory roof.  It will also want to read the state of the roof from the limit switches and motor current, which the motor control unit converts into a voltage, but I know how to do this.  What I don't know is how to send commands to the ESP.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.