LECTURE 9 ¥µ¡¼¥Ü¥â¡¼¥¿¤òÆ°¤«¤¹¡Ê¹â®PWMµ¡Ç½»ÈÍÑ¡Ë

¡û ¤Ï¤¸¤á¤Ë

É®¼Ô¤¬¥Þ¥¤¥³¥ó¤ò»È¤Ã¤Æ¤ä¤ê¤¿¤«¤Ã¤¿»ö¤Î°ì¤Ä¤Ë¡¢¥µ¡¼¥Ü¥â¡¼¥¿¤òÆ°¤«¤·¤Æ¤ß¤è¤¦¡ª¤È¤¤¤¦¤Î¤¬¤¢¤ê¤Þ¤¹¡£Ê̤˥ޥ¤¥³¥ó¤Ç¤ä¤é¤Ê¤¯¤Æ¤â¤¤¤¤¤Î¤Ç¤¹¤¬¡¢²¿¤È¤Ê¤¯¡Ä¥µ¡¼¥Ü¥â¡¼¥¿¤Ï°ÌÃÖ·è¤á¤ÎÀºÅÙ¤¬¹â¤¯°ÂÄꤷ¤Æ¥È¥ë¥¯¤ò½Ð¤»¤ë¤Î¤Ç¡¢ºÇ¶á¤À¤È£²Â­Êâ¹Ô¥í¥Ü¥Ã¥È¤Î²ÄÆ°Éô¤Ë¤è¤¯»È¤ï¤ì¤Æ¤¤¤¿¤ê¤·¤Þ¤¹¡£

¥µ¡¼¥Ü¥â¡¼¥¿¤ÎÀ©¸æ¤Ë¤Ï¡¢²óž³Ñ¤Ë±þ¤¸¤¿°ìÄê¼þ´ü¤Î¥Ñ¥ë¥¹Éý¤Î¿®¹æ¤òÍ¿¤¨¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£²óž³Ñ¤òÊѤ¨¤ë¾ì¹ç¤Ï¥Ñ¥ë¥¹Éý¤òÊѤ¨¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£¤³¤ì¤ò PWM (Pulse Width Modulation) À©¸æ¤È¸À¤¤¤Þ¤¹¡£¤³¤³¤Ç¤Ï¡¢¥¿¥¤¥Þ/¥«¥¦¥ó¥¿1 ¤¬È÷¤¨¤Æ¤¤¤ë PWM µ¡Ç½¤Î¤¦¤Á¹â® PWM µ¡Ç½¤ò»È¤Ã¤Æ¡¢¥µ¡¼¥Ü¥â¡¼¥¿¤òÆ°¤«¤·¤Æ¤ß¤Þ¤¹¡£

¡û ¥µ¡¼¥Ü¥â¡¼¥¿¤Ë¤Ä¤¤¤Æ

¼Â¸³ÍѤËÍÑ°Õ¤·¤¿¤Î¤Ï¡¢GRAND WING(ÂæÏѤΥ᡼¥«¡¼) ¤Î S03T 2BB ¤È¤¤¤¦¥µ¡¼¥Ü¥â¡¼¥¿¤Ç¤¹¡£¤É¤³¤Ç¹ØÆþ¤·¤¿¤«Ëº¤ì¤Þ¤·¤¿¤¬¡¢1600±ß¤¯¤é¤¤¤À¤Ã¤¿Íͤʵ¤¤¬¤·¤Þ¤¹¡£

¥µ¡¼¥Ü¥â¡¼¥¿

°Ê²¼¤ÎÍͤʻÅÍͤǤ¹¡£¥È¥ë¥¯¤Ï½Ð¤ë¤±¤ì¤É®ÅÙ¤¬ÃÙ¤¤¤Î¤¬ÆÃħ¤ÎÍͤǤ¹¡£

  • ÅŸ»4.8V»þ ¥È¥ë¥¯¡§7.2kg-cm ®ÅÙ¡§0.33sec/60¡ë
  • ÅŸ»6.0V»þ ¥È¥ë¥¯¡§8.0kg-cm ®ÅÙ¡§0.27sec/60¡ë
  • ½Å¤µ 46£ç
  • À£Ë¡ 39.5¡ß20.0¡ß39.6mm

¥³¥Í¥¯¥¿Éôʬ¤Ï¢­¤ÎÍͤˤʤäƤ¤¤Þ¤¹¡£

¥³¥Í¥¯¥¿Éôʬ

