{"id":1574,"date":"2024-06-26T14:03:23","date_gmt":"2024-06-26T14:03:23","guid":{"rendered":"https:\/\/iotthinghub.com\/?p=1574"},"modified":"2024-08-11T16:07:06","modified_gmt":"2024-08-11T16:07:06","slug":"rpm-meter","status":"publish","type":"post","link":"https:\/\/iotthinghub.com\/?p=1574","title":{"rendered":"RPM Meter"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"590\" height=\"131\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/rpmm.png\" alt=\"\" class=\"wp-image-1578\" style=\"width:216px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/rpmm.png 590w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/rpmm-300x67.png 300w\" sizes=\"(max-width: 590px) 100vw, 590px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-1 wp-block-paragraph\" style=\"color:#5c5c5c\">In this project we use IR Tx diode and IR Rx diode. The sensor circuit diagram is as follow-<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-7387b849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"590\" height=\"316\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/Rpm-meter.png\" alt=\"\" class=\"wp-image-1581\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/Rpm-meter.png 590w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/Rpm-meter-300x161.png 300w\" sizes=\"(max-width: 590px) 100vw, 590px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-color has-link-color wp-elements-2 wp-block-paragraph\" style=\"color:#252525\">The RPM meter based on two procedures<\/p>\n\n\n\n<ol style=\"color:#5c5c5c\" class=\"wp-block-list has-text-color has-link-color wp-elements-3\">\n<li>Count the pulse<\/li>\n\n\n\n<li>Calculate the value per second<\/li>\n<\/ol>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-4 wp-block-paragraph\" style=\"color:#5c5c5c\">It is easy to calculate pulse using external interrupt pin. Let use ATmega8 for this purpose. The logic should be as soon as any falling edge is found, it triggered an external interrupt. Now to enable external interrupt on falling edge<\/p>\n<\/div>\n<\/div>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n  #include&lt;avr\/interrupt.h&gt;\nsei();\t\/\/Global Interrupt Enable\nGICR |=(1&lt;&lt;INT0);\t\/\/ External Interrupt Request 0 Enable\nMCUCR|=(1&lt;&lt;ISC01);  \/\/ The falling edge of INT0 generates an interrupt request\nISR(TIMER1_COMPA_vect)\n{\n   Global_Variable ++; \/\/ update your global variable\n}\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-5 wp-block-paragraph\" style=\"color:#5c5c5c\">The next step is to make a delay of 1s with the help of Timer so that we can easily find the counting value of the pulse. This counting pulse is the RPS (Revolution Per second). Let use Timer1 with F_CPU=8MHz and Prescaler=256. The logic is<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n TCCR1B|=(1&lt;&lt;WGM12);   \/\/CTC mode with TOP=OCR1A\n TCCR1B|=(1&lt;&lt;CS12);      \/\/Prescaler=256\n OCR1A=31249;   \/\/F_CPU=8MHz,Prescaler=256  Delay=  1s\n TIMSK|=(1&lt;&lt;OCIE1A); \/\/Timer\/Counter1, Output Compare A Match Interrupt Enable\n ISR(TIMER1_COMPA_vect)\n {\n   rps=  Global_Variable;  \/\/RPS Value\n   rpm=  Global_Variable *60;  \/\/RPM Value\n   Global_Variable =0;\n }\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-6 wp-block-paragraph\" style=\"color:#5c5c5c\">Since for purity external interrupt will be executed first than the timer compare interrupt. The main program is as follow-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n\/************************************************************************************************\n*************************************************************************************************\n*************************************RPM Meter***********************************************\n*************************************************************************************************\n\t\tSubeer Kumar Sarkar\n\t\tElectrical &amp; Electronic Engineer\n************************************************************************************************\n************************************************************************************************\n***********************************************************************************************\/\n#include&lt;stdio.h&gt;\n#include&lt;avr\/io.h&gt;\n#include&lt;avr\/interrupt.h&gt;\n#include&quot;lcd.h&quot;\nfloat rpm,sample=0,rps;\nchar display&#x5B;16];\nint main(void)\n{\nLCD_INIT(); \t\t\t\t\t\t\t\/\/LCD Initilation\nsei();\t\t\t\t\t\t\t\t\t\/\/Globel Interrupt Enable\nGICR |=(1&lt;&lt;INT0);\t\t\t\t\t\t\/\/External Interrupt Request 0 Enable\nMCUCR|=(1&lt;&lt;ISC01);\t\t\t\t\t\t\/\/The falling edge of INT0 generates an interrupt request\nTCCR1B|=(1&lt;&lt;WGM12); \t\t\t\t\t\/\/CTC mode with TOP=OCR1A\nTCCR1B|=(1&lt;&lt;CS12);\t\t\t\t\t\t\/\/Prescaler=256\nOCR1A=31249;\t\t\t\t\t\t\t\/\/F_CPU=8MHz,Prescaler=256  Delay=  1s\nTIMSK|=(1&lt;&lt;OCIE1A);\t\t\t\t\t    \/\/Timer\/Counter1, Output Compare A Match Interrupt Enable\nwhile(1)\n{\n\tLCD_write_string(1,1,&quot;***RPM Meter***&quot;);\n\tsprintf(display,&quot;RPM=%.0fRPS=%.0f&quot;,(double)rpm,(double)rps);\n\tLCD_write_string(1,2,display);\n}\nreturn 0;\n}\nISR(INT0_vect)\n{\n  sample++;\n}\nISR(TIMER1_COMPA_vect)\n{\n  rps=sample;\n  rpm=sample*60;\n  sample=0;\n}\n<\/pre><\/div>\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-7387b849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-3e41869c wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/RPM-meter.rar\" style=\"border-radius:10px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--40)\">download<\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p class=\"has-text-color has-link-color has-upper-heading-font-size wp-elements-7 wp-block-paragraph\" style=\"color:#323232\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/RPM-meter.rar\">RPM meter.rar<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this project we use IR Tx diode and IR Rx diode. The sensor circuit diagram is as follow- The RPM meter based on two procedures It is easy to calculate pulse using external interrupt pin. Let use ATmega8 for this purpose. The logic should be as soon as any falling edge is found, it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-1574","post","type-post","status-publish","format-standard","hentry","category-timer-counter"],"_links":{"self":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/1574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1574"}],"version-history":[{"count":15,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/1574\/revisions"}],"predecessor-version":[{"id":2597,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/1574\/revisions\/2597"}],"wp:attachment":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}