ããŒã1-çè«ç
ããŒããŒããArduinoã«æ¥ç¶ããã«ã¯ãå€ãã®æ¹æ³ããããŸãã
- ããŒãã«çŽæ¥ãã£ã€ããŠããéåžžã®ãããªãã¯ã¹ããŒããŒãïŒ Keypad Tutorial ïŒã çæ-ããã¯å€ãã®å ¥å/åºåããŒããããã€ãã®ãã¿ã³ãå æããŸãã
- I2Cãä»ããŠæ¥ç¶ããããããªãã¯ã¹ããŒããŒãïŒ I2CããŒããšã¯ã¹ãã³ããŒããã³ããŒããã ïŒã å©ç¹-åºåã¯2ã€ã®ã¿ã§ãåããã¹ã§è€æ°ã®ããã€ã¹ã䜿çšã§ããŸãã çæ-ãããžã§ã¯ãã§I2Cãæäœããããã®ã©ã€ãã©ãªãå«ããå¿ èŠããããŸãããã¿ã³ã¯ãããã§ã
- éåžžã®PS / 2ããŒããŒãïŒ PS2ããŒããŒã ïŒã å©ç¹-倧èŠæš¡ãªããŒããŠã§ã¢ããŒã¹ããããã奜ã¿ã«å¯Ÿå¿ããå€æ°ã®ãã¿ã³ãå¿ èŠãªçµè«ã¯ã»ãšãã©ãããŸããã çæ-ã¹ãã£ã³ã³ãŒãããµã€ãºãå€æããããã®ã©ã€ãã©ãªãå¿ èŠ-PS / 2ããŒããŒãã¯ã¢ãã€ã«ãµã€ãºã§å€ãããªã
ãã¿ã³ã®æ°ãå°ãªããããµã€ãºã倧ããããã«ããããã¹ãŠã®æ¹æ³ãæåŠããŸããããç§ã¯ãã10幎åããã¢ã³ãã¬ã¹ããŒã«ã«ããŠãæºåž¯é»è©±çšã®ãããã¥ã¢ããŒããŒããæã£ãŠããããšãæãåºããŸãã-ãšãªã¯ãœã³ãã£ããããŒãïŒ
å ·äœçã«ã¯ããã®ã¢ãã«CHA-01ã¯5ãã«ãçšã«èšèšãããŠãããé»è©±...ã¢ãã ã®ããã§ãïŒ
CHA-10ã¢ãã«ããããŸããããã¯ãæ°ããïŒ5ã7æ³ã®é»è©±ã«ã€ããŠèšãã°ïŒé»è©±ã§äœ¿çšããã3.3ãã«ãã§åäœããŸãã äž¡æ¹ã®ã¢ãã«ã¯ãEBayã§è³Œå ¥ããã®ãé£ãããããŸããã
å€æŽãããŠããªãããŒãžã§ã³ã®ããŒããŒãã«å¶éããããšãã§ããŸãã æ¥ç¶ããå€ãé»è©±æ©ã®ã³ãã¯ã¿ãæ¢ããŸãã ããŒããŒãå ¥åã解æããç掻ã楜ããã©ã€ãã©ãªãéçºããã
ãã ããé·ãéåã¶ããšã¯ã§ããŸãã-倧ããªãããã³ã«ãªãŒããŒãããïŒ0ããŒãæŒããšããAT * EKSE = 0ããwww-ãAT * EAPP = 0.5ããWWWïŒãããWWWããªã©ïŒãšå ¥åã®æå¹åSMSãã¿ã³ãæŒããåŸã§ã®ã¿ã䜿ããããã倱ãããŸãã
解決çã¯ããã®ããŒããŒãã«åºã¥ããŠãå¿ èŠã«å¿ããŠåäœããå¿ èŠã«å¿ããŠåäœãå€æŽã§ããæ©èœã䜿çšããããšã§ãã
ããŒã2-å®çšç
ã€ã³ã¿ãŒãããã§æ€çŽ¢ããçµæã次ã®ããŒãžãèŠã€ãããŸããããã®ããŒãžããªã¯ãŒã¯ã®åºç€ãšããŠäœ¿çšããŸããã ããããã®æã貎éãªæ å ±ã¯ãããŒããŒãã®ãã€ã¯ãã³ã³ãããŒã©ãŒãšAtmel Mega162ãçµè«ã§äžèŽããåŸè ã¯çµã¿èŸŒã¿ã®ãã®ã«çœ®ãæããããšãã§ãããšããããšã§ããã
å éšã§ã¯ãããŒããŒãã¯æšæºã®7x7ãããªãã¯ã¹ãããªãã¯ã¹ã§ããããã€ã¯ãã³ã³ãããŒã©ãŒã®14ãã³ãå æããŸãã å€éšæ å ±ã¯UARTãä»ããŠçºè¡ãããŸãã
äžèšã®æ å ±ã«åºã¥ããŠãå€æèšç»ãäœæããŠããŸãã
-ãã€ã¯ãã³ã³ãããŒã©ãŒãmega162ïŒåžå Žã§3ãã«ïŒã«äº€æ
-ã³ãã¯ã¿ããå ±éãã«äº€æããŸã
-å¿ èŠãªãšãã«ãã€ã§ããœãããŠã§ã¢ãå€æŽããæ©èœãè¿œå ããŸãïŒå©ç¹ã¯ããŒãããŒããŒãä»ããŠå®è£ ãããŸãïŒ
-AVR / Arduinoã§åäœããããã«éåžžã®IDEãæ§æããŸãïŒããã§ã¯äžèŠãªC ++ /ã©ã€ãã©ãªãåé€ããŸãïŒ
-å¥å šæ§ããã§ãã¯ããç°¡åãªãœãããŠã§ã¢ãæžã
ã¯ãã ä»ãã¹ããŒã·ã§ã³ã§æŠè£ ããäžèŠãªã³ã³ããŒãã³ããåãå€ããŸãã
CHA-01ã®å ã®ã³ãã¯ã¿ã®ãã³é åã¯ã次ã®å Žæã«ãããŸã ã
1ã5-Vcc +5ãã«ã
2-ãã£ããããŒãã®ã·ãªã¢ã«åºå
3-GND
4-ãã£ããããŒãã®ã·ãªã¢ã«å ¥å
éšåãã¯ãã ä»ãããŸãã
äžèšã®èšäºã®èè ãšã¯ç°ãªããæšæºã®PBS-08ã©ã€ã³ãã³ãã¯ã¿ãšããŠéžæããŸããããã¡ã€ã«ãªãã§ã±ãŒã¹ã«å®å šã«åãŸããããŒãäžã®é©åãªå Žæã«çœ®ãããšããã§ããŸãã ãããŠã圌ã¯å€éšå ±æ¯åšã«åãæ¿ããªãããšã«æ±ºããŸããã
RXãTXãGNDãVccãMOSIãMISOãSCKãããã³RSTãã³ãã¯ã¿ã«åºåãããŸããã ãããã£ãŠãã±ãŒã¹ããããã€ã¹ãåãå€ãããšãªããããã€ã¹ãããã«åããã°ã©ã ã§ããŸãã
ãã¹ãŠã®æºåãæŽããããã°ã©ããŒã«æ¥ç¶ã§ããããã§ãïŒUSBASPã䜿çšããŸããããarduinoã䜿çšããŠä»ã®AVRãããã°ã©ãã³ã°ã§ããŸã-ArduinoISP ïŒ
ããããavrdudeã¯ãã€ã¯ãã³ã³ãããŒã©ãŒãèŠãããšãå®å šã«æåŠããŠããŸãã ãã®åãããç§ã¯ãã®ãããªå€åã®çµéšããããŸããã§ãã-ç§ã¯èšºæã®ããã«ãããçµéšè±å¯ãªä»²éã«é Œããªããã°ãªããŸããã§ããã ãªã·ãã¹ã³ãŒããšçºé»æ©ãåããéç ²ãåŒãç¶ãã ã çãæŠãã®åŸãç§ã¯âŠRTFMã«éãããŸããã
USBASPã¯é«éãã€ã¯ãã³ã³ãããŒã©ãŒïŒ4 MHz以äžïŒã§åäœããmega162ã¯ããã©ã«ãã§ã8ã«ããé€ç®åšããå«ã¿ã1 MHzã®åšæ³¢æ°ã§å éšãžã§ãã¬ãŒã¿ãŒããåäœããŸãã ããŒããŒãã®1 MHzã®åšæ³¢æ°ã¯ååãããïŒãããŠæ¶è²»ã¯å°ãªãïŒã®ã§ãç§ã¯ãããå€æŽãããç¶æ³ããæãåºãæ¹æ³ãæ¢ãããšã«ããŸããã ãœãªã¥ãŒã·ã§ã³ã¯ããã«èŠã€ãããŸãã-USBASPã«ã¯ããã€ã¯ãã³ã³ãããŒã©ãŒãšã®ãéä¿¡åšæ³¢æ°ããäžãããžã£ã³ããŒããããŸãïŒãŸãã¯ãavrdudeã«ããã°ã©ã ã§ãããè¡ã-Bãªãã·ã§ã³ãããã-B 3ã圹ç«ã¡ãŸããïŒã
avrdudeãæ°Žæ¶ãèŠãã®ã§ããã©ãã·ã¥ããã©ãã·ã¥ããŠå¿ããå¿ èŠãããããã«æãããŸã:)ããããæåã®RTFMã®çµéšã«ãããç§ã¯å°ãå·éã«ãªããæåã«ãšãã¥ã¬ãŒã¿ã§ãœãããŠã§ã¢ãå®è¡ããããšã«ããŸããïŒæ£åœãªçç±ã§å€æããããïŒã ãã®ããã«ãçµéšè±å¯ãªä»²éã®ããããŠã¹ã§ãããŒããŒãåè·¯ãçµã¿ç«ãŠãããŸããã ãããŠãããŒããŒããããŒãªã³ã°ããUARTã«å¿ èŠãªæåã衚瀺ãããã¡ãŒã ãŠã§ã¢ãäœæãããŸããã ãã®ããããã¹ãŠãã³ã³ãã€ã«ããããšãã¥ã¬ãŒã¿ãŒã«ããŒããããä»®æ³ç«¯æ«ã®ãã©ã¡ãŒã¿ãŒã¯9600.8n1ã«èšå®ãããŸãã ããããäœããã®çç±ã§ç«¯æ«ã¯ããŒãæŒããããšãã«ãŽãã衚瀺ããŸãã ãšãã¥ã¬ãŒã¿ã®ãããã°USARTã¢ãŒãã§ã¯ã亀æã¬ãŒãã9600ã§ã¯ãªã10200ã«èšå®ãããŠããããšã瀺ãããŸãã...ç¹°ãè¿ããŸãããRTFM-ããŒã¬ãŒãã¯æ°Žæ¶åšæ³¢æ°ã«äŸåãã1 MHzã§æšæºèšå®ã§ã¯4800ïŒ0.2ïŒ ã®ãšã©ãŒïŒã«å°éã§ããŸããã9600ã§ã¯ãã§ã«ãšã©ãŒãçºçããŠããŸã7ïŒ ïŒ ããŒã¿ã·ãŒãã«ã¯ãããŸããŸãªããŒã¬ãŒã/ MHzã®ãšã©ãŒããŒãã«ãå«ãŸããŠããŸãã1MHzã®åšæ³¢æ°ã§ã¯ãããã«ã¬ãŒãUSARTãèšå®ããã ãã§0.2ïŒ ã®ãšã©ãŒãéæã§ããããšãããããŸãã Cã§ã¯ã次ã®ããã«ãªããŸãã
#define F_CPU 1000000UL #define BAUD_RATE 9600UL // Init serial UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*8L)-1); UBRR0H = ((F_CPU/(BAUD_RATE*8L)-1) >> 8); UCSR0A = _BV(U2X0); // Set double-speed, for low freq cpu UCSR0B = _BV(TXEN0)|_BV(RXEN0); // Enable TX, Enable RX UCSR0C = _BV(URSEL0)|_BV(UCSZ00)|_BV(UCSZ01); // 8n1 async
äžãäžãç§ãã¡ã®ã³ãŒãã¯ãšãã¥ã¬ãŒã¿ãŒã§åé¡ãªãåäœããŸã-ãã¹ãŠã®ã¯ãªãã¯ã衚瀺ããShiftããŒãæŒããšããŸããããŸãã
ãœãããŠã§ã¢ãããŒããŒãã«å ¥åããŸãã ããŒãããŒããŒã¯æåã®ãªã³ã¯ïŒ stk500boot.zip ïŒããååŸããŸãã ã USARTã§ãæ©èœããããããœãŒã¹ã®åæåãšé床ã9600ã«å€æŽããŸããã
ããŒãããŒããŒã¯ã次ã®ã³ãã³ãã䜿çšããŠUSBASPããæµã蟌ãŸããŸãã
avrdude -c usbasp -p m162 -B 3 -U flash:w:stk500boot.hex:i -U hfuse:w:0x98:m
reset-vectorãå€æŽããã«ã¯ãhfuseãå€æŽããå¿ èŠããããŸããããã«ããããã€ã¯ãã³ã³ãããŒã©ãŒãããŒãããŒããŒããã®ããŒããéå§ããŸãã
ããŒããŒããšã®ãããªãéä¿¡ã¯UARTãä»ããŠè¡ãããšãã§ããUSBASPã¯å¿ èŠãããŸããã
ç§ã¯FTDIã«åºã¥ããUSB-UARTïŒã·ãªã¢ã«ïŒã³ã³ããŒã¿ãŒãéžæããŸãã-Arduinaèªäœã¯åããããäžã«æ§ç¯ãããŠãããããã·ã¹ãã å ã«æ¢ã«ãã©ã€ããŒããããŸãã
å¶ç¶ã«ããã³ã³ããŒã¿ãŒã®ã³ãã¯ã¿ãŒãšããŒããŒãã¯å®å šã«é©åããŠãããããçŽæ¥æ¥ç¶ããŸããã
ãã®STK500ããŒãããŒããŒã¯äºææ§ããããšãã声æã«ããããããïŒavrdudeã¯stk500v1ã¿ã€ãã®ããã°ã©ããŒãä»ããŠäœæ¥ããããããŸããã§ããïŒãããã€ã¹IDãæ£ãããªãããšãèªããŸããã ãœãŒã¹ãããããŒãããŒããŒãããã€ã¹IDãèªã¿åã£ãŠäžããããšãã§ããããšãæããã ã£ãã®ã§ãæ€çŽ¢ããããšã§ãarduinoã¿ã€ããæå®ããå Žåã«æ£åžžã«æ©èœããããšãããããŸããã
UARTçµç±ã§ãã¡ãŒã ãŠã§ã¢ãã¢ããããŒãããããã®ã³ãã³ãïŒ
avrdude -c arduino -p m162 -b 9600 -P /dev/tty.usbserial-00001004 -U flash:w:chatboard.hex:i
端æ«ã確èªãããšããã¹ãŠã®ãã¿ã³ãæŒãããŠããããã§ã¯ãªãã[ã¯ã]ãã¿ã³ãæŒããŠãœãããŠã§ã¢æŽæ°ã¢ãŒãã«åãæ¿ããŠããããŒãããŒããŒã®äž»ãªæ©èœãæ©èœããŸããã UARTãä»ããããŒããŒãã®ãã©ãã·ã¥ã¯äžå¯èœã«ãªããŸããã ãã詳现ãªèª¿æ»ã§ã¯ã7x7ãããªãã¯ã¹ã®3åã®ãã¿ã³ãæ©èœããªãããšã瀺ãããŸããã ãã¹ãŠãRTFMã«åã³çœ®ãããŸãã...ããŒããŒãã®ããŒãªã³ã°ã«äœ¿çšãã3ã€ã®åºåã«ã¯ãããã©ã«ãã§ä»£æ¿æ©èœïŒJTAGïŒãæå¹ã«ãªã£ãŠããŸãã JTAGããªãã«ããïŒhfusââeã0xD8ã«æžãæããïŒãšãå®å šã«æ©èœããããŒããŒããåŸãããŸãã
Arduinoã«æ¥ç¶ããæéã ã€ã³ã¿ãŒãã§ã€ã¹ã³ãã¯ã¿ãšããŠã誀ã£ãŠäžé©åãªãã®ãä»ããªãããã«ãéæšæºã®miniUSBãéžæããŸããã ã¯ã€ã€ãŒã®æäŸè ã¯å€ãããŠã¹ã§ããïŒä»ã®å Žæã§ãšã³ã³ãŒããŒãåãåºãããšãã§ããŸãïŒã ããŒããŒããžã®æ¥ç¶ã¯ãæšæºã®ãã³ã³ãã¯ã¿ã§ãã
miniUSB-UARTã¢ããã¿ãŒã¯ãUARTãSensorShieldã«ãã³ã¢ãŠãããããã«äœæãããŸããïŒç§ã®ãã¬ããããŒãã«ã¯ãUARTã®æšæºåãããåºåã¯ãŸã ãããŸããïŒã
ãŸãšã
- ããŒããŒãã¯ãã±ããã«å ¥ããŠæã¡éã¹ãã»ã©å°ããã§ãã
- UARTã§ããŒããŒããããŒãªã³ã°ãããšãå€éšã©ã€ãã©ãªãªãã§äœæ¥ã§ããŸãïŒãã©ãã·ã¥ã®ã¹ããŒã¹ãç¯çŽããŸãïŒ
- UARTã䜿çšãããšãBluetoothã·ãªã¢ã«ãŸãã¯XBeeã·ãªã¢ã«ãä»ããŠããŒããŒããã¯ã€ã€ã¬ã¹ã§ããã«æ¥ç¶ã§ããŸãã
PSã Eclipse + avr-gccã§ã³ã³ãã€ã«ããããã¡ãŒã ãŠã§ã¢ã®ãµã€ãºã¯ããã600ãã€ãã§ãã binaricaã¯3kæªæºã§ãããArduino IDEã¯èŠãŠããŸããã
PPS ãœãŒã¹ãšãã¡ãŒã ãŠã§ã¢ã¯ããããå ¥æã§ããŸãïŒ chatboard.tar.gz