Monday, April 5, 2010

How to make your own IR Receiver.. Remote Control Your PC

This post will describe how I made my own remote control receiver.. like in a costly desktop PC. Believe me its extremely easy and dirt cheap to make less than Rs 50

This post is divided into 2 parts
Hardware and Software

Lets get going..

Hardware
Bill of Material

IC 78L05 5V Volatage Regulator
1N4148 Zener Diode
4.7K resistor
4.7uF capacitor ceramic
IR receiver TSOP
DB9 Serial Port Connector
Any remote control... even your music system remote/tv remote will work
Circuit Diagram

Solder the circuit as per the diagram

End products looks like this (trainees are advised not to learn the bad soldering/electrical hygiene techniques I have demonstrated)






Software Part :Linux

Now getting to the second part of the deal.. getting the stuff working in linux

My test platform :
Ubuntu Jaunty Jacklope +9.04, 2.6.28-16-generic running on
AMD 64 X2 Dual Core Processor 4600+,2GB RAM, 2x120 GB,Flatron W2242T

Software required:
Ensure that you are connected to net , Fire up your terminal and punch the following commands
sudo aptitude search lirc

type follwing to install lirc with its dependant packages
sudo aptitude install lirc lirc-x

..to be continued

Decode AIS String using PHP

This is for all who may want to decode an AIS String but never knew how to do.

For all who don't know what is AIS.. try this link
http://www.imo.org/Safety/mainframe.asp?topic_id=754
http://en.wikipedia.org/wiki/Automatic_ ... ion_System



this code is tested for type 1 messages and further development has been stalled. I had just coded it in my free time on ship. It is scripted in PHP. but you may adapt for c++ or VB.

100% original
//code to decode ais messages
/*
? Receives a broadcast message,
? Organises the binary bits of the Message Data into 6-bit strings,
? Converts the 6-bit strings into their representative "valid characters" – see IEC 61162-1,
table 7,
? Assembles the valid characters into an encapsulation string, and
? Transfers the encapsulation string using the VDM sentence formatter.

sample message
!AIVDM,1,1,,A,1P000Oh1IT1svTP2r:43grwb0Eq4,0*01

*/
$ais = "1P000Oh1IT1svTP2r:43grwb0Eq4";
$aisdata168=NULL;//six bit array of ascii characters
$ais_nmea_array = str_split($ais);
foreach ($ais_nmea_array as $value)
{
$dec=ascii_2_dec($value);
$bit8=asciidec_2_8bit($dec);
$bit6=dec_2_6bit($bit8);
echo $value ."-" .$bit6 ."
";
$aisdata168 .=$bit6;
}
echo $aisdata168 . "
";

echo "mmsi= " . bindec(substr($aisdata168,9,29)) . "
";
echo "cog= " . bindec(substr($aisdata168,116,12))/10 . "
";
echo "sog= " . bindec(substr($aisdata168,50,10))/10 . "
";

function ascii_2_dec($chr)
{
$dec=ord($chr);//get decimal ascii code
$hex=dechex($dec);//convert decimal to hex
return ($dec);
}

function asciidec_2_8bit($ascii)
{
if ($ascii<48){}
else
{
if($ascii>119){}
else
{
if($ascii>87 && $ascii <96){}
else
{
$ascii=$ascii+40;
if ($ascii>128){$ascii=$ascii+32;}
else{$ascii=$ascii+40;}
}
}
}
return ($ascii);
}
function dec_2_6bit($dec)
{
$bin=decbin($dec);
return(substr($bin, -6));
}