tag:blogger.com,1999:blog-40788054491604158512024-03-13T11:20:53.671+09:00EngineeringExceptionSAEKI Yoshiyasu's weblogAnonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-4078805449160415851.post-32783969674964220602013-03-31T15:18:00.000+09:002013-04-01T21:24:44.247+09:00serjtag patches for avrdude-5.11.1<br />
I needed to update firmware of <a href="http://www.aitendo.com/product/3174">AVR-USBasp-B</a> (<a href="http://www.fischl.de/usbasp/">original USBasp's page</a>) which I bought at Akihabara<br />
<br />
<pre class="prettyprint">avrdude: Warning: Found USB device "USBasp" with old VID/PID! Please update firmware of USBasp!
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
</pre><br />
But I don't have another writer (Arduino runs in another project, so I don't use <a href="http://laclefyoshi.blogspot.com/2011/01/note-of-caution-for-arduino-isp.html">Arduino-ISP</a>). I tried to use FTDI BitBang AVR-Writer with FT232R.<br />
<br />
I needed to apply patches to <a href="http://www.nongnu.org/avrdude/">avrdude</a> for using FTDI BitBang AVR-Writer but <a href="http://suz-avr.sblo.jp/category/780472-1.html">the original avrdude-serjtag patches</a> don't support avrdude-5.11.1 (latest version). So I edited the patches and created github repository: <a href="https://github.com/laclefyoshi/avrdude-serjtag">laclefyoshi/avrdude-serjtag ยท GitHub</a>.<br />
<br />
After building and installing avrdude (read README.md), I succeeded to update firmware of AVR-USBasp-B.<br />
<br />
<a href="http://3.bp.blogspot.com/-4PWNNZC1ZsE/UVfVCt-Q4kI/AAAAAAAABVs/C8bCTNZMCoI/s1600/IMG_0173.JPG" imageanchor="1" ><img border="0" src="http://3.bp.blogspot.com/-4PWNNZC1ZsE/UVfVCt-Q4kI/AAAAAAAABVs/C8bCTNZMCoI/s320/IMG_0173.JPG" /></a><br />
<br />
<pre class="prettyprint">$ sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext
$ avrdude -C /opt/usr/avrdude/etc/avrdude.conf -c diecimila -P ft0 -p m8 -v
avrdude: Version 5.11.1, compiled on Mar 30 2013 at 17:18:59
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "/opt/usr/avrdude/etc/avrdude.conf"
User configuration file is "/Volumes/Macintosh HD/Users/yoshiyasu/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : ft0
Using Programmer : diecimila
avrdude: BitBang OK
avrdude: pin assign miso 3 sck 5 mosi 6 reset 7
avrdude: drain OK
AVR Part : ATMEGA8
Chip Erase delay : 10000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 4 20 128 0 no 512 4 0 9000 9000 0xff 0xff
flash 33 10 64 0 yes 8192 64 128 4500 4500 0xff 0x00
lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : ft245r
Description : FT232R Synchronous BitBang
ft245r: bitclk 230400 -> ft baud 115200
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9307
avrdude: safemode: lfuse reads as EF
avrdude: safemode: hfuse reads as D9
avrdude: safemode: lfuse reads as EF
avrdude: safemode: hfuse reads as D9
avrdude: safemode: Fuses OK
avrdude done. Thank you.
$ avrdude -C /opt/usr/avrdude/etc/avrdude.conf -c diecimila -P ft0 -p m8 -U flash:w:usbasp.atmega8.2011-05-28.hex:i
avrdude: BitBang OK
avrdude: pin assign miso 3 sck 5 mosi 6 reset 7
avrdude: drain OK
ft245r: bitclk 230400 -> ft baud 115200
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9307
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
ft245r: bitclk 230400 -> ft baud 115200
avrdude: reading input file "usbasp.atmega8.2011-05-28.hex"
avrdude: writing flash (4700 bytes):
Writing | ################################################## | 100% 2.25s
avrdude: 4700 bytes of flash written
avrdude: verifying flash memory against usbasp.atmega8.2011-05-28.hex:
avrdude: load data flash data from input file usbasp.atmega8.2011-05-28.hex:
avrdude: input file usbasp.atmega8.2011-05-28.hex contains 4700 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 1.29s
avrdude: verifying ...
avrdude: 4700 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
$ avrdude -C /opt/usr/avrdude/etc/avrdude.conf -c diecimila -P ft0 -p m8 -U hfuse:w:0xC9:m # read http://www.fischl.de/usbasp/Readme.txt
$ sudo kextload /System/Library/Extensions/FTDIUSBSerialDriver.kext
</pre><br />
I read Atmega8 with USBasp.<br />
<br />
<pre class="prettyprint">$ avrdude -C /opt/usr/avrdude/etc/avrdude.conf -c usbasp -P ft0 -p m8 -v
avrdude: Version 5.11.1, compiled on Mar 30 2013 at 17:18:59
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "/opt/usr/avrdude/etc/avrdude.conf"
User configuration file is "/Volumes/Macintosh HD/Users/yoshiyasu/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : ft0
Using Programmer : usbasp
AVR Part : ATMEGA8
Chip Erase delay : 10000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 4 20 128 0 no 512 4 0 9000 9000 0xff 0xff
flash 33 10 64 0 yes 8192 64 128 4500 4500 0xff 0x00
lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : usbasp
Description : USBasp, http://www.fischl.de/usbasp/
avrdude: auto set sck period (because given equals null)
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9307
avrdude: safemode: lfuse reads as DF
avrdude: safemode: hfuse reads as CA
avrdude: safemode: lfuse reads as DF
avrdude: safemode: hfuse reads as CA
avrdude: safemode: Fuses OK
avrdude done. Thank you.
</pre><br />
USBasp is small and good programmer. Recently, sometimes, I want to take time away from Arduino and use AVR microcontrollers.<br />
<br />
Thanks.Anonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.com1tag:blogger.com,1999:blog-4078805449160415851.post-91660336289402754662013-02-09T22:56:00.003+09:002013-02-09T22:57:44.833+09:00controlling digital camera with Arduino and light<br />
I bought a digital camera: <a href="http://en.wikipedia.org/wiki/Canon_EOS_650D">EOS Kiss X6i</a> last year.<br />
<br />
This camera has an interface for remote controller. On examination, I knew this plug is 2.5mm stereo mini plug and has very simple mechanism. So I connected the camera and Arduino.<br />
<br />
<a href="http://www.doc-diy.net/photo/eos_wired_remote/">This page</a> provides me with useful information.<br />
<br />
Arduino read Analog-Pin 1 (connecting with a light sensor input). If the value of Analog-Pin 1 exceeds a certain value, Arduino outputs Digital-Pin 2 (focus) and 3 (shutter).<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-nEOHE4x0250/URZQRiKPmaI/AAAAAAAABBk/ePyyUeUciKA/s1600/camera_with_arduino.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="400" width="380" src="http://2.bp.blogspot.com/-nEOHE4x0250/URZQRiKPmaI/AAAAAAAABBk/ePyyUeUciKA/s400/camera_with_arduino.png" /></a></div><br />
<script src="https://gist.github.com/laclefyoshi/4745322.js"></script><br />
<br />
I think that taking pictures continuously is to place excessive strain on camera, so I set 30 seconds of delay.<br />
<br />
<iframe width="420" height="315" src="http://www.youtube.com/embed/UJOT296v9TM" frameborder="0" allowfullscreen></iframe><br />
<br />
The light sensor can replace other sensors or triggers. For example, Ethernet shield can be connected. I enjoy the extension of my camera's release.<br />
<br />
Thanks.<br />
Anonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.com0tag:blogger.com,1999:blog-4078805449160415851.post-53946265309442195972011-01-29T16:15:00.003+09:002011-02-26T23:25:46.464+09:00Timer and Thread programming with ArduinoI want Arduino to do something periodically. I have found two methods: Timer and Thread.<br />
<br />
<h4>Timer</h4><br />
Speaking of timer programming with Arduino, <a href="http://arduino.cc/playground/Main/MsTimer2">MsTimer2</a> is popular. But <a href="http://www.arduino.cc/playground/Main/FlexiTimer2">FlexiTimer2</a> also seems to be popular lately. Both of libraries is compatible in the methods. So I use FlexiTimer2.<br />
<br />
I wrote a code for blinking 2 LEDs. One blinks at 1000 milliseconds interval and the other blinks at 2000 milliseconds interval. But the behavior of this code was different from what I assumed. As a result, LED2 only blinked at 2000 milliseconds interval, and LED1 remained silent.<br />
<br />
<script src="https://gist.github.com/800358.js"> </script><br />
<br />
Thus, I can't set up 2 timers with FlexiTimer2.<br />
<br />
When more than 2 timers are needed, <a href="http://www.arduino.cc/playground/Code/Metro">Metro</a> is suited.<br />
<br />
<script src="https://gist.github.com/800363.js"> </script><br />
<br />
It is unstylish that <code>Metro.check()</code> is needed in <code>loop()</code>. But this code is fine.<br />
<br />
<h4>Thread</h4><br />
Of course, ATmega (Arduino's microcontroller) doesn't supprt multiple threads. But there is a method for the thread programming in microcontroller. That is <a href="http://www.sics.se/~adam/pt/">protothreads</a>. <br />
<br />
<blockquote>Protothreads are extremely lightweight stackless threads designed for severely memory constrained systems, such as small embedded systems or wireless sensor network nodes.</blockquote><br />
And For using protothreads in Arduino, there is simple tutorials <a href="http://www.arduino.cc/playground/Main/GeneralCodeLibrary#Timing_tutorial">here</a> and <a href="http://arduinocollective.com/2009/12/05/arduino-threading/">here</a>.<br />
<br />
So I wrote a code like the above code. One LED blinks at 1000 milliseconds interval and the other LED blinks at 2000 milliseconds interval.<br />
<br />
<script src="https://gist.github.com/800391.js"> </script><br />
<br />
protothreads is not a library for setting up timer. There is PT_WAIT_UNTIL(pt, CONDITION) in the above code. We can set a variety of conditions.<br />
<br />
I added Metro timer to the above code. So, LED1 (protothreads) and LED3 (Metro) blinks at 1000 milliseconds interval, and LED2 (protothreads) and LED4 (Metro) blinks at 2000 milliseconds interval.<br />
<br />
<script src="https://gist.github.com/800403.js"> </script><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_ggjk2-1GdpM/TUO69RCeFOI/AAAAAAAAAQc/TNtRNALyTpc/s1600/P1060797.JPG" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="240" width="320" src="http://1.bp.blogspot.com/_ggjk2-1GdpM/TUO69RCeFOI/AAAAAAAAAQc/TNtRNALyTpc/s320/P1060797.JPG" /></a></div><br />
There is a demo movie. There are 4 LEDs: from left, LED1 (protothreads:1000 msec), LED2 (protothreads:2000 msec), LED3 (Metro:1000 msec), LED4 (Metro:2000 msec).<br />
<br />
<iframe title="YouTube video player" class="youtube-player" type="text/html" width="480" height="390" src="http://www.youtube.com/embed/Rn6fJ-TDyJM" frameborder="0" allowFullScreen></iframe><br />
<br />
I found that the timing of LED1 and LED2 was off gradually. Therefore, protothreads is not suitable for Arduino to do something periodically. <br />
<br />
I will use these libraries in the suitable situation.<br />
<br />
Thanks.Anonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.com3tag:blogger.com,1999:blog-4078805449160415851.post-7820226617601397452011-01-22T13:02:00.001+09:002011-01-22T13:11:24.725+09:00Arduino DNS server (like dnsmasq)In <a href="http://laclefyoshi.blogspot.com/2011/01/arduino-dns-server-fake.html">the previous entry</a>, I made Arduino DNS server (fake). "fake" means that the server is rough because the server always replies the same IP address.<br />
<br />
So I made a new Arduino DNS server. This server is slightly more intelligent than the previous server.<br />
<br />
This server has a routing table that contains pairs of domain name and IP address. The routing table is generated from <a href="http://en.wikipedia.org/wiki/Hosts_(file)">hosts file</a>. This design is determined by reference to <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq</a>. Because the routing table stores in SRAM of Arduino, the number of pairs is limited. My Arduino is Duemilanove. The size of SRAM of Duemilanove is 2 KB. As a result of checking some numbers of pairs, I knew that the maximum number of pairs was 7. Of course, when the server code is improved, the number will be changed.<br />
<br />
A hosts file should be stored in "/etc/" directory (hostsPath) of microSD card. The following is an example of hosts file used by the Arduino DNS server. The parts of comments are ignored at the stage of reading file.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_ggjk2-1GdpM/TTpYxqAvF8I/AAAAAAAAAQU/MB415LbyEvI/s1600/etc.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="54" width="320" src="http://2.bp.blogspot.com/_ggjk2-1GdpM/TTpYxqAvF8I/AAAAAAAAAQU/MB415LbyEvI/s320/etc.jpg" /></a></div><br />
<pre class="prettyprint"># /etc/hosts
# comment: this is hosts file
192.168.254.10 hoge.example.com
192.168.254.11 foo.example.com
192.168.254.12 bar.example.com # comment
</pre><br />
The following is the code of Arduino DNS server.<br />
<br />
<script src="https://gist.github.com/790835.js"> </script><br />
<br />
I checked this server with dig.<br />
<br />
<pre class="prettyprint">$ dig @192.168.254.100 foo.example.com
; <<>> DiG 9.6.0-APPLE-P2 <<>> @192.168.254.100 foo.example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40440
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;foo.example.com. IN A
;; ANSWER SECTION:
foo.example.com. 60 IN A 192.168.254.11
;; Query time: 5 msec
;; SERVER: 192.168.254.100#53(192.168.254.100)
;; WHEN: Sat Jan 22 12:51:18 2011
;; MSG SIZE rcvd: 49
</pre>
<pre class="prettyprint">$ dig @192.168.254.100 foo0.example.com # no answer
;; Warning: Message parser reports malformed message packet.
; <<>> DiG 9.6.0-APPLE-P2 <<>> @192.168.254.100 foo0.example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 42293
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; Query time: 2 msec
;; SERVER: 192.168.254.100#53(192.168.254.100)
;; WHEN: Sat Jan 22 12:52:17 2011
;; MSG SIZE rcvd: 12
</pre>
<br />
This behavior (message flags etc.) of the server is like dnsmasq.<br />
<br />
Thanks.Anonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.com0tag:blogger.com,1999:blog-4078805449160415851.post-53844905896103776402011-01-15T13:39:00.006+09:002011-01-15T14:29:47.192+09:00Arduino DNS server (fake)I tried to make DNS server with Arduino and Ethernet Shield.<br />
<br />
Firstly I looked for minimal implementation of DNS Server and I found <a href="http://code.activestate.com/recipes/491264-mini-fake-dns-server/">Mini Fake DNS server</a> and <a href="http://twistedmatrix.com/documents/10.1.0/names/howto/names.html">Twisted DNS Server</a> (twisted.names is $PYTHONPATH/site-packages/twisted/names).<br />
<br />
I made a simple Arduino DNS server by reference to above samples, <a href="http://tools.ietf.org/html/rfc1035">RFC 1035 - DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION</a> and <a href="http://www.networksorcery.com/enp/protocol/dns.htm">RFC Sourcebook: DNS</a>. This DNS server returns 192.168.0.100 (resIp) as IP address toward all requests like the above sample server.<br />
<br />
<script src="https://gist.github.com/769513.js">
</script><br />
<br />
I checked to see if this DNS server replied a correct message with dig.<br />
<br />
<pre class="prettyprint">$ dig @192.168.254.100 foo.saekiyoshiyasu.org
; <<>> DiG 9.6.0-APPLE-P2 <<>> @192.168.254.100 foo.saekiyoshiyasu.org
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24247
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;foo.saekiyoshiyasu.org. IN A
;; ANSWER SECTION:
foo.saekiyoshiyasu.org. 60 IN A 192.168.0.100
;; Query time: 27 msec
;; SERVER: 192.168.254.100#53(192.168.254.100)
;; WHEN: Fri Jan 14 23:24:46 2011
;; MSG SIZE rcvd: 56
</pre>The behavior of this DNS server is some strange because it always replies the same IP address. But I understood that I can do UDP network programming in Arduino. As the above code, when we want to send a non-string data, we must use Udp.sendPacket((uint8_t *)buffer, (uint16_t)len, remoteIp, remotePort).<br />
<br />
I usually use <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq</a> as a DNS server for LAN. dnsmasq generates routing table from /etc/hosts. So I want to improve this Arduino DNS Ssrver to read hosts file in microSD card (because there is a slot for microSD card on Ethernet Shield) for generating routing table flexibly.<br />
<br />
Thanks.Anonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.com0tag:blogger.com,1999:blog-4078805449160415851.post-65641082273006084202011-01-08T17:17:00.001+09:002011-01-08T17:18:19.838+09:00A note of caution for Arduino ISPI'm making Arduino-compatible devices. Firstly, I made a minimal circuit in accordance with <a href="http://arduino.cc/en/Tutorial/ArduinoToBreadboard">this document: Circuit (targeting an AVR on a breadboard)</a>. For making Arduino, I needed to prepare chips burned Arduino bootloader. So I tried to burn Arduino bootloader onto two chips: ATmega 8 and ATmega 168p with <a href="http://arduino.cc/en/Tutorial/ArduinoISP">Arduino ISP</a>.<br />
<br />
But there were some troubles. My development environment is Arduino Duemilanove and Arduino 0022 on Mac.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/_ggjk2-1GdpM/TSgdv1b3sXI/AAAAAAAAAQM/QhPM2XCpeQk/s1600/P1060789.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/_ggjk2-1GdpM/TSgdv1b3sXI/AAAAAAAAAQM/QhPM2XCpeQk/s320/P1060789.JPG" width="240" /></a></div><br />
<h4>avrdude: stk500_getsync(): not in sync: resp=0x15</h4><br />
I tried to burn Arduino bootloader onto ATmega 8. I chose [Arduino NG or older w/ ATmega8] in [Tools]-[Board] and clicked [w/ Arduino as ISP] in [Tools]-[Burn bootloader]. But it failed with a error message: "avrdude: stk500_getsync(): not in sync: resp=0x15".<br />
<br />
This error is because of Auto Reset capabilities of Arduino. <a href="http://www.arduino.cc/playground/Code/MegaISP">This document: MegaISP</a> gave me some details. This error occurs on Mac or Linux. For using Arduino as ISP, I need to disable Auto Reset capabilities. Therefore I inserted 110 ohms (330 ohms / 3) resistor between Reset-pin and 5V-pin. This resistor should be above 110 ohms and below 124 in accordance with <a href="http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection">this document: DisablingAutoResetOnSerialConnection</a>.<br />
<br />
I tried to burn Arduino bootloader onth ATmega 8 again and succeeded in it. I connected 19 pin of ATmega 8 and GND with a LED and it flashed. This behavior proves buring Arduino bootloader in accordance with <a href="http://www.arduino.cc/en/Hacking/Bootloader">this document: Bootloader</a>.<br />
<br />
<h4>avrdude: Expected signature for ATMEGA168 is 1E 94 06</h4><br />
I continuously tried to burn Arduino bootloader onto ATmega 168p. I chose [Arduino Diecimila, Duemilanove, or Nano w/ ATmega168] in [Tools]-[Board] and clicked [w/ Arduino as ISP] in [Tools]-[Burn bootloader]. But it failed with a error message: "avrdude: Expected signature for ATMEGA168 is 1E 94 06".<br />
<br />
This error is bevause of arvdude in Arduino development environment (Arduino.app). arvdude in Arduino.app refers to /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf. There is m168 section (for ATmega 168) but there is not m168p section (for ATmega 168p) in this avrdude.conf.<br />
<br />
So I found <a href="http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html">avrdude.conf including m168p</a> section with Google. And I used arvdude in Terminal for burning Arduino bootloader onth ATmega 168p.<br />
<br />
<pre class="prettyprint">$ cd /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/bootloaders/atmega
# there are bootloader files for ATmega168/328.
$ AVR=/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr
# root directory for AVR tools
$ $AVR/bin/avrdude -C /tmp/avrdude.conf -p m168p -P /dev/tty.usbserial-A7006SSA -c avrisp -b 19200 -U flash:w:ATmegaBOOT_168_diecimila.hex
# maybe -F is needed before -U
</pre><br />
I checked the success of burning bootloader with LED and 19 pin.<br />
<br />
<h4>upload scketch</h4><br />
I need to remember to remove the chip from the Arduino board.<br />
<br />
Thanks.Anonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.com14tag:blogger.com,1999:blog-4078805449160415851.post-68843433790522235172010-12-25T13:52:00.001+09:002010-12-29T07:58:20.681+09:00Controlling GLCD with Arduino and iPod touchI bought Graphics LCD (KS0107). So I tried to control this GLCD with iPod touch/Safari through WebSocket.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/_ggjk2-1GdpM/TRVyird-7NI/AAAAAAAAAPw/54vxVYwnzAk/s1600/Sketch.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="215" width="320" src="http://4.bp.blogspot.com/_ggjk2-1GdpM/TRVyird-7NI/AAAAAAAAAPw/54vxVYwnzAk/s320/Sketch.png" /></a></div><br />
For controlling GLCD, I used Arduino and <a href="http://www.arduino.cc/playground/Code/GLCDks0108">KS0108 library</a>. Firstly I wrote the Arduino code that Arduino receives a drawing data from serial port and draws a picture on GLCD.<br />
<br />
<script src="https://gist.github.com/754682.js"> </script><br />
<br />
A drawing data is sequences of lines constructed of start and end point. For example, if there is a drawing data: "10,10:20,20;20,20:30,10;", this data means that the first line connects (10,10) and (20,20) and the second line connects (20,20) and (30,10).<br />
<br />
Secondly I wrote the WebSocket Server in Python/<a href="http://www.tornadoweb.org/">Tornado</a>. This server receives a drawing data from iPod touch/Safari through WebSocket connection and sends the data to Arduino thought Serial port. I used <a href="http://pyserial.sourceforge.net/">pySerial</a> for Serial communication.<br />
<br />
<script src="https://gist.github.com/754683.js"> </script><br />
<br />
Finally I wrote a web page for drawing a picture and sending a drawing data. This page uses Canvas and WebSocket and is written in HTML5. This page can be loaded and used on iOS Safari or Google Chrome.<br />
<br />
<script src="https://gist.github.com/754685.js"> </script><br />
<br />
On iOS Safari, the pen is my finger or touch pen. On Google Chrome, the pen is mouse cursor. For reducing the size of data, I thin out points of pen's motion.<br />
<br />
I used it and made expository movie.<br />
<br />
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/dVjzc1N4-4A?fs=1&hl=ja_JP"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/dVjzc1N4-4A?fs=1&hl=ja_JP" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object><br />
<br />
I wanted to draw some amusing picture but I don't have a talent for painting.<br />
<br />
Thanks.Anonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.com1tag:blogger.com,1999:blog-4078805449160415851.post-15659847749292530492010-12-18T12:17:00.000+09:002010-12-18T12:17:28.777+09:00Arduino library for im.kayac.comI wanted Arduino to send messages to my iPod touch at need. In a case like this, <a href="http://en.wikipedia.org/wiki/Apple_Push_Notification_Service">Apple Push Notification Service</a> is suited.<br />
<br />
So, I developed <a href="https://bitbucket.org/laclefyoshi/arduino-imkayaccom/wiki/Home">Arduino library for posting messages to im.kayac.com</a>.<br />
<br />
Actually I wanted to develop an Arduino library for <a href="http://notifo.com/">Notifo</a>. But Ethernet library of Arduino doesn't support HTTPS connection. It is nice that <a href="http://im.kayac.com/">im.kayac.com</a> supports HTTP connection and multiple authorization.<br />
<br />
<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/K7KCY_9XDgk?fs=1&hl=ja_JP"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/K7KCY_9XDgk?fs=1&hl=ja_JP" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object><br />
<br />
With this library, I can recieve any messages immediately in iPod touch or Jabber client from Arduino. Too long (> 200 characters) or non-ascii message is not supported, but this limitation can be changed by editing "Imkayaccom.h".<br />
<br />
I think that this library is used in interactive system between people and environment like rooms embedded sensors.<br />
<br />
If you can't use this library for any reason, you can use following code in your Arduino code.<br />
<br />
<script src="https://gist.github.com/744925.js"> </script><br />
<br />
Thanks.Anonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.com0tag:blogger.com,1999:blog-4078805449160415851.post-47892168204724554882010-12-04T14:30:00.000+09:002010-12-04T14:30:22.820+09:00Controlling Arduino with iPod touch through WebSocketIn <a href="http://laclefyoshi.blogspot.com/2010/11/websocket-and-devicemotion-event-on-ios.html">my previous entry</a>, I made an application with DeviceMotion Event and WebSocket in iPod touch.<br />
<br />
WebSocket server is written in Python/<a href="http://www.tornadoweb.org/">Tornado</a>. So WebSocket message should be able to be relayed to other softwares or devices.<br />
<br />
I try to control Arduino device with iPod touch through WebSocket.<br />
<br />
<h4>Design</h4><br />
Flowing data among iPod touch, WebSocket server and Arduino is written in JSON.<br />
<br />
There is a ball in a web page displayed in iPod touch/Safari. The ball moves with DeviceMotion Event by the tilt of iPod touch. The color of a ball is selected by form between red and green.<br />
<br />
The web page sends a data including color and location of ball to a WebSocket server. The WebSocket server relays the data to Arduino through TCP socket connection.<br />
<br />
If Arduino carrying the Ethernet Shield and Matrix LED gets a ball data from WebSocket Server, Arduino displays the information of the ball with Matrix LED. For controlling 2 colors Matrix LED, MAX7219 x 2 is used.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_ggjk2-1GdpM/TPnES_3pGtI/AAAAAAAAAPA/IOS_hV-Mrkg/s1600/websocketarduino.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="271" src="http://2.bp.blogspot.com/_ggjk2-1GdpM/TPnES_3pGtI/AAAAAAAAAPA/IOS_hV-Mrkg/s320/websocketarduino.png" width="320" /></a></div><br />
<h4>Implementation</h4><br />
WebSocket server written in Tornado is referenced with "http://192.168.254.23:8888" and "ws://192.168.254.23:8888/ball".<br />
<br />
<script src="https://gist.github.com/727794.js">
</script><br />
<br />
This WebSocket server needs to be run on PC in advance.<br />
<br />
If this WebSocket server receives a JSON data, it sends to Arduino as TCP packet. Arduino has "192.168.254.100:9999" as IP-address:Listening-Port.<br />
<br />
In the code for Arduino, I use Ethernet library, Matrix library and <a href="https://github.com/interactive-matter/aJson">aJson library</a>.<br />
<br />
The data from WebSocket server includes color and location of a ball. The color of ball is used for the color of LED. The location of ball is 0 ~ 300 (X-axis) and 0 ~ 336 (Y-axis). Because Matrix LED has 8x8 LED, I use map(), that is a built-in function for Arduino, for handling location of ball and LED.<br />
<br />
<script src="https://gist.github.com/727799.js">
</script><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_ggjk2-1GdpM/TPnEPISldII/AAAAAAAAAO4/s0gmxDS8LXc/s1600/P1060735.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://2.bp.blogspot.com/_ggjk2-1GdpM/TPnEPISldII/AAAAAAAAAO4/s0gmxDS8LXc/s320/P1060735.JPG" width="320" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_ggjk2-1GdpM/TPnERpViJQI/AAAAAAAAAO8/cEgGyglI4fg/s1600/P1060736.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://2.bp.blogspot.com/_ggjk2-1GdpM/TPnERpViJQI/AAAAAAAAAO8/cEgGyglI4fg/s320/P1060736.JPG" width="320" /></a></div><br />
The web page is written in HTML5 because I use WebSocket and DeviceMotion Event. This web page reads the situation of iPod touch, updates the location of a ball and sends the information as JSON data to WebSocket server every 1 sec.<br />
<br />
This page needs to be deployed in the same directory as WebSocket server.<br />
<br />
<script src="https://gist.github.com/727801.js">
</script><br />
<br />
<h4>Playing</h4><br />
<pre class="prettyprint">$ ls
balls_canvas.html balls_websocket.py
$ python balls_websocket.py
(waiting as Web/WebSocket server)
</pre><br />
The web page is displayed in Safari of iPod touch. If I tilt iPod touch or change the color of a ball, the ball in the web page moves or changes the color. In the back, the web page sends JSON data as the information of the ball to the WebSocket server and the WebSocket server sends the data to Arduino. The situation of Matrix LED controlled by Arduino is determined by reference to the JSON data.<br />
<br />
<object height="385" width="480"><param name="movie" value="http://www.youtube.com/v/hf4TIT_yGuo?fs=1&hl=ja_JP"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/hf4TIT_yGuo?fs=1&hl=ja_JP" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object><br />
<br />
Thanks.Anonymoushttp://www.blogger.com/profile/09934531596280495750noreply@blogger.com3