<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[<span>[AN]</span> anup narkhede]]></title>
  <link href="http://anup.info/atom.xml" rel="self"/>
  <link href="http://anup.info/"/>
  <updated>2012-10-13T19:53:00+01:00</updated>
  <id>http://anup.info/</id>
  <author>
    <name><![CDATA[Anup Narkhede]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Mimo USB Monitor and Raspberry Pi]]></title>
    <link href="http://anup.info/blog/2012/10/13/raspberry-pi-mimo-monitor/"/>
    <updated>2012-10-13T00:00:00+01:00</updated>
    <id>http://anup.info/blog/2012/10/13/raspberry-pi-mimo-monitor</id>
    <content type="html"><![CDATA[<p>Since past few weeks, I&#8217;ve been trying to put my Mimo UM-740 touchscreen monitor to a good use. Sounds old school, but yeah we are talking about pre-ipad age when I used it as a touch screen skypephone device.</p>

<p>Follow this tutorial to configure the monitor as a primary display for raspberry-pi. Although I have explained the steps against Nanovision Mimo UM740, they should work with any displaylink USB monitor.</p>

<p>My setup:</p>

<ul>
<li>7 port powered USB hub</li>
<li>RaspberryPi running raspbian wheezy</li>
<li>Mimo UM740 touchscreen monitor</li>
<li>Ubuntu 12.04 machine for kernel compilation</li>
</ul>


<h3>Step 1: Prepare SD card</h3>

<ol>
<li><a href="http://elinux.org/RPi_Easy_SD_Card_Setup">Setup SD card with raspbian wheezy</a></li>
<li>Boot using a standard hdml monitor</li>
<li>Using raspi-config, enable ssh server and disable the GUI mode on startup. This will enable us to work on it without a monitor.</li>
</ol>


<h3>Step 2: Compile Kernel with udlfb support</h3>

<p>First, we need to enable Displaylink framebuffer support in the kernel. I have followed <a href="http://mitchtech.net/raspberry-pi-kernel-compile/">these steps</a> to compile the kernel on Ubuntu 12.04.</p>

<p>2.1: Install dependencies</p>

<pre><code>apt-get install git-core gcc-4.6-arm-linux-gnueabi
</code></pre>

<p>2.2: Symlink the cross compiler</p>

<pre><code>sudo ln -s /usr/bin/arm-linux-gnueabi-gcc-4.6 /usr/bin/arm-linux-gnueabi-gcc
</code></pre>

<p>2.3: Checkout source code</p>

<pre><code>mkdir raspberrypi
cd raspberrypi 
git clone git://github.com/raspberrypi/linux.git
</code></pre>

<p>2.4: Configure</p>

<pre><code>cd linux
cp arch/arm/configs/bcmrpi_cutdown_defconfig .config
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig
#optional#make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig
</code></pre>

<p>Make sure that displaylink framebuffer support is enabled:</p>

<ol>
<li><p>Follow &#8216;Device Drivers&#8217; > &#8216;Graphics Support&#8217; > &#8216;Support for Framebuffer support&#8217;.</p></li>
<li><p>Enable &#8216;Displaylink USB Framebuffer support&#8217; by selecting &#8216;M&#8217;.</p></li>
</ol>


<p>2.5: Compile</p>

<pre><code>make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k -j3
</code></pre>

<p>References:</p>

<ul>
<li><a href="http://elinux.org/RPi_Kernel_Compilation">http://elinux.org/RPi_Kernel_Compilation</a></li>
<li><a href="http://mitchtech.net/raspberry-pi-kernel-compile/">http://mitchtech.net/raspberry-pi-kernel-compile/</a></li>
</ul>


<h3>Step 3: Replace kernel.img on SD card</h3>

<p>Once compilation is successful, package the kernel image:</p>

<pre><code>mkdir ../modules
make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/
cd ../tools/mkimage/
./imagetool-uncompressed.py ../../linux/arch/arm/boot/Image
</code></pre>

<p>This will create kernel.img in the current directory. Mount the SD card and replace existing kernel.img with the one which we just built.</p>

<p>Connect the monitor through a powered USB hub and reboot the pi. If everything has gone well, you should see a green screen.</p>

<h4>Troubleshooting</h4>

<p>Connect to ethernet &amp; check if monitor was detected correctly:</p>

<pre><code>$ dmesg | grep DisplayLink
usb 1-1.2.2.4: Manufacturer: DisplayLink
udlfb: DisplayLink nanovision MiMo - serial #USM700-8B280858
udlfb: DisplayLink USB device /dev/fb1 attached. 800x480 resolution. Using 1504K framebuffer memory
</code></pre>

<p>You should see two framebuffer devices, one for the hdmi adapter (fb0) and other for  the USB monitor (fb1).</p>

<pre><code>$ ls /dev | grep fb
fb0
fb1
</code></pre>

<h3>Step 4: Configure Xorg</h3>

<p>Using ssh, create /etc/X11/xorg.conf on the pi using following configuration:</p>

<pre><code>Section "Device" 
  Identifier "uga" 
  driver "fbdev" 
  Option "fbdev" "/dev/fb1" 
  Option "ShadowFB" "off"
EndSection 

Section "Monitor" 
  Identifier "monitor" 
EndSection 

Section "Screen" 
  Identifier "screen" 
  Device "uga" 
  Monitor "monitor" 
EndSection 

Section "ServerLayout" 
  Identifier "default" 
  Screen 0 "screen" 0 0 
EndSection
</code></pre>

<p>Start the GUI mode using &#8216;startx&#8217; and you are done!</p>

<p><img src="http://anup.info/images/mimo.jpg"></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Raspbmc and wifi]]></title>
    <link href="http://anup.info/blog/2012/07/29/raspbmc-wifi/"/>
    <updated>2012-07-29T00:07:00+01:00</updated>
    <id>http://anup.info/blog/2012/07/29/raspbmc-wifi</id>
    <content type="html"><![CDATA[<p>In this post, I share my experience with raspbmc and making it work with a wifi dongle. If you are looking to get rid of ethernet cable and keyboard, make the xbmc stand alone and control it using the web remote, this post is for you.</p>

<p>Bear in mind that not all wifi dongles have supported drivers for debian. As a safe bet, pick one from the <a href="http://elinux.org/RPi_VerifiedPeripherals#USB_WiFi_Adapters">list of verified wifi adpaters</a>. I used <a href="http://www.tenda.cn/tendacn/Product/show.aspx?productid=340">Tenda W311U wireless adapter</a> as it is well tested with debian and comes at a decent price.</p>

<p>To install the supported drivers, you&#8217;ll need to access the terminal on raspbmc. Follow these tips to switch between terminal and xbmc.</p>

<h4>To Access terminal from xbmc</h4>

<p>Click on Power icon, Exit. When the splash screen comes up, press escape. You will be shown a login prompt. Use login: pi, password: raspberry.</p>

<h4>To Launch xbmc from terminal</h4>

<pre><code>%sudo initctl start xbmc
</code></pre>

<h3>Install drivers</h3>

<p>Once you are logged on to the terminal, update sources for aptitude and install drivers by following steps below:</p>

<pre><code>%sudo nano /etc/apt/sources.list
</code></pre>

<p>add line:</p>

<pre><code>deb http://ftp.uk.debian.org/debian/ squeeze main non-free
</code></pre>

<p>Then install the driver:</p>

<pre><code>%sudo apt-get update
%sudo apt-get install firmware-ralink
</code></pre>

<p>Check device status:</p>

<pre><code>%nmcli dev
=&gt;
eth0   802-3-ethernet  connected
wlan   802-11-wireless unmanaged
</code></pre>

<p>Scan for wifi access points:</p>

<pre><code>%nmcli dev wifi list
</code></pre>

<p>You should see a list of available wireless access points.</p>

<h3>Configure the wireless network interface</h3>

<p>Once you have the device drivers installed, you need to configure the network interface.</p>

<pre><code>%sudo nano /etc/network/interfaces
</code></pre>

<p>Add following lines:</p>

<pre><code>auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa.conf
</code></pre>

<p>Create the wpa.conf</p>

<pre><code>%sudo nano /etc/wpa.conf
</code></pre>

<p>Add following lines:</p>

<pre><code>network={
ssid="NETWORK_SSID"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="NETWORK_PASSWORD"
}
</code></pre>

<p>Note: Replace NETWORK_SSID and NETWORK_PASSWORD with the wifi credentials.</p>

<p>Disconnect ethernet and run:</p>

<pre><code>sudo ifdown wlan0
sudo ifup wlan0
</code></pre>

<p>You should be connected. Now test the connection status (ex: ping google.com).</p>

<h3>Enable wifi connection after reboot</h3>

<p>If you want to set the wifi as default connection after power on, follow these steps.</p>

<pre><code>%sudo nano /etc/init.d/wifi.sh
</code></pre>

<p>add content:</p>

<pre><code>#!/bin/bash
sudo ifdown wlan0
sudo ifup wlan0
</code></pre>

<p>Make it executable and register:</p>

<pre><code>%sudo chmod +x /etc/init.d/wifi.sh
%sudo update-rc.d wifi.sh defaults 100
</code></pre>

<p>Every time the raspbmc boots up, it will automatically connect to the configured wireless access point.</p>

<iframe width="640" height="510" src="http://www.youtube.com/embed/oJIhAPdQOzM " frameborder="0" allowfullscreen></iframe>


<h3>Bye bye keyboard</h3>

<p>Xbmc comes with <a href="http://wiki.xbmc.org/index.php?title=Web_interface">a web interface</a>, this allows us to control it without a keyboard. Just hit http://<ip of raspbmc>:8080/ from your ipad or laptop and start controlling. You can even use the official xbmc remotes for <a href="http://itunes.apple.com/gb/app/xbmc-remote/id289316916">apple</a> and <a href="https://play.google.com/store/apps/details?id=org.xbmc.android.remote">android</a> which are much better.</p>

<p>Nice, now you can have a standalone media center connected using wifi.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Raspberry Pi: Getting started]]></title>
    <link href="http://anup.info/blog/2012/07/28/raspberry-pi-getting-started/"/>
    <updated>2012-07-28T10:00:00+01:00</updated>
    <id>http://anup.info/blog/2012/07/28/raspberry-pi-getting-started</id>
    <content type="html"><![CDATA[<p>After a wait of over 4 weeks, I finally received my <a href="http://raspberrypi.org">raspberry pi</a> from RS components. This tiny motherboard comes with a great number of features for a modest price of 30£ and is already being considered as a hacker&#8217;s paradise. Getting started with Raspbian &#8216;Wheezy&#8217; was simple, thanks to the <a href="http://www.raspberrypi.org/quick-start-guide">quick start guide</a>. However, I came across <a href="http://www.raspbmc.com">raspbmc</a>, which is a minimal distribution of debian linux with xbmc pre-configured and optimized for your raspberry pi. This blog post is about my experience to get raspbmc up and running.</p>

<p>My setup:</p>

<ul>
<li>Scandisk SD card</li>
<li>My HTC desire charger to power the board (you can even use an iPad charger)</li>
<li>HDMI to DVI-D adapter, to connect my BenQ monitor</li>
<li>Speakers</li>
<li>Ethernet cable</li>
<li>USB keyboard</li>
</ul>


<p><img src="http://anup.info/images/pi.jpg"></p>

<p>Unlike Wheezy, raspbmc doesn&#8217;t come with a complete bootable OS distrubution. Instead, it provides an installer images which requires a working internet connection to download and configure the OS.</p>

<p>Configuring SD card with the installer is simple. Insert the SD card and run:</p>

<pre><code>wget http://svn.stmlabs.com/svn/raspbmc/testing/installers/python/install.py
sudo chmod +x install.py
sudo python install.py
</code></pre>

<p>Proceed with the on screen instructions and select the SD card (for me it was disk1s1). Once it finishes, you&#8217;ll see a message &#8216;Raspbmc is now ready to finish setup on your Pi, please insert the SD card with an active internet connection.&#8217;.</p>

<p>Plug the SD card in the pi and power it up. It starts with downloading and installation of kernel modules &amp; libraries, and it reboots. For some reason, the pi wouldn&#8217;t come up after the reboot. As suggested by the good eggs from internet, I replaced the bootcode.bin on the SD card with <a href="https://github.com/raspberrypi/firmware/blob/234c19de7cbaaf4997671d61df20a05759066295/boot/bootcode.bin">this version</a> and then it booted properly.</p>

<p>Next, I was stuck at the following message:</p>

<pre><code>Raspbmc Updater
Downloading a new XBMC build.. (stuck at 21%)
</code></pre>

<p><a href="http://www.youtube.com/watch?v=nn2FB1P_Mn8">Turning the power off and on</a> fixed it (Worked in the 3rd attempt).</p>

<p><img src="http://anup.info/images/raspbmc.jpg"></p>

<p>And here&#8217;s my raspberry pi running xbmc!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Wood Craft]]></title>
    <link href="http://anup.info/blog/2012/05/17/wood-craft/"/>
    <updated>2012-05-17T23:07:00+01:00</updated>
    <id>http://anup.info/blog/2012/05/17/wood-craft</id>
    <content type="html"><![CDATA[<p>When you need a tank, you need a tank!</p>

<p><img src="http://anup.info/images/tank.jpg"></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ultrasonic range finder]]></title>
    <link href="http://anup.info/blog/2012/05/17/ultrasonic-range-finder/"/>
    <updated>2012-05-17T23:07:00+01:00</updated>
    <id>http://anup.info/blog/2012/05/17/ultrasonic-range-finder</id>
    <content type="html"><![CDATA[<p>SRF05 is an ultrasonic ranger module for arduino. Using the previously posted GLCD setup, I have built a simple range finder.</p>

<h3>Interface</h3>

<p>Trigger and echo pins of sensor module are connected to I/O pins 12 and 13 respectively.</p>

<h3>Demo</h3>

<iframe width="640" height="510" src="http://www.youtube.com/embed/iIpgDTsnCwU " frameborder="0" allowfullscreen></iframe>


<h3>Code</h3>

<pre><code>#include &lt;glcd.h&gt;
#include &lt;fonts/allFonts.h&gt;

int trigger = 12;
int echo    = 13;

void setup()
{
 GLCD.Init();
 GLCD.SelectFont(System5x7);
 pinMode(trigger, OUTPUT);
 pinMode(echo, INPUT); 
}

void loop(){
  int distance  = calculateDistance();
  displayOutput(distance);
  delay(100);
}

int calculateDistance(){
  digitalWrite(trigger, LOW);
  delayMicroseconds(2);
  digitalWrite(trigger, HIGH);
  delayMicroseconds(5);
  digitalWrite(trigger, LOW);
  return (pulseIn(echo, HIGH)/58);
}

void displayOutput(int distance){
  GLCD.ClearScreen();
  GLCD.print("Distance: ");
  GLCD.print(distance);
  GLCD.print("cm");
}
</code></pre>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[em-serialport]]></title>
    <link href="http://anup.info/blog/2012/02/28/em-serialport/"/>
    <updated>2012-02-28T21:25:00+00:00</updated>
    <id>http://anup.info/blog/2012/02/28/em-serialport</id>
    <content type="html"><![CDATA[<p>I was looking for a way to send interrupts from Arduino to my macbook, without performing polling on a port. Here is a simple attempt to make it work. <a href="http://github.com/railsbob/em-serialport">em-serialport</a> is <a href="http://github.com/eventmachine/eventmachine">eventmachine</a> compatible asynchronous library based on <a href="http://ruby-serialport.rubyforge.org/">ruby-serialport</a>.</p>

<p>The operation is simple. Whenever data is is available over serial port, on_data callback gets invoked. Similarly send_data writes the data on serial port.</p>

<h2>Installation</h2>

<pre><code>gem install em-serialport
</code></pre>

<h2>Usage</h2>

<p>If you are on Mac, you need to set up a virtual USB serial port by installing a driver from <a href="http://www.ftdichip.com/Drivers/VCP.htm">http://www.ftdichip.com/Drivers/VCP.htm</a>. Identify your serial port device. For ex: /dev/tty.usbserial-xxxxxxxx</p>

<pre><code>EM.run do
  serial = EventMachine.open_serial('/dev/tty.usbserial-xxxxxxxx', 9600, 8, 1, 0)
  serial.send_data "foo"

  serial.on_data do |data|
    # you got data. Eat it.
  end
end
</code></pre>

<h2>Serial Monitor</h2>

<p>The gem comes with a simple command line Serial Monitor. Launch it as:</p>

<pre><code>bundle exec serial-monitor /dev/tty.usbserial-xxxxxxxx
</code></pre>

<p>Here is a working example, tested with an <a href="arduino%20echo%20server">https://github.com/railsbob/arduino-examples/tree/master/echo_server</a>. It simply reads and writes data to serial port from command line.</p>

<pre><code>Serial monitor initialized. Enter data followed by a newline character.
Ctrl-C to stop
hello
received: hello
A very long sentence
received: A v
received: ery long
received:  sentence
</code></pre>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Interface LCD TM12864L with Arduino]]></title>
    <link href="http://anup.info/blog/2012/02/04/arduino-mega-128x64-lcd/"/>
    <updated>2012-02-04T19:36:00+00:00</updated>
    <id>http://anup.info/blog/2012/02/04/arduino-mega-128x64-lcd</id>
    <content type="html"><![CDATA[<p>I bought TM12864L LCD display off ebay, however it came without any datasheet or documentation. After looking for help in forums, I was finally able to make it work. Here is a guide to interface TM12864L LCD display with Arduino Mega (1280).</p>

<h3>Connections</h3>

<p><img src="http://anup.info/images/128x64-wiring.jpg"></p>

<h3>GLCD Library</h3>

<p>Once the module is wired in, you need to set up <a href="http://www.arduino.cc/playground/uploads/Code/GLCD_V3_beta.zip">GLCD library</a> in <a href="http://arduino.cc/hu/Main/Software">Arduino SDK</a>. Follow these steps for OSX:</p>

<ul>
<li>Assuming that your SDK is configured at ~/Documents/Arduino, create a folder &#8216;libraries&#8217; inside Arduino folder.</li>
<li>Unzip <a href="http://www.arduino.cc/playground/uploads/Code/GLCD_V3_beta.zip">GLCD library</a> &amp; move it to ~/Documents/Arduino/libraries/glcd</li>
<li>Start Arduino SDK and you should see &#8216;glcd&#8217; under Sketch > Import Library > Contributed menu.</li>
</ul>


<h3>Running Examples</h3>

<p>GLCD library comes with extensive code samples. If you have configured the library correctly, you should be able to see and compile demo examples from: File > Examples > glcd menu.</p>

<h3>Resources</h3>

<ul>
<li><a href="http://anup.info/datasheets/tm12864l.pdf">TM12864L Datasheet</a></li>
<li><a href="http://www.arduino.cc/playground/uploads/Code/GLCD_Documentation.pdf">GLCD Documentation</a></li>
</ul>

]]></content>
  </entry>
  
</feed>
