mbed Sensor node for Instrumented Booth over ETH.
Dependencies: EthernetInterface-1 MaxbotixDriver Presence HTU21D_TEMP_HUMID_SENSOR_SAMPLE Resources SHARPIR mbed-rtos mbed-src WDT_K64F nsdl_lib
Fork of Trenton_Switch_LPC1768_ETH by
Revision 40:b2e9bc654ca1, committed 2015-02-11
- Comitter:
- andcor02
- Date:
- Wed Feb 11 12:36:45 2015 +0000
- Parent:
- 39:9c1b17345678
- Child:
- 41:212121c1a108
- Commit message:
- Working Set for long distance door
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Door_Trip/DoorTrip.cpp Wed Feb 11 12:36:45 2015 +0000 @@ -0,0 +1,54 @@ +/* + DoorTrip.cpp - DoorTrip sensor library + Developed by Andrea Corrado & Eric Gowland + + Connect to a hardware device that is boolean present/not present. Such as PIR, Rangefinder or laser with appropriate signalling. + Also drives LED as DoorTrip indicator. +*/ + + +#include "mbed.h" +#include "DoorTrip.h" + + + +DoorTrip::DoorTrip(PinName pin, bool true_on_rise, int debounce_time_ms):_myint(pin), _led1(LED1) +{ + debounce_ms = debounce_time_ms; + _true_on_rise = true_on_rise; +// if(true_on_rise) { +// _myint.rise(this, &DoorTrip::DoorTrip_interrupt_off); +// _myint.fall(this, &DoorTrip::DoorTrip_interrupt_on); +// } else { +// _myint.rise(this, &DoorTrip::DoorTrip_interrupt_on); +// _myint.fall(this, &DoorTrip::DoorTrip_interrupt_off); +// } + _detection=false; +// debounce_timer.start(); + _led1=1; + +} + +void DoorTrip::DoorTrip_interrupt_off(){ + if(debounce_timer.read_ms() > debounce_ms) { + _detection=false; + _led1=1; + } +} + +void DoorTrip::DoorTrip_interrupt_on() //Detection of motion. +{ + //Always trigger detection.. + _detection=true; + _led1=0; + debounce_timer.reset(); // Reset counter to 0... +} + +bool DoorTrip::isPresent(){ +// if (debounce_timer.read_ms() > debounce_ms) { + //Poll the pin and update value... + _detection = (_true_on_rise && _myint == 1) || (!_true_on_rise && _myint == 0); + if(_detection) _led1 = 0; else _led1 = 1; +// } + return !_detection; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Door_Trip/DoorTrip.h Wed Feb 11 12:36:45 2015 +0000 @@ -0,0 +1,34 @@ +/* + DoorTrip.cpp - DoorTrip sensor library + Developed by Andrea Corrado & Eric Gowland + + Connect to a hardware device that is boolean present/not present. Such as PIR, Rangefinder or laser with appropriate signalling. + Also drives LED as DoorTrip indicator. +*/ + + +#ifndef MBED_DOOR_H +#define MBED_DOOR_H + +#include "mbed.h" + +class DoorTrip{ + +public: + + DoorTrip(PinName pin, bool true_on_rise, int debounce_time_ms); + bool isPresent(); + +private: + InterruptIn _myint; + DigitalOut _led1; + bool _detection; + bool _true_on_rise; + int debounce_ms; + Timer debounce_timer; + void DoorTrip_interrupt_on(); + void DoorTrip_interrupt_off(); + +}; + +#endif \ No newline at end of file
--- a/EthernetInterface.lib Mon Feb 09 16:43:27 2015 +0000 +++ b/EthernetInterface.lib Wed Feb 11 12:36:45 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/#d1ccbed7687a +http://mbed.org/users/mbed_official/code/EthernetInterface/#fb309b990168
--- a/Presence.lib Mon Feb 09 16:43:27 2015 +0000 +++ b/Presence.lib Wed Feb 11 12:36:45 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/ASE/code/Presence/#b1c665320f0c +http://developer.mbed.org/teams/ASE/code/Presence/#f12e18827f3e
--- a/Resources.lib Mon Feb 09 16:43:27 2015 +0000 +++ b/Resources.lib Wed Feb 11 12:36:45 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/ASE/code/Resources/#ad57a552e2f0 +http://developer.mbed.org/teams/ASE/code/Resources/#a708d3686f4b
--- a/mbed-rtos.lib Mon Feb 09 16:43:27 2015 +0000 +++ b/mbed-rtos.lib Wed Feb 11 12:36:45 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#f1ef95efa5ad +http://mbed.org/users/mbed_official/code/mbed-rtos/#ab4200083b07
--- a/mbed-src.lib Mon Feb 09 16:43:27 2015 +0000 +++ b/mbed-src.lib Wed Feb 11 12:36:45 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-src/#cef2a8a56f9e +http://mbed.org/users/mbed_official/code/mbed-src/#fc4922e0c183
--- a/node_cfg.h Mon Feb 09 16:43:27 2015 +0000 +++ b/node_cfg.h Wed Feb 11 12:36:45 2015 +0000 @@ -10,8 +10,8 @@ //Which Sensors #define NODE_SENSOR_STATION 1 // use K64F platform. Base sensor platform. Includes Microphone, temperature. #define NODE_HEIGHT_STATION 0 // use K64F platform. This include door height sensor -#define NODE_KIOSK_STATION 0 // use K64F platform. This includes kiosk presence sensor -#define NODE_DOOR_TRIP_STATION 0 // use K64F platform. This includes door tripwire sensor +#define NODE_KIOSK_STATION 1 // use K64F platform. This includes kiosk presence sensor +#define NODE_DOOR_TRIP_STATION 1 // use K64F platform. This includes door tripwire sensor #define NODE_PIR_STATION 0 // use K64F platform. This includes pir motion sensor #define HEART_BEAT 1 // For debug...
--- a/sensor_ctl.cpp Mon Feb 09 16:43:27 2015 +0000 +++ b/sensor_ctl.cpp Wed Feb 11 12:36:45 2015 +0000 @@ -10,6 +10,7 @@ #include "sonar.h" #include "Presence.h" #include "SHARPIR.h" +#include "DoorTrip.h" //Sensor MDS Resources #include "door_trip.h" @@ -23,13 +24,13 @@ RHT03 temperature(PTB2); MAX9814 microphone(PTB3); //Analogue in required. #if NODE_PIR_STATION -Presence pir(PTB11, false, PIR_SENSOR_DEBOUNCE_MS); //(InterruptPin), for PIR sensor, +presence pir(PTB11, false, PIR_SENSOR_DEBOUNCE_MS); //(InterruptPin), for PIR sensor, #endif //NODE PIR STATION #if NODE_KIOSK_STATION -Presence kiosk(PTB10, true, KIOSK_SENSOR_DEBOUNCE_MS); //(Interrupt pinrequired, no timeout) +presence kiosk(PTB10, true, KIOSK_SENSOR_DEBOUNCE_MS); //(Interrupt pinrequired, no timeout) #endif //NODE KIOSK STATION #if NODE_DOOR_TRIP_STATION -SHARPIR sharpir(PTB10); //(AnalogIn required), for IR door trip +DoorTrip laser(PTC3, true, DOOR_SENSOR_DEBOUNCE_MS ); //(AnalogIn required), for IR door trip #endif //NODE TRIP STATION #if NODE_HEIGHT_STATION Timer sonarTimer; @@ -65,7 +66,7 @@ //Initialisation void init_sensors() { #if NODE_DOOR_TRIP_STATION - door_trip_starting_volts = sharpir.volt(); + #endif #if NODE_HEIGHT_STATION sonarTimer.start(); @@ -128,17 +129,10 @@ #if NODE_DOOR_TRIP_STATION void handle_door_trip_report_timer(){ - float value= sharpir.volt(); - printf ("\n\r door:%f", value); - bool new_door_trip = 0; - if (value>door_trip_starting_volts+0.2) { - new_door_trip=true; - } else if (value<door_trip_starting_volts+0.2) { - new_door_trip=false; - } - - if (new_door_trip != current_door_trip_value) { - current_door_trip_value = new_door_trip; + bool new_laser = laser.isPresent(); + + if(new_laser != current_door_trip_value) { + current_door_trip_value = new_laser; door_trip_report(); } }
--- a/sensor_ctl.h Mon Feb 09 16:43:27 2015 +0000 +++ b/sensor_ctl.h Wed Feb 11 12:36:45 2015 +0000 @@ -15,6 +15,7 @@ #define KIOSK_SENSOR_DEBOUNCE_MS 500 #define PIR_SENSOR_DEBOUNCE_MS 5000 +#define DOOR_SENSOR_DEBOUNCE_MS 200 //Externally visible values.