<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4110028886767234394</id><updated>2011-12-20T23:36:37.553+01:00</updated><category term='6lowpan'/><category term='ZigBee'/><category term='thermostat'/><category term='WSN'/><category term='roguelike'/><category term='Zigbit'/><category term='Contiki'/><category term='IETF'/><category term='home automation'/><category term='RPL'/><category term='electronics'/><title type='text'>Six Pine Trees</title><subtitle type='html'>Blog about coding and tinkering</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-905396430399521003</id><published>2011-11-17T21:54:00.000+01:00</published><updated>2011-11-17T22:47:45.925+01:00</updated><title type='text'>Grinch Border Router - routing in LAN environments</title><content type='html'>&lt;p&gt;Recently I've made some tests how to connect to 6LoWPAN nodes in home LAN environment, using ordinary PCs. I've been using Grinch Border Router described in previous entries. The main aim was to use no static routes to send traffic to wireless nodes - I've tried to use only Router Discovery.&lt;/p&gt;&lt;p&gt;In general, avoiding manual configuration of networks is a hot topic nowadays - not only in Wireless Sensor Networks. There are many problems to solve:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Prefix delegation&lt;br /&gt;&lt;li&gt;Service discovery&lt;br /&gt;&lt;li&gt;Interaction with sleeping or mobile nodes&lt;/ul&gt;&lt;p&gt;The problems above are also present for the home LANs. The basic RFC4861 Neighbor Discovery is quite limited and it's hard to achieve a fully functional LAN with Internet connection using only that (without DHCP). However most new solutions are not supported by common everyday devices found in LANs (like PCs or smartphones). Grinch Border Router is no exception to that - it is a very basic device, and with 8kb of RAM it is not capable of any complicated techniques.&lt;/p&gt;&lt;h2&gt;LAN physical setup&lt;/h2&gt;&lt;p&gt;I've assembled a simple Home LAN as a testbed. Physical setup of the testbed is shown on a picture below - as you can see it is not very realistic (for a typical household) - as it includes a separate switch and wireless router - I'll explain that below:&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://lh6.googleusercontent.com/-bjhuGGWRvXg/TrVkNrzlimI/AAAAAAAAEFg/x5kXw02Zf0o/s929/RIO_Exp.png" imageanchor="1" style=""&gt;&lt;img border="0" height="273" width="550" src="https://lh6.googleusercontent.com/-bjhuGGWRvXg/TrVkNrzlimI/AAAAAAAAEFg/x5kXw02Zf0o/s929/RIO_Exp.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The testbed contains two PCs, D-Link 5-port switch, Grinch Border Router, Atmel Raven board and a D-Link DIR-600 wireless router. Test LAN is based entirely on the switch. The wireless router is used only for IPv6 tunnel. At the beginning I planned to use the router for my LAN instead of switch (it would be a more realistic setup). However I decided to add a separate switch because of two reasons:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;IPv4 traffic - wireless router is used for my primary IPv4 internet connection - and Grinch has no hardware packet filtering.&lt;br /&gt;&lt;li&gt;D-Link DIR-600 has some undocumented IPv6 ability. In theory it's IPv4 only, but it sends Router Advertisements, and I was concerned that it would disturb the experiment.&lt;/ul&gt;&lt;h2&gt;LAN logical setup&lt;/h2&gt;&lt;p&gt;Logical setup of the testbed is shown on a picture below - it is much more realistic than the physical one:&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-oyI7vZlFOXs/TrVs6arZpbI/AAAAAAAAEFw/WvrTIR33qEY/s1600/RIO_Log_Exp_shd.png" imageanchor="1" style=""&gt;&lt;img border="0" height="273" width="550" src="https://lh3.googleusercontent.com/-oyI7vZlFOXs/TrVs6arZpbI/AAAAAAAAEFw/WvrTIR33qEY/s929/RIO_Log_Exp_shd.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;LAN contains one host (one of the laptops) and two routers - one connected to the IPv6 Internet and one connected to Wireless Sensor Network. On the WSN side there is a single node with HTTP webserver (Raven) and RPL is used for routing. For the IPv6 Internet connection &lt;a href="http://gogonet.gogo6.com/page/freenet6-ipv6-services"&gt;Freenet6&lt;/a&gt; GoGo Client is used - I have no public IP therefore normal tunnel won't work. Through GoGo client /56 prefix is received. LAN uses the first /64 subnet in the prefix, WSN uses the second one.&lt;/p&gt;&lt;h2&gt;Problem formulation&lt;/h2&gt;&lt;p&gt;When aiming for a zero-configuration connection to WSN nodes in home LAN, one of the main problems is choosing the right router for outgoing transmissions. In LAN like above, a host gets Router Advertisements from both WSN and Internet routers, and saves their addresses in Default Router List. When IPv6-enabled host has more than one router in its Default Router List, it selects the router for outgoing traffic in round-robin fashion (&lt;a href="http://tools.ietf.org/html/rfc4861#section-6.3.6"&gt;RFC4861&lt;/a&gt;). In typical IPv6 operation it's not a problem - if host chooses non-optimal router, the router sends a Redirect message to the host. Redirect tells the host to use other router for that particular destination. Host saves this information in its Destination Cache and next time it sends the traffic to the correct router. Routers need to know about each other and about accessible routes to send Redirects. Normally routers use some kind of dynamic routing protocol to inform each other about known routes (e.g., RIPng).&lt;/p&gt;&lt;p&gt;Contiki OS (used by Grinch border router) doesn't support redirects, or any typical routing protocols. It's not a big technical problem, as the simplest routing protocol - RIPng can be certainly operated by a router like Grinch (maybe with 16kb of RAM). However it's not the only problem. Typical IPv4 home routers don't support any kind of routing protocol - they are simple gateways which send traffic to a default route. There are no "typical IPv6 home routers" on the market yet - only "IPv6 enabled routers", but existing guidelines for home routers don't contain routing protocol support as a mandatory functionality (&lt;a href="http://tools.ietf.org/id/draft-ietf-v6ops-ipv6-cpe-router-09.txt"&gt;RFC6024&lt;/a&gt;). Windows operating system also doesn't support any dynamic routing protocols in Home Edition. At the moment probably the only IPv6 home router solution with RIPng support are special OpenWRT and DD-WRT builds. It might in a couple of years lead to a situation where Internet of Things home deployment is hampered by lack of proper router functionality.&lt;/p&gt;&lt;h2&gt;Partial solution - Route Information Options&lt;/h2&gt;I've decided to look for another solution and found a nice candidate. &lt;a src="http://tools.ietf.org/html/rfc4191"&gt;RFC4191&lt;/a&gt; contains an extension of original Neighbor Discovery which allows adding Route Information Option to Router Advertisements. Router can use this option to inform hosts on a network about routes it knows about. However the router should not use Route Information Option to send its whole routing table to all hosts - it should only advertise specific, important routes. The WSN border router is exactly such case - it should include the route to the WSN in its RAs. &lt;/p&gt;&lt;p&gt;Advantages:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;doesn't require any configuration on hosts&lt;br /&gt;&lt;li&gt;allows hosts to send traffic to the best router straight away, without waiting for a redirect.&lt;br /&gt;&lt;li&gt;no need for a dynamic routing protocol&lt;/ul&gt;&lt;p&gt;Disadvantages&lt;/p&gt;&lt;ul&gt;&lt;li&gt;doesn't provide WSN-to-Internet connectivity (for that routing protocol is required)&lt;br /&gt;&lt;li&gt;not supported in most systems (see below)&lt;/ul&gt;&lt;h2&gt;Route Information Options for Grinch&lt;/h2&gt;&lt;p&gt;Adding RFC4191 support to Grinch was quite trivial - the router only has to send Router Advertisements with an additional bit flag, and Route Information Option. The implementation is compatible with multiple interfaces extension added to Grinch earlier. I've added another structure that holds all information necessary for RIOs (uip_ds6_route_info). Because of that the code is not very well optimized for RAM usage. It is possible to implement a more efficient approach, that would use pointers to prefixes held in Prefix Table or Routing Table, but Routing Table doesn't contain lifetime necessary for the RIO, so still some kind of additional structure is necessary. Other solution is to change Contiki Routing Table to contain route lifetime - it's used by RPL anyway.&lt;/p&gt;&lt;p&gt;Modified code is available in &lt;a href="https://github.com/siskin/contiki-mirror/commit/0796b3b69ec6a34d5089349f5277848cf01ec906"&gt;Git repository:&lt;/a&gt;:&lt;/p&gt;&lt;h2&gt;RIO tests&lt;/h2&gt;&lt;p&gt;I've run some tests with RFC4191 enabled Grinch. The border router was set to send Router Advertisements with Prefix Information Option containing LAN prefix, and Route Information Option containing WSN prefix. The LAN prefix was also advertised by the laptop running freenet6 client ("Internet router"). Grinch was tested with four kinds of devices - results below:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Laptop with Windows XP - IPv6 has to be enabled on the laptop before any experiments. Laptop receives modified Router Advertisements from Grinch correctly and adds a route to WSN to its routing table. It's immediately possible to ping Raven board after that. However Windows XP doesn't support IPv6 DNS, so it's impossible to connect to ipv6.google.com even after adding DNS server manually. Fail.&lt;br /&gt;&lt;li&gt;Laptop with Ubuntu 11.04 - Internet connectivity works after adding DNS manually. However there is no RFC4191 &lt;a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/235258/comments/23"&gt;support in Ubuntu&lt;/a&gt;. Fail.&lt;br /&gt;&lt;li&gt;Android 2.2 - for that test I modified the LAN physical setup, and used wireless router instead of switch. Then I connected the phone to WLAN using WiFi. My phone received IPv6 address but it had no applications that could use IPv6 - even ping!!! Also it didn't support RFC4191. Android really needs better IPv6 support. Fail.&lt;br /&gt;&lt;li&gt; Laptop with Windows 7 - Internet connectivity works after adding DNS manually. Also laptop receives Router Advertisements with RIO from Grinch correctly and adds a route to WSN to its routing table. However the network is not very stable - pings are sometimes lost for no reason.&lt;br /&gt;&lt;/ul&gt;&lt;h2&gt;Further tests with Windows 7&lt;/h2&gt;&lt;p&gt;After playing with the network a bit more I've determined that two more details in Grinch software had to be changed:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Neighbor Advertisement Router Flag - in Grinch NAs it was set to zero (default for Contiki). That caused the laptop to remove all entries related to Grinch from the Routing Table. It caused periodic "flapping" of the routing table - sometimes pings worked, and a while later they didn't. After changing the Router Flag to 1, the flapping behavior disappeared.&lt;br /&gt;&lt;li&gt;Router Advertisement Router Lifetime - any non-zero value made Grinch to be added to Default Router List on the laptop. It sometimes caused the Internet traffic to be directed to Grinch (with no Redirect ability). This could totally break down Internet connectivity for the laptop. After changing Router Lifetime in Grinch RAs to zero, it is no longer considered a candidate for a Default Router, but Route Information Options still work.&lt;/ul&gt;&lt;p&gt;With these changes the solution can be considered successful - I've tested it with my wife's new Windows 7 laptop (with vanilla OS), and it connected to Raven without any problems. Connection to ipv6.google.com required manual DNS setup. Both changes are included in the Git code above.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-905396430399521003?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/905396430399521003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2011/11/grinch-border-router-routing-in-lan.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/905396430399521003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/905396430399521003'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2011/11/grinch-border-router-routing-in-lan.html' title='Grinch Border Router - routing in LAN environments'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='https://lh6.googleusercontent.com/-bjhuGGWRvXg/TrVkNrzlimI/AAAAAAAAEFg/x5kXw02Zf0o/s72-c/RIO_Exp.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-7628261983149624166</id><published>2011-09-29T19:54:00.001+02:00</published><updated>2011-09-29T19:54:41.391+02:00</updated><title type='text'>Grinch Border Router - routing HTTP traffic</title><content type='html'>&lt;p&gt;In my last post devoted to Grinch Border Router I described how to forward pings through the router. However the router wasn't capable of sending much more than standard size pings. It wasn't possible to route any IPv6 packet larger than 152 bytes. I blamed it on Zigbit's limited memory, and decided to get a new module with Atmega128RFA1.&lt;/p&gt;&lt;p&gt;However in the meantime I had some problems with my DSLR and decided to try, and repair it myself. I failed miserably and damaged the power board of the camera, and had to send it to the professionaI support. I had to pay for the new power board, and had no cash for the RFA1 modules, so I decided to work on the Zigbit a little bit more :) . It quickly turned out, that Zigbit has enough memory for everything. I just had to turn off the webserver, and I managed to fit the full 1280-byte buffer for the packets. I also had to correct some bugs:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Debug comments - debug comments in AVR can be put either into flash memory, or RAM memory. RAM is faster, but very limited, so I was using primarily flash comments. This significantly slowed down the microcontroller, so that it was not possible to send 6lowpan fragmented packets. After turning off all debug comments the border has enough processing power to forward packets that need fragmentation.&lt;br /&gt;&lt;li&gt;ENC28J60 driver bug - the driver has a config parameter MAX_FRAMELEN which limits maximum packet size. In my first build it was set to 500 bytes. It made HTTP communication impossible.&lt;br /&gt;&lt;li&gt;In my first build the interrupts were turned off when receiving packets from ENC28J60. I changed it to turn off interrupts also when sending packets. The stability of the Grinch Border Router increased greatly (works for several hours without freezing).&lt;/ul&gt;&lt;p&gt;After these changes the Grinch has become quite usable as a border router. It is possible to access Raven webserver from the PC almost every time. Also large 1232 byte pings are forwarded without problems. The router is still not ready for the deployment, but it's perfectly ready for testing of wireless sensor networks.&lt;/p&gt;&lt;p&gt;Next thing to do is the automatic discovery of Grinch in the network. For that Router Advertisements are needed. I still haven't modified this part of Contiki to support multiple interfaces, but it shouldn't be hard. I also plan to run some long tests of the router to see how stable it is.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-7628261983149624166?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/7628261983149624166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2011/09/grinch-border-router-routing-http.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/7628261983149624166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/7628261983149624166'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2011/09/grinch-border-router-routing-http.html' title='Grinch Border Router - routing HTTP traffic'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-4364442190376738335</id><published>2011-06-08T21:33:00.035+02:00</published><updated>2011-06-08T22:18:18.478+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WSN'/><category scheme='http://www.blogger.com/atom/ns#' term='RPL'/><category scheme='http://www.blogger.com/atom/ns#' term='6lowpan'/><category scheme='http://www.blogger.com/atom/ns#' term='Contiki'/><title type='text'>Grinch - simple 6lowpan RPL border router</title><content type='html'>The biggest advantage of IP based Wireless Sensor Networks is their ability to be seamlessly connected to the Internet. A device which passes data from the lowpan to ordinary network is called a "border router". Such a device must support at least two network interfaces: 802.15.4 for the lowpan, and 802.3 or 802.11 for the uplink.&lt;br&gt;&lt;br&gt;Contiki OS does not currently support multiple interfaces, but it is possible to deploy a border router on Contiki with serial interface for uplink. Depending on the hardware platform it can be done in two ways: either with special software called tunslip6, or with RNDIS device driver. Both solutions need a running PC with Linux or Windows, which  makes them inconvenient for simple home automation solutions.&lt;br&gt;&lt;br&gt;Because of that I decided to develop a simple border router with Ethernet interface. After asking on Contiki mailing list I discovered that nobody is actively working on a multiple interfaces support, so I decided to add it myself. First results of ping tests are presented below - I wrote a simple tutorial in a spirit of &lt;a href="http://www.sics.se/contiki/tutorials/tutorial-running-contiki-with-uipv6-and-sicslowpan-support-on-the-atmel-raven.html"&gt;Contiki Atmel Raven Tutorial&lt;/a&gt;.&lt;h2&gt;Hardware&lt;/h2&gt;I assembled a quick prototype board with 15.4 and Ethernet interfaces. I called  it "Grinch" (I did most of the soldering during last Christmas). The board is based on the Zigbit module. Zigbits contain Atmega 1281 microcontroller and AT86RF230 radio transceiver that communicate over SPI. For Ethernet I chose Microchip ENC28J60, very simple Ethernet controller with SPI interface.&lt;br&gt;&lt;br&gt;Last year I designed and ordered some breakout boards for the Zigbits with goldpin connectors, and ENC28J60 is sold in DIP packages, so I chose not to use any SMD components in my project. I used simple prototype board with greenwire connections. I soldered the components ad-hoc without a schematic, but later I made some simple drawing in Eagle to document the project &lt;a href="https://docs.google.com/leaf?id=0B8FGeVJ54jMSNGIxZWE0OTQtMGRiNS00ZmE2LWI5NWUtOTQ4ODVhMzNmMmE2&amp;hl=pl&amp;authkey=CNi4upEC"&gt;(link)&lt;/a&gt;. Below is the photo of the board.&lt;img src="https://lh5.googleusercontent.com/-evWEVxu9ORA/Teum8mQP8TI/AAAAAAAAEC8/i7pKHbDB4dk/s720/DSC_0418.JPG" width=100% align=center&gt;Zigbit has a serious drawback - it has only 8kb of RAM, and it limits the number of neighbors and routes that can be maintained. Also it leaves very little room for the webserver (which is very useful for debugging). Also 6lowpan fragmentation is not possible - there is no space for buffers. For any future border router projects I strongly recommend Redwire MC13224 or Dresden Elektronik Atmega128RFA1 modules.&lt;br&gt;&lt;br&gt;Working Grinch Border Router is shown on a picture below:&lt;img src="https://lh5.googleusercontent.com/-egx5a4lfpvg/Teum8bn490I/AAAAAAAAEC4/WdmK92GHd-c/s720/DSC_0420.JPG" width=100% align=center&gt;After assembling the board it is good to test it using some simple IPv4 AVR software unrelated to Contiki. &lt;a href="http://tuxgraphics.org/electronics/"&gt;Tuxgraphics&lt;/a&gt; is a very good page with test examples.&lt;h2&gt;Software&lt;/h2&gt;The mod contains the following additions to the github contiki-mirror repo:&lt;ul&gt;&lt;li&gt;ENC28J60 driver for AVR microcontrollers&lt;li&gt;Multiple interfaces support&lt;/ul&gt;ENC28J60 driver is based on driver by Guido Socher and wrapped with a modified template from Contiki Docs - example-packet-drv.c . The only significant change from Guido's code is that first 14 bytes of every received frame are copied into the different buffer than the rest. This way no intermediate processing is necessary before submitting a packet to uip stack. ENC28J60 driver switches the interrupts off for the duration of the read - otherwise if RF230 interrupts launch during ENC read, it can crash the system for good. Contiki is a non-preemptive system, so ENC28J60 and RF230 drivers can peacefully coexist and share SPI interface - as long as interrupts are taken care of and both drivers properly set the Chip Select (CS) pin after using the interface. ENC28J60 driver works fairly well, and was tested with IPv4 and IPv6 Contiki - it can be used in projects totally unrelated to Wireless Sensor Networks.&lt;br&gt;&lt;br&gt;  Multiple interfaces support is implemented in a very straightforward way - all interface-describing structures defined in /core/net/uip-ds6.h are changed into arrays of structures instead. All functions are modified to get along with this change. The modification is not very complicated, but code needs to be fixed in numerous places. Most code changes are located in the /core/net directory. The more serious code changes are:&lt;ul&gt;&lt;li&gt;Initialization - contiki-conf has to be changed to support two interfaces&lt;li&gt;Link-layer Address Option construction -  Ethernet and 802.15.4 link-layer addresses have different length&lt;li&gt;Periodic processing - to keep the code simple single timer is used for all interfaces&lt;/ul&gt;For proper functioning of uIP stack, every function needs to operate on correct interface. This is done by a combination of these two methods:&lt;ul&gt;&lt;li&gt;Common functions operate on the interface, which id is saved in a uip_last_active_interface variable (current name is not very good). The value of this variable is changed whenever a packet is received or meant to be sent. For example ping reply is always sent to the interface where the request came from.&lt;li&gt;Interface specific functions operate on hardcoded interface identifiers - for example RPL packets are always sent to IF_RADIO interface, and ENC28J60 driver operates only on IF_FALLBACK interface.&lt;/ul&gt;This part of mod has to be considered experimental - there is no guarantee that any Contiki tools or apps will run with it (for example Cooja).   Git repository with the mod is accessible at Github: &lt;br&gt;&lt;br&gt;  &lt;span style="font-weight:bold"&gt;git@github.com:siskin/contiki-mirror.git&lt;br&gt;branch: multiple-netif&lt;/span&gt;   &lt;h2&gt;Test overview&lt;/h2&gt;This demo is based entirely on pings - with no application data transfer. I tried a simple test with HTTP, but it failed completely - the reason for that is probably the limited capability of Zigbit to fragment IPv6 HTTP communications (they are normally too big). I plan to use CoAP later but I have no working code for Raven yet. However the ping test can verify most of the properties of the new multiple interfaces capability.  &lt;img src="https://lh4.googleusercontent.com/-UwlTwvaKEec/Te5ewA7JwqI/AAAAAAAAEDM/Xz3Hn-QVaqE/s640/test_setup.png" width=100%&gt; &lt;h2&gt;Compiling the code&lt;/h2&gt;Binaries can be compiled using the following commands:&lt;br&gt;&lt;br&gt;  &lt;span style="font-style:italic"&gt;cd c:/contiki-mirror/examples/webserver-ipv6-raven&lt;br&gt; make&lt;br&gt;&lt;br&gt;  cd c:/contiki-mirror/platform/avr-ravenlcd&lt;br&gt; make&lt;br&gt;&lt;br&gt;  cd c:/contiki-mirror/examples/ipv6/rpl-border-router-eth&lt;br&gt; make&lt;/span&gt;&lt;br&gt;&lt;br&gt;  All examples have proper Makefile.target files - there is no need to specify target from command line. Note that AVR Raven is also compiled with multiple interfaces support, but number of interfaces is set to 1.  Installing the software on Raven is shown in the &lt;a href="http://www.sics.se/contiki/tutorials/tutorial-running-contiki-with-uipv6-and-sicslowpan-support-on-the-atmel-raven.html"&gt;Contiki Atmel Raven Tutorial&lt;/a&gt;. Installing the software on Grinch is similar - but it is dependent on the physical layout of the board. &lt;h2&gt;Addressing and Windows setup&lt;/h2&gt;The example uses RPL routing on the 802.15.4 side and static routes on the Ethernet side. Ethernet IPv6 prefix and RPL prefix are both hard-coded inside rpl-border-router-eth.c file. Handling of these two prefixes is different - IPv6 prefix makes the node assume, that all addresses with the same prefix are on link. Because of that, this type of prefix doesn't work well for radio links, where some nodes with a matching address can be out of range. Inside rpl-border-router-eth.c file there is a quick hack which adds the IPv6 prefix only for IF_FALLBACK interface.  To run the test it's necessary to add a Global IPv6 Address for the PC Ethernet interface (otherwise pings from Raven to PC won't work), and to add a static route to Raven. Here are the necessary commands for Windows 7:  &lt;br&gt;&lt;br&gt;First you have to find the name of the Ethernet interface on a PC. It can be checked under Network-&gt;Properties-&gt;Network connections: &lt;img src="https://lh3.googleusercontent.com/-wR68gbt-gQo/Te-puXAiVXI/AAAAAAAAEDg/5bxbMyDFLOU/network_connections.png" width=100%&gt; As you can see on my PC there are two network interfaces - one of them is WiFi and the other one is Ethernet. The name of Ethernet interface is "Połączenie lokalne" (I have a Polish version of Windows 7 - don't worry your name will be normal :) ). Now it's good to right-click the Ethernet connection and uncheck all fields except IPv6: &lt;div width=100% style="text-align:center"&gt;&lt;img src="https://lh6.googleusercontent.com/-1iCsha99M00/Te-sLrXoesI/AAAAAAAAEDk/gChTZOYIjDM/connection_properties.png" width=50% &gt;&lt;/div&gt;Next you can close Network Properties and open Command Line &lt;span style="font-weight:bold"&gt;as an administrator&lt;/span&gt;. Type:&lt;br&gt;&lt;br&gt;  &lt;span style="font-style:italic"&gt;ipconfig&lt;/span&gt;&lt;br&gt;&lt;br&gt;  Windows displays the information about interfaces. The result below: &lt;img src="https://lh5.googleusercontent.com/-bDKn0EJx8TQ/Te-puWWky5I/AAAAAAAAEDc/Qt_uH3aCOXg/s640/ipconfig.png" width=100%&gt; As you can see, "Połączenie lokalne" has no IPv4 addresses and one IPv6 address &lt;span style="font-style:italic"&gt;fe80::21e:33ff:feae:63a8%11&lt;/span&gt; . This is a link-local address, and it's not enough for the test. We have to add a Global IPv6 Address. We will use a prefix &lt;span style="font-style:italic"&gt;aaaa::/64&lt;/span&gt; and host address the same like the link local interface. You can use a different address but you will have to set it in:&lt;br&gt;&lt;br&gt;  &lt;span style="font-style:italic"&gt;c:/contiki-mirror/platform/avr-raven/apps/raven-lcd-interface/raven-lcd.c&lt;/span&gt;&lt;br&gt;&lt;br&gt;  in a next line after&lt;br&gt;&lt;br&gt;  &lt;span style="font-style:italic"&gt;#elif MULTIPLE_INTERFACES_TEST_PING_PC&lt;/span&gt; &lt;br&gt;&lt;br&gt; (otherwise you won't be able to ping PC from Raven). To add an address we will issue a command:&lt;br&gt;&lt;br&gt;  &lt;span style="font-style:italic"&gt;netsh interface ipv6 add address interface="Połączenie lokalne" aaaa::21e:33ff:feae:63a8&lt;/span&gt;&lt;br&gt;&lt;br&gt;  After address is added we can use &lt;span style="font-style:italic"&gt;ipconfig&lt;/span&gt; once again to verify the address. Next we have to add a route - otherwise the PC won't know that it can reach Raven through border router. We will use a following command:&lt;br&gt;&lt;br&gt;  &lt;span style="font-style:italic"&gt;netsh interface ipv6 add route interface="Połączenie lokalne" aaaa:0:0:1::/64 fe80::aa:bbff:fecc:ddee&lt;/span&gt; &lt;br&gt;&lt;br&gt; By using this command we inform our PC that to send packets to all addresses with &lt;span style="font-style:italic"&gt;aaaa:0:0:1::/64&lt;/span&gt; prefix, it needs to send packets to a MAC address which matches the link-local address &lt;span style="font-style:italic"&gt;fe80::aa:bbff:fecc:ddee&lt;/span&gt; (it is a link-local address of the Grinch). To resolve the MAC address, PC automatically sends Neighbor Solicitation packet (it's part of IPv6 stack). The outcome of the add operation can be verified with the command:&lt;br&gt;&lt;br&gt;  &lt;span style="font-style:italic"&gt;netsh interface ipv6 show route&lt;/span&gt; &lt;br&gt;&lt;br&gt; Output below: &lt;img src="https://lh4.googleusercontent.com/-OBmlywCDXYw/Te-3ZLmMtGI/AAAAAAAAEDo/xmy04DoeQnI/s576/show_route.png" width=100%&gt;  &lt;h2&gt;Running the test&lt;/h2&gt;&lt;h4&gt;CMD Files&lt;/h4&gt;Windows command line throughly sucks. It doesn't remember previous commands like in Linux, and it's tedious to enter all the commands from keyboard each time. To speed up the testing I suggest saving individual commands in text files with .cmd  extension (for example pngr.cmd), inside your user directory. This way after your command line starts up, you are in your user directory, and you just have to type the name of the file, not the full command.   &lt;h4&gt;Pinging the Grinch from PC&lt;/h4&gt;You can ping both global and link-local address of the Grinch - it should reply in both cases. Plug in the power and Ethernet cable and type:&lt;br&gt;&lt;br&gt;  &lt;span style="font-style:italic"&gt;ping -6 fe80::aa:bbff:fecc:ddee&lt;br&gt; ping -6 aaaa::aa:bbff:fecc:ddee&lt;/span&gt; &lt;br&gt;&lt;br&gt; My typical response time is 4ms. First ping almost always hits timeout - during this time PC performs address resolution. &lt;h4&gt;Pinging the Raven from the PC&lt;/h4&gt;After powering the Raven up it will play some tune - funny, but not when you're coding at 2AM :) . To succesfully ping the Raven we need to know, that Grinch has an RPL route to it. The route should be established in 15-20 seconds after starting the Raven. We can check it using webserver on Grinch. Open your web browser and type in address of the Grinch, like on the picture below. &lt;img src="https://lh4.googleusercontent.com/-OgztGZv7I6I/Te_BmrOq3yI/AAAAAAAAEDs/dNdZoHS4Xyo/webserver.png" width=100%&gt; If the route exists it will be displayed on the webpage. After that you can issue a ping command:&lt;br&gt;&lt;br&gt;  &lt;span style="font-style:italic"&gt;ping -6 aaaa::1:1:2:3:4&lt;/span&gt;&lt;br&gt;&lt;br&gt;  The Raven will cheerfully beep after receiving ping, so you will immediately know if you're successful. My typical response time is 17ms. &lt;h4&gt;Pinging PC from the Raven&lt;/h4&gt;To ping the PC from the Raven we also need an RPL route to Grinch. Ping is initialized from Raven LCD menu - basically you have to click the little joystick switch twice to the right. Successful pings will also be confirmed with a beep. &lt;h4&gt;Known Bugs&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;DAD packets for Ethernet interface are not really sent, because Ethernet link needs a second to initialize, therefore uIP always considers DAD as successful. I don't have a good idea yet how to fix this bug, but it's almost harmless. DAD for 802.15.4 are sent properly&lt;li&gt;Some comments don't include interface ID - it's not really a bug, just an inconvenience when using RS232 debug.&lt;li&gt;When Grinch Border Router is turned off and turned on again, it doesn't register a route to Raven - it is some RPL issue and not a purpose of this tutorial. Remember to power up both Grinch and Raven simultanously before running the test.&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-4364442190376738335?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/4364442190376738335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2011/06/grinch-simple-6lowpan-rpl-border-router.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/4364442190376738335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/4364442190376738335'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2011/06/grinch-simple-6lowpan-rpl-border-router.html' title='Grinch - simple 6lowpan RPL border router'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='https://lh5.googleusercontent.com/-evWEVxu9ORA/Teum8mQP8TI/AAAAAAAAEC8/i7pKHbDB4dk/s72-c/DSC_0418.JPG' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-7709366357391487067</id><published>2011-03-29T18:20:00.001+02:00</published><updated>2011-03-29T18:20:45.247+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ZigBee'/><category scheme='http://www.blogger.com/atom/ns#' term='IETF'/><category scheme='http://www.blogger.com/atom/ns#' term='RPL'/><category scheme='http://www.blogger.com/atom/ns#' term='6lowpan'/><title type='text'>IETF Tutorial in Prague</title><content type='html'>On Saturday, March 26th, I've attended IETF &lt;a href="http://www.iab.org/about/workshops/smartobjects/tutorial.html"&gt;Tutorial on Interconnecting Smart Objects with the Internet&lt;/a&gt; in Prague. Not being actively involved in any organized research I was waiting for the tutorial with much anticipation. The event comprised several lectures by the most active Internet of Things researchers. Here are some comments.&lt;br /&gt;&lt;br /&gt;First lecture was given by Carsten Bormann, a co-author of "6LowPAN The Wireless Embedded Internet". The presentation contained many slides from that book actually. Prof. Bormann briefly explained the 6LowPAN Header Compression, Packet Fragmentation and Neighbor Discovery. These techniques are essential for running IP over 802.15.4. There are still substantial changes going on in these areas - for example early methods of Header Compression (described in the book) were obsoleted because of inability to compress global prefixes (the biggest part of the network traffic).&lt;br /&gt;&lt;br /&gt;Second lecture was on routing in low-power and lossy networks (LLNs). It was delivered by JP Vasseur, the chair of IETF Roll group. The main topic was RPL protocol - new, specially designed protocol for routing in WSNs. The protocol looks completed at the moment, with no bigger issues to resolve. However the relationship between the RPL and normal 6LowPAN Neighbor Discovery looks very shady to me - both techniques seem to overlap in great deal. Even now Contiki RPL implementations run with ND switched off. &lt;br /&gt;&lt;br /&gt;Third lecture, by Zach Shelby was devoted to Constrained Application Protocol. CoAP also slightly evolved since I first learned about it in Finland. For example SUBSCRIBE method was changed into an optional observation mechanism. What surprised me the most was the lack of enthusiasm of some of the participants (presumably other IETF members) about introducing a new protocol. It seems that IETF "rough consensus" is really rough sometimes.&lt;br /&gt;&lt;br /&gt;Fourth lecture was done by Apple researcher Stuart Cheshire. He was talking about IP networks used to replace other short range connections (like USB) with no configuration necessary (service discovery performed through new technique - multicast DNS). The lecture included simple technological demo, that clearly shown Apple's philosophy in design: it worked instantly, with no user configuration. &lt;br /&gt;&lt;br /&gt;Fifth lecture was given by Adam Dunkels from SICS. Adam explained some Contiki concepts - protothreads, and Contiki MAC, and he did it in great style. It was fascinating to listen about the operating principle of protothreads (almost as if  it wasn't some high level C concept). &lt;br /&gt;&lt;br /&gt;The last lecture was presented by Robert Cragie - ZigBee Alliance researcher. It was really interesting, as the ZigBee Alliance was recently forced (by some US energy related department) to adopt IP in its design. To accomplish that, ZigBee Alliance plans to develop new ZigBee IP "superstandard" based on 6LowPAN, RPL, and other IoT related technologies. Cragie pointed out current weaknesses of that approach - such as overlapping standards, and lots of optional parameters, that can prevent two devices from different vendors from communicating with each other. ZigBee Alliance wants to address these problems by describing exactly which standards and options to use. In my opinion, by developing a uniform IP-based communication stack ZigBee IP can become a real leader in the area in a couple of years.&lt;br /&gt;&lt;br /&gt;The meeting was my first opportunity to see how IETF works (although the real IETF 80 meeting started on Monday). Some of the IETF members are true geeks, who remember some long lost Internet technologies, and dispute about every detail and usecase of the protocols. In today's money driven world, this organization seems strangely out of place.  But I think that because of that the future of the Internet is in good hands.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-7709366357391487067?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/7709366357391487067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2011/03/6lowpan.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/7709366357391487067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/7709366357391487067'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2011/03/6lowpan.html' title='IETF Tutorial in Prague'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-2849428987604980573</id><published>2010-09-12T17:44:00.000+02:00</published><updated>2010-09-12T17:44:45.553+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='roguelike'/><title type='text'>Roguelike</title><content type='html'>During last 3 years I spent some of my time trying to learn how to write a roguelike. Roguelikes are cRPG games with no graphical mode, where environment is represented with ASCII characters (for example @ is player character). I discovered my first roguelike - ADOM when I was around 13 and I have always wanted to code one. I decided to write a post about developing a roguelike, because it's a way to summarize some things (and if I won't write it down it will rot on my hard drive for infinity).&lt;br /&gt;&lt;br /&gt;I started by reading tutorials about writing games. In general it's very hard to find a good tutorial about game writing. Game development, like any other technical activity is about layers of knowledge - you begin with some simple functions that do only one thing, but you organize them into bigger structures that can provide complicated results. Most tutorials contain only the basic steps, but tell you nothing about the upper layers. The best tutorial about game writing I found is Philip Hanna's &lt;a href="http://www.cs.qub.ac.uk/~P.Hanna/CSC207/CSC207.htm"&gt;CSC207&lt;/a&gt;. It's a university course, and contains many good examples, as well as the game engine written in Java. The engine is written in a very generic way. It allows you to start your own project, but it's never optimized for it - so sooner or later it forces you to write your own engine - but at that time you already know what you want and how to achieve it. Very good teaching trick Mr Hanna!&lt;br /&gt;&lt;br /&gt;I started my game using Philip Hanna's engine. At the beginning I really liked writing in Java. It was much faster to write than in C or C++. But after a while I became fed up with it - I had to create getter/setter methods for every variable, and the code was hard to change or read. Later I learned some tricks in the Eclipse IDE which helped a lot - automated refactoring and getter/setter creators. But I still wasn't happy with it. Then I found Python.&lt;br /&gt;&lt;br /&gt;Python is probably the best language for hobbyists out there - it's fun to use, reasonably fast (at least I think so), and with quite good support. At the beginning Python webpage scared me off because there is some new version of Python 3.0 coming out, and no library works with it. But then I realised that nobody uses it yet, and everything works with Python 2.6 (it's a risky idea to make language backward incompatible).&lt;br /&gt;&lt;br /&gt;I decided to start with &lt;a href="http://www.pygame.org/"&gt;Pygame&lt;/a&gt; - a library which is basically a binding to SDL library written in C. I read some basic tutorials, and started to port my earlier Java code to Python - mostly that meant holding DEL button for a long, long time. Python code is much shorter and easier to read than Java code (however some things are longer - like always including "self" as the first argument to a class method).&lt;br /&gt;&lt;br /&gt;Below is a main class of my game - its temporary nickname is Towers :) : &lt;br /&gt;&lt;br /&gt;&lt;div class="python"&gt;&lt;ol&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="co1"&gt;#File: game.py&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="co1"&gt;#Author: MW&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="kw1"&gt;import&lt;/span&gt; pygame, &lt;span class="kw3"&gt;sys&lt;/span&gt;,&lt;span class="kw3"&gt;os&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&lt;span class="kw1"&gt;from&lt;/span&gt; pygame.&lt;span class="kw2"&gt;locals&lt;/span&gt; &lt;span class="kw1"&gt;import&lt;/span&gt; &lt;span class="sy0"&gt;*&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="kw1"&gt;from&lt;/span&gt; &lt;span class="kw2"&gt;map&lt;/span&gt; &lt;span class="kw1"&gt;import&lt;/span&gt; Map&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="kw1"&gt;from&lt;/span&gt; &lt;span class="kw2"&gt;input&lt;/span&gt; &lt;span class="kw1"&gt;import&lt;/span&gt; Input&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="co1"&gt;# Uncomment the lines below to enable profiling&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&lt;span class="co1"&gt;#import profile&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="co1"&gt;#import pstats&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="kw1"&gt;if&lt;/span&gt; &lt;span class="kw1"&gt;not&lt;/span&gt; pygame.&lt;span class="me1"&gt;font&lt;/span&gt;: &lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;'Warning, fonts disabled'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="kw1"&gt;if&lt;/span&gt; &lt;span class="kw1"&gt;not&lt;/span&gt; pygame.&lt;span class="me1"&gt;mixer&lt;/span&gt;: &lt;span class="kw1"&gt;print&lt;/span&gt; &lt;span class="st0"&gt;'Warning, sound disabled'&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="kw1"&gt;class&lt;/span&gt; Game:&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;def&lt;/span&gt; &lt;span class="kw4"&gt;__init__&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;,width=&lt;span class="nu0"&gt;800&lt;/span&gt;,height=&lt;span class="nu0"&gt;600&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;._running = &lt;span class="kw2"&gt;True&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;screen&lt;/span&gt; = &lt;span class="kw2"&gt;None&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;screen_width&lt;/span&gt; = width&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;screen_height&lt;/span&gt; = height&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;def&lt;/span&gt; game_init&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;: &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pygame.&lt;span class="me1"&gt;init&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;screen&lt;/span&gt; = pygame.&lt;span class="me1"&gt;display&lt;/span&gt;.&lt;span class="me1"&gt;set_mode&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;screen_width&lt;/span&gt;, &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;screen_height&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pygame.&lt;span class="me1"&gt;key&lt;/span&gt;.&lt;span class="me1"&gt;set_repeat&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="nu0"&gt;200&lt;/span&gt;,&lt;span class="nu0"&gt;50&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pygame.&lt;span class="me1"&gt;display&lt;/span&gt;.&lt;span class="me1"&gt;set_caption&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="st0"&gt;'Game'&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="kw2"&gt;input&lt;/span&gt; = Input&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="kw2"&gt;map&lt;/span&gt; = Map&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;,&lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="kw2"&gt;input&lt;/span&gt;,&lt;span class="nu0"&gt;100&lt;/span&gt;,&lt;span class="nu0"&gt;100&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;clock&lt;/span&gt; = pygame.&lt;span class="kw3"&gt;time&lt;/span&gt;.&lt;span class="me1"&gt;Clock&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;def&lt;/span&gt; game_input&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="kw2"&gt;input&lt;/span&gt;.&lt;span class="me1"&gt;set_events&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;pygame.&lt;span class="me1"&gt;event&lt;/span&gt;.&lt;span class="me1"&gt;get&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;if&lt;/span&gt; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="kw2"&gt;input&lt;/span&gt;.&lt;span class="me1"&gt;get_event&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;QUIT&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;: &lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw3"&gt;sys&lt;/span&gt;.&lt;span class="me1"&gt;exit&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;def&lt;/span&gt; game_update&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="kw2"&gt;map&lt;/span&gt;.&lt;span class="me1"&gt;update&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;def&lt;/span&gt; game_render&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="kw2"&gt;map&lt;/span&gt;.&lt;span class="me1"&gt;render&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pygame.&lt;span class="me1"&gt;display&lt;/span&gt;.&lt;span class="me1"&gt;update&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;def&lt;/span&gt; main_loop&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="kw2"&gt;self&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;game_init&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw1"&gt;while&lt;/span&gt; &lt;span class="kw2"&gt;True&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;time_passed&lt;/span&gt; = &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;clock&lt;/span&gt;.&lt;span class="me1"&gt;tick&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="nu0"&gt;60&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;game_input&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;game_update&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="kw2"&gt;self&lt;/span&gt;.&lt;span class="me1"&gt;game_render&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&lt;span class="kw1"&gt;if&lt;/span&gt; __name__ == &lt;span class="st0"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; towers = Game&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; towers.&lt;span class="me1"&gt;main_loop&lt;/span&gt;&lt;span class="br0"&gt;&amp;#40;&lt;/span&gt;&lt;span class="br0"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;# Comment 1 line above and uncomment the lines below to enable profiling&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;#profile.run('import game; towers.main_loop()', 'profile.tmp') &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;#p = pstats.Stats('profile.tmp')&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li2"&gt;&lt;div class="de2"&gt;&amp;nbsp; &amp;nbsp; &lt;span class="co1"&gt;#p.sort_stats('cumulative').print_stats(10)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li class="li1"&gt;&lt;div class="de1"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;Python allows for both object-oriented and procedure-oriented programming, but my code is rather oo-way. The object of the Game class is created in the if statement at the end of the file. After that the main_loop method is called. At first it calls game_init method and initializes Pygame objects: display and clock. It also creates input object which is a wrapping over Pygame's event module, and map object which contains the rest of the game. Then it loops infinitely through three methods: game_input, game_update and game_render. Such design separates game logic (game_update) from gathering player input and displaying the game on the screen. &lt;br /&gt;&lt;br /&gt;So much writing and code still does nothing, but that's the beauty of the OOP - you don't need to know what's inside the object (the implementation) to write a proper code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-2849428987604980573?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/2849428987604980573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/09/roguelike.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/2849428987604980573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/2849428987604980573'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/09/roguelike.html' title='Roguelike'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-3187062209244303557</id><published>2010-06-13T22:45:00.005+02:00</published><updated>2010-09-12T17:54:05.304+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WSN'/><title type='text'>UBI Summer School</title><content type='html'>Last week I attended 1st &lt;a href="http://www.ubioulu.fi/en/UBI-summer-school-2010"&gt;UBI Summer School in Oulu&lt;/a&gt;, Finland. It was organized as a part of Ubiquitous Oulu Project. Its main topic was ubiquitous and urban computing. The School comprised of six workshops. I took part in workshop E - "IP-based sensor networks" by Zach Shelby. It was the most geeky and technical workshop of all - other workshops were much more human and application oriented.&lt;br /&gt;&lt;br /&gt;The main focus of the IP-based WSN workshop wasn't 6LoWPAN (as one could expect), but &lt;a href="http://datatracker.ietf.org/doc/draft-ietf-core-coap/"&gt;CoAP&lt;/a&gt; - Constrained Application Protocol. CoAP is an application protocol (ISO OSI layer 7) designed for WSN operation - it's RESTful, it features subscribe/notify mechanism and service discovery and it has a very small header. HTTP has neither of these. CoAP is still only an IETF draft, but taking into consideration the absence of open standards in the area it might really catch on.&lt;br /&gt;&lt;br /&gt;I've got to admit that two weeks ago I didn't know what REST really was, but I like the RESTful approach very much - it's not based on some complicated messages, but rather on availability and state of resources. I find this philosophy coherent with Unix/Linux systems, where every device, or process is represented by a file in a system tree. &lt;br /&gt;&lt;br /&gt;Other features of CoAP: subscription and discovery are even more interesting. Subscription is a must for communication with WSN nodes that are asleep most of the time. Service discovery makes application deployment for such nodes much easier - and it also makes maintenance and network expansion a lot more simple (maybe someday google will start to index your WSN nodes too :) ). &lt;br /&gt;&lt;br /&gt;According to other participants of the UBI school the REST way is the only way for WSN (except one guy who did research into SOAP and EXI, but stupid airlines lost his luggage, and he was forced to leave the school before he could show us the results). But some of the people weren't convinced that new protocol is really necessary - people will still use old and clumsy (but more diverse and supported) protocols, and not a specialized thing like CoAP. Being more of a hardware guy I still can't present my own opinion in the area. Time will tell.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-3187062209244303557?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/3187062209244303557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/06/ubi-summer-school.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/3187062209244303557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/3187062209244303557'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/06/ubi-summer-school.html' title='UBI Summer School'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-2891483062161809550</id><published>2010-05-16T12:22:00.003+02:00</published><updated>2010-05-16T17:40:22.926+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WSN'/><category scheme='http://www.blogger.com/atom/ns#' term='Zigbit'/><title type='text'>Breakout boards - first test</title><content type='html'>Yesterday my wife went binge drinking (bachelorette party) so I finally had some time to assemble my Meshnetics breakout boards. They contain only five elements each, but assembling them is a real PITA because of the Meshnetics modules. I soldered them with normal soldering iron and used solder wick to remove any jumpers. Afer soldering I tested the boards with a multimeter set to beep. For the power supply I used two AA NiMH batteries in nice battery holder with a switch (sadly it has no place for screws). I measured the output voltage of the battery packs - it was around 2.6V for each. Meshnetics need between 1.8V and 3.6V to work properly.  After assembling I connected the modules to the AVR Dragon JTAG programmer, and tried to read their signatures using AVR Studio. It worked perfectly - photo:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://lh3.ggpht.com/_MjKc_EYPO4I/S-_EnuYhoWI/AAAAAAAAD98/lHb6bYeDOyc/DSC_0031.JPG" width=100% align=center&gt;&lt;br /&gt;&lt;br /&gt;Breakout boards can be programmed and tested without any additional hardware, so they can be used as a very primitive WSN nodes. I didn't include any sensors and actuators on them - even LEDs or microswitches - so using them in such way would be really painful. However for a single module I can use AVR Dragon for fake I/O so it should be possible to run some software tests without designing and building target boards.&lt;br /&gt;&lt;br /&gt;In the meantime I've also been thinking about some name for my devices. In my opinion name is a very important thing - human brain needs names to process data, and a bad name might be harmful to entire project. I'm not a native English speaker so inventing a good name is not so easy. At first I thought about "smartlets" - like smart droplets :). However it has already been taken up by Apple - from a totally different angle - smart outlets. I need to think a bit more. &lt;br /&gt;&lt;br /&gt;Now the coffee for my wife...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-2891483062161809550?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/2891483062161809550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/05/breakout-boards-first-test.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/2891483062161809550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/2891483062161809550'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/05/breakout-boards-first-test.html' title='Breakout boards - first test'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_MjKc_EYPO4I/S-_EnuYhoWI/AAAAAAAAD98/lHb6bYeDOyc/s72-c/DSC_0031.JPG' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-1309438000047633332</id><published>2010-05-07T22:15:00.003+02:00</published><updated>2010-05-07T22:22:26.891+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WSN'/><category scheme='http://www.blogger.com/atom/ns#' term='Zigbit'/><title type='text'>WSN-intro and Meshnetics breakout boards</title><content type='html'>A couple of years ago, first news about Wireless Sensor Networks started to appear on the Web. At the beginning there were scattered pieces of information, but slowly it became a recognizable and popular research direction. I really like the idea of wireless sensor networks - tiny, simple devices called "motes" with limited sensing abilities, and processing power are used to collect data about physical and social phenomenons. Single mote has very little usefulness, but a network of them can support really innovative projects. It really sparks up imagination.&lt;br /&gt;&lt;br /&gt;The most popular standard in the WSN area nowadays is the Zigbee. It is supported by Zigbee Alliance - association of many international companies (among them Cisco, Atmel, TI and many other). However there are many other standards around - both open and proprietary. I recently became interested in 6LoWPAN - it's a collection of standards maintained by &lt;a href="http://www.ietf.org/"&gt;IETF&lt;/a&gt; - an international non-profit organization, that also maintains IP, and other Internet-related standards. 6LoWPAN makes it possible to use IP (only v6) on low-power radio links used in WSN.&lt;br /&gt;&lt;br /&gt;After doing some research I determined that probably the easiest way to start doing some 6LoWPAN research is to use &lt;a href="http://www.sics.se/contiki/"&gt;Contiki OS&lt;/a&gt; - operating system for embedded devices from SICS. Contiki already supports many 6LoWPAN concepts and many other are being actively developed. Contiki is available for many different platforms, but I think that MSP430-based devices are best supported. Contiki is equipped with java-based network simulator Cooja - so it's possible to start doing research without actually having any motes. I am getting ready to test that approach - I already installed Ubuntu Linux, and I hope to start some tests soon.&lt;br /&gt;&lt;br /&gt;Regardless of the simulator I plan to do some test with real motes. For my development platform I chose Atmel/Meshnetics Zigbit ATZB-24-A2 modules. They are quite cheap, available in Poland and contain a microcontroller, a transceiver and an on-chip antenna. I found a very good French &lt;a href="http://www.owbox.com/v1/zigbee-modules-RF-basse-consommation-development.php"&gt;site&lt;/a&gt; which contains many useful comments about these modules. My first step was to design a breakout board for the Zigbit modules. Zigbits are quite difficult to solder without hot-air station. I don't have such a station, so I plan to solder the modules once and for good to these breakout boards, and connect the boards to other devices with simple pin headers. My breakout boards will also contain JTAG and power-supply connectors - so I should be able to do some simple programming and debugging only with breakout boards. Here is the picture of the finished board next to a Zigbit module:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://lh4.ggpht.com/_MjKc_EYPO4I/S-Rzcst5EWI/AAAAAAAAD74/O8H3rPTSKfo/DSC_0362.JPG" width=100% align=center&gt;&lt;br /&gt;&lt;br /&gt;I made some rookie mistakes with the design - I got the description printed over the pads, but in general it looks just like I wanted :) . Now I'll have to come up with an idea how to solder it right. Any suggestions?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-1309438000047633332?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/1309438000047633332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/05/wsn-intro-and-meshnetics-breakout.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/1309438000047633332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/1309438000047633332'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/05/wsn-intro-and-meshnetics-breakout.html' title='WSN-intro and Meshnetics breakout boards'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_MjKc_EYPO4I/S-Rzcst5EWI/AAAAAAAAD74/O8H3rPTSKfo/s72-c/DSC_0362.JPG' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-2442589625546455763</id><published>2010-03-04T17:26:00.001+01:00</published><updated>2010-03-04T17:28:51.681+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='electronics'/><category scheme='http://www.blogger.com/atom/ns#' term='home automation'/><category scheme='http://www.blogger.com/atom/ns#' term='thermostat'/><title type='text'>Project #1 - PCB Design</title><content type='html'>With electronic schematic ready I created a PCB from it. The process was rather straightforward - Eagle created the PCB project automatically ("Board" button). Then I had to set my PCB size, and place all the elements on the board. I also had to use "Mirror" command on every SMD component to transfer them to the bottom side of the board - so that all the connections are on one side of the board (blue color is default for connections on the bottom).&lt;br /&gt;&lt;br /&gt;I decided not to use autorouter, so routing was a rather lengthy process - like a huge jigsaw. At first I wanted to conform to placement and routing rules in Atmel &lt;a href="http://www.atmel.com/dyn/resources/prod_documents/doc2521.pdf"&gt;AVR042&lt;/a&gt; Note (place decoupling capacitor as close to μC as possible, etc.) and in DS1307 RTC &lt;a href="http://www.sparkfun.com/datasheets/Components/DS1307.pdf"&gt;datasheet&lt;/a&gt; (do not route any wires under DS1307 RTC circuit). But eventually I gave up on these precautions - I wasn't sure if they really matter with home-made PCBs. Also I lacked some Eagle skills to implement them properly (for example how to create ground planes). I'll try to learn these things next time. &lt;br /&gt;&lt;br /&gt;One more thing to check when developing non-professional PCB is route spacing, and element pad size. Narrow routes placed near to each other may cause problems with etching.  Small element pads are more prone to damage from drilling. I know no easy way to change size of pads in Eagle - probably the only way is to modify the symbol of the element. &lt;br /&gt;&lt;br /&gt;The result is below - as you can see I already took into consideration dimensions of casing that I am going to use - that's why there is a hole in the middle.&lt;br /&gt;&lt;img src="http://lh6.ggpht.com/_MjKc_EYPO4I/S4_dcaZdejI/AAAAAAAADwI/Qdy3Ky68ALM/s512/sil3-brd.png" width=100% align=center&gt;&lt;br /&gt;&lt;br /&gt;Board &lt;a href="http://docs.google.com/leaf?id=0B8FGeVJ54jMSM2JkYTVjZWMtMTBkMS00ZDBiLTgzNzYtZjUzOGNmNjBkYTA1&amp;hl=pl"&gt;file&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-2442589625546455763?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/2442589625546455763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/03/project-1-pcb-design.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/2442589625546455763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/2442589625546455763'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/03/project-1-pcb-design.html' title='Project #1 - PCB Design'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_MjKc_EYPO4I/S4_dcaZdejI/AAAAAAAADwI/Qdy3Ky68ALM/s72-c/sil3-brd.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-4990861002576958800</id><published>2010-02-01T21:17:00.001+01:00</published><updated>2010-02-01T21:24:01.878+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='electronics'/><category scheme='http://www.blogger.com/atom/ns#' term='home automation'/><category scheme='http://www.blogger.com/atom/ns#' term='thermostat'/><title type='text'>Project #1 - circuit diagram</title><content type='html'>I finished doing the circuit diagram for my thermostat. Screenshot below:&lt;br /&gt;&lt;img src="http://lh4.ggpht.com/_MjKc_EYPO4I/S2cjPHtw7VI/AAAAAAAADuI/Orc-1pfPxuk/sil3.png" width=100% align=center&gt;&lt;br /&gt;&lt;br /&gt;Full schematic &lt;a href="https://docs.google.com/leaf?id=0B8FGeVJ54jMSNmI1MDE2YWQtODNhZS00MDMxLThhOGMtYzcxYjljNjVhMTFm&amp;hl=pl"&gt;here&lt;/a&gt; (for Eagle 5.6).&lt;br /&gt;&lt;br /&gt;I eventually chose Atmega16 for my CPU. It has enough memory and processing power for my needs (at least I hope so). Power is supplied from +5V 1.2A switching-mode power supply connected to SV3. Such power supply is noisy so to stabilize input voltage I use C1 and C12 capacitors (one tantalum 10uF and one simple ceramic 100nF). Q2 crystal together with C10 and C11 caps are used to generate clock signal and SV1 is used to program Atmega in ISP mode. &lt;br /&gt;&lt;br /&gt;On the diagram there are two ICs, which perform the functions needed by a thermostat. IC1 is DS1307, a Real-Time Clock chip. It will be used to keep track of the time flow. The other IC is DS1721, a Digital Thermometer. It will be used to monitor the temperature in the room. Both chips communicate with Atmega16 by TWI (Two-Wire Interface).&lt;br /&gt;&lt;br /&gt;Jumpers JP3 to JP6 are necessary to connect buttons. I will put buttons on the separate board, to make it easier to attach them to the casing. JP2 is used to connect standard 2x16 LCD with Hitachi HD44780 controller. Buttons and LCD Display together form user interface of the thermostat.&lt;br /&gt;&lt;br /&gt;I added MAX3232 to the schematic. I don't plan to use it now, but it's very easy to implement some basic communication in RS232 standard, so it might come in handy in the future. I also added SV2 jumper for 1-wire, so I'll be able to plug in additional digital thermometer later (DS1820).&lt;br /&gt;&lt;br /&gt;Finally there is K1 - electromechanical relay. It is the only output of my thermostat, and it will be used to control the boiler. T1 transistor is protected against voltage spikes by D2 diode.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-4990861002576958800?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/4990861002576958800/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/02/project-1-circuit-diagram.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/4990861002576958800'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/4990861002576958800'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/02/project-1-circuit-diagram.html' title='Project #1 - circuit diagram'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_MjKc_EYPO4I/S2cjPHtw7VI/AAAAAAAADuI/Orc-1pfPxuk/s72-c/sil3.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-1429241643406241877</id><published>2010-01-18T20:01:00.000+01:00</published><updated>2010-01-18T20:01:41.096+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='electronics'/><category scheme='http://www.blogger.com/atom/ns#' term='home automation'/><category scheme='http://www.blogger.com/atom/ns#' term='thermostat'/><title type='text'>Project #1 - input voltage</title><content type='html'>It seems that sometimes your experience in some subject is your worst enemy. I started drawing my schematic, and because ARM microcontrollers need +3.3V input voltage I automatically assumed that AVR need it too. So I put inside LM1117 voltage regulator and other unnecessary components. Today my colleague told me, that AVR works fine with +5V. I scrapped 50% of the schematic and started again.&lt;br /&gt;&lt;br /&gt;Immediately I discovered that +5V circuits are cheaper than +3.3V (for example when you compare MAX232 and MAX3232). Later I found also that AVR may work faster on +5V - 16MHz. On +3.3V it may work with 8MHz only. Not that I need 16MHz anyway for my PRT (Programmable Room Thermostat).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-1429241643406241877?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/1429241643406241877/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-input-voltage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/1429241643406241877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/1429241643406241877'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-input-voltage.html' title='Project #1 - input voltage'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-1863459746755351157</id><published>2010-01-17T15:34:00.000+01:00</published><updated>2010-01-17T15:34:36.601+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='electronics'/><category scheme='http://www.blogger.com/atom/ns#' term='home automation'/><category scheme='http://www.blogger.com/atom/ns#' term='thermostat'/><title type='text'>Project #1 - electronic CAD</title><content type='html'>To make a simple PCB by etching, I don't need any software, or special equipment - just some good chemical solvent (for cleaning the copper) and permanent marker (for drawing connections). But it's extremely hard to make anything more complicated that way - it's a medieval-book-writing-monk type of work. &lt;br /&gt;&lt;br /&gt;Using specialist CAD software helps a great deal. What does PCB CAD essentially do? It connects the logical design of the circuit with physical design of the PCB. First I make an electronic schematic of my circuit - using logical symbols like resistors, capacitors, ICs and connectors. Every time I need to use a part I open part database, choose a suitable element, and place its symbol onto the schematic. Then I connect the parts using wires (lines). When I'm done, I click "PCB Design", and the program opens another window, where once again I place symbols of my components. But this time I place physical parts - with proper dimensions, pinouts and packages - the program automatically assigns physical symbol to every logical symbol. After that I route wires between the symbols and it's done. Optionally I may generate CAM files used to manufacture my PCB on CNC machine.&lt;br /&gt;&lt;br /&gt;There are many free PCB CAD programs on the web. These are often connected to some big part suppliers. This is probably the most complete &lt;a href="http://www.olimex.com/pcb/dtools.html"&gt;list&lt;/a&gt; available. For my project I chose a program called &lt;a href="http://www.cadsoft.de/"&gt;Eagle&lt;/a&gt; by German company CADSoft. It's free for hobbyists, and has some limitations, but they are not important in small projects. Eagle was fully independent software some time ago, but it has been purchased by Farnell - big part supplier. I expect some new version of Eagle with integrated Farnell part base to appear. However Farnell is quite expensive when buying small quantities of parts (ex. single ICs), so a hobbyist like myself won't be using this kind of integration much. It's quite sad, because integrated part base would make my life much easier. Maybe in a country like US people may put any part they want into their projects, but here in PL I have to carefully check availability of every part. Otherwise I'll either wait 2 months to get it, or pay 2 times the price, sometimes both.&lt;br /&gt;&lt;br /&gt;About Eagle - it has some pros and cons - I'll describe them briefly:&lt;br /&gt;(+)&lt;ul&gt;&lt;li&gt; Has decent database (I usually find what I'm looking for) and user-made libraries&lt;br /&gt;&lt;li&gt; Easy to use (it has a command line for hard-core users)&lt;br /&gt;&lt;li&gt; Many resources on the web&lt;br /&gt;&lt;/ul&gt;(-)&lt;ul&gt;&lt;li&gt; Pathethic database searching (it's 2010 now, everybody has autocompletion and search-as-you-type in their programs, and here I have to type name in little window and press Enter)&lt;br /&gt;&lt;li&gt; Shortcut  - not Windows compatible&lt;br /&gt;&lt;li&gt; Tediousness - for example as a hobbyist I want electrical pads in my projects a bit larger than default - I don't know how to achieve it without modifying every single symbol&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;With this post I finished the introduction to my project. The information contained here is obvious for most people, but I felt that it's necessary to describe it, as it's part of the project too. With the next post I hope to move on to some technical details.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-1863459746755351157?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/1863459746755351157/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-electronic-cad.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/1863459746755351157'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/1863459746755351157'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-electronic-cad.html' title='Project #1 - electronic CAD'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-4904399270984501048</id><published>2010-01-10T20:52:00.000+01:00</published><updated>2010-01-10T20:52:40.732+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='electronics'/><category scheme='http://www.blogger.com/atom/ns#' term='home automation'/><category scheme='http://www.blogger.com/atom/ns#' term='thermostat'/><title type='text'>Project #1 - choosing microcontroller</title><content type='html'>In every project there are some decisions to make at the beginning which influence all further steps. In small embedded project probably the most important choice is about the microcontroller. At first I wanted to use ARM microcontroller, more specifically Atmel SAM7X. I have experience in programming these μCs in C, they are reliable, powerful, not very expensive, and you don't need any external programmer to program them (thanks to SAM-BA). I have a &lt;a href="http://www.sklep.propox.com/index.php?d=produkt&amp;id=2812"&gt;minimodule&lt;/a&gt; based on SAM7X256 I bought to play with it, but never made anything useful of it, so I thought I'd put it into the thermostat. But on Friday evening I checked everything up once again, and I totally changed my mind. Atmel SAM7X256 is at least 20 times too powerful for a simple project like mine - it would be stupid to waste it to click a relay two times a day.&lt;br /&gt;&lt;br /&gt;My natural second choice was Atmel AVR. These μCs are extremely popular in PL among hobbyists. Professionals also widely use them - in commercial applications engineers usually have to cut their costs and use reliable solutions. There are tons of code and resources for AVR on the web, and also official application notes on Atmel's webpage. I did one little project with AVR Atmega8 about six years ago - it was a basic mobile robot. I used very cheap LPT programmer, and coded robot behaviour in &lt;a href="http://www.mcselec.com/"&gt;BASCOM&lt;/a&gt; - simple BASIC-like language for beginners. Nowadays LPT port is quite uncommon. Luckily I have an ISP programmer, which I bought to play with some other stuff, but never made anything useful of it (there seems to be some pattern here). I'm also not going to use BASCOM anymore - I feel that C has the right power to ease of use ratio for me. &lt;br /&gt;&lt;br /&gt;After choosing μC I decided that I'll be making my circuit board from scratch by etching. I always did my circuits on protoboards using greenwire (kynar) to make point-to-point connections. It's great for prototyping, but it's slower and less reliable. Using a protoboard is also bad psychologically - I want to finish my thermostat fast, not prototype it forever. &lt;br /&gt;&lt;br /&gt;The next step is to choose some CAD software for PCB design, and get to some real work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-4904399270984501048?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/4904399270984501048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-choosing-microcontroller.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/4904399270984501048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/4904399270984501048'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-choosing-microcontroller.html' title='Project #1 - choosing microcontroller'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-8592410503910588020</id><published>2010-01-05T22:12:00.000+01:00</published><updated>2010-01-05T22:12:07.923+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='electronics'/><category scheme='http://www.blogger.com/atom/ns#' term='home automation'/><category scheme='http://www.blogger.com/atom/ns#' term='thermostat'/><title type='text'>Project #1 - controlling the boiler</title><content type='html'>At the beginning of the project I need to make some important decisions how to build the thermostat, and what components to use. The first problem is how to control the boiler. I checked the manual of my boiler, and I found a schematic (version in Spanish, but quite obvious):&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://lh3.ggpht.com/_MjKc_EYPO4I/S0OmWLlfJBI/AAAAAAAADtQ/sGh9bKvFM0c/s1600/skanowanie0002.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://lh3.ggpht.com/_MjKc_EYPO4I/S0OmWLlfJBI/AAAAAAAADtQ/sGh9bKvFM0c/s320/skanowanie0002.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;On the schematic there is a jumper P1 which connects terminals 6 and 9. The boiler was supplied with the jumper in place. Removing the jumper turns off the heating circuit of the combi-boiler, even if heating is enabled on control panel (and domestic water works normally). That's very good news, because the only thing I need to do is to replace the P1 jumper with a relay, and I don't have to care about electrical compatibility of my thermostat and the boiler. Well I just have to choose a relay big enough for the voltage and current present in the circuit.&lt;br /&gt;&lt;br /&gt;I measured the voltage between terminals 6 and 9, and my ancient multimeter shows 28V. Quite strange value, but it doesn't matter - 125V or 250V relay will work perfectly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-8592410503910588020?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/8592410503910588020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-controlling-boiler.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/8592410503910588020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/8592410503910588020'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-controlling-boiler.html' title='Project #1 - controlling the boiler'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_MjKc_EYPO4I/S0OmWLlfJBI/AAAAAAAADtQ/sGh9bKvFM0c/s72-c/skanowanie0002.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4110028886767234394.post-449193315255126749</id><published>2010-01-02T18:41:00.001+01:00</published><updated>2010-01-02T18:43:40.709+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='electronics'/><category scheme='http://www.blogger.com/atom/ns#' term='home automation'/><category scheme='http://www.blogger.com/atom/ns#' term='thermostat'/><title type='text'>Project #1 - programmable thermostat</title><content type='html'>My first project is a programmable thermostat for a boiler mounted in my apartment. In a town where I live there is a small CHP power station (combined heat and power). It was built long ago to support the industry with hot water for technical processes, and actually generates very little electricity (6MW in winter, during other seasons even less). The station supplies almost all apartment and commercial buildings in the area with hot water for heating and washing purposes. My building is probably the only exception. Such solution is both blessing and curse, as it gives me better control over heating, but is not forgiving of any mistakes ($$$).&lt;br /&gt;&lt;br /&gt;The boiler is 24kW Nike Mini from Italian company Immergas, not the latest model, but still quite new. It is a combi-boiler - it produces hot water for both heating and domestic uses. The boiler can be set to provide domestic water only, or both heating and domestic water. Domestic water flows through heat exchanger and then directly to taps.  Water for heating flows in a closed circuit and it's moved by electrical pump. The temperature of the heating water is measured by a sensor, and when it's too low, the boiler ignites itself and works for some time (it's either fixed time or until the temperature raises to acceptable value - I don't know).&lt;br /&gt;&lt;br /&gt;The problem is that the boiler doesn't measure the temperature inside the apartment, so it doesn't switch off even if the temperature reaches preferred value. It also has no means of time-related programming, so it runs all the time, even when nobody's home. That's why the programmable thermostat is necessary. This device switches the boiler on only when the current temperature in the apartment (precisely in one of the rooms) is lower than value set in thermostat's memory.&lt;br /&gt;&lt;br /&gt;Of course Immergas sells all kinds of thermostats for its boilers. Small electronic companies and workshops also sell thermostats which can easily be adapted to control my boiler. But by making it I hope to learn some new skills and test some solutions which might be useful later.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4110028886767234394-449193315255126749?l=sixpinetrees.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sixpinetrees.blogspot.com/feeds/449193315255126749/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-programmable-thermostat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/449193315255126749'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4110028886767234394/posts/default/449193315255126749'/><link rel='alternate' type='text/html' href='http://sixpinetrees.blogspot.com/2010/01/project-1-programmable-thermostat.html' title='Project #1 - programmable thermostat'/><author><name>Maciek</name><uri>http://www.blogger.com/profile/00637081137275676603</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