GND ÅŸ» À©¸æ¿®¹æ
Ã㿧 ÀÖ¿§ ¥ª¥ì¥ó¥¸¿§

¢¨Àþ¤Î¿§¤Ï¥á¡¼¥«¡¼¤Ë¤è¤Ã¤Æ¿ô¼ïÎฺߤ¹¤ëÍͤǤ¹¡£

¥ª¥ì¥ó¥¸¿§¤ÎÀ©¸æ¿®¹æÀþ¤ò OC1A ¥Ô¥ó¤ÈÀܳ¤·¤Þ¤¹¡£¥á¡¼¥«¤Î»ÅÍͤˤè¤ë¤È¡¢1 ¼þ´ü¤ò 20ms ¤È¤·¤Æ¤½¤Î´Ö¤ËȯÀ¸¤µ¤»¤ë¥Ñ¥ë¥¹Éý¤Ë¤è¤Ã¤Æ²¼É½¤ÎÍͤ˲óž³ÑÅÙ¤¬·è¤Þ¤ëÍͤǤ¹¡£

¥Ñ¥ë¥¹Éý ²óž³ÑÅÙ
0.8¡Á0.9ms »þ·×²ó¤ê(CW)»þ¤Î°ÂÁ´Îΰè
0.9ms »þ·×²ó¤ê60¡ë¡Þ10¡ë
1.5ms 0¡ë¡ÊÃæ¿´°ÌÃÖ¡Ë
2.1ms È¿»þ·×²ó¤ê60¡ë¡Þ10¡ë
2.1¡Á2.2ms È¿»þ·×²ó¤ê(CCW)»þ¤Î°ÂÁ´Îΰè

¼Â¸³¤Ë¤è¤ë¤È¡¢Ìó0.57ms ¡Á 1.5ms ¡Á 2.5ms ÄøÅÙ¤ÎÈÏ°Ï¤Ç 180¡ëÄø¤Î²óž³ÑÅÙ¤ò³Îǧ¤Ç¤­¤Þ¤·¤¿¡£

²óžÊý¸þ¤È²óž³Ñ

¥Ñ¥ë¥¹¤ÎÍÍ»Ò

¡û ¥¿¥¤¥Þ/¥«¥¦¥ó¥¿1 ¤Î¹â® PWM µ¡Ç½¤Ë¤Ä¤¤¤Æ

¥¿¥¤¥Þ/¥«¥¦¥ó¥¿1 ¤Î¹â® PWM µ¡Ç½¤Ç¤Ï¡¢TCNT1 ¥ì¥¸¥¹¥¿¤È OCR1A/OCR1B ¥ì¥¸¥¹¥¿¤È¤ÎÈæ³Ó°ìÃפª¤è¤Ó TCNT1 ¥ì¥¸¥¹¥¿¤¬ 0x0000 ¤ËÅþ㤹¤ëºÝ¤Ë OC1A/OC1B ¥Ô¥ó¤Î½ÐÎϤòȿž¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¥«¥¦¥ó¥¿¤ÎºÇÂçÃͤÈÈæ³Ó°ìÃפËÍѤ¤¤ë OCR1A/OCR1B ¤ÎÃͤòÄ´À᤹¤ë¤³¤È¤Ç¡¢OC1A/OC1B ¥Ô¥ó¤Ë½ÐÎϤµ¤ì¤ë¥Ñ¥ë¥¹Éý¤òÀ©¸æ¤·¡¢¥µ¡¼¥Ü¥â¡¼¥¿¤òÆ°¤«¤·¤Þ¤¹¡£

