ãµãŒããåããã·ã¹ãã ã§äžèŠãªèŠçŽ ãåé¿ããéãæ倧éã«äœ¿çšããæ¹æ³ã«é¢ããçãæçš¿
èæ¯
ç§ã¯éåžžã«é·ãéç æ°ã«ããã£ãŠãããLinuxãOpenWRTããããã¯ãŒã¯ããã³ã¯ã€ã€ã¬ã¹ãã¯ãããžãŒãã»ãã¥ãªãã£ã«æ©ãŸãããŠããŸããããä»ã§ã¯åŸã ã«ããããå·¥åŠãã¹ããŒãããŒã ã«ææããŠããŸãã ããã¯ãã¹ãŠãç¹ã«æ¢è£œã®ãã³ãã¬ãŒããç¡æã®ãªãŒãã³ãœãŒã¹ã³ãŒããéåžžã«å€ãå Žåãéåžžã«ã¯ãŒã«ã§ãããæã«ã¯å®å šã«æªã®åŽé¢ã«è¡ããããžãã¯ãã¹ã¯ã©ããã«ãã°ããæããããšãã§ããŸãã
ãã ããLEDãç¹æ» ããã ãã§ãªããé¢å¿ãç®èŠãããããå¹æãæž¡ãããé©çšãããåé¡ã解決ããå¿ èŠããããŸãã ããã§ãå®æåã®è±å¯ããè³è³ãã¹ãã ãšæãããŸãããæªéã¯ãã€ãã®ããã«è©³çŽ°ã«ãããŸãã
/
ããžãã¯ãå¶åŸ¡ããããšã®1ã€ã§ããããã«ãããã©ã€ãã®ãªã³/ãªããç°¡åã«ãªããŸãããŸãã倧æ°è³ªã»ã³ãµãŒïŒMQ-135ïŒãæŸããå¿ èŠã«å¿ããŠããŒãããªã³ã«ããããšãã§ããŸãã ããã¯ãã¹ãŠã¯ãŒã«ã§ããã21äžçŽã®äžåºã§ã¯ãå®å®è¹ãçŽ æŽãããåå Žãèããéã¯ãã£ãšã¯ãŒã«ãªãã®ãæ±ããŸãã ç§ã®èŠç·ã¯ãµãŒãã®å¶åŸ¡ã«èœã¡ãŸããã ã©ãããŠïŒ ãããã¯ã¯ãããããããåçŽãªæ æããŸã§ãå€ãã®ã¡ã«ããºã ã«ååšãããããéåžžã«åºç¯å²ã§ãã ãã©ã¹ã¯ãèªç©ºæ©ã§ã¯ãšã³ãžã³ãåãæ¹æ³ã§å¶åŸ¡ãããããã«ãã䜿çšç¯å²ãåçŽã«æ¡å€§ãããšããäºå®ã§ãã
ãã£ããã®äžã§æåŸ ããèå³ã®ãã人
é·ãéãããã¯ã«ç²ŸéããŠããããã€ã³ãã«ãŸã£ããã«è¡ããã人-ã ã¹ããããã€ã¹ããã ãã»ã¯ã·ã§ã³ã«ã¹ã¯ããŒã«ããŠãæ°è»œã«ã
æåããå§ãã
ãã®ããŒãã®æ¬è³ªã¯èª°ããç解ã§ãããã®ã§ãã£ãããããŸããµãŒãã®ã³ã³ããŒãã³ãã«æ³šæãæãå¿ èŠããããŸãã
é»æ°ã¢ãŒã¿ãŒãã®ã¢ããã¯ã¹ãããã³ã·ã§ã¡ãŒã¿ãŒãã³ã³ãããŒã©ãŒã ç¬åµçãªãã®ã¯ãã¹ãŠã·ã³ãã«ã§ããã
ãµãŒããã©ã€ãã®å¶åŸ¡ã«ã¯ããã«ã¹å¹ å€èª¿ãŸãã¯PWMã䜿çšãããŸãã è€éãªããšã¯äœããªããããã¯åãªãç©åœ¢ãã«ã¹ã®åœ¢ã®ä¿¡å·ã§ãã äž»ãªãã©ã¡ãŒã¿ã¯ããã«ã¹å¹ ãšããŒãºå¹ ã§ãã ãäžæåæ¢ãããŸãã¯æ£ããåŒã³åºãæ¹ãè¯ã-æéã¯ãä¿¡å·ã®åšæ³¢æ°ãèšå®ããŸãã ããšãã°ã100 msã®åšæå¹ ãããå Žåãåšæ³¢æ°ã¯10 Hzã«ãªããŸãã èšç®ã¯éåžžã«ç°¡åã§ããããªç§ãç§ã«å€æãããã®æ°å€ã§åäœãé€ç®ããŸãã ãããã£ãŠã100ms = 0.1sã§ã1ã0.1ã§å²ããš10ã«ãªããŸããé»åã§ç¢ºèªã§ããŸãã
ãã«ã¹å¹ ã¯ãµãŒãã®å転è§åºŠãèšå®ããèªç©ºæ©ã¢ãŒã¿ãŒã®å Žåã¯å転ã®é床ãšæ¹åãèšå®ããŸãã
æŠç¥çã«ã¯ã次ã®ããã«ãªããŸãã
ãããŠããã®ãããªãªã·ãã¹ã³ãŒãã§ïŒ
次ã«ããµãŒãããã®ãããªä¿¡å·ãã©ã®ããã«èªèãããã«ã€ããŠèª¬æããŸãã ãããŠãæªéã¯çŽ°éšãŸã§éãã«å¿ã³å¯ã£ãŠããŸãã
å®éã«ã¯ãã³ã³ãããŒã©ãŒã¯ããžã¿ã«ã§ãã¢ããã°ã§ãããŸããŸããã
ãããå®å šã«åçŽãªå Žåãéãã¯ã¢ããã°ã³ã³ãããŒã©ãŒãã€ã³ãã«ã¹ã®ç¬éã«ã®ã¿é»å§ãäŸçµŠãããããŸãã¯äŸçµŠããªãããšã§ãã ãã«ã¹ééã40ã120ããŸãã¯ããšãã°240ããªç§ã«èšå®ãããšãåäœäžã«ãµãŒããã©ã®ããã«ããŽããŽããåãå§ããããããããŸãã ããã¯ããã€ã¯ãåè·¯ãå éšã«ããããµãŒããã©ã€ãå šäœã®åšæ³¢æ°ãå€éšä¿¡å·ã®åšæ³¢æ°ã«çããããã§ãã æšæºã®20ããªç§ã¯50 Hzã40ããªç§ã¯25 Hzã§ãã ãããã£ãŠãé»å§ãã¢ãŒã¿ïŒïŒã«äŸçµŠãããïŒãŸãã¯äŸçµŠãããªãïŒãŸãã¯æ¯ç§ïŒïŒåã åšæ³¢æ°ãäžããããšã§ããã«ã¯ãå€§å¹ ã«æžãããã¡ã«ããºã ã®ããé ãåäœãå®çŸã§ããŸãããæ¢ã«èª¬æãããããããããç ç²ã«ããŸãã
éåžžãããžã¿ã«ã³ã³ãããŒã©ãŒã¯ã¹ãã©ããä»ãã®å°ããªãã€ã¯ãããã»ããµã§ãã ã¢ããã°ãã€ã¯ãåè·¯ãšã®äž»ãªéãã¯ãåäœã®å éšåšæ³¢æ°ãäžå®ã§ããããšã§ãã å¶åŸ¡ä¿¡å·ã®åšæ³¢æ°ã奜ããªã ãæžããããšãã§ããŸããããã¯åå¿æéã«ã®ã¿åœ±é¿ããŸããããã«ã¯ã¯äžå®ã§ãã ãã ããé·ãééã§å°ããªéšåã§äœçœ®ã®å€åãäžãããšãé ãå転é床ãå®çŸã§ããŸãã ãã§ã«ç¹å®ã®ãµãŒããšãã®ãã©ã¡ãŒã¿ãŒã«äŸåããŠããŸãã
ä¿¡å·ãçæããæ¹æ³ã¯ïŒ
ãã®ããã«ã圌ãã¯éåžžäœããã®çš®é¡ã®ãã€ã¯ãã³ã³ãããŒã©ãŒã䜿çšããArduinoãã©ãããã©ãŒã ã«ç¹å¥ãªæãæã£ãŠããŸãã ãã¹ãŠãã·ã³ãã«ã§ãã æ¢è£œã®ã©ã€ãã©ãªã䜿çšãããä¿¡å·ãã©ã¡ãŒã¿ãŒãç®çã®é¢æ°ã«äŸçµŠããç®çã®å¹ ã®æå®ãããGPIOã§ãã«ã¹ãååŸããŸãã
ããããã¡ã€ã³ããã€ã¹ãšãã¢ã«ãªã£ãŠãããã€ã¯ãã³ã³ãããŒã©ãŒãšãåé¡ã解決ããããã®ã³ã³ãããŒã©ãŒèªäœã®ãã¯ãŒã䜿çšããæ¹æ³ããªãå Žåã¯ã©ãã§ããããïŒ ä»£æ¿ãªãã·ã§ã³ãæ¢ãããšã¯æ®ã£ãŠããŸãã ãããŠãç§ã¯ãã®ãããªãã®ãæã£ãŠããŸãïŒ
ã¿ã€ãã«ãããã§ã«æãããªããã«ãOpenWrtãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã䜿çšãããŸãã ããã¯æ¬è³ªçã«æ¬æ ŒçãªLinuxã«ãŒãã«ãã£ã¹ããªãã¥ãŒã·ã§ã³ã§ãã ãããŠãååãªæ©äŒãšã«ã¹ã¿ãã€ãºã®æè»æ§ãæäŸããŸãã OpenWrtãšãã®æŽŸçç©ã¯ãããŸããŸãªãã¹ããŒãããŒã ãã·ã¹ãã ã§ç©æ¥µçã«äœ¿çšãããŠããŸããããã®è©³çŽ°ã«ã€ããŠã¯å¥ã®èšäºã§èª¬æããŠããŸãã PWMïŒãŸãã¯ãã«ãžã§ã¢PWMïŒä¿¡å·ãçæããæ¹æ³ã¯ïŒ Arduinoã»ã©è€éã§ã¯ãªãããšãããããŸããã ãããè¡ãã«ã¯ãåãGPIOã䜿çšããå¿ èŠããããã©ã€ãã©ãªã®ä»£ããã«PWM-GPIO-CustomãšåŒã°ããã«ãŒãã«ã¢ãžã¥ãŒã«ã䜿çšããå¿ èŠããããŸãã åäœããOpenWrtã®æåŸã®å®å®ããŒãžã§ã³ã¯12.09ã§ããããããç解ããããã«çŸåšã®ãã©ã³ã¯ã§åäœãããããã«çŽ1é±éãè²»ãããŸããã çç±ã¯ããããŸããããå ¬åŒãªããžããªã«ã¯ãã®ã¢ãžã¥ãŒã«ã®ããã±ãŒãžã¯ãªããèªåã§çµã¿ç«ãŠãå¿ èŠããããŸãããããã»ã©é£ãããããŸããã 以äžã«æ¹æ³ãæžããŸãã
é ãè¿œã£ã説æ
ãã®ããããŸãã¯OpenWrtãã«ãããŒã«ããããããŠã³ããŒãããå¿ èŠããããŸãã æ£çŽã«èšããšãLinuxã®ã€ã³ã¹ããŒã«ããå§ããå¿ èŠããããŸãããå€ãã®äººããã§ã«ãã®ãã€ã³ããå®äºããŠããããšãé¡ã£ãŠããŸãã
ã ãããããªãã¯ããŒã«ãããçšã®ãã©ã«ããäœæããããã«è¡ããŸãã
ã³ãã³ãã䜿çšããŠãœãŒã¹ãããŠã³ããŒãã§ããŸã
git clone git://git.openwrt.org/12.09/openwrt.git
ãŠã£ã³ããŠã®äžéšã«ç«¯æ«ããããŸããïŒ
ç³ãèš³ãããŸããããããã¯éåžžã«äŸ¿å©ã§ãã
ããŠã³ããŒãåŸãopenwrtãã©ã«ããŒã«ç§»åããã³ãã³ãã䜿çšããŠããã±ãŒãžãããŠã³ããŒãããå¿ èŠããããŸã
git clone git://git.openwrt.org/12.09/packages.git
ããã§ããã¹ãŠã®ããã±ãŒãžãœãŒã¹ã³ãŒããã§ããŸããã ããããåŸ ã£ãŠãã ãã...ããããpwm-gpio-customã¯ã©ãã§ããïŒ åœŒã¯ããã«ããŸããã
絶æããªãã§ãã ããã 圌ã¯ããã«ããŸã
openwrt / packageå ã®ã³ã³ãã³ãã解åããã ãã§ããã¹ãŠåé¡ãããŸããã
ããã§ãã¢ã»ã³ããªã«çŽæ¥æž¡ããŸãã
openwrtãã©ã«ããŒããã-jn
make -jn kernel_menuconfig
å®è¡ããå¿ èŠããããŸã
nã®ä»£ããã«ãã³ã¢ã®æ°+ 1ã«çœ®ãæããå¿ èŠããããŸãã
éãã¡ãã¥ãŒãéããŸãã [ããã€ã¹ãã©ã€ã]ãéžæããŸãã
PWMãµããŒããæ€çŽ¢ïŒ
GPIOã䜿çšããŠã¢ã€ãã PWMãšãã¥ã¬ãŒã·ã§ã³ãã¢ã¯ãã£ãã«ããŸãã ã¹ããŒã¹ãéžæããŠãã ããã ã©ãã«ã§ãæãããããšãå¿ èŠã§ããããã¯éèŠã§ãïŒ
ãã®åŸãã«ãŒãã«ãå°ãåæ§æããå¿ èŠããããŸãã é©åãªã¢ã€ãã ãæ¢ããŠããŸãïŒ
[é«è§£å床ã¿ã€ããŒãµããŒã]é ç®ã«ã¢ã¹ã¿ãªã¹ã¯ãä»ããã¿ã€ããŒã®é »åºŠã1000HZã«èšå®ãã[ãã¬ãã·ã§ã³ã¢ãã«]ãã©ã¡ãŒã¿ãŒã§[äœé 延ãã¹ã¯ããã]ãéžæããŸãã
ã«ãŒã¿ãŒã®ããŒããŠã§ã¢ãã©ãããã©ãŒã ã確å®ã«ç¥ãå¿ èŠããããŸãã ãããããã£ãšéèŠãªã®ã¯ãæ§æã§æå®ããããšã§ãã ãã®Atheros ar71xxããããŸãïŒ
å¿ èŠãªã«ãŒãã«æ§æãå®äºããŸããã ããã§ãæåŸã®Exitãã¯ãªãã¯ãããšããã«ãã·ã¹ãã ã¯å€æŽãä¿åãã䟡å€ããããã©ãããå°ããã®ã§ãè¯å®ã§çããå¿ èŠããããŸãã
次ã«ãã³ãã³ã
make -jn menuconfig
䜿çšããŠãåãæ¹æ³ã§OSã®ã¢ã»ã³ããªãæ§æããå¿ èŠããããŸãã
次ã«ã[ã«ãŒãã«ã¢ãžã¥ãŒã«]ã¡ãã¥ãŒã§ïŒ
ä»ã®ã¢ãžã¥ãŒã«ãéžæïŒ
ãããŠãkmod-pwm-gpio-customã«ã¢ã¹ã¿ãªã¹ã¯ãä»ããŸãïŒ
ãã¹ãŠãçµã¿ç«ãŠãéå§ã§ããŸãã ãã¹ãŠåã
make -jn
åŸãã«å¯ãããã£ãŠäœããèŠãããšãæ®ã£ãŠããŸãããè¶/ã³ãŒããŒã飲ãããšãã§ããŸããçµã¿ç«ãŠããã»ã¹ã¯éããããŸããã
ãã«ããå®äºãããšã binãã©ã«ããŒã«ç§»åã§ããŸãã ãã©ãããã©ãŒã ãšç»åãå«ããã©ã«ããŒããããŸãã æšæºã®æ瀺ã«åŸã£ãŠå®å šã«ãã©ãã·ã¥ã§ããŸãã ãã¡ãŒã ãŠã§ã¢ããã»ã¹ãå®äºãããšããã«ãtelnetãå®å šã«ééã§ããŸãã kmod-pwm-gpio-customããã±ãŒãžãããã€ã¹èªäœã«è¿œå ããŠã³ããŒãããå¿ èŠããããŸãã ããã¯ãSCPãŸãã¯wgetãä»ããŠè¡ãããopenssh-sftp-serverãã€ã³ã¹ããŒã«ããŠFileZillaã䜿çšããŸãã
ROMã¯ãŽã ç¶ã§ã¯ãªãããã®ãã£ã¬ã¯ããªã¯ç©ççã«RAMïŒéåžžã¯32ã64 MbïŒã«ãããããããã±ãŒãžèªäœã/ tmpãã£ã¬ã¯ããªã«ããŠã³ããŒãããããšããå§ãããŸãã ããã±ãŒãžãããŠã³ããŒãããåŸã
opkg install /tmp/kmod-pwm-gpio-custom_xxx.ipk.
å¿ èŠããããŸã
opkg install /tmp/kmod-pwm-gpio-custom_xxx.ipk.
ããã±ãŒãžã®ååãããŸãæ°ã«ããããšã¯ã§ããŸãããTABã®èªåè£å®ã¯ããŸãæ©èœããŸãã
PWMä¿¡å·çæ
ããã±ãŒãžãã€ã³ã¹ããŒã«ããåŸãGPIOã®çŽæ¥å¶åŸ¡ãšPWMä¿¡å·ã®çæã«é²ãããšãã§ããŸãã
ãããè¡ãã«ã¯ãã«ãŒãã«ã¢ãžã¥ãŒã«ãã¢ã¯ãã£ãã«ããå¿ èŠããããŸãã ãããè¡ãã«ã¯ã
insmod pwm-gpio-custom bus0=0,23 bus1=1,20
ã³ãã³ã
insmod pwm-gpio-custom bus0=0,23 bus1=1,20
ããã¯ããã®æ¹æ³ã®ã»ãã®äžäŸã§ãã busXã¯ã
/sys/lass/pwm
åãçªå·ã®äžã§ããã£ã©ã¯ã¿ãŒããã€ã¹ãä»ããŠå¶åŸ¡ã§ãããã¹ã®çªå·ãèšå®ããŸãããã®ãã¡ã®2ã€ããããŸãïŒ gpio_pwm.0ïŒ0ããã³gpio_pwm.1ïŒ0 ã 察å¿ããå€æ°ããã¡ã€ã«ã«æžã蟌ãã ãã§ãPWMãã©ã¡ãŒã¿ãŒãæäœã§ããŸãã ã¯ããã»ãšãã©å¿ããŠããŸããããã¹ãŠã®å€ã¯ããç§ã§èšå®ãããŠããŸãã è¡ããïŒ
echo 10000000 > /sys/class/pwm/gpio_pwm.0\:0/period_ns
æéãæå®ããŸãã ãã®å Žåã100 Hzã§ãã
echo 8500000 > /sys/class/pwm/gpio_pwm.0\:0/duty_ns
ãã¥ãŒãã£ãµã€ã¯ã«ãæå®ããŸãã
ã¯ããããã©ã«ãã§ã¯äžéšã®çµè«ãå転ããŸããæéå ã®ããã€ããã®æéãèšå®ããå¿ èŠããããŸãã GPIOã®Highå€ã1ã®å Žåã
echo 1500000 > /sys/class/pwm/gpio_pwm.0\:0/duty_ns
ãèšå®ããå¿ èŠããããŸãããã«ã¹èªäœã®æéã瀺ãããŸãã
çµéšçã«ç¢ºèªã§ããŸãã ãã¶ãç§ã¯èŠã€ãããã誰ããããªããããçŸããããæ¹æ³ãæããŠãããã§ããã=ïŒ
çŸåšã¯ãä¿¡å·ãã¢ã¯ãã£ãã«ããããã ãã«æ®ã£ãŠããŸãã
echo 1 > /sys/class/pwm/gpio_pwm.0\:0/run
ãããŠããªã·ãã¹ã³ãŒãã§æ¬¡ã®ããã«ãªããŸã
ãµãŒãã±ãŒãã«ãPWMãã³ã«æ¥ç¶ãããšãæ£ç¢ºã«äžå€®ã®äœçœ®ã«åãŸããŸãã ãã¡ãããé»æºãæ¥ç¶ããå¿ èŠããããŸãã
ãããã«
ãã®ããã«ããŠã200 Hzã®åšæ³¢æ°ã§ä¿¡å·ãçæããããšãã§ããŸããã€ãŸãã1ã€ã®ãã©ã€ãã®åå¿æéã5 msã«ççž®ãããŸãã ããã¯ã®ééã«ã¯éèŠã§ã¯ãªããããããŸããããèªç©ºæ©ã«ãšã£ãŠã¯éåžžã«éèŠã§ãã è¿ãå°æ¥ãã¢ãŒã¿ãŒãšã³ã³ãããŒã©ãŒãæã«å ¥ãããããšã«ããªã³ãã«ã¯åžã®åªããèªè ããã®ãããªå®éšã貞ããŠãããŠã2çªç®ã®èšäºãæ²èŒãããããšãé¡ã£ãŠããŸãã
æåŸãŸã§èªãã§ãããŠããããšãã ããã€ãšããŠãå°ããããªã玹ä»ããŸãããã
ä»äºã®ãã¢ã³ã¹ãã¬ãŒã·ã§ã³ã å³ç«¯ãšå·Šç«¯ã®äœçœ®ã«åããã2ã€ã®ãã£ã³ãã«ã
PWMä¿¡å·ã®ãããªãã¢ã
PS
ã¡ãŒã«ã§åçããå¿ èŠãªè³ªåãæ確ã«ããŠãããClaudio Mignantiã¢ãžã¥ãŒã«ã®äœè ã«æ·±ãæè¬ããããšæããŸãã
ãµãŒããã©ã€ããšå¶åŸ¡ä¿¡å·ã®åè·¯ã¯wiki.amperka.ruã§ååŸãããŸãã ã
è¿œå ãèŠæãããå Žåã¯ãã³ã¡ã³ãã«æžããŠãã ããã
UPDïŒ a5b㯠ã䜿çšãããããã€ã¹ã®çš®é¡ã«é¢å¿ããããŸãã ãŸããããã¯ç§å¯ã§ã¯ãããŸããã ãã®ããŒãã¯ãEL-M150ã®äžåœèªçã§ãã å éšã®ããã»ããµã¯Atheros AR9331ã§ãã
mr3020ãwr703nãªã©ã®äžè¬çãªã«ãŒã¿ãŒã§éåžžã«åºã䜿çšãããŠããŸãã
ããŒãã¯æ¬¡ã®ããã«ãªããŸãã