aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Delmar Davis <don@suspectdevices.com>2017-10-27 22:38:30 -0700
committerDonald Delmar Davis <don@suspectdevices.com>2017-10-27 22:38:30 -0700
commit624b639fef090cf88d269e7934a49137a9476ac6 (patch)
tree136c00527253dc4bf58f0a93154f4c63caccb908
parent9c120d9b4adc2905342bab7f54ee16683b06216f (diff)
Put Light Curtain Logic back into safety module. Clean up a few things.
-rwxr-xr-xArduino/ems-light/Configuration.h11
-rwxr-xr-xArduino/ems-light/Monitor.cpp1
-rwxr-xr-xArduino/ems-light/SafetyThird.h54
-rw-r--r--ems-light.xcworkspace/xcuserdata/don.xcuserdatad/UserInterfaceState.xcuserstatebin16706 -> 16694 bytes
4 files changed, 65 insertions, 1 deletions
diff --git a/Arduino/ems-light/Configuration.h b/Arduino/ems-light/Configuration.h
index 5a54e0b..822846d 100755
--- a/Arduino/ems-light/Configuration.h
+++ b/Arduino/ems-light/Configuration.h
@@ -24,6 +24,17 @@
#ifndef E_STOP_PULLED
#define E_STOP_PULLED 1
#endif
+
+//
+// Define LIGHT_CURTAIN pins to enable light curtain
+//
+//#define LIGHT_CURTAIN_OSDD_PIN 5
+//#define LIGHT_CURTAIN_START_PIN 6
+#define LIGHT_CURTAIN_START LOW
+#define LIGHT_CURTAIN_STOP HIGH
+#define LIGHT_CURTAIN_OK LOW
+#define LIGHT_CURTAIN_NOT_CLEAR HIGH
+
//
// Define K1_PIN if konactor is connected to machine
//
diff --git a/Arduino/ems-light/Monitor.cpp b/Arduino/ems-light/Monitor.cpp
index b4a9de6..90ba398 100755
--- a/Arduino/ems-light/Monitor.cpp
+++ b/Arduino/ems-light/Monitor.cpp
@@ -146,6 +146,7 @@ void Monitor::init(){
clock.init(); // needed to timestamp debug statement.
+ registerAction(_SYN_, &ACK);
registerAction(_DVL_, &DVL);
registerAction(_GIT_, &GIT);
registerAction(_HLP_, &HLP);
diff --git a/Arduino/ems-light/SafetyThird.h b/Arduino/ems-light/SafetyThird.h
index 8fa4f13..3b318a5 100755
--- a/Arduino/ems-light/SafetyThird.h
+++ b/Arduino/ems-light/SafetyThird.h
@@ -65,11 +65,34 @@ class SafetyThird {
private:
bool _eStop;
bool _prevEStop;
+ bool _prevLightCurtain;
// put the contactor variables back here
// mebby look at the light curtain as well
Task _doDoRunRun;
public:
+
+ bool _lightCurtain;
+ bool _lightCurtainReset;
+
+#ifdef LIGHT_CURTAIN_START_PIN
+ static void LCS(uint8_t kwIndex, uint8_t verb, char *args) {
+ //
+ // set logic here
+ //
+ monitor.update("LCS","%s",safety._lightCurtain?"ON":"OFF");
+ safety.first();
+ }
+
+ static void LCR(uint8_t kwIndex, uint8_t verb, char *args) {
+ if (verb=='!') {
+ safety._lightCurtainReset = (atoi(args));
+ digitalWrite(LIGHT_CURTAIN_START_PIN,safety._lightCurtainReset);
+ }
+ safety.first();
+ monitor.update("LCR","%s",safety._lightCurtainReset?"ON":"OFF");
+ }
+#endif
static void run() {safety.first();}
@@ -80,6 +103,12 @@ public:
#else
_eStop = false;
#endif
+
+#ifdef LIGHT_CURTAIN_OSDD_PIN
+ _lightCurtain = (digitalRead(LIGHT_CURTAIN_OSDD_PIN) == LIGHT_CURTAIN_NOT_CLEAR);
+#else
+ _lightCurtain = false;
+#endif
if ((machine.inSafeStateToRun)
&& (_eStop)
)
@@ -102,7 +131,22 @@ public:
#endif
}
}
-
+ //
+ // this is rough... Fix when there is hardware to test with
+ //
+ if(_lightCurtain!=_prevLightCurtain) {
+ if (_lightCurtain) {
+#ifdef K1_PIN
+ digitalWrite(K1_PIN,KONTACTOR_OFF);
+#endif
+ } else {
+#ifdef K1_PIN
+ digitalWrite(K1_PIN,KONTACTOR_OFF);
+#endif≄
+ }
+ monitor.update("LCS","%s",_lightCurtain?"ON":"OFF");
+ }
+ _prevLightCurtain=_lightCurtain;
_prevEStop=_eStop;
}
uint redLightVal; // red led value prolly bad style
@@ -125,6 +169,14 @@ public:
// Might move this to machine or other more generic place.
// http://www.arduino.org/learning/reference/analogwriteresolution
analogWriteResolution(ANALOG_WRITE_RESOLUTION);
+#ifdef LIGHT_CURTAIN_RESET_PIN
+ _lightCurtainReset = true;
+ digitalWrite(LIGHT_CURTAIN_START_PIN,LIGHT_CURTAIN_START);
+#else
+ _lightCurtainReset = false;
+#endif
+ _prevLightCurtain=false;
+ _prevEStop=false;
redLight(redLightVal=RED_OFF);
_doDoRunRun.set(77L, TASK_FOREVER, &run);
diff --git a/ems-light.xcworkspace/xcuserdata/don.xcuserdatad/UserInterfaceState.xcuserstate b/ems-light.xcworkspace/xcuserdata/don.xcuserdatad/UserInterfaceState.xcuserstate
index 1277a9a..05016b6 100644
--- a/ems-light.xcworkspace/xcuserdata/don.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/ems-light.xcworkspace/xcuserdata/don.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