You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
10 KiB

5 years ago
  1. \documentclass[11pt]{article}
  2. %Gummi|065|=)
  3. \usepackage{graphicx}
  4. \usepackage{caption}
  5. \title{\textbf{ZMHW Modector}}
  6. \author{Steak Electronics}
  7. \date{}
  8. \begin{document}
  9. \maketitle
  10. \tableofcontents
  11. \section{Overview}
  12. Making and deploying a Motion Sensor for Zoneminder CCTV software installations. These sensors use ZMTrigger.pl (wiki.zoneminder.com/ZMTrigger) to activate an alarm on a camera for a period of time. The advantage of hardware motion sensors over the software detection of Zoneminder, is that the hardware motion sensors avoid some of the problems inherent in software detection, such as false positives from day-to-night, bugs, missed detections, and others.
  13. I've tried different motion sensors. Let's start with the Infrared Laser Diode.
  14. \section{Parts List}
  15. \begin{itemize}
  16. \item Arduino Uno (official recommended)(DIP recommended)
  17. \item ENC28J60 ethernet module
  18. \item Passive PoE adaptors for IP Cameras
  19. \item Series 1A fuse
  20. \item Sick WS15-D1130 Infrared Laser Diode Motion Sensor
  21. \item General Purpose Diode (I used 1N4818 diode) (may also use transistor, per data sheet for Sick)
  22. \item Jumper Wires
  23. \item Copper Wire (22-26 gauge)
  24. \item Enclosure
  25. \item Ethernet Wire
  26. \item (optional) Low Profile one and two gang wall outlet
  27. \item (optional) Blank cover plate, for one and two wall gang wall outlet
  28. \item (optional) Electrical tape (I prefer halfway decent electrical tape)
  29. \item (optional) piezo speaker
  30. \item (optional) extras of everything, in case anything fails
  31. \end{itemize}
  32. Later on we will try a different sensor. The HFS-DC06H. This sensor is a combination of an HB100 radio, with a decoding board that will read the signal and output a logic high or low. You may also want to try PIR sensors.
  33. \subsection{Other Sensors}
  34. \begin{itemize}
  35. \item HFS-DC06H
  36. \item PIR Sensor
  37. \item Any other Laser Diode Sensor you like
  38. \item Reflective tape
  39. \end{itemize}
  40. %\includegraphics[scale=0.8]{../pics/resistances.png}
  41. %\captionof{figure}{Application Note resistance table}
  42. \section{Work Log}
  43. \subsection{Sick Motion Sensor}
  44. The first tests were with the Sick diode sensor and receiver. This device is good for a doorway, where the door must be opened in order for people to pass. Putting it in the way of the door ensures that it will activate. It has a distance of at a max 15 feet or 3 meters. It is a laser type tripwire, which means it can be avoided, if someone knows where it is.
  45. Device was assembled and using the ZMHW Modector source code. This is simply an Arduino sketch with UIPEthernet (to use the ENC28J60) (make sure CS is pin 10 on Uno). For more details see source code. Explaining the details is out of the spec of this doc. Simply put, the ENC28J60 is connected, the Sick sensor black wire is connected to Analog input 1, and a speaker is connected.
  46. \includegraphics[scale=0.4]{../pics/DSCN0207.JPG}
  47. \captionof{figure}{Testing the Sick IR Diode Tripwire }
  48. Figure 1 shows two things, first off a diode connected in series with the output of the Sick sensor, and also the orange LED on the top of the sensor. The orange led will be green when there is no connection between the diodes and orange when the Diodes (or LEDs) are lined up correctly. When someone moves across the field of their vision, the orange LED will change to green.\footnote{This will later become important when installing the IR diode and receiver, as they must be lined up correctly.}
  49. \subsection{Diode on Output of Sick Sensor instead of Transistor (Hack)}
  50. Some IR diode / receiver pairs output a high or low. Some, like the Sick sensor, output a high or low (depending on whether you connect to white or black wire), however they are meant to be connected to a transistor, and thus if you connect it directly to a micro expecting it to go high or low, it will not. Being lazy, and seeking a quick solution, I put a 1N4819 in series with the output of the Sick sensor.
  51. TODO: pictures showing waveforms
  52. \footnote{This is possibly an issue of output impedance, but I will admit, at the time, I didn't bother to check.}
  53. Using the black wire, it will be normally low and go high when motion is detected (the white wire is the opposite). If you connect to a micro it will fail to go high (why?). If you put a diode on the end in series, it will turn the normally low to a noisy normally low, and sometimes it will go between 2.5-5 volts in spikes. This allows us to use the ADC to read the Sick sensor, and avoid the use of adding a transistor in. The transistor would allow for a digitalRead to be used, but we have plenty of Analog inputs to use, so let's use one of those.
  54. It's important to line up the emitter and receiver. If they are not lined up precisely, they will not get a sync, and the motion detection will fail. Thankfully, the diode outputs more of a cone, and less of a straight line, so some buffer is there. When the lights are dark, it is possible to see the red IR emitted if the distance is not too much.
  55. \subsection{Broken ENC28J60 Module}
  56. During my testing, I suddenly was unable to get an IP address. I checked the testsuite sketches, which didn't work, then began tearing down my setup, testing another Arduino and ENC module. It turned out, the ENC28J60 module failed on me. Make sure to buy backups.
  57. \subsection{Installation Log in Pictures}
  58. Here is an overview of what installing this in the wall might look like. One side is emitter, the other the receiver.
  59. \includegraphics[scale=0.25]{../pics/DSCN0217.JPG}
  60. \captionof{figure}{}
  61. \includegraphics[scale=0.25]{../pics/DSCN0220.JPG}
  62. \captionof{figure}{}
  63. \includegraphics[scale=0.25]{../pics/DSCN0225.JPG}
  64. \captionof{figure}{}
  65. \includegraphics[scale=0.25]{../pics/DSCN0227.JPG}
  66. \captionof{figure}{Part 1 of sensor. By mounting it on the right side of a project box, we can get a 90 degree angle.}
  67. \includegraphics[scale=0.25]{../pics/walloutlet2.jpg}
  68. \captionof{figure}{Arduino and Part 2 of sensor. Lined up with the other part.}
  69. \section{Omrom Photoelectric IR Emitter/Receiver}
  70. All electronics is currently selling used Omrom photoelectric sensors, they are model: e3f2-r2c4. These types of photoelectric sensors are from a large catalog of different types. Some AC some DC powered. Different max distance, etc... See resources in this git repository for some PDFs.
  71. I tested one without knowing how to use them, but had poor results. I was only able to get the light to flash when I dismantled the device, and put my hand very close to the IR. Teardown pictures are in the photos folder. The devices were not easy to dismantle, and can't really be put back together as they were originally. However, they did seem otherwise well made. \footnote{Repairs may be difficult.}
  72. \includegraphics[scale=0.25]{../pics/DSCN0265.JPG}
  73. \captionof{figure}{Omrom 'Photoelectric' IR Emitter and Receiver Pair. Notice the two diodes behind the black cover on the right side.}
  74. After finding some documentation on these in the reviews, I found out that the IR emitters require a reflective sticker in order to 'see' their IR beam reflect back. Not just a white surface, but the type of reflector you might see on a construction or night worker orange vest.
  75. Hookup Instructions from All Electronics Comments:
  76. \begin{verbatim}
  77. is. To use with 5v ttl (using a second 5v source) wire as such:
  78. Brown to +12V; Blue to ground; Pink to either +12 or ground
  79. depending whether you want Light-ON or Dark-ON mode;
  80. Black to a 4.7K resistor with the other side of the resistor
  81. connected to a separate +5V source (the arduino). The 5v ttl
  82. signal is at the point where the black wire connects to the
  83. resistor.
  84. \end{verbatim}
  85. One thing I also noticed, was that used photo electric sensors from brand names can be obtained for discounts on the auction sites, to see if a good deal can be had. When buying them new, they can be relatively expensive for a hobbyist working out of his/her garage.
  86. \includegraphics[scale=0.25]{../pics/DSCN0273.JPG}
  87. \captionof{figure}{IR in action. (without a reflective sticker, it doesn't go very far!)}
  88. \section{Using the HFS-DC06H Microwave Sensor}
  89. As I've tried with the HB100 (just the RF part of this HFS-DC06H), without success, I've moved to the HFS-DC06H microwave sensor which includes the Op Amp and accompanying circuitry (it simply outputs a digital high or low).
  90. During testing, I found that the HFS sensor would not work correctly with my laptops usb 2.0 power supply. I thought it might be RF interferance from the metallic perf board – something I've seen before with an FM bug radio – but it was not. The HFS and the ENC require external power that is greater than my laptop can output.
  91. \subsection{Uno Memory Limitations}
  92. Using ethernet with the Uno is always touchy. Version control is important, to have a functional version to work off of.
  93. When writing my code, I found errors creep in due to using too much of what the Arduino IDE calls dynamic memory. You can see how much dynamic memory is used in Arduino by hitting verify (not upload but verify)and reading the output from the toolchain. You can also use a tool to see how much SRAM is used (code is online:https://jeelabs.org/2011/05/22/atmega-memory-use/) the following function:
  94. \begin{verbatim}
  95. “Here’s a small utility function which determines how much RAM is currently unused:
  96. int freeRam () {
  97. extern int __heap_start, *__brkval;
  98. int v;
  99. return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
  100. }
  101. And here’s a sketch using that code:
  102. void setup () {
  103. Serial.begin(57600);
  104. Serial.println("\n[memCheck]");
  105. Serial.println(freeRam());
  106. }
  107. void loop () {}
  108. The result will be:
  109. [memCheck]
  110. 1846
  111. \end{verbatim}
  112. The UIPEthernet code requires significant RAM for the Uno. This is not a new problem for me, but it rears its ugly head again. However, this is a good thing. Limits are good.
  113. An easy resolution for this is to put all serial.print lines into flash memory. You can verify this helps, by taking a serial.print, and commenting it out, and comparing the before and after dynamic memory used in verify. To put serial print lines in flash:
  114. (https://www.arduino.cc/reference/en/language/functions/communication/serial/write/)
  115. (https://www.arduino.cc/reference/en/language/functions/communication/serial/print/)
  116. As I recall, there may be limitations to what you can do with Serial.print(F()), fotr example, converting variables into it will likely not work without further finesse, and libraries that print through serial likely won't work.
  117. Low RAM errors can creep into strange places. For example, see these two wiresharks, where my code was running, equally as well, but the new code revision simply didn't work:
  118. XW11.tex
  119. \end{document}