¹â® PWM µ¡Ç½¤Ç¤Ï¥«¥¦¥ó¥¿ºÇÂçÃͤò 0xff (8¥Ó¥Ã¥È)/0x1ff (9¥Ó¥Ã¥È)/0x3ff (10¥Ó¥Ã¥È)/ICR1/OCR1A ¤«¤éÁª¤Ö¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ËÜʸ½ñ¤Ç¤Ï ICR1 ¤ò¥«¥¦¥ó¥¿ºÇÂçÃͤȤ·¤Æ»ÈÍѤ·¤Þ¤¹¡£¤Ê¤ª¥«¥¦¥ó¥¿ºÇÂçÃͤȤ·¤Æ ICR1 ¤È OCR1A ¤òÁª¤Ö¾ì¹ç¤Î°ã¤¤¤Ï¼ç¤Ë°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£

  • OCR1A ¤Ø¤Î½ñ¤­¹þ¤ß¤Ï TCNT1 ¤¬ 0x0000 ¤Ë¤Ê¤ë¥¿¥¤¥ß¥ó¥°¤ÇÈ¿±Ç¤µ¤ì¤Þ¤¹¡£¥«¥¦¥ó¥¿ºÇÂçÃͤòÊѹ¹¤¹¤ë¾ì¹ç¤Ï¥¿¥¤¥ß¥ó¥°¤¬°ìÄꤹ¤ë¤¿¤á¤³¤Á¤é¤¬¸þ¤¤¤Æ¤¤¤Þ¤¹¤¬¡¢¥«¥¦¥ó¥¿À©¸æ°Ê³°¤Ë»ÈÍѤ¹¤ëÈæ³Ó°ìÃץ쥸¥¹¥¿¤¬°ì¤Ä¸º¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

  • ICR1 ¤Ø¤Î½ñ¤­¹þ¤ß¤Ï¨ºÂ¤ËÈ¿±Ç¤µ¤ì¤Þ¤¹¡£¥«¥¦¥ó¥¿ºÇÂçÃͤò½ñ¤­´¹¤¨¤Ê¤¤¾ì¹ç¤Ë¤Ï¤³¤Á¤é¤¬»È¤¨¤Þ¤¹¡£

ËÜʸ½ñ¤Ç¤Ï ICR1 = 19999 ¤È¤·¡¢¥¿¥¤¥Þ/¥«¥¦¥ó¥¿1 ¤Î¥¯¥í¥Ã¥¯¤Ï ¥·¥¹¥Æ¥à¥¯¥í¥Ã¥¯/8 ¤È¤·¤Þ¤¹¡£¤³¤ì¤Ë¤è¤ê PWM ½ÐÎϼþÇÈ¿ô¤Ï

f_pwm = f_system_clock / (8 x (1 + ¥«¥¦¥ó¥¿ºÇÂçÃÍ)) = 8MHz / (8 x 20000) = 50Hz

¤Ä¤Þ¤ê 20ms ¤È¤Ê¤ê¤Þ¤¹¡£¤Þ¤¿ OC1A ¥Ô¥ó¤Î½ÐÎϥ⡼¥É¤ò

Èæ³Ó°ìÃ×»þ TCNT1=0x0000
Low ½ÐÎÏ High ½ÐÎÏ

¤ËÀßÄꤷ¤Þ¤¹¡£¤³¤Î¾ì¹ç¤Î TCNT1 ¤ÎÊѲ½¤È OC1A ¥Ô¥ó½ÐÎϤδط¸¤Ï²¼¿Þ¤ÎÄ̤ê¤È¤Ê¤ê¤Þ¤¹¡£

¹â® PWM Æ°ºî¤Î¥¿¥¤¥ß¥ó¥°

¤Þ¤¿¡¢OCR1A ¤ò²¼É½¤ÎÃͤËÊѲ½¤µ¤»¤ë¤³¤È¤Ç¡¢OC1A ¥Ô¥ó¤ËÀܳ¤·¤¿¥µ¡¼¥Ü¥â¡¼¥¿¤òÈ¿»þ·×²ó¤ê60¡ë¢ªÃæ¿´¢ª»þ·×²ó¤ê60¡ë¤È²óž¤µ¤»¤Þ¤¹¡£ËÜʸ½ñ¤Ç¤Ï¡¢OCR1A ¤Î¹¹¿·¤Ï TCNT1 ¤¬ ICR1 ¤ËÅþ㤷¤¿ºÝ¤ËȯÀ¸¤¹¤ëÊá³Í³ä¤ê¹þ¤ß»þ¤Ë¹Ô¤¤¤Þ¤¹¡£

OCR1A ¥Ñ¥ë¥¹Éý
2100 2.1ms
1500 1.5ms
900 0.9ms

¡û ²óÏ©¿Þ

LECTURE 1 ATmega8535 ¤ª¤è¤Ó»ÈÍѴĶ­¤Ë¤Ä¤¤¤Æ ¤Ë·ÇºÜ¤·¤Æ¤¢¤ëÁ´ÂβóÏ©¿Þ¤ËÂФ·¤Æ¡¢ATMega8535 ¤Î OC1A ¥Ô¥ó¤ª¤è¤Ó¥µ¡¼¥Ü¥â¡¼¥¿¤ÈÀܳ¤¹¤ë¿®¹æÀþ¡Ü¥³¥Í¥¯¥¿Éôʬ¤òÀÖÏȤǰϤó¤À¿Þ¤ò ¤³¤Á¤é ¤ËÃÖ¤¤¤Æ¤ª¤­¤Þ¤¹¡£

