{"id":3522,"date":"2015-01-01T11:59:40","date_gmt":"2015-01-01T16:59:40","guid":{"rendered":"http:\/\/www.plastibots.com\/?p=3522"},"modified":"2017-05-27T06:35:19","modified_gmt":"2017-05-27T11:35:19","slug":"quadcopter-enhanced-lost-model-alarm","status":"publish","type":"post","link":"https:\/\/www.plastibots.com\/index.php\/2015\/01\/01\/quadcopter-enhanced-lost-model-alarm\/","title":{"rendered":"Quadcopter &#8211; Enhanced Lost Model Alarm"},"content":{"rendered":"<p>Just 24 hours earlier I built my first Lost Model Alarm. \u00a0Not being satisfied with good enough, <a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-3526 size-thumbnail\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_3-150x150.jpg\" alt=\"LoMaE_3\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_3-150x150.jpg 150w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_3-64x64.jpg 64w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_3-128x128.jpg 128w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_3-320x320.jpg 320w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a>I&#8217;ve built an enhanced version. \u00a0Of course, you could just <a href=\"http:\/\/www.banggood.com\/MJX-F45-RC-Helicopter-Spare-Part-Signal-loss-Alarm-and-Lost-Plane-Finder-p-71544.html?p=R90804949020201412E4\" target=\"_blank\">buy<\/a> one, but where&#8217;s the fun in that?! \u00a0As mentioned in my original posting, I wanted the alarm to have\u00a0multiple modes. \u00a0First, I wanted to be able to have it triggered while the TX is on using one of the available aux controls. \u00a0Second, I wanted it to always come on if the TX looses power (presumably range). \u00a0I&#8217;ve managed to figure out how to do this using the\u00a0Turnigy 9x Pit Trim pot (Aux 2).<\/p>\n<p>&nbsp;<\/p>\n<p><!--more--><\/p>\n<p>Update: Sept 2015: Check out my latest post on how to<a href=\"http:\/\/www.plastibots.com\/index.php\/2015\/09\/06\/configuring-lost-model-alarm-flip-32-and-cleanflight\/\" target=\"_blank\"> install and configure<\/a> this alarm with Flip32 and Cleanflight.<\/p>\n<p><strong>Parts:<\/strong><\/p>\n<ul>\n<li>ATTiny85 (An 84 or even 25 may work as well)<\/li>\n<li>Piezo buzzer (5V or higher)<\/li>\n<li>100 Ohm resistor<\/li>\n<li>LED (blue was used here &#8211; range is about 2.5 &#8211; 3.5v)<\/li>\n<li>Servo lead wire<\/li>\n<\/ul>\n<p><center><a href=\"https:\/\/deals.banggood.com\/deals\/edm\/topic\/RCCarnival.html?&#038;utm_campaign=RCCarnival&#038;utm_content=klaus&#038;p=R90804949020201412E4&#038;bid=34891&#038;utm_design=41\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/img.banggood.com\/deals\/affiliate_member_banner\/0634ac7160d3fd64ddf19bdcbdd401bb44.jpg\" \/><\/a><\/center><\/p>\n<p>Update (Sept 2105)<\/p>\n<p>I&#8217;ve since modified the Arduino code and setup for this to simplify it as an on\/off alarm controlled by an Aux switch. \u00a0Check this out for more info.<\/p>\n<p><strong>Tx Set-up:<\/strong><\/p>\n<p>The Turnigy 9x Ch7 is configured to Pit Trim &#8211; which is Aux 2. \u00a0Also note that you may have to reverse the channel if your values appear opposite when testing (see Tips below). \u00a0To do this, navigate to the settings &gt; Reverse section in your TX and reverse Aux 2. \u00a0You can also see the trimpot change if you go to Display &gt; Settings. \u00a0When turned all the way CCW, the \u00a0bar should appear filled to the right, and vise-versa as you turn it CW.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Improvements over the original alarm:<\/strong><\/p>\n<ul>\n<li>I wanted to keep the AtTiny85 pins exposed for future updates.<\/li>\n<li>I also added an 100 Ohm resistor inline as the LED only needs about 2.5v.<\/li>\n<li>Set my Turnigy TX Ch7 using the Pit Trim (Aux 2). \u00a0The values for Pit Trim range from 1043 (all the way CCW) to 1867 (all the way CW)<\/li>\n<li>The code watches the PPM signal and reacts as follows:\n<ul>\n<li>If the TX is switched off (value falls to 0), trigger the alarm. \u00a0For the Arduino code, I just look for any value less than 50 (this allows for some buffer).<\/li>\n<li>If the trimpot is turned up all the way CW, trigger the alarm. \u00a0I also wanted to change the tone and beep rate depending on how high I turn the trimpot. \u00a0The Arduino code does this by reacting for any value above 1500, and will trigger the faster beep above 1700 and slower beep above 1500.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<table class=\" aligncenter\" style=\"width: 827px; height: 156px;\" border=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td><a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-3524 size-thumbnail alignleft\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_1-150x150.jpg\" alt=\"LoMaE_1\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_1-150x150.jpg 150w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_1-64x64.jpg 64w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_1-128x128.jpg 128w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_1-320x320.jpg 320w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-3525 size-thumbnail alignright\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_2-150x150.jpg\" alt=\"LoMaE_2\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_2-150x150.jpg 150w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_2-64x64.jpg 64w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_2-128x128.jpg 128w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_2-320x320.jpg 320w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: left;\"><strong>Wiring it up:<\/strong><\/p>\n<p style=\"text-align: left;\">This should be pretty easy if you have basic soldering skills. \u00a0The pins are somewhat close, but with a little patience you should be fine. \u00a0 The AtTiny85 pins number from 1 &#8211; 8 with Pin 1 being identified by the dot on the top of the IC. \u00a0Solder the piezo, LED and servo wire GND to pin 4. \u00a0In the images above you can see how I set the Tiny in the base of the piezo. \u00a0It fit perfectly, and you can even glue it in there. \u00a0Next, solder the servo wire white (shown as yellow below) to pin 5, then the piezo &#8220;+&#8221; to pin 6. \u00a0Solder the 100 Ohm resistor to the &#8220;+&#8221; of the LED, then solder the other end to pin 7 on the Tiny. \u00a0You&#8217;re done.<\/p>\n<p style=\"text-align: left;\"><a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2014\/12\/QuadAlarm_bb-e1419973545610.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-3495\" src=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2014\/12\/QuadAlarm_bb-e1419973545610-300x191.jpg\" alt=\"QuadAlarm_bb\" width=\"300\" height=\"191\" srcset=\"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2014\/12\/QuadAlarm_bb-e1419973545610-300x191.jpg 300w, https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2014\/12\/QuadAlarm_bb-e1419973545610.jpg 913w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: left;\"><strong>Programming the circuit:<\/strong><\/p>\n<p style=\"text-align: left;\">This is where things can get a little tricky as you have to program the ATTiny. \u00a0 There are plenty of instructions out there, if you Google it. \u00a0This <a href=\"http:\/\/highlowtech.org\/?p=1695\" target=\"_blank\">one<\/a> works. \u00a0 Essentially, you use an Arduino Uno (or other) set as a programmer and then connect the Tiny to the Arduino, select the ATTiny85 board (usually 8MHz) and download the code. \u00a0Once you have successfully done this, don&#8217;t connect it to your model just yet. You don&#8217;t want to fry the thing if you connected something wrong. \u00a0If you are confident the code downloaded successfully, connect the servo lead to a 5V power source (just the red and black wires). \u00a0If the code downloaded, you should hear the piezo beeping and see the LED light. \u00a0Essentially, the code that looks for a value &lt; 50 is triggering as there is no input on the signal line. This is simulating the same thing as the Tx power being lost. \u00a0 If it did not work, first check your soldering. \u00a0If that is fine, your code may not have downloaded successfully. \u00a0Go get a beer, come back in 5 minutes and try programming it again. \u00a0You need to ensure that your Tiny successfully takes the code. \u00a0I also suggest you <a href=\"https:\/\/www.google.ca\/search?=attiny+arduino+programmer&amp;espv=2&amp;biw=1920&amp;bih=965&amp;tbm=isch&amp;tbo=u&amp;source=univ&amp;sa=X&amp;ei=f4ClVPPsINL4yQTirYGYAw&amp;ved=0CDUQsAQ\" target=\"_blank\">Google some programmer image samples<\/a> to see the variety of programmer set-up&#8217;s out there. I use this <a href=\"http:\/\/tinkerlog1.files.wordpress.com\/2009\/01\/s_dsc_0124.jpg?w=584\" target=\"_blank\">one<\/a>.<\/p>\n<p style=\"text-align: left;\"><strong>Tips:<\/strong><\/p>\n<p style=\"text-align: left;\">You can use the same code below to read the PPM values from your receiver. \u00a0Simply uncomment the <em>Serial.print<\/em> lines and remove the rest of the logic. \u00a0Connect your RX signal pin to the pin identified for <em>RcPin<\/em> (0 on the ATTiny below) and the RX black wire to GND on your Ardiuno. \u00a0 This assumes you have your Arduino connected to your PC\/Mac, so don&#8217;t connect the red (5v) wire coming out of your RX to anything. \u00a0Run the below sketch, open the serial window and watch the values being returned as you turn the trim knob. \u00a0If they are not changing you need to check to ensure you have the right channel configured on your TX and you are plugged into the same channel on your RX. \u00a0Also ensure you power up your Quad Rx.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Enhancements:<\/strong><\/p>\n<p>Having a range of values from a trimpot gives you a plethora of control options using a single channel. \u00a0 Ideas:<\/p>\n<ul>\n<li>You could configure the below code to trigger an external more powerful alarm when the PPM value is in a specific range (i.e. 1800 &#8211; 1850).<\/li>\n<li>Have it trigger a high intensity LED powered off the main battery pack using a transistor to switch the LED or blink it.<\/li>\n<li>Use the trimpot ranges to trigger different activities. \u00a0For example, you could still have the alarm trigger when the Tx looses power (value = 0) and have a multi-coloured LED light strip that changes colours depending on values greater than 0.<\/li>\n<\/ul>\n<p style=\"text-align: left;\"><strong>Arduino Sketch:<\/strong><\/p>\n<p style=\"text-align: left;\">\u00a0Download: \u00a0<a href=\"http:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/QuadRemoteSwitchIntercept2_0.ino\">QuadRemoteSwitchIntercept.ino<\/a><\/p>\n<pre>\/\/ATTiny85  - pinouts are here http:\/\/highlowtech.org\/wp-content\/uploads\/2011\/10\/ATtiny45-85.png\r\n\/\/pin #1 has the black dot on the chip.\r\n\/\/ 1      8\r\n\/\/ 2      7\r\n\/\/ 3      6\r\n\/\/ 4      5\r\n\r\n\r\nint rcPin = 0;     \/\/ PWM signal in from RC receiver - connect to Pin 5 (see above)\r\nint buzzerPin = 1;  \/\/Buzzer pin out to buzzer  - connect to Pin 6 (see above)\r\nint ledPin = 2;     \/\/Optional - connect to Pin 6 (see above)\r\nint chPWMVal = 0;        \/\/ Receiver channel pwm value - connect to a free channel on your RX. Leave value at 0.\r\n\r\nvoid setup() {\r\n  pinMode(rcPin, INPUT);\r\n  pinMode(buzzerPin, OUTPUT);  \r\n  pinMode(ledPin, OUTPUT);    \r\n  \/\/Serial.begin(9600);  \/\/for debugging\r\n}\r\n\r\nvoid loop() {\r\n  \/\/ Read in the length of the signal in microseconds\r\n  chPWMVal = pulseIn(rcPin, HIGH, 25000);\r\n  digitalWrite(ledPin, LOW);   \/\/ turn the LED on (HIGH is the voltage level)\r\n  \/\/Serial.print(\"Channel #: \");\r\n  \/\/Serial.println(chPWMVal);\r\n  \r\n  \/\/Logic is based on Turnigy 9x Pt Trim configured on Aux 5.  \r\n  \/\/When turned all the way CCW values read ~1043\r\n  \/\/When turned all the way CW value read ~1867\r\n  \/\/When the TX is turned off or looses range, the value drops to 0. \r\n  \/\/Based on this, trigger the alarm if the value is above 1500 or below 50 (allows some bias)\r\n  \/\/This will allow the alarm to be triggered in 2 situations:\r\n  \/\/a) when the TX is turned off\r\n  \/\/b) when the Pit Trim pot is turned all the way CW - this allows the TX to remain on while the alarm is being sounded.\r\n  \r\n  if ((chPWMVal &gt; 1500) || (chPWMVal &lt; 50))\r\n  {\r\n    if (chPWMVal &gt; 1700)\r\n    {\r\n      digitalWrite(ledPin, HIGH);   \/\/ turn the LED on (HIGH is the voltage level)\r\n      tone(buzzerPin, 2800, 300);\r\n      delay(300);\r\n      digitalWrite(ledPin, LOW);    \/\/ turn the LED off by making the voltage LOW\r\n      delay(200);\r\n    }\r\n    else\r\n    {\r\n      digitalWrite(ledPin, HIGH);   \/\/ turn the LED on (HIGH is the voltage level)\r\n      tone(buzzerPin, 3000, 300);\r\n      delay(800);\r\n      digitalWrite(ledPin, LOW);    \/\/ turn the LED off by making the voltage LOW\r\n      delay(200);\r\n    }  \r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Just 24 hours earlier I built my first Lost Model Alarm. \u00a0Not being satisfied with good enough, I&#8217;ve built an enhanced version. \u00a0Of course, you could just buy one, but where&#8217;s the fun in that?! \u00a0As mentioned in my original posting, I wanted the alarm to have\u00a0multiple modes. \u00a0First, I wanted to be able to have it triggered while the TX is on using one of the available aux controls. \u00a0Second, I wanted it to &hellip; <a href=\"https:\/\/www.plastibots.com\/index.php\/2015\/01\/01\/quadcopter-enhanced-lost-model-alarm\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":3526,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[65,6,57,19],"tags":[101,68,94],"class_list":["post-3522","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino-electronics","category-dyihacks","category-electronics","category-remote-controlled","tag-alarm","tag-attiny85","tag-quad","has_thumb"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/www.plastibots.com\/wordpress\/wp-content\/uploads\/2015\/01\/LoMaE_3.jpg","jetpack_shortlink":"https:\/\/wp.me\/pK41j-UO","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts\/3522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/comments?post=3522"}],"version-history":[{"count":0,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/posts\/3522\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/media\/3526"}],"wp:attachment":[{"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/media?parent=3522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/categories?post=3522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.plastibots.com\/index.php\/wp-json\/wp\/v2\/tags?post=3522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}