Pages

Monday 29 September 2014

Use Raspberry Pi as a Game Server

            The Raspberry pi is a mini computer which is designed in a single board with all the essential components required for running an operating system. The Raspberry pi is a device which uses the Broadcom controller chip which is a SoC (System on Chip). This SoC has the powerful ARM11 processor which runs on 700 MHz at its core. This minicomputer comes without a display unit, but it can be used with HDTV display or normal NTSC or PAL standard TV screen. It has an Ethernet port which allows it to be connected to a network. Operating systems from Mac, Windows and Linux can be loaded in the Raspberry pi. The capability of this inexpensive board to load operating systems from Linux and accessibility of the board through a LAN network makes it a perfect choice for tiny dedicated web servers.
This article focus on how to configure the Raspberry pi board as a web server and the technique to make it serve a graphical game for those who type the IP or address of the Raspberry pi board from the address tab of their web browser. The Raspberry pi web server is available in the same LAN network or it can be made available to anyone who has the internet connectivity using the technique of port forwarding. 

In this particular project Ubuntu is installed on Raspberry pi board and is loaded on the Raspberry pi board and is connected to a router using a cross-over LAN cable. Hence the only additional hardware required with the Raspberry pi for this project is a LAN cable only.
Once connected to the router with Ubuntu OS on it, it can be accessed remotely from other systems connected in same LAN network. The board can be accessed from a Linux PC using the secure shell which is enabled in the Ubuntu of Raspberry pi board.  If the IP of the Raspberry pi board in the network is say, 192.168.1.5 then the following command can be used to login as the user named ‘pi’ in the Raspberry pi;
ssh pi@192.168.0.5
The password for the username ‘pi’ will be prompted and it is ‘raspberry’ by default. The same can be done from the windows system with the help of software like ‘PuTTY’ which can be downloaded for free. One might find difficulty in finding the IP address of the Raspberry pi board in the LAN and it can be easily done with the help of software like ‘Ip Scanner’.
Check the IP range of the router before further editing and it can be simply found by checking the IP of the system which is use to access the Raspberry pi board. For a Linux PC the IP address can be found by using the command;
ifconfig
and for a windows system the IP address can be found using the command:
ipconfig
Now add the following lines below that commented statement;
Make sure that the will set for the Raspberry pi board is not already in use for any other PCs and it can be done by using the ‘ping’ command from both Linux and Windows PC.
If there is no PC having the IP address 192.168.1.68 then the following ‘ping’ command should fail.
ping 192.168.1.68

Once logged into the Raspberry pi, the first think to do is to set a static IP address and it can be done by editing a single file in the Ubuntu. The file named ‘interfaces’ need to be edited and saved which is in the directory /etc/network. Open the file using the VIM editor and disable off the following statement;
iface eth0 inet static
The statement can be disabled by commenting it off like as shown below;
# iface eth0 inet static
If the IP of the PC found to be like 192.168.1.5, then write the following statements only
                                                                                           address 192.168.1.68
netmask 255.255.255.0
gateway 192.168.1.1
Save the file and it is suggested to restart the Raspberry pi board which will set the new IP address as 192.168.1.68.
If the IP of the PC found to be like 192.168.0.5, then write the following statements only
                               address 192.168.0.68
netmask 255.255.255.0
gateway 192.168.0.1


Save the file and it is suggested to restart the Raspberry pi board which will set the new IP address as 192.168.0.68.
Use the following command to reboot the Raspberry pi board;
reboot

