Wednesday, 23 November 2016

First ideas and tests on ''Horses eyes''

Sensors are needed for two reasons. For providing horses interaction with the outside world and for safety purposes.

We started with two types of sensors. Ultrasonic Range Finder HC-SR04 (datasheet) and infrared HC-SR501 (datasheet and some additional interesting paper).

For the test purposes we made basic Ardino code for each sensor.

Ultrasonic HC-SR04

LED 13 turns on when object under 1m distance is detected. Each measurement is displayed on Serial Monitor. There is also 1s delay in order to make measurements readable.

#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     11  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define LED_PIN 13 // LED indicator of action.

int MAX_DISTANCE = 400; // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
int ACTION_DISTANCE = 100; // Distance where "Horse" takes action (in centimeters).
int  DISTANCE = 0;
void setup() {

  Serial.begin (9600);

  pinMode(TRIGGER_PIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);

  pinMode(ECHO_PIN, INPUT);

  MAX_DISTANCE = MAX_DISTANCE * 2 * 29.1; // Turn MAX_DISTANCE from CM into "TIME".
  ACTION_DISTANCE = ACTION_DISTANCE * 2 * 29.1; // Turn ACTION_DISTANCE from CM into "TIME".
}

void loop() {

  DISTANCE = dist_measure();

  if (DISTANCE < ACTION_DISTANCE) { // "Horse" takes action
    digitalWrite(LED_PIN, HIGH);
  }
  else {
    digitalWrite(LED_PIN, LOW);
  }

  Serial.println(DISTANCE / 58.2);
  delay(1000);
}

////////////////////////////////////////////////////////
int dist_measure() {
  unsigned long duration;

  // "Triggering" measurement
  digitalWrite(TRIGGER_PIN, HIGH);
  delayMicroseconds(20);
  digitalWrite(TRIGGER_PIN, LOW);

  // "Reciving" echo
  DISTANCE = pulseIn(ECHO_PIN, HIGH, MAX_DISTANCE);
  if (DISTANCE == 0) {
    DISTANCE  = MAX_DISTANCE;
  }
  return DISTANCE;
}


First tests shows us that the range of sensor is relatively limited, since the angle of its vision is only 15° on each side. Sound absorbing materials (thick clothes) are affecting on measurements accuracy.

To extend the vision angle we are considering to connect more than one sensor together with diode OR logic circuit.

Photo taken from: https://en.wikipedia.org/wiki/Diode_logic

Infrared HC-SR501

LED 13 turns on when object is detected. Detection of object is displayed on Serial Monitor in binary value. Again 1s delay is inserted in order to make measurements readable.

 #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the IR sensor.  
 #define LED_PIN 13 // LED indicator of action.  
 int ACTION = LOW; // Should "Horse" take action.  
 void setup() {  
  Serial.begin (9600);  
  pinMode(TRIGGER_PIN, INPUT);  
  pinMode(LED_PIN, OUTPUT);  
  digitalWrite(LED_PIN, LOW);  
 }  
 void loop() {  
  ACTION = digitalRead(TRIGGER_PIN);  
  Serial.println(ACTION);  
  digitalWrite(LED_PIN, ACTION);  
  delay(1000);  
 }  

This sensor can sense (warm bodies) motion so it can be used to detect people, however it is useless for detecting walls or furniture. Range of sensor seems to be ok.


Conclusion

So far we are satisfied with the results. Since two types of sensors have different characteristics we believe that combined together we can get best sense of vision for the horse. Nevertheless we still have to discuss and test different solutions and decide where the sensors will be set.

No comments:

Post a Comment