Sunday, October 30, 2011

DIY outdoor all-weather 3G/Wi-Fi router

My father lives in the village where no broadband connection is available. To access Internet he used creepy and hell expensive GPRS connection. Once tired by absence of normal connection and impossibility to show him some video on youtube I decided to make something to resolve this nonsense. At that time I was aware few neighbors of him are using 3G USB modems with Yagi antenna attached. After small research USB modem was bought to do the same. Unfortunately first attempts to connect to the network using solely internal antenna was complete failure. But when I was outside house and connected 1/4-wavelength long piece of copper wire into modem’s antenna socket, I was able to connect to the network.

Due to impossibility to make connection from the house, first more or less working solution included wireless router with USB port (at the time one of the cheapest TP-Link TL-MR3220) that was located in attic and this fascinating wire antenna:

It's how broadband looks far away from the city

Surely I was able to connect modem directly to PC using only external antenna and USB extension cable, but I have reasons to go wireless. To name a few:

  • I and my nephew have wi-fi enabled devices (phones, laptops, ipods, etc.) we would like to use them anywhere in the premises. So this hotspot will serve not only standalone desktop PC, but any wireless device in range.
  • I didn't wanted use PC as a router as it often turned off because is a little loudly and located in the living room.
  • While drilling in the attic was OK, inside cabling will be a pain. Wireless access from desktop is a real saving and relief.

Few weeks after installation I visited father again and found that:

Monday, February 7, 2011

Debugging firmware without debugger

My thermocouple sensor stuck for a while on firmware development stage until my Logic Sniffer is arrived.

This is because I faced a problem with I2C communication:

  1. When I communicating my firmware based on Atmel’s AVR302 application note source code, it works as expected;
  2. When I poll LM75A I2C thermometer it also working fine, but after I read value from it strange side effect appears: my firmware stops responding with address acknowledge when I trying to address it;
  3. After few (rather random) polls to LM75A my firmware are able to process commands until thermometer part is polled again.

There are many wait loops in firmware source code originated from app note like following:

whi_dac:
sbis PINB,PINB2 ; wait for SCL high rjmp whi_dac wlo_dac:
sbic PINB,PINB2 ; wait for SCL low rjmp wlo_dac

It seems to me that because of incorrect handling of a bus states firmware hangs on one of these loops.

I ordered logic analyzer to examine bus traffic but because it seems that the package delayed somewhere due to Chinese New Year I want to try today one approach that come to my mind during last week how to debug firmware inside ATTiny13 without hawing hardware debugger. Idea is pretty simple:

  • ATTiny13 has 8 pins;
  • 3 is pre-occupied (RESET, VCC, GND);
  • On 2 pins (PB2(T0) as SCL and PB1(INT0) as SDA) sits I2C bus;
  • Thus 3 pins (PB0, PB3, PB4) are free and could be used for debug purposes.

Idea is to use LEDs connected to free 3 pins as indicators of key points in source code. 23 gives us 8 possible combinations. All that I need is to set PB0, PB3, PB4 to HIGH/LOW state according to key point number in binary format.