Once the Raspberry pi reboots try to login using the new IP address.
The next step is to download and install the Apache server for the Ubuntu. It can be done using the following commands;
sudo apt-get update
sudo apt-get install apache2
Now simply copy the game folder in the directory “/var/www”. Change the permission of files in the game folder named say ‘game’, using the following command so that it can be accessed by others in the network.
chmod 777 game/*
Now open a browser in the PC and type the address of the Raspberry pi board in the address tab and start playing the game.
The Raspberry pi is connected to the port number 80 of the router and it can be forwarded to the internet by logging into the router and do the settings under ‘PORT FORWARDING’, the steps will vary from one router model to another.
Enable the forwarding of the port 80 using the following details;

Port to be forwarded : 80
Starting port number : 80
End port number : 81
Protocol : ALL or TCP/UDP

Find the public IP of the router also and if the public IP is say 123.238.112.227; then one can use the same IP to play the game from the Raspberry pi game server from anywhere around the world using a web enabled device.

Video:





Sunday 28 September 2014

ZigBee/XBee Technology

             The explosion in wireless technology has seen the emergence of many standards, especially in the industrial, scientific and medical (ISM) radio band. There have been a multitude of proprietary protocols for control applications, which bottlenecked interfacing. Need for a widely accepted standard for communication between sensors in low data rate wireless networks was felt. As an answer to this dilemma, many companies forged an alliance to create a standard which would be accepted worldwide. It was this Zigbee Alliance that created Zigbee
Bluetooth and Wi-Fi should not be confused with Zibgee. Both Bluetooth and Wi-Fi have been developed for communication of large amount of data with complex structure like the media files, software etc.  Zigbee on the other hand has been developed looking into the needs of communication of data with simple structure like the data from the sensors.


What is Zigbee and who all are involved?

Zigbee is a low power spin off of WiFi. It is a specification for small, low power radios based on IEEE 802.15.4 – 2003 Wireless Personal Area Networks standard. The specification was accepted and ratified by the Zigbee alliance in December 2004. Zigbee Alliance is a group of more than 300 companies including industry majors like Philips, Mitsubishi Electric, Epson, Atmel, Texas Instruments etc. which are committed towards developing and promoting this standard. The alliance is responsible for publishing and maintaining the ZIgbee specification and has updated it time and again after making it public for the first time in 2005. Most of the recent devices conform to the Zigbee 2007 specifications has two feature sets– Zigbee and Zigbee Pro. The manufacturers which are members of the Alliance provide software, hardware and reference designs to anyone who wants to build applications using Zigbee.
Many years ago, when Bluetooth technology was introduced, it was thought that Bluetooth would make WiFi redundant. But the two coexist quite well today, so do many other Wireless standards like WirelessHART and ISA100.11a. Then why would we need another WPAN standard like Zigbee? The answer is, the application focus of Zigbee Alliance - low cost and low power for energy efficient and cost effective intelligent devices. Moreover, Zigbee and Bluetooth have different application focus. Despite of all their similarities, and despite the fact that both are based on the IEEE 802.15 standards, the two are different in technology as well as scope. Bluetooth is made with mobile phones as its centre of universe enabling media transfer at rates in excess of 1 Mbps while Zigbee is built with emphasis on low data rate control system sensors featuring slower data of just 250 kbps.

Zigbee Networks:

Zigbee devices can form networks with Mesh, Star and Generic Mesh topologies among themselves. The network can be expanded as a cluster of smaller networks. A ZigBee network can have three types of nodes: Zigbee Coordinator (ZBC), Zigbee router (ZBR) and Zigbee End Device (ZBE) each having some unique property.
Let us understand Zigbee through a typical usage scenario in a home automation system. There can be only one ZBC in a network, the one that initiates the network in the first place and stores the information about the network. This would be the main control panel or remote control in the living room of each storey.  All the devices in the network communicate with this ZBC. It has routing capabilities and acts as a bridge to other networks on other floors. A ZBR is an optional component used to extend the coverage, say, providing access to the Zigbee receivers controlling the garage lighting and shutter which is in the nearby shed. The router itself may host an application like a CC Camera which is continuously in active monitoring state. It can also handle local address allocation or de-allocation . A ZBE is optimized for low power consumption and is the cheapest among the three node types. It communicates only with the coordinator and is the point where sensors are deployed. Any end device like lighting units, air conditioning elements etc. can be Zigbee End Devices. Unicast Device Discovery is done if Network ID is available; else Broadcast Device Discovery is done. A ZBR or ZBC’s response to Device Discovery query is a payload containing IEEE address, the Network Address and all known network addresses. Device bindings which are logical links between end devices can be created like binding of a Lamp Application Object with a Switch Application Object. The Radio unit and the Processing unit are often built into a single chip to reduce costs. When a car enters the premises, the radio transmitter inside the car broadcasts its presence to the Zigbee Coordinator through routers. The coordinator then binds the garage shutter’s receiver with the Car’s transmitter and all packets from the Car transmitter are routed to the Shutter, which can then open and close without stepping out of the car. The whole transaction can be automated such that by the time the car reaches the garage door, it automatically opens.
In a network, data traffic can be periodic, intermittent or repetitive. When data is periodic, the application determines the rate of transfer. Intermittent data needs optimum power savings and hence the data rate is stimulus dependent. For repetitive type of data, guaranteed time slots are used, for example the air conditioning unit.

Architectural Overview:

Zigbee bases itself on the IEEE 802.15.4-2003 specifications which lay down standards for the Physical and MAC layers. The protocol stack is completed by adding Zigbee’s own Network and Application Layers. Drawing analogies from the OSI protocol stack simplifies the study of Zigbee protocol. In the figure below, the two protocols are stacked up side by side to see the similarity of roles of various layers.
A brief overview of each layer is now presented below:
Physical Layer
Zigbee uses three frequency bands for transmission- 868 MHz band with a single channel has a raw data rate of 20 kb/s. The 915MHz band with 10 channels has each channel’s central frequency separated from the adjacent band by 2 MHz and data rate of 40 kb/s. BPSK modulated symbols are transmitted at 1 bit per symbol using Direct Sequence Spread Spectrum (DSSS) technique with 15 bit chips. The 2.4 GHz ISM band with 16 channels, 5 MHz wide offers 250 kb/s data rate. It employs O-QPSK modulation with 4 bits/symbol transmitted using DSSS with 32 Bit chips. To reduce the transmitted power, the Zigbee transmitters use Energy Detection (ED) and Link Quality Indication (LQI). It is the responsibility of the physical layer to perform channel assessment.
MAC Layer
Channel access is primarily through Carrier Sense Multiple Access- Collision Avoidance (CSMA-CA). On a node hop to hop basis, the MAC layer can take care of transmitting data. Depending on the mode of transmission, i.e. Beacon or Non-Beacon mode, the MAC layer decides whether to use slotted or unslotted CSMA-CA. The MAC layer takes care of scanning the channel, starting PANs, detecting and resolving PAN ID conflicts, sending beacons, performing device discovery, association and disassociation, synchronizing network device and realigning orphaned devices on the network. Along with this, the MAC layer also provides some standard security features like access control, encryption of data, duplicate rejection and frame integrity. Like in the case of the standard OSI MAC Layer, MAC layer in Zigbee also cannot take care of the situation when the nodes have intermediate nodes between them. This functionality of routing the packets to their destinations is provided in the network layer.
Network and Security Layer
The network layer takes care of network startup, device configuration, topology specific routing, and providing security. On each node, the network layer is the part of the stack that does the route calculations, neighbor discovery and reception control. All the nodes are optimized using unique 64 bit addresses as per the IEEE 802.15.4 standard, supporting a maximum of 65536, 16 bit network address devices which can have 256 sub addresses. The network routing table is populated when the devices come alive in the network for the first time by generating Broadcast Routing Request Packets (RREQ). Endpoint routers respond to these packets as Routing Response Packets (RREP).
Application Support Sub-Layer
It interfaces the network layer and application layer providing a general set of services through two entities, the APS Data Entity (APSDE) and APS Management Entity (APSME) accessed through their respective Service Access Points (SAP). These provide services like binding management, making application level PDU, group filtering, and managing Object database called APS Information Base, providing reliability of transaction etc. which are the necessary functions for an application to work properly.

Application Framework
It is the environment to host application objects on a Zigbee device.Up to 240 distinct application objects can be defined uniquely. It consists of the application profiles as the top layer over ZDO which provides the base functionality.
·         Application Profiles define an accepted language for exchanging data and provide interoperable services across different manufacturers. Zigbee Alliance has released several Standard Profiles which contain different device descriptors which have unique identifiers.
·         ZigBee Device Objects (ZDO) provides an interface between the application objects, the device profiles, and the APS layer in Zigbee devices. It is located between the Application Profiles and the application support sub-layer. The ZDO are responsible for initializing the APS, the network layer, and the Security Service Provider, and also forming the configuration information from applications to implement discovery, security, network and binding management.


Data Transfer Modes
This data can be transferred in two modes: Beacon Mode and Non-beacon mode. In beacon mode, the data is sent periodically over the network. In between the time period when the devices are not sending data, they may enter a low power sleep state to minimize power consumption. However, such close timing and network synchronization has precise timing needs as the beacon period is of the order of milliseconds. This can pose design constraints while reducing costs and eventually is a tradeoff between the design constraints and costs involved. In a non-beacon mode, the coordinators and the routers active in the network have to stay awake for most of the time to listen incoming data and hence need robust power supplies. Hence, the end devices can sleep most of the time and wake up solely for sending data, or on receiving a trigger, while the core devices need to be active, creating an asymmetric power distribution in the network. This creates a heterogeneous network.
Having gone through the protocol stack of the Zigbee protocol, let us have a look at its pros and cons. Zigbee has proven to be a good extension of existing standards, which is now backed by many companies worldwide. This is a big leap towards achieving a widely accepted industry standard. On the flipside, ZIgbee networks have a single point of failure especially in the star networks.   
Zigbee devices find use in a multitude of areas like Industrial, commercial, toys, Computer Peripherals, Personal Health Care, Building Automation etc., virtually everything imaginable in the role of Wireless Sensor Nodes or short range communications. . The first thrust of the Alliance seemed to be Smart Energy and Home Automation. There are 5 application profiles that have been released so far involving Home Automation and Smart Energy, and others involving Building Automation and Retail Services are in the pipeline. This has met with phenomenal success and now, Zigbee has started to form strong foothold in Advanced Metering Infrastructures (AMI). Zigbee and RF4CE have made combined efforts to develop the Zigbee RF4CE specifications for consumer devices that could replace multiple remote controls with a single one.
And why is Zigbee considered a possible competitor to Bluetooth technology? The answer would be evident from a comparison between the two. This however should not be the basis of deciding which technology is the best, but to decide, what technology is best suited for the specific task. Eventually, it might coexist with Bluetooth just as Bluetooth has come to live with WiFi.





Sunday 3 August 2014

Google Glass : The Third Eye

We had all imagined what the future would be like in our childhood, picturing pretty intense technology like flying cars, houses floating in the air, holographic telephones, etc. But we look at the world now and see those ideas actually come to life. One of such devices is Google’s latest project, “Google Glass”. What is Google Glass? What does it promise to do? What are its salient features? We will find out all this and more as we go further.
In simple terms, Google Glass is a computer which you can wear on your head the same way as in you would wear a set of spectacles, which comes with an Optical Head Mounted Display (OHMD) working on a class of technology called “Augmented Reality”. Therefore, the display of this device is visible in front (upper right corner) of your vision via a prism projector lens. It possesses most of the features of a modern smartphone. It is controlled by voice command, and can take pictures and record videos of what you see.It has been developed by Google X (still in beta test phase), a special sector in Google responsible for the development of futuristic technologies. Google X is also responsible for the development of the driverless car.
Check how it feels through Google Glass.

Technical Specifications :


Google Glass runs on Android (version 4.0.4 ‘IceCream Sandwich’ or higher), which is an open source operating system (proprietorship of google inc.) used in many of today’s smartphones. The android operating system allows developers to create program applications which utilize the various hardware and software capabilities onboard the glass. It provides space for customizations to be applied on the device.
 It has a 5 megapixel camera which can record videos in 720p HD resolution with a simple voice command or a tap on the touchpad on the side. The camera is very much similar to the ones used in smartphone devices.
 A display of resolution 640x360 powered by a prism projector is used. According to google, this resolution with respect to size is the equivalent to watching a 25 inch High definition screen from two and a half meters away. The display unit is also located on a flex PCB (Printed Circuit Board) holding sensors such asInvenSense MPU-9150 (which is a glass inertial sensor), Wolfson WM7231 MEMS microphone, there is an additional microphone on the main board which will probably back up as a noise cancelling device. 
 A lithium polymer rechargeable battery with a 560mAh capacity provides a day’s usage with typical usage. The battery unit is provided in the back section of the case to structurally balance out the forward load of the optics module and the CPU board. The battery is NOT user replaceable.
The main CPU board located in the heart of the controls case. On the PCB (Printed Circuit Board) there are the core processors, 16GB SanDisk flash drive module, Wi-Fi and Bluetooth module, Elpida mobile DRAM chipset along with a few RF devices. There is an onboard 16GB of internal storage out of which 12GB is available to the user. Glass also syncs with your google drive account online to stash photos and videos.It runs a RAM of 1GB out of which 628MB is available for application use.
There is a Bluetooth and Wi-Fi unitbuilt on to the main CPU circuit. There is no GPS on board but can be paired with an android smartphone to enable google maps.
The google glass also has a touchpad on the side of the optic bearing arm, providing touch input. It can be swiped back and forth to switch between the various screens of the interface in a timeline like layout. The touchpad is developed by Synaptics driven by a Synaptics T1320A touchpad controller, which is an interface between the software and hardware.
Sound is transferred through a relatively new technology called “Bone conduction Transfer” which vibrates your skull which signals the eardrum, therefore making it almost inaudible to the people surrounding the user. The bone conduction speaker also doubles as a tactile switch.
Glass is also controlled by voice commands, through microphone. The device is activated by the user tilting their head 30­upwards (can be changed). Additionally it can also be activated by tapping the touchpad and saying “OK, Glass”. The camera is controlled by saying “Take a picture” or “Record a video”. Many other functions such as google searches, mail, directions and android applications can be controlled through voice.
The following are the expected technical specifications of google glass
Operating System: Android (4.0.4 and higher).
CPU:                      1.2GHz Dual Core Processor by Texas Instruments
Internal Storage:  16 Giga Bytes Sandisk flashdrive.
Memory:                1 Giga Byte RAM.
Power:                   Lithium Polymer Battery (560mAh).
Sound:                   Bone Conduction Transducer.
Display:                  Prism Projected Display with 640x360 pixel resolution.
Camera:                 5 Megapixel with 720p recording capability.
Sensors:                Proximity, Ambient light, Magnetometer, Microphone, Gyroscope, Accelerometer,                                       Touchpad.
Connectivity:         Bluetooth, Wi-Fi 802.11b/g, Micro USB.
Weight:                  50grams.
At present, Google Glass has only released a beta device available to a select number of individuals (developers and explorers) with a price tag of 1500$ (Roughly INR 90,000). The consumer version is also expected to be available at a much lower price (at about the cost of an IPhone) owning to subsidy from their success of the Nexus 7.

Design
The google glass is designed to be lightweight and completely unobtrusive (thanks to the titanium frame). It has an extremely robust body with a frame that comes with additional pads for comfort. It has a touchpad along one of the arm for interaction. The current explorer version does not provide for the attachment of prescription lenses if you already wear glasses, but the consumer version promises a provision for the integration of prescription lenses in the frame of Glass. Currently google glass is expected to come out in five colors; Charcoal (black), Tangerine (orange), Shale (grey), Sky (blue) and Cotton (white).
Where and how can it Be Used?
Google glass is a device which can find use in a lot of fields. To find the uses of Google Glass would itself be an operational research project. Thanks to the open source nature of android (basically programming through Java), it allows third party developers to make their own applications which broadens the scope of innovation.
For personal use, it can be used as a great tool for travel, business, social networking and amateur photography. Of course, all of this can be done on a smart phone, so why Google Glass? One answer would be that, you need not concentrate only on the device while operating it. It is completely hands free, allowing the user to enjoy the privilege of operating it on the go. You see a memorable moment which you wish to capture, but the moment has already passed by the time you remove your camera or smartphone, but if you have the Google Glass the moment is captured with a simple three words. You can capture memories as you see them, much like saving your memories on a hard disk. This is only a small part of the wide area of applications, like flight reminders, Evernote, Google Search on-the-go, assisted navigation, language translation, and many more.
In the industry Google Glass can be used to increase productivity. A workers performance can be recorded and reviewed to study areas of improvement or to maintain a database. Technicians can be provided guided instructions or to identify faults in a system. A small solar installing company in USA, “Sullivan Solar Power” has recognized the game changing power of google glass. They have organized brainstorming events to identify the range of application of glass to increase productivity. Programmers with no mobile app development experience were able to produce a workflow and an app in a couple of months testing it on a unit which was bought off EBay (global e-commerce website).

Healthcare applications of this device increase the efficiency of surgeries greatly. This was first studied by Lucein Engelen, a European healthcare professional who was invited into the explorer program by Google. He conducted research on glass in operating theatres, ambulances,trauma helicopters, home care, and as an aid to teach students via video interactions (telephonic-consultation) on google hangouts. Recently in India in January 2014, a US based orthopedic surgeon, Dr. Selen G. Parekh conducted a foot and anklesurgery wearing the google glass. This operation was telecasted live on google during a national Indo-US conference. It was claimed that it was helpful to look the patient’s X-Ray or MRI (Magnetic Resonance Image) without taking the eye off the patient. The video recorded can provide an efficient aid in teaching students and practitioners alike.

Where is it Headed?
This is a technology which is beyond its time. It has sparked a revolution in the public, raising certain privacy and legal concerns. People do not like the idea of having a private conservation with the knowledge that there is an additional eye in the picture. Google glass is already banned in certain places containing sensitive business information. For the users, security is a major concern if the device is stolen, which may lead to piracy of private information. Google is working on security measures to deactivate a stolen device via an online interface. All in all, it will take a few years for this new market to settle in.
Google X which is barely out of the box with Google glass is already working on Google Glass 2 and another device which is rumored to the same capability on a contact lens via nanotechnology. Google faces tough competition from its rivals, apple and Microsoft who are working on similar products. Samsung are also rumored to be working on a more trendy and affordable version of the glass. In the end, leaders, Google Inc., have big plans for google glass as a mass consumer product on the turn of the decade.  
The Consumer version of Glass will soon be available in google stores later this year (around May, 2014) at a lower price and with possible lens fixture provisions.
--
Are you Interest to get Raspberry Pi, Arduino & Other Microcontroller based projects . plz visit to Novudux.