¤³¤Î¥³¥Í¥¯¥¿¤È¥µ¡¼¥Ü¥â¡¼¥¿¤Î¥³¥Í¥¯¥¿¤ò¡¢¿®¹æÀþ¤¬¹ç¤¦ÍͤËÀܳ¤·¤Æ¤¯¤À¤µ¤¤¡£

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÈÀâÌÀ

¥¿¥¤¥Þ/¥«¥¦¥ó¥¿1¤Î¹â® PWM µ¡Ç½¤ò»È¤Ã¤Æ¥µ¡¼¥Ü¥â¡¼¥¿¤òÆ°¤«¤¹¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò 09pwm.tar.gz ¤«¤é¥À¥¦¥ó¥í¡¼¥É¤Ç¤­¤Þ¤¹¡£¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤é¡¢Á´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò ¸Ç¤á¤¿ tar ¥Õ¥¡¥¤¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

Ãæ¤Ë¤Ï

  • Makefile
  • util.h
  • util.c
  • timer1.h
  • timer1.c
  • main.c

¤¬³ÊǼ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£util.h/util.c ¤Ë¤Ä¤¤¤Æ¤Ï LECTURE 4 A/D ÊÑ´¹¤Ç¥Ü¥ê¥å¡¼¥à¡Ê²ÄÊÑÄñ¹³¡ËÃͤòÆÉ¤à ¤ÎÆâÍƤÈƱ¤¸¡¢timer1.h/timer1.c ¤Ë¤Ä¤¤¤Æ¤Ï LECTURE 8 ¥¿¥¤¥Þ/¥«¥¦¥ó¥¿1¤ò»È¤¦ ¤ÎÆâÍƤÈƱ¤¸¤Ç Makefile ¤â¤Û¤È¤ó¤ÉÊѤï¤é¤Ê¤¤¤Î¤Ç¡¢main.c ¤Ë¤Ä¤¤¤Æ°Ê²¼¤ËºÜ¤»¤Þ¤¹¡£¤Ê¤ª¡¢°Ê²¼¤Ë·ÇºÜ¤·¤Æ¤¤¤ë¥½¡¼¥¹¥³¡¼¥É¤Ë¤Ï½¤Àµ BSD ¥é¥¤¥»¥ó¥¹¾ò¹à¤ò´Þ¤á¤Æ¤¤¤Þ¤»¤ó¤¬¡¢¥½¡¼¥¹¥³¡¼¥ÉÇÛÉۤϽ¤Àµ BSD ¥é¥¤¥»¥ó¥¹¤Ë½¾¤¤¤Þ¤¹¡Ê¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤ÎÌÈÀÕ»ö¹à¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡Ë¡£

¤³¤ì¤Þ¤Ç¤Ë¥Ò¥å¡¼¥º¥Ó¥Ã¥È¤ÎÀßÄê¤ò¹Ô¤Ã¤¿¤³¤È¤¬°ìÅÙ¤â̵¤¤¾ì¹ç¤Ï¡¢¤Þ¤ººÇ½é¤Ë make fuse ¤ò¼Â¹Ô¤·¤Æ¤¯¤À¤µ¤¤¡£fuse ¥¿¡¼¥²¥Ã¥È¤Ë¤Ä¤¤¤Æ¤Ï¡¢LECTURE 2 LED ¤òÅÀÌǤµ¤»¤ë ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Î¹à¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

make ¼Â¹Ô¸å¡¢¥×¥í¥°¥é¥à¤ò¥¢¥Ã¥×¥í¡¼¥É¤¹¤ë¾ì¹ç¤Ï make uisp ¤ò¼Â¹Ô¤·¤Æ¤¯¤À¤µ¤¤¡£

¥µ¡¼¥Ü¥â¡¼¥¿¤¬Ìó 1 ÉÃËè¤ËÈ¿»þ·×²ó¤ê60¡ë¢ªÃæ¿´¢ª»þ·×²ó¤ê60¡ë¡Ä¤Î½ç¤Ë²óž³Ñ¤òÊѤ¨¤Þ¤¹¡£

