Arduinoã§1Hzã®PWMãçæãã
Arduinoã§ã¯analogWrite(pin,value)ã§PWMå€èª¿ããç©åœ¢æ³¢ãåºåããããšãã§ããŸãã éåžžã®PWMåšæ³¢æ°ã¯490Hzã997Hzãªã®ã§ããã ä»åã¯ãPWMåšæ³¢æ°ã1Hzãšããã話ã§ãã analogWrite()ã¯äœ¿ãããAVRã©ã€ã¯ãªæžãæ¹ãããŠãå®çŸããŸãã ATmega328ã®ããŒã¿ã·ãŒããšãã©ã¡ãã³ããªããã¬ãžã¹ã¿ãèšå®ããŸãã ã§ããã°ã¬ãžã¹ã¿ãªããé¢åããããããããããªããã觊ããããªãã£ããã§ããã©ãããããæ¹æ³ããªãïŒ PWMãšã¯ ãã®èŸºã¯èªåã®èŠæžã§ãããã®ã§ããããæ¹ã¯ãã£é£ã°ããŠãã ãã(^^) PWMã¯ãPulse Width Modulationãã®é æåããšã£ããã®ã§ãæåéããã«ã¹å¹ å€èª¿ã§ãã ç©åœ¢æ³¢ã®å¹ ãèªåšã«èª¿æŽããŠãå¹³åé»å§ãäžãããäžãããã§ããŸãã äŸãã°ã5Vã®é»å§ãONãã£ã±ãªãïŒ5Vã ãã£ã±ãªãïŒãªãå¹³åé»å§ã¯ãã¡ãã5Vã§ãã ã§ãããPWMã§åšæTäžã®ãªã³æéTonã®å²åDuty( = Ton / T )ã50%ã®ç©åœ¢æ³¢ãåºããŠããã°ãå¹³åé»å§ã¯ 5V * 50% = 2.5V ãšãªããååã®é»å§ãåºããŠããããšã«ãªããŸãã ãããLEDã«ç¹ããã°ãã¡ãã£ãšèæãç¹ããŸããã ãããªæãã§Dutyãè²ã å€ããã°ãé»å§ã調æŽã§ããããšãããããŸãã analogWriteé¢æ°ã§ã¯ãanalogWrite(pin,value)ã®valueãDutyã«çžåœããŸãã valueã¯0~255(= 8bit = 2^8 = 256)ã®å€ãšããŸãã ãªã1HzïŒ è©³ããã¯å¥èšäºã§çŽ¹ä»äºå®ã§ãããäœæž©èª¿çåšã§äœ¿ãSSRãå¶åŸ¡ããããã§ã(^^) SSRã¯ACé»å§ïŒäº€æµé»å§ïŒãå¶åŸ¡ããŸãã PWMã¯ãDCé»å§ïŒçŽæµé»å§ïŒã§ã¯Dutyã§å¹³åå€ãšããŠåãåºããŸãããACã ãšDuty=50%ãšããŠãååã®é»å§ã«ã¯ãªããŸããã ãŸãã50Hzãšããé ãåšæ³¢æ°ãå¶åŸ¡ããã®ã§ãArduinoããã©ã«ãã®PWMåšæ³¢æ°ã§ã¯æ©ãããŸããã ããã§ã1HzãšããŸããã Arduinoã®PWM ãšããã§PWMã¯ã¿ã€ããŒãšããæ©èœã§å®çŸããŠããŸãã ããã¯Arduinoã«éãããPICãmbedãªã©ã®ä»ã®ãã€ã³ã³ãããã§ãã Arduinoã¯ATmega328ãšããMicrochip瀟ïŒæ§Atmel瀟ïŒã®ãã€ã³ã³ãã¡ã€ã³ããããšããŠèŒããŠããŸãã Arduinoã«ã¯ïŒãšããããATmega328ïŒã«ã¯ä»¥äžã®3ã€ã®ã¿ã€ããŒïŒæ£ç¢ºã«ã¯Timer/CounterïŒããããArduinoã§ã¯ãããã以äžã®ãããªåœ¹å²ã«ãªã£ãŠããŸããïŒUnoã®äŸã§ãïŒ Timer/Counter ãããæ° Arduinoã§ã®pinçªå· Arduinoã§ã®åœ¹å² Arduinoã§ã®PWMåšæ³¢æ° Timer0 8bit 5,6 æ®éã®ããžã¿ã«ãã³,delay(),millis(),micros() PWMåºããªã997Hz Timer1 16bit 9,10 æ®éã®ããžã¿ã«ãã³ PWMåºããªã490Hz Timer2 8bit 3,11 æ®éã®ããžã¿ã«ãã³,tone() åäž ã¿ã€ããŒã¯3ã€ã®ãã¡ã©ãã䜿ã£ãŠãããã§ãããArduinoã®æ©èœãšããŠããdelay()ãtone()ã§Timer0ãTimer2ã䜿ã£ãŠããã®ã§ãTimer0ã2ã®PWMåšæ³¢æ°ãå€æŽããŠããŸããšåœ±é¿ãåºãŠããŸããŸãã äŸãã°ãdelay(500)ãšæžãã°500msã®ãŠãšã€ããæ¬æ¥çºçããŸãããå€æŽãããšåãããã«æžããŠã500msã§ã¯ãªããªã£ãŠããŸããŸãã ã§ãã®ã§ãäœã䜿ã£ãŠãªããããªTimer1ïŒ9ã10pinã®ã©ã¡ããïŒã䜿ãããšã«ããŸãã...