¤³¤Á¤é¤Ï¥µ¡¼¥Ü¥â¡¼¥¿Æ°ºî¤ÎÆ°²è¤Ç¤¹¡Ê10Éá£YouTube ¤ËÀܳ¤·¤Þ¤¹¡Ë¡£

  • main.c
        1    #include <avr/interrupt.h>
        2    #include <avr/io.h>
        3    #include <avr/sleep.h>
        4    
        5    #include "timer1.h"
        6    #include "util.h"
        7    
        8    
        9    #define ICR1_AS_TOP     19999
       10    #define OCR1A_LIMIT_CCW 2100
       11    #define OCR1A_CENTER    1500
       12    #define OCR1A_LIMIT_CW  900
       13    
       14    static void timer1_ic_interrupt(void);
       15    
       16    
       17    int
       18    main(void)
       19    {
       20            DDRD |= _BV(DDD5);  /* PD5 ¥Ô¥ó¤ò½ÐÎϤËÀßÄê */
       21            pullup();
       22    
       23            timer1_ic_enable();
       24            timer1_ic_set_interrupt(timer1_ic_interrupt);
       25            timer1_set_wave_mode(WGM1_FAST_PWM_ICR1);
       26            timer1_set_coma_mode(COM_A_HIGH_FIRST);
       27            timer1_set_count(0);
       28            timer1_set_icr1(ICR1_AS_TOP);
       29            timer1_set_ocr1a(OCR1A_LIMIT_CCW);
       30    
       31            sei();
       32    
       33            /* (8MHz/8)/20000 = 50Hz */
       34            timer1_start(TIMER1_CK_8);
       35        
       36            while (1){
       37                    sleep_mode();
       38            }
       39    
       40            return 0; /* ·Ù¹ð¤òÈò¤±¤ë¤¿¤á */
       41    }
       42    
       43    
       44    static void 
       45    timer1_ic_interrupt(void)
       46    {
       47            static int ocra[3] = {
       48                    OCR1A_LIMIT_CCW,
       49                    OCR1A_CENTER,
       50                    OCR1A_LIMIT_CW,
       51            };
       52    
       53            static int dir   = 0;
       54            static int count = 0;
       55    
       56            /* 1ÉÃËè¤ËÊý¸þ¤òÊѤ¨¤ë */
       57            if (++ count == 50) {
       58                    dir = (dir + 1) % 3;
       59                    count = 0;
       60                    timer1_set_ocr1a(ocra[dir]);
       61            }
       62    }
       63    
       64    /* End of main.c */
    
    
    • 17 ¡Á 41 ¹ÔÌÜ (main())

      • pullup() ¤ÎÁ°¤Ë PORTD5 ¤Î¤ß½ÐÎÏÊý¸þ¤ËÀßÄê
      • pullup() (pullup.h¡¢PORTD5 °Ê³°¤ÎÁ´ÆþÎϥݡ¼¥È¤ÎÆâÉô¥×¥ë¥¢¥Ã¥×¤òÍ­¸ú²½)
      • timer1_ic_enable() (timer1.h¡¢¥«¥¦¥ó¥¿ºÇÂçÃÍ ICR1 Åþã»þ¤ÎÊá³Í³ä¤ê¹þ¤ßÍ­¸ú²½)
      • timer1_ic_set_interrupt() (timer1.h¡¢Êá³Í³ä¤ê¹þ¤ß»þ¤Ë¼Â¹Ô¤¹¤ë¥æ¡¼¥¶´Ø¿ô¤ÎÅÐÏ¿)
      • timer1_set_wave_mode() (timer1.h¡¢ÇÈ·ÁÀ¸À®¼ïÊ̤òÀßÄê)
      • timer1_set_coma_mode() (timer1.h¡¢Èæ³ÓA½ÐÎϥ⡼¥É¤òÀßÄê)
      • timer1_set_count() (timer1.h¡¢TCNT1 ¤Î½é´üÃͤòÀßÄê)
      • timer1_set_icr1() (timer1.h¡¢ICR1 ¤ÎÃͤòÀßÄê)
      • timer1_set_ocr1a() (timer1.h¡¢OCR1A ¤ÎÃͤòÀßÄê)

      ¤ò¹Ô¤Ã¤¿¸å¡¢sei() (avr/interrupt.h) ¤ò¼Â¹Ô¤·¤Æ¥·¥¹¥Æ¥à¤Î³ä¤ê¹þ¤ß¤òÍ­¸ú²½¤·¤Æ¤¤¤Þ¤¹¡£

      ¤³¤Î½é´ü²½¥Õ¥§¡¼¥º¤Ç timer1_set_wave_mode(WGM1_FAST_PWM_ICR1) ¤Ë¤è¤Ã¤ÆÇÈ·ÁÀ¸À®¼ïÊ̤ò "¹â® PWM Æ°ºî¡Ê¥«¥¦¥ó¥¿ºÇÂçÃÍ¤Ï ICR1¡Ë"¤ËÀßÄꤷ¤Æ¤¤¤Þ¤¹¡£ ¤Þ¤¿¡¢timer1_set_coma_mode(COM_A_HIGH_FIRST) ¤Ë¤è¤Ã¤Æ OC1A ¥Ô¥ó¤Î½ÐÎϥ⡼¥É¤ò

      Èæ³Ó°ìÃ×»þ TCNT1=0x0000
      Low ½ÐÎÏ High ½ÐÎÏ

      ¤ËÀßÄꤷ¤Æ¤¤¤Þ¤¹¡Ê¥¿¥¤¥Þ/¥«¥¦¥ó¥¿1 ¤Î¹â® PWM µ¡Ç½¤Ë¤Ä¤¤¤Æ»²¾È¡Ë¡£

      ¤Þ¤¿¡¢timer1_ic_enable()/timer1_ic_set_interrupt() ¤òÍѤ¤¤ÆÊá³Í³ä¤ê¹þ¤ß¤òÍ­¸ú¤Ë¤·¤Æ¤¤¤Þ¤¹¡£ ¹â® PWM µ¡Ç½¤Ç ICR1 ¤ò¥«¥¦¥ó¥¿ºÇÂçÃͤˤ¹¤ë¤È¡¢¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤ÈƱ»þ¤ËÊá³Í³ä¤ê¹þ¤ß¤¬È¯À¸¤·¤Þ¤¹¡£ ¤³¤³¤Ç¤Ï¥ª¡¼¥Ð¡¼¥Õ¥í¡¼³ä¤ê¹þ¤ß¤ÎÂå¤ï¤ê¤Ë¤³¤Á¤é¤ò»È¤¦¤³¤È¤Ë¤·¤Þ¤·¤¿¡£

      °Ê¸å sleep_mode() ¤Ë¤Æ¥¢¥¤¥É¥ëÆ°ºî¤Ë°Ü¹Ô¤·¡¢¥µ¡¼¥Ü¥â¡¼¥¿¤Î¼ó¿¶¤êÀ©¸æ¤Ï Êá³Í³ä¤ê¹þ¤ß¥Ï¥ó¥É¥é¤ËǤ¤»¤Þ¤¹¡£

    • 44 ¡Á 62 ¹ÔÌÜ (timer1_ic_interrupt())

      Êá³Í³ä¤ê¹þ¤ß»þ¤Ë¼Â¹Ô¤µ¤ì¤ë¥æ¡¼¥¶´Ø¿ô¤Ç¤¹¡£²¿¤â¤·¤Ê¤±¤ì¤Ð¥µ¡¼¥Ü¥â¡¼¥¿¤ÏÆ°¤­¤Þ¤»¤ó¡£

      static ÊÑ¿ô¤Ç¤¢¤ë count ¤Ç³ä¤ê¹þ¤ß²ó¿ô¤ò¿ô¤¨¡¢50 ²ó¤Ë°ìÅÙ OCR1A ¤ÎÃͤòÊѤ¨¤ë¤³¤È¤Ç¥Ñ¥ë¥¹Éý¤òÊѤ¨¤Þ¤¹¡£³ä¤ê¹þ¤ß¼þ´ü¤¬ 50Hz ¤Ç¤¢¤ë¤¿¤á¡¢OCR1A ¤ÎÊѹ¹¼þ´ü¤Ï 50/50 = 1 Hz = 1 ÉäȤʤê¤Þ¤¹¡£¤Ä¤Þ¤ê 1 ÉÃËè¤Ë¥µ¡¼¥Ü¥â¡¼¥¿¤Ï¸þ¤­¤òÊѤ¨¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

°Ê¾å¤Ç²òÀâ¤Ï½ª¤ï¤ê¤Ç¤¹¡£¼¡²ó¤Ï¡¢¥¿¥¤¥Þ/¥«¥¦¥ó¥¿0 ¤ÎÈæ³Ó°ìÃ׳ä¤ê¹þ¤ß¤ò»È¤Ã¤ÆƱ¤¸Íͤ˥µ¡¼¥Ü¥â¡¼¥¿¤òÆ°¤«¤·¤Æ¤ß¤¿¤¤¤È»×¤¤¤Þ¤¹¡£