<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>RedAcacia</title>
	<atom:link href="http://redacacia.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://redacacia.wordpress.com</link>
	<description>Just tech-oriented projects and sharing them!</description>
	<lastBuildDate>Tue, 17 Jan 2012 10:54:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='redacacia.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>RedAcacia</title>
		<link>http://redacacia.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://redacacia.wordpress.com/osd.xml" title="RedAcacia" />
	<atom:link rel='hub' href='http://redacacia.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Voice Operated Internet Control of a PICAXE (Part II)</title>
		<link>http://redacacia.wordpress.com/2011/09/02/voice-operated-internet-control-of-a-picaxe-part-ii/</link>
		<comments>http://redacacia.wordpress.com/2011/09/02/voice-operated-internet-control-of-a-picaxe-part-ii/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 15:12:16 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=383</guid>
		<description><![CDATA[Objectives Experiment with more advanced features offered by Picaxe microcontroller. Measure temperature through a Maxim  DS18B20   sensor and obtain interactivity with recourse to audio response using text to voice offered by Google translate. The electronic setup A AXE050 board with Picaxe18M microcontroller &#8230; <a href="http://redacacia.wordpress.com/2011/09/02/voice-operated-internet-control-of-a-picaxe-part-ii/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=383&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Objectives</strong></p>
<p>Experiment with more advanced features offered by Picaxe microcontroller. Measure temperature through a Maxim  <a href="http://aliatron.com/loja/catalog/product_info.php?products_id=395">DS18B20</a>   sensor and obtain interactivity with recourse to audio response using text to voice offered by Google translate.</p>
<p><strong>The electronic setup</strong></p>
<p>A <a href="http://aliatron.com/loja/catalog/product_info.php?products_id=658">AXE050 board </a>with Picaxe18M microcontroller is used just as in <a href="http://redacacia.wordpress.com/2011/08/28/voice-operated-internet-control-of-a-picaxe/">Part I</a>. Here is a picture of AXE050:</p>
<div id="attachment_9" class="wp-caption aligncenter" style="width: 303px"><a href="http://redacacia.files.wordpress.com/2010/08/axe049.jpg"><img class="size-full wp-image-9" title="AXE050" src="http://redacacia.files.wordpress.com/2010/08/axe049.jpg?w=640" alt=""   /></a><p class="wp-caption-text">AXE050 Board</p></div>
<p>Temperature sensor Maxim  <a href="http://aliatron.com/loja/catalog/product_info.php?products_id=395">DS18B20</a>  is added to the AXE050 board reads temperatures. The advantage of using Picaxe18M is that the same ports are used for control and programming.</p>
<div id="attachment_53" class="wp-caption aligncenter" style="width: 238px"><a href="http://redacacia.files.wordpress.com/2010/08/ds18b20_pinout.gif"><img class="size-full wp-image-53" title="ds18B20_pinout" src="http://redacacia.files.wordpress.com/2010/08/ds18b20_pinout.gif?w=640" alt=""   /></a><p class="wp-caption-text">DS18B20 Pinout</p></div>
<div id="attachment_54" class="wp-caption aligncenter" style="width: 299px"><a href="http://redacacia.files.wordpress.com/2010/08/18m_ds18b20.gif"><img class="size-full wp-image-54" title="18M_DS18B20" src="http://redacacia.files.wordpress.com/2010/08/18m_ds18b20.gif?w=640" alt=""   /></a><p class="wp-caption-text">PICAXE-18M and DS18B20 connections</p></div>
<p>Reading and control of AXE050 board is done using RS232 protocol. The onboard connections are used for RS232 control.</p>
<p><strong>Pre-Requirements</strong></p>
<p>Before carrying out this part of project, <a href="http://redacacia.wordpress.com/2011/08/28/voice-operated-internet-control-of-a-picaxe/">Voice Operated Internet Control of a PICAXE (Part I)</a> must have been implemented, i.e. experimented already with simple switching of a LED on the AXE050 board. The firmware on the chip will be the same as in Part I, and the same as in <a href="http://redacacia.wordpress.com/2010/08/05/internet-control-of-a-picaxe/">Internet Control of a Picaxe</a> published here long time ago.</p>
<p>RS232 control is done again in DOS environment, using <a href="http://netlab1.usu.edu/pub/kermit/MSK316.ZIP">Kermit for DOS</a>. Kermit scripts are run by PHP, to control AXE050. Kermit’s executable MSK316.exe is installed in same directory as all files. As mentioned in part I, all files will be in c:\xampp\htdocs.</p>
<p><strong>Note:</strong> COM2 is used  at baudrate of 4800 setup in Control Pannel of Windows XP.</p>
<p><strong>Now the scripts&#8230;</strong></p>
<p>STATUS Kermit script (name it <strong>status.ksc</strong>):</p>
<p><pre class="brush: plain;">set port 2
set baud 4800
clear
output c=s
input /nowrap</pre></p>
<p>The new command is <strong>input /nowrap</strong>, being used to obtain output from Kermit and pipe it into the server.</p>
<p>This script is called in a BATCH file (name it <strong>sta.bat</strong>):</p>
<p><pre class="brush: plain;">@echo off
c:\wamp\www\msk316 take status.ksc
exit</pre></p>
<p>TEMPERATURE Kermit script (name it <strong>gettemp.ksc</strong>):</p>
<p><pre class="brush: plain;">set port 2
set baud 4800
clear
output c=t
input /nowrap</pre></p>
<p>Again we use new command <strong>input /nowrap.</strong></p>
<p>This script is called in a BATCH file (name it <strong>temp.bat</strong>):</p>
<p><pre class="brush: plain;">@echo off
c:\wamp\www\msk316 take gettemp.ksc
exit</pre></p>
<p>All batch files are then converted into <strong>.exe</strong> using <a href="http://www.download3k.com/DownloadLink1-Bat-To-Exe-Converter.html">Bat_to_Exe_Converter</a>. As result, will have two new executables <strong>sta.exe</strong> and <strong>temp.exe</strong> in the folder htdocs, besides the previous part I executables <strong>ledon.exe</strong> and <strong>ledoff.exe</strong>.</p>
<p><strong>Finally again the html and php codes…</strong></p>
<p>Substitute <strong>index.html</strong> of Part I with new one as shown below, again within htdocs folder of Windows-based <a href="http://redacacia.wordpress.com/2010/08/05/internet-control-of-a-picaxe/www.apachefriends.org/en/xampp-windows.html">XAMPP</a> server.</p>
<p><strong>index.html</strong></p>
<p><pre class="brush: plain;">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;content-language&quot; content=&quot;en-US&quot;&gt;
&lt;meta charset=&quot;utf-8&quot;&gt;

&lt;title&gt;Voice Operated Control &lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function checkSpeechSupport(){
var element=document.createElement(&quot;input&quot;);
if (!('webkitSpeech' in element)) {
alert(&quot;Sorry! Your browser does not support the Speech Input&quot;);
}
}
function checkanswer() {
var answer = document.getElementById('q2answer').value;

if (answer == 'light on') {

window.location.href = &quot;http://localhost/processing.php?action=on&quot;;
}

else if (answer == 'lights on') {

window.location.href = &quot;http://localhost/processing.php?action=on&quot;;
}

else if (answer == 'light off') {

window.location.href = &quot;http://localhost/processing.php?action=off&quot;;
}

else if (answer == 'lights off') {

window.location.href = &quot;http://localhost/processing.php?action=off&quot;;
}

else if (answer == 'temperature') {

window.location.href = &quot;http://localhost/processing.php?action=tem&quot;;
}

else if (answer == 'temperatures') {

window.location.href = &quot;http://localhost/processing.php?action=tem&quot;;
}

else if (answer == 'status') {

window.location.href = &quot;http://localhost/processing.php?action=sta&quot;;
}

else {
window.location.href = &quot;alert.php&quot;;
}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onLoad=&quot;checkSpeechSupport()&quot;&gt;
&lt;form id=&quot;speechform&quot;&gt;
&lt;fieldset id=&quot;inputs&quot;&gt;
&lt;font face=&quot;arial, verdana&quot;&gt;&lt;legend&gt;&lt;h2&gt;Voice Control of Picaxe AXE-050U:&lt;/h2&gt;&lt;/legend&gt;
&lt;label for=&quot;q2answer&quot;&gt;Say commands: &quot;light on&quot;, &quot;light off&quot;&lt;br&gt;&quot;temperature&quot; and &quot;status&quot;:&lt;/label&gt;&lt;/font&gt;
&lt;input id=&quot;q2answer&quot; name=&quot;q2answer&quot; type=&quot;text&quot; x-webkit-speech onwebkitspeechchange=&quot;checkanswer()&quot;/&gt;&lt;br/&gt;
&lt;img src=&quot;http://localhost:8888/out.jpg&quot;&gt;
&lt;/fieldset&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

</pre></p>
<p>Substitute <strong>processing.php</strong> of Part I with new one as shown below, again within htdocs folder</p>
<p><strong>processing php</strong></p>
<p><pre class="brush: plain;">
&lt;?php
// numerical to text class included
include 'num2text.class.php';
//check the GET actions variable to see if something needs to be done
    if (isset($_GET['action'])) {
    //Action has been requested
    //Issue the command we wish to send to the Picaxe

    if ($_GET['action'] == &quot;on&quot;) {
        //Turn LED on - for this simple script we are just looking for either a 1 or 0
    $page = &quot;index.html&quot;;
    header(&quot;Refresh: 4; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;);
          exec ('sta.exe',$report);
           // check waht is in array $report
           // print_r($report);
          $pieces = explode(' ',$report[0]);
          if ($pieces[1] == 1) {
                echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;LIGHT IS ALREADY ON&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&quot;;
                echo &quot;&lt;iframe src=\&quot;http://translate.google.com/translate_tts?tl=en&amp;q=light+is+already+on!\&quot; name=\&quot;top\&quot; width=\&quot;320\&quot; marginwidth=\&quot;0\&quot; height=\&quot;50\&quot;&gt;&lt;/iframe&gt;&quot;;
          }
          else {
          exec('ledon.exe');
          echo &quot;&lt;hr align='center' size=\&quot;4\&quot; color=\&quot;orange\&quot;&gt;&lt;br&gt;&quot;;
          echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;LIGHT IS NOW ON&lt;/b&gt;&lt;/font&gt;&lt;p&gt;&quot;;
          echo &quot;&lt;iframe src=\&quot;http://translate.google.com/translate_tts?tl=en&amp;q=light+is+now+on!\&quot; name=\&quot;top\&quot; width=\&quot;320\&quot; marginwidth=\&quot;0\&quot; height=\&quot;50\&quot;&gt;&lt;/iframe&gt;&quot;;
      }

      }

     else if ($_GET['action'] == &quot;off&quot;) {
     //Turn LED off
     //Now we &quot;open&quot; the serial port so we can write to it
     $page = &quot;index.html&quot;;
     header(&quot;Refresh: 4; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;);
           exec ('sta.exe',$report);
           // check waht is in array $report
           // print_r($report);
           $pieces = explode(' ',$report[0]);
           if ($pieces[1] == 0) {
                echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;LIGHT IS ALREADY OFF&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&quot;;
                echo &quot;&lt;iframe src=\&quot;http://translate.google.com/translate_tts?tl=en&amp;q=light+is+already+off!\&quot; name=\&quot;top\&quot; width=\&quot;320\&quot; marginwidth=\&quot;0\&quot; height=\&quot;50\&quot;&gt;&lt;/iframe&gt;&quot;;
           }
           else {
           exec('ledoff.exe');
           echo &quot;&lt;hr align='center' size=\&quot;4\&quot; color=\&quot;orange\&quot;&gt;&lt;br&gt;&quot;;
           echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;LIGHT IS NOW OFF&lt;/b&gt;&lt;/font&gt;&lt;p&gt;&quot;;
           echo &quot;&lt;iframe src=\&quot;http://translate.google.com/translate_tts?tl=en&amp;q=light+is+now+off!\&quot; name=\&quot;top\&quot; width=\&quot;320\&quot; marginwidth=\&quot;0\&quot; height=\&quot;50\&quot;&gt;&lt;/iframe&gt;&quot;;
           }
      }

      else if ($_GET['action'] == &quot;tem&quot;) {
           exec ('temp.exe',$report);
           $pieces = explode(' ', $report[0]);
           $n2s = new num2text($pieces[1]);
           $page = &quot;index.html&quot;;
           header(&quot;Refresh: 4; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;);
           echo &quot;&lt;hr align='center' size=\&quot;4\&quot; color=\&quot;orange\&quot;&gt;&lt;br&gt;&lt;b&gt;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;font color=blue&gt;LOCAL TEMPERATURE:&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;br&gt;&quot;;
           echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;&quot;.$pieces[1].&quot;&amp;nbsp;ºC&lt;/b&gt;&lt;/font&gt;&lt;p&gt;&quot;;
           echo &quot;&lt;iframe src=\&quot;http://translate.google.com/translate_tts?tl=en&amp;q=local+temperature%+is+&quot;.$n2s.&quot;+degrees+celsius.\&quot; name=\&quot;top\&quot; width=\&quot;320\&quot; marginwidth=\&quot;0\&quot; height=\&quot;50\&quot;&gt;&lt;/iframe&gt;&quot;;

        }

      else if ($_GET['action'] == &quot;sta&quot;) {
      $page = &quot;index.html&quot;;
      header(&quot;Refresh: 4; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;);
           exec ('sta.exe',$report);
           // check waht is in array $report
           // print_r($report);
           $pieces = explode(' ',$report[0]);
           // check what is in $pieces
           // echo $pieces[1].&quot;&lt;br&gt;&quot;; // piece1
           //echo $pieces[2].&quot;&lt;br&gt;&quot;; // piece2
           echo &quot;&lt;hr align='center' size=\&quot;4\&quot; color=\&quot;orange\&quot;&gt;&lt;br&gt;&lt;b&gt;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;font color=blue&gt;LOCAL STATUS:&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;&quot;;

                if ($pieces[1] == 1) {
                echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;LIGHT IS ON&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&quot;;
                echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;TEMPERATURE IS &quot;.$pieces[2].&quot;&amp;nbsp;ºC&lt;/b&gt;&lt;/font&gt;&lt;p&gt;&quot;;
                $n2s = new num2text($pieces[2]);
                echo &quot;&lt;iframe src=\&quot;http://translate.google.com/translate_tts?tl=en&amp;q=light+is+on.+local+temperature+is+&quot;.$n2s.&quot;+degrees+celsius+.\&quot; name=\&quot;top\&quot; width=\&quot;320\&quot; marginwidth=\&quot;0\&quot; height=\&quot;50\&quot;&gt;&lt;/iframe&gt;&quot;;
                }
                else if ($pieces[1] == 0) {
                echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;LIGHT IS OFF&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&quot;;
                echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;TEMPERATURE IS &quot;.$pieces[2].&quot;&amp;nbsp;ºC&lt;/b&gt;&lt;/font&gt;&lt;p&gt;&quot;;
                $n2s = new num2text($pieces[2]);
                echo &quot;&lt;iframe src=\&quot;http://translate.google.com/translate_tts?tl=en&amp;q=light+is+off.+local+temperature+is+&quot;.$n2s.&quot;+degrees+celsius+.\&quot; name=\&quot;top\&quot; width=\&quot;400\&quot; marginwidth=\&quot;0\&quot; height=\&quot;50\&quot;&gt;&lt;/iframe&gt;&quot;;
                }
        }
      }
?&gt;
</pre></p>
<p><strong>NOTE: </strong>iframe is used to avoid opening a new page and also problems in starting automatically Google&#8217;s voice file not starting automatically. </p>
<p>The following php class is courtesy of <a href="http://www.jaygilford.com/php/number-to-text-converting-php-class/">Jay Gilford</a>, it is included in above <strong>processing.php</strong> and is used to convert numerals into text, to avoid any problems in Google tanslate not recognising numerals as by default %20 is added by the Chrome in the URL</p>
<p><strong>num2text.class.php</strong></p>
<p><pre class="brush: plain;">
&lt;?php
class num2text {
    private $_original = 0;
    private $_parsed_number_text = '';
    private $_single_nums = array(1 =&gt; 'one', 2 =&gt; 'two', 3 =&gt; 'three', 4 =&gt; 'four', 5 =&gt; 'five', 6 =&gt; 'six', 7 =&gt; 'seven', 8 =&gt; 'eight', 9 =&gt;
        'nine', );

    private $_teen_nums = array(0 =&gt; 'ten', 1 =&gt; 'eleven', 2 =&gt; 'twelve', 3 =&gt; 'thirteen', 4 =&gt; 'Fourteen', 5 =&gt; 'fifteen', 6 =&gt; 'sixteen', 7 =&gt;
        'seventeen', 8 =&gt; 'eighteen', 9 =&gt; 'nineteen', );

    private $_tens_nums = array(2 =&gt; 'twenty', 3 =&gt; 'thirty', 4 =&gt; 'forty', 5 =&gt; 'fifty', 6 =&gt; 'sixty', 7 =&gt; 'seventy', 8 =&gt; 'eighty', 9 =&gt;
        'ninety', );

    private $_chunks_nums = array(1 =&gt; 'thousand', 2 =&gt; 'million', 3 =&gt; 'billion', 4 =&gt; 'trillion', 5 =&gt; 'quadrillion', 6 =&gt; 'quintrillion', 7 =&gt;
        'sextillion', 8 =&gt; 'septillion', 9 =&gt; 'octillion', 9 =&gt; 'nonillion', 9 =&gt; 'decillion', );

    function __construct($number) {
        $this-&gt;_original = trim($number);
        $this-&gt;parse();
    }

    public function parse($new_number = NULL) {
        if($new_number !== NULL) {
            $this-&gt;_original = trim($new_number);
        }
        if($this-&gt;_original == 0) return 'Zero';

        $num = str_split($this-&gt;_original, 1);
        krsort($num);
        $chunks = array_chunk($num, 3);
        krsort($chunks);

        $final_num = array();
        foreach ($chunks as $k =&gt; $v) {
            ksort($v);
            $temp = trim($this-&gt;_parse_num(implode('', $v)));
            if($temp != '') {
                $final_num[$k] = $temp;
                if (isset($this-&gt;_chunks_nums[$k]) &amp;&amp; $this-&gt;_chunks_nums[$k] != '') {
                    $final_num[$k] .= ' '.$this-&gt;_chunks_nums[$k];
                }
            }
        }
        $this-&gt;_parsed_number_text = implode(', ', $final_num);
        return $this-&gt;_parsed_number_text;
    }

    public function __toString() {
        return $this-&gt;_parsed_number_text;
    }

    private function _parse_num($num) {
        $temp = array();
        if (isset($num[2])) {
            if (isset($this-&gt;_single_nums[$num[2]])) {
                $temp['h'] = $this-&gt;_single_nums[$num[2]].' Hundred';
            }
        }

        if (isset($num[1])) {
            if ($num[1] == 1) {
                $temp['t'] = $this-&gt;_teen_nums[$num[0]];
            } else {
                if (isset($this-&gt;_tens_nums[$num[1]])) {
                    $temp['t'] = $this-&gt;_tens_nums[$num[1]];
                }
            }
        }

        if (!isset($num[1]) || $num[1] != 1) {
            if (isset($this-&gt;_single_nums[$num[0]])) {
                if (isset($temp['t'])) {
                    $temp['t'] .= ' '.$this-&gt;_single_nums[$num[0]];
                } else {
                    $temp['u'] = $this-&gt;_single_nums[$num[0]];
                }
            }
        }
        return implode(' and ', $temp);
    }
}

?&gt;
</pre></p>
<p><strong>alert.php</strong></p>
<p><pre class="brush: plain;">
&lt;?php
$page = &quot;script.html&quot;;
    header(&quot;Refresh: 4; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;);
    echo &quot;&lt;hr align='center' size=\&quot;4\&quot; color=\&quot;orange\&quot;&gt;&lt;br&gt;&lt;b&gt;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;font color=blue&gt;OOPS! TRY AGAIN!&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;p&gt;&quot;;
    echo &quot;&lt;iframe src=\&quot;http://translate.google.com/translate_tts?tl=en&amp;q=oops!try+again!\&quot; name=\&quot;top\&quot; width=\&quot;320\&quot; marginwidth=\&quot;0\&quot; height=\&quot;50\&quot;&gt;&lt;/iframe&gt;&quot;;
?&gt;
</pre></p>
<p><strong></strong> </p>
<p><strong>YAWCAM </strong></p>
<p>In order to view the LED switiching on and off a webcam setup is required as in Part I.</p>
<p><strong>Trying out</strong></p>
<p>We are now ready to open index.html. Point your Chrome 11 browser to http://localhost/index.html. Tou may now see the following (after you have directed your webcam to the AXE050 board):</p>
<div id="attachment_388" class="wp-caption aligncenter" style="width: 624px"><a href="http://redacacia.files.wordpress.com/2011/09/index_off.png"><img class="size-full wp-image-388" title="Index Page" src="http://redacacia.files.wordpress.com/2011/09/index_off.png?w=640" alt=""   /></a><p class="wp-caption-text">Main Page Showing PICAXE050</p></div>
<p>Simply click on the microphone and this should prompt you to speak.</p>
<p>Say the words “light on” and if the answer is right processing.php link will be opened. The browser records your voice input, it contacts Google Servers to do the translation into text for you, and the value will be put in the text field. The page processing.php will be opened if everything is OK as shown below:</p>
<div id="attachment_390" class="wp-caption aligncenter" style="width: 620px"><a href="http://redacacia.files.wordpress.com/2011/09/index_off_msg.png"><img class="size-full wp-image-390" title="Message of Light On" src="http://redacacia.files.wordpress.com/2011/09/index_off_msg.png?w=640" alt=""   /></a><p class="wp-caption-text">Page showing LIGHT is on and voice message</p></div>
<p>In backgroung status.exe and edon.exe will be run for a short duration and a LED on the AXE050 will switch on. The processing page will automatically redirect to index.html page which will now show a live image of AXE050 with a LED switched on:</p>
<div id="attachment_391" class="wp-caption aligncenter" style="width: 622px"><a href="http://redacacia.files.wordpress.com/2011/09/index_on1.png"><img class="size-full wp-image-391" title="Main Page" src="http://redacacia.files.wordpress.com/2011/09/index_on1.png?w=640" alt=""   /></a><p class="wp-caption-text">Main page shows a duly lit LED</p></div>
<p>If the command is not recognised you will prompted to say it again, as page alert.php will open and you will hear the robotic voice from Google saying “Oops! Try again!”:</p>
<div id="attachment_392" class="wp-caption aligncenter" style="width: 618px"><a href="http://redacacia.files.wordpress.com/2011/09/oopstryagain.png"><img class="size-full wp-image-392" title="Try Again Page" src="http://redacacia.files.wordpress.com/2011/09/oopstryagain.png?w=640" alt=""   /></a><p class="wp-caption-text">Alert of Unrecognised Speech</p></div>
<p>The page will be shown briefly redirecting to main page index.html. If the command &#8220;light on&#8221; is repeated, even tough the LED is already on, the following page will be shown:</p>
<div id="attachment_393" class="wp-caption aligncenter" style="width: 617px"><a href="http://redacacia.files.wordpress.com/2011/09/index-_already_on_msg.png"><img class="size-full wp-image-393" title="Already On Message" src="http://redacacia.files.wordpress.com/2011/09/index-_already_on_msg.png?w=640" alt=""   /></a><p class="wp-caption-text">Already on alert and message</p></div>
<p>This page will redirect also to index.html.</p>
<p>Now try out the voice command &#8220;status&#8221; and the page will show the actual status of LED and local temperature:</p>
<div id="attachment_395" class="wp-caption aligncenter" style="width: 616px"><a href="http://redacacia.files.wordpress.com/2011/09/index_status_msg.png"><img class="size-full wp-image-395" title="Local Status Page" src="http://redacacia.files.wordpress.com/2011/09/index_status_msg.png?w=640" alt=""   /></a><p class="wp-caption-text">Local status of LEd and temperature and message</p></div>
<p>Finally, try voice commands &#8220;light off&#8221;, &#8220;temperature&#8221; and &#8220;status&#8221; when light is both &#8220;on&#8221;! and &#8220;off&#8221;. If all is functioning correctly. all these voice commands will be recognised, and there will be interactivity when commands are repeated for cases such as of &#8220;light on&#8221; and &#8220;light off&#8221;.</p>
<p><strong>Further work</strong></p>
<p>More vocabulary  of voice recognition can be added improving speech recognition. Databases can be set up, not only to log issued commands, but also to obtain local conditons, and general status. Additional sensors can be added, such as humidity and light (LDR on AXE050 can be used to measure light at certain extaint). Graphs can be displayed, and trigger points set, adding support for email and/or sms when  events or alarms occur.</p>
<p><strong>Conclusions</strong></p>
<p>Voice recognition has been achieved and demonstrated using Google servers (that effectively are becoming Cloud voice servers), obtaining control and interactivity with a real world application. In less than a decade, voice recognition is starting to come to age, although is still not there fully yet. An exciting perspective that opens up, is the near future availability of speech recognition in mobile phones and more and more devices responding to voice commands.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/383/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/383/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/383/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=383&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2011/09/02/voice-operated-internet-control-of-a-picaxe-part-ii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://translate.google.com/translate_tts?tl=en&amp;amp" length="0" type="audio/mpeg" />
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/08/axe049.jpg" medium="image">
			<media:title type="html">AXE050</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/08/ds18b20_pinout.gif" medium="image">
			<media:title type="html">ds18B20_pinout</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/08/18m_ds18b20.gif" medium="image">
			<media:title type="html">18M_DS18B20</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/09/index_off.png" medium="image">
			<media:title type="html">Index Page</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/09/index_off_msg.png" medium="image">
			<media:title type="html">Message of Light On</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/09/index_on1.png" medium="image">
			<media:title type="html">Main Page</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/09/oopstryagain.png" medium="image">
			<media:title type="html">Try Again Page</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/09/index-_already_on_msg.png" medium="image">
			<media:title type="html">Already On Message</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/09/index_status_msg.png" medium="image">
			<media:title type="html">Local Status Page</media:title>
		</media:content>
	</item>
		<item>
		<title>Voice Operated Internet Control of a PICAXE (Part I)</title>
		<link>http://redacacia.wordpress.com/2011/08/28/voice-operated-internet-control-of-a-picaxe/</link>
		<comments>http://redacacia.wordpress.com/2011/08/28/voice-operated-internet-control-of-a-picaxe/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 17:33:25 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=342</guid>
		<description><![CDATA[Objectives Experiment with speech recognition in order to control an electronic device remotely through Internet, and demonstrate new functionalities of Google Chrome 11 browser supporting voice-to-text and HTML5. Introduction In April 2011, Google released version 11 of the Chrome browser. One of &#8230; <a href="http://redacacia.wordpress.com/2011/08/28/voice-operated-internet-control-of-a-picaxe/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=342&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Objectives</strong></p>
<p>Experiment with speech recognition in order to control an electronic device remotely through Internet, and demonstrate new functionalities of Google Chrome 11 browser supporting voice-to-text and HTML5.</p>
<p><strong>Introduction</strong></p>
<p>In April 2011, Google released version 11 of the Chrome browser. One of the most important addition to the new version of Chrome browser is the support for speech recognition. One can enable speech recognition with a simple tag &lt;input type=&#8221;text&#8221; <em>x</em>-<em>webkit-speech</em> /&gt;.</p>
<p>Google is effectively using the <a title="WebKit" href="http://en.wikipedia.org/wiki/WebKit">WebKit</a> <a title="Layout engine" href="http://en.wikipedia.org/wiki/Layout_engine">layout engine</a>,  first released as a <a title="Beta version" href="http://en.wikipedia.org/wiki/Beta_version">beta version</a> by <a title="Microsoft Windows" href="http://en.wikipedia.org/wiki/Microsoft_Windows">Microsoft Windows</a> in September 2008, and the public stable release was released in December 2008.</p>
<p><strong>The electronic setup</strong></p>
<p><strong></strong>A <a href="http://aliatron.com/loja/catalog/product_info.php?products_id=658">AXE050 board </a>with Picaxe18M microcontroller is used. Picaxe products are manufactured by <a href="http://rev-ed.co.uk/">Revolution Education</a>. Here is a picture of AXE050:</p>
<div id="attachment_9" class="wp-caption aligncenter" style="width: 303px"><a href="http://redacacia.files.wordpress.com/2010/08/axe049.jpg"><img class="size-full wp-image-9" title="AXE050" src="http://redacacia.files.wordpress.com/2010/08/axe049.jpg?w=640" alt=""   /></a><p class="wp-caption-text">AXE050 Board</p></div>
<p><strong>Note:</strong> AXE027 programming serial cable is required. Picaxe-18M uses the same port for programming and serial communication with PC.</p>
<p>The firmware in AXE-050 is the same as we used in <a href="http://redacacia.wordpress.com/2010/08/05/internet-control-of-a-picaxe/">Internet Control of a Picaxe</a> (check the link). The idea behind using the same firmware without modifications, is to use it in future voice operated projects (if I get time for them&#8230;)</p>
<p><strong>The main server</strong></p>
<p>A Windows-based <a href="http://redacacia.wordpress.com/2010/08/05/internet-control-of-a-picaxe/www.apachefriends.org/en/xampp-windows.html">XAMPP</a> server is installed in the PC. The server is hooked to a local network with a fixed local IP. The application is situated in a network that has no fixed public IP, hence <a href="http://www.dyndns.com/">DynDNS</a> services is used. The router routes all external demands to the fixed local IP.</p>
<p>Windows XP and later do not allow easy RS232 control through Internet. To  overcome such a blockage, RS232 control is done through DOS, using <a href="http://netlab1.usu.edu/pub/kermit/MSK316.ZIP">Kermit for DOS</a>. Kermit scripts are run by PHP, to control AXE050. Kermit’s executable MSK316.exe is installed in same directory as all files. They will be all in c:\xampp\htdocs (rename the servers default index page to another name)</p>
<p>Note COM2 is used  at baudrate of 4800 setup in Control Pannel of Windows XP.</p>
<p>LED ON Kermit script (name it ledon.ksc):</p>
<p><pre class="brush: plain;">

set port 2
set baud 4800
output c=n
exit 0

</pre></p>
<p>This script is called in a BATCH file (name it ledon.bat):</p>
<p><pre class="brush: plain;">

@echo off
c:\xampp\htdocs\msk316 take ledon.ksc
exit

</pre></p>
<p>LED OFF Kermit script (name it ledoff.ksc):</p>
<p><pre class="brush: plain;">

set port 2
set baud 4800
output c=f
exit 0

</pre></p>
<p>This script is called in a BATCH file (name it ledon.bat):</p>
<p><pre class="brush: plain;">

@echo off
c:\xampp\htdocs\msk31 take ledoff.ksc
exit

</pre></p>
<p>All batch files are then converted into .exe using <a href="http://www.download3k.com/DownloadLink1-Bat-To-Exe-Converter.html">Bat_to_Exe_Converter</a>. So we will have two executables ledon.exe and ledoff.exe in the folder htdocs</p>
<p><strong>Finally the html and php codes&#8230;</strong></p>
<p>The html code is based on Romin Irani&#8217;s <a href="http://www.rominirani.com/2011/07/12/voice-enabled-web-applications-via-x-webkit-speech/">Voice Enabled Web Applications via x-webkit-speech</a> example, that has been adapted to suit the requirements of this actual project.</p>
<p><strong>index.html</strong></p>
<p><pre class="brush: plain;">

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;content-language&quot; content=&quot;en-US&quot;&gt;
&lt;meta charset=&quot;utf-8&quot;&gt;

&lt;title&gt;Voice Operated Control &lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function checkSpeechSupport(){
var element=document.createElement(&quot;input&quot;);
if (!('webkitSpeech' in element)) {
alert(&quot;Sorry! Your browser does not support the Speech Input&quot;);
}
}
function checkanswer() {
var answer = document.getElementById('q2answer').value;

if (answer == 'light on') {

window.location.href = &quot;http://localhost/processing.php?action=on&quot;;
}

else if (answer == 'light off') {

window.location.href = &quot;http://localhost/processing.php?action=off&quot;;
}

else {

window.open('http://translate.google.com/translate_tts?tl=en&amp;q=oops!%20try%20again%E2%80%9D');

}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onLoad=&quot;checkSpeechSupport()&quot;&gt;
&lt;form id=&quot;speechform&quot;&gt;
&lt;fieldset id=&quot;inputs&quot;&gt;
&lt;font face=&quot;arial, verdana&quot;&gt;&lt;legend&gt;&lt;h2&gt;Voice Control of Picaxe AXE-050U:&lt;/h2&gt;&lt;/legend&gt;
&lt;label for=&quot;q2answer&quot;&gt;Say &quot;light on&quot; or &quot;light off&quot; command:&lt;/label&gt;&lt;/font&gt;
&lt;input id=&quot;q2answer&quot; name=&quot;q2answer&quot; type=&quot;text&quot; x-webkit-speech onwebkitspeechchange=&quot;checkanswer()&quot;/&gt;&lt;br/&gt;
&lt;img src=&quot;http://localhost:8888/out.jpg&quot;&gt;
&lt;/fieldset&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre></p>
<p><strong>processing.php</strong></p>
<p><pre class="brush: plain;">
&lt;?php
//check the GET actions variable to see if something needs to be done
    if (isset($_GET['action'])) {
    //Action has been requested
    //Issue the command we wish to send to the Picaxe
    if ($_GET['action'] == &quot;on&quot;) {
        //Turn LED on - for this simple script we are just looking for either a 1 or 0
    $page = &quot;script.html&quot;;
    header(&quot;Refresh: 2; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;);

          echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;LIGHT ON&lt;/b&gt;&lt;/font&gt;&quot;;
          exec(&quot;ledon.exe&quot;);

     }

     else if ($_GET['action'] == &quot;off&quot;) {
     //Turn LED off
     //Now we &quot;open&quot; the serial port so we can write to it
     $page = &quot;script.html&quot;;
     header(&quot;Refresh: 2; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;);

        exec('ledoff.exe');
          echo &quot;&lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;LIGHT OFF&lt;/b&gt;&lt;/font&gt;&quot;;
      }

      }
?&gt;
</pre></p>
<p>We are almost ready. We need to add video to the main index.html page, In the form section you will see http://localhost:8888/out.jpg. In fact we need to run a video server. Yawam is chosen to show a live image of the status of our AXE050 board.</p>
<p><strong>YAWCAM </strong></p>
<p>In order to view the LED switiching on and off a webcam setup is required. <a href="http://www.yawcam.com/">YAWCAM</a> freeware is advised.  Having the requirements mentioned on the YAMCAM website one can easily establish a streaming server on port 8888. If the PC is behind a router the video streaming server port must be opened on the router.</p>
<p>Once YAWCAM is duly working you will need to enable Http and Stream in COntrol Panel of YAWCAM as the following image shows:</p>
<div id="attachment_361" class="wp-caption aligncenter" style="width: 281px"><a href="http://redacacia.files.wordpress.com/2011/08/yamcam_cp.png"><img class="size-full wp-image-361" title="YAWCAM Control Panel" src="http://redacacia.files.wordpress.com/2011/08/yamcam_cp.png?w=640" alt=""   /></a><p class="wp-caption-text">Http and Stream enabled</p></div>
<p><strong>Trying out</strong></p>
<p>We are now ready to open index.html. Point your Chrome 11 browser to http://localhost/index.html. Tou may now see the following (after you have directed your webcam to the AXE050 board):</p>
<div id="attachment_363" class="wp-caption aligncenter" style="width: 599px"><a href="http://redacacia.files.wordpress.com/2011/08/main_ledoff.png"><img class="size-full wp-image-363" title="Main Page " src="http://redacacia.files.wordpress.com/2011/08/main_ledoff.png?w=640" alt=""   /></a><p class="wp-caption-text">Main Page Showing PICAXE050</p></div>
<p>Notice the little microphone shown at the end of the input text field. You will need a duly set up microphone in your PC (I have used an USB microphone). <strong>Do not write anything in the input field. </strong>Simply click on the microphone and this should prompt you to speak as shown below:</p>
<div id="attachment_366" class="wp-caption aligncenter" style="width: 144px"><a href="http://redacacia.files.wordpress.com/2011/08/speaknow.png"><img class="size-full wp-image-366" src="http://redacacia.files.wordpress.com/2011/08/speaknow.png?w=640" alt=""   /></a><p class="wp-caption-text">Chrome 11 prompting to speak</p></div>
<p>Once the browser records your voice input, it contacts Google Servers to do the translation into text for you, and the value will be put in the text field. Say the words &#8220;light on&#8221; and if the answer is right processing.php link will be opened:</p>
<p><img title="Processing the Command" src="http://redacacia.files.wordpress.com/2011/08/ledon.png?w=614&#038;h=540" alt="" width="614" height="540" /></p>
<p>In backgroung ledon.exe will be run for a short duration and a LED on the AXE050 will switch on. The processing page will be automatically redirected to index.html page which will now show a live image of AXE050 with a LED switched on:</p>
<div id="attachment_368" class="wp-caption aligncenter" style="width: 599px"><a href="http://redacacia.files.wordpress.com/2011/08/main_ledon.png"><img class="size-full wp-image-368" title="Main Page" src="http://redacacia.files.wordpress.com/2011/08/main_ledon.png?w=640" alt=""   /></a><p class="wp-caption-text">Image shows a LED duly lit</p></div>
<p>If the command is not recognised you will prompted to say it again, as you will hear the robotic voice from Google &#8220;Oops! Try again!&#8221;. You can disable popup in your Chrome 11 browser if you don&#8217;t want popoups that you have to close.</p>
<p>Now we are ready to switch off the LED with voice command &#8220;light off&#8221;. If the command is recognised, processing.php will be opened again, and the following page will be shown:</p>
<p><a href="http://redacacia.files.wordpress.com/2011/08/ledoff1.png"><img class="aligncenter size-full wp-image-370" title="LIGHT OFF" src="http://redacacia.files.wordpress.com/2011/08/ledoff1.png?w=640" alt=""   /></a></p>
<p>In backgroung ledoff.exe will run for a short duration and the LED on the AXE050 will switch off. The processing.php page will be redirected to index.html page which will now show a live image of AXE050 with LED duly off, as we were in our first initial stage.</p>
<p><strong>Conclusion</strong></p>
<p>We have experimented with voice (speech) recognition. The technology has not come to age yet. One has different accents and pronunciations (mine is a big mixture <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ) and it is a huge task to recognise all of differing human voices. The interaction with devices adds an extra dimension to voice recognition. Chrome 11 browser&#8217;s support for speech to text is not well domumented. but gradually its potential is being discovered and shared.</p>
<p><strong>NOTE: Check <a href="http://redacacia.wordpress.com/2011/09/02/voice-operated-internet-control-of-a-picaxe-part-ii/">part II </a>of this project!</strong></p>
<p><strong>Acknowledgements</strong></p>
<p>A special thanks to <a href="http://www.maxmcarter.com/picaxe/picaxe_server.html">Max Carter</a> for sharing the orignail PICAXE firmware, and to <a href="http://www.rominirani.com/2011/07/12/voice-enabled-web-applications-via-x-webkit-speech/">Romin Irani </a>for his above mentioned  index.html code (duly adapted for purpose of this project).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/342/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/342/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/342/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=342&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2011/08/28/voice-operated-internet-control-of-a-picaxe/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://translate.google.com/translate_tts?tl=en&amp;amp" length="0" type="audio/mpeg" />
<enclosure url="http://translate.google.com/translate_tts?tl=en&amp;amp" length="0" type="audio/mpeg" />
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/08/axe049.jpg" medium="image">
			<media:title type="html">AXE050</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/08/yamcam_cp.png" medium="image">
			<media:title type="html">YAWCAM Control Panel</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/08/main_ledoff.png" medium="image">
			<media:title type="html">Main Page </media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/08/speaknow.png" medium="image" />

		<media:content url="http://redacacia.files.wordpress.com/2011/08/ledon.png" medium="image">
			<media:title type="html">Processing the Command</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/08/main_ledon.png" medium="image">
			<media:title type="html">Main Page</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/08/ledoff1.png" medium="image">
			<media:title type="html">LIGHT OFF</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing: Fatal Error Call To Undefined Function Json_decode</title>
		<link>http://redacacia.wordpress.com/2011/07/29/fixing-fatal-error-call-to-undefined-function-json_decode/</link>
		<comments>http://redacacia.wordpress.com/2011/07/29/fixing-fatal-error-call-to-undefined-function-json_decode/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 13:08:32 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=322</guid>
		<description><![CDATA[Introduction On moving to my new CentOS server (with php version 5.1.6), the php code for automatically twitting latest posts from my forums to Twitter stopped working (check the php code here  A Twitbot Using OAUTH). I will explain below &#8230; <a href="http://redacacia.wordpress.com/2011/07/29/fixing-fatal-error-call-to-undefined-function-json_decode/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=322&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><em>Introduction</em></strong></p>
<p><em>On moving to my new CentOS server (with php version 5.1.6), the php code for automatically twitting latest posts from my forums to Twitter stopped working (check the php code here  <a href="http://redacacia.wordpress.com/2010/08/05/a-twitbot-using-oauth/">A Twitbot Using OAUTH</a>). </em></p>
<p><em>I will explain below how the errors were determined and fixed. This post may help others to fix a similar problem.</em></p>
<p><strong>Determine the symptoms</strong></p>
<ol>
<li>Enable error messages to be shown by writing ini_set( &#8216; display_errors &#8216;,  &#8216; 1&#8242;);  in your PHP code.</li>
<li>If the error message is &#8220;Fatal Error Call to Undefined Function Json_decode ()&#8221;, read on&#8230; </li>
</ol>
<p><strong>The solution by installing JSON PHP Extension</strong></p>
<p>1 . Ssh into your webserver with root privileges</p>
<p>2 .  Install gcc make:<br />
          # yum install gcc make</p>
<p>3 .  Install php-pear and php-devel :<br />
          # yum install php-pear php-devel   </p>
<p>4 .  Install  json:<br />
          # pecl install json</p>
<p>If there are no dependency errors, or other, and all packages duly install you will next:<br />
&lt;</p>
<ol>
<li>Open your php.ini file  (ex. nano /etc/php.ini)</li>
<li>Find in php.ini a section called Dynamic Extensions</li>
<li>Add a line: extension = json.so</li>
<li>Save php.ini and restart Apache (ex. service httpd restart)</li>
</ol>
<p>You can check if json is enabled, installing in your httpdocs folder a php file (ex. test.php) with the following code:</p>
<p>&lt;?php<br />
phpinfo();<br />
?&gt;</p>
<p>If you open this page in your browser, you will see information on what your server&#8217;s php supports, and surely json will be one fo them:</p>
<div id="attachment_329" class="wp-caption aligncenter" style="width: 626px"><a href="http://redacacia.files.wordpress.com/2011/07/enable_json.png"><img class="size-full wp-image-329" title="phpinfo() showing json eabled" src="http://redacacia.files.wordpress.com/2011/07/enable_json.png?w=640" alt=""   /></a><p class="wp-caption-text">phpinfo() showing json enabled</p></div>
<p>Finally test json, with following php code (ex. test_json.php) in your httpdocs folder as shown in  <a href="http://php.net/manual/en/function.json-decode.php">php.net website</a></p>
<p>&lt;?php<br />
$json = &#8216;{&#8220;a&#8221;:1,&#8221;b&#8221;:2,&#8221;c&#8221;:3,&#8221;d&#8221;:4,&#8221;e&#8221;:5}&#8217;;<br />
var_dump(json_decode($json));<br />
var_dump(json_decode($json, true));<br />
?&gt;<br />
 </p>
<p>If you open the file in your browser, the result will be:</p>
<p>object(stdClass)#1 (5) {<br />
["a"] =&gt; int(1)<br />
["b"] =&gt; int(2)<br />
["c"] =&gt; int(3)<br />
["d"] =&gt; int(4)<br />
["e"] =&gt; int(5)<br />
}<br />
array(5) {<br />
["a"] =&gt; int(1)<br />
["b"] =&gt; int(2)<br />
["c"] =&gt; int(3)<br />
["d"] =&gt; int(4)<br />
["e"] =&gt; int(5)<br />
}</p>
<p>Json_decode is now working in your server, and there will be no more error reports such as &#8220;Fatal Error Call to Undefined Function Json_decode()&#8221;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/322/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=322&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2011/07/29/fixing-fatal-error-call-to-undefined-function-json_decode/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2011/07/enable_json.png" medium="image">
			<media:title type="html">phpinfo() showing json eabled</media:title>
		</media:content>
	</item>
		<item>
		<title>A Simple Home Alarm System with DAQ and Labview</title>
		<link>http://redacacia.wordpress.com/2010/11/17/a-simple-home-alarm-system-with-daq-and-labview/</link>
		<comments>http://redacacia.wordpress.com/2010/11/17/a-simple-home-alarm-system-with-daq-and-labview/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 01:45:29 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=289</guid>
		<description><![CDATA[We all like peace of mind knowing that our home is safe when we are away, at work, or for whatever other reasons. The system here is a simple home alarm system with a motion sensor. The Labview virtual instrument &#8230; <a href="http://redacacia.wordpress.com/2010/11/17/a-simple-home-alarm-system-with-daq-and-labview/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=289&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>We all like peace of mind knowing that our home is safe when we are away, at work, or for whatever other reasons. The system here is a simple home alarm system with a motion sensor. The Labview virtual instrument (VI) described here can be easily expanded to a full-fledged alarm system with several sensors, and strategies of detection. </em></p>
<p><strong>Objectives:</strong></p>
<p><span style="color:#000000;">Design a simple alarm system using a PIR (Passive InfraRed) motion sensor that will detect movement on digital input of a DAQ device, and then output an alarm sound using the computer speakers,  sending at the same time a message of intrusion.</span></p>
<p><strong><span style="color:#000000;">Background:</span></strong></p>
<p><span style="color:#000000;">A Passive InfraRed sensor (PIR sensor) is an <a title="Electronic device" href="http://en.wikipedia.org/wiki/Electronic_device">electronic device</a> that measures <a title="Infrared" href="http://en.wikipedia.org/wiki/Infrared">infrared</a> (IR) light radiating from objects in its field of view. PIR sensors are often used in the construction of <em>PIR-based <a title="Motion detector" href="http://en.wikipedia.org/wiki/Motion_detector">motion detectors</a></em> (see below). Apparent motion is detected when an infrared source with one <a title="Temperature" href="http://en.wikipedia.org/wiki/Temperature">temperature</a>, such as a <a title="Human" href="http://en.wikipedia.org/wiki/Human">human</a>, passes in front of an infrared source with another temperature, such as a <a title="Wall" href="http://en.wikipedia.org/wiki/Wall">wall</a></span><span style="color:#000000;">.(<a href="http://en.wikipedia.org/wiki/Passive_infrared_sensor">source</a>)</span></p>
<p><strong>Pre-Requirements:</strong></p>
<p>Labview and DAQmx softwares  installed in your PC, and the DAQ device duly working, and recognised by Labview.</p>
<p><strong>Required Equipment:</strong></p>
<p>NI Labview 2010 Student<br />
NI DAQmx 9.0.2<br />
NI <a href="http://aliatron.com/loja/catalog/product_info.php?products_id=638">USB-6009 </a>DAQ device<br />
<a href="http://http://aliatron.com/loja/catalog/product_info.php?products_id=756">PIR movement sensor</a> C-7288 or similar<br />
Wiring leads</p>
<p><img class="aligncenter" src="http://www.aliatron.com/loja/catalog/images/usb6008.gif" alt="" /></p>
<p><a href="http://redacacia.files.wordpress.com/2010/11/pir_sensor.gif"><img class="aligncenter size-full wp-image-298" title="pir_sensor" src="http://redacacia.files.wordpress.com/2010/11/pir_sensor.gif?w=640" alt=""   /></a><strong> </strong></p>
<p><span style="color:#000000;"><strong><br />
</strong></span></p>
<p><strong>Basic Knowledge:</strong></p>
<p>It is required to have basic knowledge in setting up a simple VI, such as the VI in the project <a href="http://redacacia.wordpress.com/2010/10/14/internet-control-of-a-labview-vi/">Internet Control of a Labview VI</a>.</p>
<p><strong>The PIR Connections:</strong></p>
<p><strong><a href="http://redacacia.files.wordpress.com/2010/11/pir_sensor_circ.gif"><img class="size-full wp-image-299 alignnone" title="pir_sensor_circ" src="http://redacacia.files.wordpress.com/2010/11/pir_sensor_circ.gif?w=640" alt=""   /></a></strong></p>
<p><strong>The Labview VI:</strong></p>
<p>Build a Labview VI such as shown below. It uses an email SubVI that sends an email notification using SMTP service:</p>
<p><a href="http://redacacia.files.wordpress.com/2010/11/home_alarm_vi.gif"><img class="size-full wp-image-301 alignnone" title="home_alarm_vi" src="http://redacacia.files.wordpress.com/2010/11/home_alarm_vi.gif?w=640&#038;h=342" alt="" width="640" height="342" /></a></p>
<p>The Labview VI and all the components are <a href="http://aliatron.com/download/home_alarm.zip">available here</a>.</p>
<p><strong>Before Running the VI:</strong></p>
<p>You need to have your DAQ Assistant function correctly set for your DAQ device. Check the above mentioned project <a href="http://redacacia.wordpress.com/2010/10/14/internet-control-of-a-labview-vi/">Internet Control of a Labview VI</a>.</p>
<p>Next, you need to open the Email_alert_subVI.vi contained in the zipped file just downloaded. You need to set up the SMTP details correctly.</p>
<p>Test the subVI running it, and checking whether you receive the email sent by the subVI.<em> Please note that you have to be online to test the subVI. </em></p>
<p><em> </em>In order to make default the set up constants of SMTP, <em>make current value default</em> in the Block Diagram (e.g. for Sender&#8217;s Name constant, right click onto it with mouse, choose <em>Data Operations,</em> and next choose <em>Make Current Value Default, a</em>nd so on for each constant).</p>
<p>After setting up all constants, save the subVI, and open it, and check if the values you have chosen are shown on your subVIs&#8217;s Front Panel. Double check, testing again the subVI ensuring email is sent to you by the subVI.</p>
<p><strong>How it works:</strong></p>
<p>When running continuously the VI, the DAQ device detects motion with PIR sensor. The detected signal generates a 400Hz sinal that is sounded in your PC speakers, and the Intrusion LED on Front Panel of Labview VI is switched on.</p>
<p>The detected signal sends an email alert, using the subVI already set up by you with your SMTC account detals.</p>
<p>The alarm latches, and can be only stopped if you reset it by pressing the RESET button on the Front Panel. After resetting the VI will be ready to detect any new motion.</p>
<p><strong>Tips and Tricks:</strong></p>
<ul>
<li>You can modify the VI in order log each intrusion time to file using a ‘Write To Spreadsheet File.vi’ express VI. There are plenty of examples on Internet on how to do it.</li>
<li>Expand your application by integrating more logic into the VI.  Possible scenarios might include a wait of a few seconds after clicking run to give you time to exit your home before the alarm starts to detect motion.</li>
<li>You can sent text messages to your cell phone using email to text servies (SMS) such as <a href="http://www.clickatell.com/">Clickatell</a>, and many other such services. Normally these services are not free, but they are reliable. They all allow free credit to test your system.</li>
<li>You can add an arming feature with keyboard input such as the Home Alarm at Student Projects page  <a href="http://crown.panam.edu/measurements/programs/">found here</a>.</li>
<li>You can also add webcam as a motion detector and record any intrusion. You can find a tutorial with <a href="http://www.yawcam.com/">Yawcam</a>. The system will send you also a text message (SMS) making use of a cheap webcam. Press <a href="http://www.raymond.cc/blog/archives/2010/02/19/set-up-logitech-webcam-as-motion-detector-and-send-alert-via-sms-text-message/">here to see the tutorial</a>.</li>
</ul>
<p><strong><span style="color:#000000;">Acknowledgments:</span></strong></p>
<p><span style="color:#000000;">A special thanks is due to NI Developper Zone for inspiration. The actual project is based on article <a href="http://zone.ni.com/devzone/cda/epd/p/id/6405">Dorm Room Alarm System Using a PIR Motion Detector</a>, and following resources:</span></p>
<ul>
<li><span style="color:#000000;"><a href="http://zone.ni.com/devzone/cda/epd/p/id/393">latch.vi</a></span></li>
<li><span style="color:#000000;"><a href="http://decibel.ni.com/content/docs/DOC-2401">gmailv86.vi</a> </span></li>
</ul>
<p><strong><br />
</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/289/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=289&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2010/11/17/a-simple-home-alarm-system-with-daq-and-labview/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://www.aliatron.com/loja/catalog/images/usb6008.gif" medium="image" />

		<media:content url="http://redacacia.files.wordpress.com/2010/11/pir_sensor.gif" medium="image">
			<media:title type="html">pir_sensor</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/11/pir_sensor_circ.gif" medium="image">
			<media:title type="html">pir_sensor_circ</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/11/home_alarm_vi.gif" medium="image">
			<media:title type="html">home_alarm_vi</media:title>
		</media:content>
	</item>
		<item>
		<title>Internet Control of a Labview VI (Part II)</title>
		<link>http://redacacia.wordpress.com/2010/10/15/internet-control-of-a-labview-vi-part-ii/</link>
		<comments>http://redacacia.wordpress.com/2010/10/15/internet-control-of-a-labview-vi-part-ii/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 13:26:10 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=269</guid>
		<description><![CDATA[In part I we have built a simple VI that controls a LED, switching it on or off through a virtual pressure button. We will now show step by step how to launch the application in the Internet and control &#8230; <a href="http://redacacia.wordpress.com/2010/10/15/internet-control-of-a-labview-vi-part-ii/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=269&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://redacacia.files.wordpress.com/2010/10/fig43.jpg"></a><a href="http://redacacia.wordpress.com/2010/10/14/internet-control-of-a-labview-vi/">In part I</a> we have built a simple VI that controls a LED, switching it on or off through a virtual pressure button. We will now show step by step how to launch the application in the Internet and control it remotely.</p>
<p><strong>STEP 23 </strong>-  Before anything else, we need to prepare the VI for multiple viewing. To do so in File menu we choose VI proprieties</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig29.jpg"><img class="aligncenter size-full wp-image-270" title="fig29" src="http://redacacia.files.wordpress.com/2010/10/fig29.jpg?w=640" alt=""   /></a></p>
<p>A new window will open and in this select in Categories drop down menu <em>Execution</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig30.jpg"><img class="aligncenter size-full wp-image-271" title="fig30" src="http://redacacia.files.wordpress.com/2010/10/fig30.jpg?w=640" alt=""   /></a></em></p>
<p>A new widow will open and select <em>Reentrant execution </em>as shown in image</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig31.jpg"><img class="aligncenter size-full wp-image-272" title="fig31" src="http://redacacia.files.wordpress.com/2010/10/fig31.jpg?w=640" alt=""   /></a></p>
<p>Press OK</p>
<p> <strong>STEP 24 </strong>-  Next we prepare the webserver. In menu Tools choose <em>Options</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig32.jpg"><img class="aligncenter size-full wp-image-273" title="fig32" src="http://redacacia.files.wordpress.com/2010/10/fig32.jpg?w=640" alt=""   /></a></em></p>
<p>In Options window, choose <em>Web Server: Configuration</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig33.jpg"><img class="aligncenter size-full wp-image-274" title="fig33" src="http://redacacia.files.wordpress.com/2010/10/fig33.jpg?w=640" alt=""   /></a></em></p>
<p>Enable server by clicking in the choice box on the right of the phrase <em>Enable Web Server</em>.</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig34.jpg"><img class="aligncenter size-full wp-image-275" title="fig34" src="http://redacacia.files.wordpress.com/2010/10/fig34.jpg?w=640" alt=""   /></a></p>
<p>Press OK.</p>
<p><strong>STEP 25 </strong>- Choose now <em>Web Server – Visible VIs</em>, and add switched_usb6009.vi as shown, in the field below the phrase Visible VI. Keep all other defaults as they appear</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig35.jpg"><img class="aligncenter size-full wp-image-276" title="fig35" src="http://redacacia.files.wordpress.com/2010/10/fig35.jpg?w=640" alt=""   /></a></p>
<p>Press OK</p>
<p> <strong>STEP 26 </strong>- We will next prepare the webpage and launch it. Choose <em>Tools -&gt; Web Publishing Tool</em></p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig36.jpg"><img class="aligncenter size-full wp-image-277" title="fig36" src="http://redacacia.files.wordpress.com/2010/10/fig36.jpg?w=640" alt=""   /></a></p>
<p>In Web Publishing Tool window choose the VI</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig37.jpg"><img class="aligncenter size-full wp-image-278" title="fig37" src="http://redacacia.files.wordpress.com/2010/10/fig37.jpg?w=640" alt=""   /></a></p>
<p>Press <em>Next </em>after the VI is selected</p>
<p><strong>STEP 27 </strong>- Write the title and HTML content as suggested in the image</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig38.jpg"><img class="aligncenter size-full wp-image-279" title="fig38" src="http://redacacia.files.wordpress.com/2010/10/fig38.jpg?w=640" alt=""   /></a></p>
<p>Press <em>NEXT</em></p>
<p><strong>STEP 28 </strong>- In the next window change the default name of the html file to index. Press Save to Disk button</p>
<p>A new window will open <em>Document URL</em>, press Connect button and then OK</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig39.jpg"><img class="aligncenter size-full wp-image-280" title="fig39" src="http://redacacia.files.wordpress.com/2010/10/fig39.jpg?w=640" alt=""   /></a></p>
<p><strong>STEP 29 </strong>- The webpage will be published and the browser will open</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig40.jpg"><img class="aligncenter size-full wp-image-281" title="fig40" src="http://redacacia.files.wordpress.com/2010/10/fig40.jpg?w=640" alt=""   /></a></p>
<p>Now with the right button of the mouse placed onto the published VI choose <em>Request Control of VI</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig41.jpg"><img class="aligncenter size-full wp-image-282" title="fig41" src="http://redacacia.files.wordpress.com/2010/10/fig41.jpg?w=640" alt=""   /></a></em></p>
<p><strong>STEP 30 </strong>- The grayed buttons of the image will now show up. Press the <em>run continuously button</em> <img src="http://redacacia.files.wordpress.com/2010/10/fig261.jpg?w=24&#038;h=24" alt="" width="24" height="24" /></p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig42.jpg"><img class="aligncenter size-full wp-image-284" title="fig42" src="http://redacacia.files.wordpress.com/2010/10/fig42.jpg?w=640" alt=""   /></a></p>
<p><strong>STEP 31 </strong>- Now press the virtual button on the VI</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig43.jpg"><img class="aligncenter size-full wp-image-285" title="fig43" src="http://redacacia.files.wordpress.com/2010/10/fig43.jpg?w=640" alt=""   /></a></p>
<p>The virtual LED on the switch button will light up</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig44.jpg"><img class="aligncenter size-full wp-image-286" title="fig44" src="http://redacacia.files.wordpress.com/2010/10/fig44.jpg?w=640" alt=""   /></a></p>
<p>The LED Circuit connected to DAQ device will also light up, having thus achieved remote control of the circuit</p>
<p><img src="http://redacacia.files.wordpress.com/2010/10/ledon.jpg?w=356&#038;h=294" alt="" width="356" height="294" /></p>
<p><strong>STEP 32 </strong>- Knowing the IP of the PC (and better fixing the IP)  one ought to be open the Labview’s page on the Internet.  If the PC is behind a router, one needs to make the adequate changes in the router, in order toall external demands to the local fixed IP.</p>
<p><strong>One last thing</strong></p>
<p>In order to view the LED switiching on and off a webcam setup is required. In order to stream video <a href="http://www.yawcam.com/">YAWCAM</a> freeware is advised.  Having the requirements mentioned on the YAMCAM website one can easily establish a streaming server. If the PC is behind a router the video streaming server port must be opened on the router.</p>
<p><strong>Conclusions</strong></p>
<p>Having designed a VI we have controlled a real world circuit with a virtual button on the VI. We next have achieved Internet control of the VI using the tools that Labview offers.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/269/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=269&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2010/10/15/internet-control-of-a-labview-vi-part-ii/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig29.jpg" medium="image">
			<media:title type="html">fig29</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig30.jpg" medium="image">
			<media:title type="html">fig30</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig31.jpg" medium="image">
			<media:title type="html">fig31</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig32.jpg" medium="image">
			<media:title type="html">fig32</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig33.jpg" medium="image">
			<media:title type="html">fig33</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig34.jpg" medium="image">
			<media:title type="html">fig34</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig35.jpg" medium="image">
			<media:title type="html">fig35</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig36.jpg" medium="image">
			<media:title type="html">fig36</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig37.jpg" medium="image">
			<media:title type="html">fig37</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig38.jpg" medium="image">
			<media:title type="html">fig38</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig39.jpg" medium="image">
			<media:title type="html">fig39</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig40.jpg" medium="image">
			<media:title type="html">fig40</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig41.jpg" medium="image">
			<media:title type="html">fig41</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig261.jpg" medium="image" />

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig42.jpg" medium="image">
			<media:title type="html">fig42</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig43.jpg" medium="image">
			<media:title type="html">fig43</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig44.jpg" medium="image">
			<media:title type="html">fig44</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/ledon.jpg" medium="image" />
	</item>
		<item>
		<title>Internet Control of a Labview VI (Part I)</title>
		<link>http://redacacia.wordpress.com/2010/10/14/internet-control-of-a-labview-vi/</link>
		<comments>http://redacacia.wordpress.com/2010/10/14/internet-control-of-a-labview-vi/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 21:31:02 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=225</guid>
		<description><![CDATA[Introduction Labview from National Instruments (NI) is build upon a purely graphical, general-purpose programming language, G, with extensive libraries of functions, an integral compiler and debugging, and an application builder for stand-alone applications. The concept of VIs (Virtual Instruments), invented &#8230; <a href="http://redacacia.wordpress.com/2010/10/14/internet-control-of-a-labview-vi/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=225&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Labview from National Instruments (NI) is build upon a purely graphical, general-purpose programming language, G, with extensive libraries of functions, an integral compiler and debugging, and an application builder for stand-alone applications. The concept of VIs (Virtual Instruments), invented by National Instruments, permits the building of powerful instrumentation and control to run anywhere and everywhere.</p>
<p><strong>Objectives</strong></p>
<p>Making use of Labview and DAQ (Data Acquisition) device, build a VI (Virtual Intrument) with a switch that lights up a LED.  The project is next extended to <a href="http://redacacia.wordpress.com/2010/10/15/internet-control-of-a-labview-vi-part-ii/">control the VI from Internet</a>.</p>
<p><strong>Pre-Requirements</strong></p>
<p>Installed Labview and DAQmx softwares, and a DAQ device duly working and recognised by Labview.</p>
<p><strong>Required Equipment</strong></p>
<p>NI Labview 8.6 Student or higher<br />
NI DAQmx 8.6 or higher<br />
NI USB-6009 DAQ device<br />
200 ohms 1/4W resistor<br />
5mm red LED</p>
<p><img src="http://redacacia.files.wordpress.com/2010/10/usb6009.gif?w=332&#038;h=302" alt="" width="332" height="302" /> <img src="http://redacacia.files.wordpress.com/2010/10/components.jpg?w=98&#038;h=151" alt="" width="98" height="151" /></p>
<p><strong>The Electronic Circuit </strong></p>
<p><strong><a href="http://redacacia.files.wordpress.com/2010/10/circuit1.jpg"><img class="aligncenter size-full wp-image-229" title="circuit" src="http://redacacia.files.wordpress.com/2010/10/circuit1.jpg?w=640" alt="Circuit diagram with indications of connections to USB-6009"   /></a></strong></p>
<p><strong>A Simple VI</strong></p>
<p><strong>STEP 1 </strong>- Start Labview</p>
<p><strong>STEP 2</strong> &#8211; A new window is opened <em>Getting Started </em></p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig1.jpg"><img class="aligncenter size-full wp-image-230" title="fig1" src="http://redacacia.files.wordpress.com/2010/10/fig1.jpg?w=640" alt="Getting Started window"   /></a></p>
<p><strong>STEP 3</strong> &#8211; Under Files menu, start a new VI pressing on <em>Blank VI</em> link. It will open the Front Panel of a new untitled blank VI.</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig2.jpg"><img class="aligncenter size-full wp-image-231" title="fig2" src="http://redacacia.files.wordpress.com/2010/10/fig2.jpg?w=640" alt="Frontal Panel"   /></a></p>
<p><strong>STEP 4 </strong>- On the Front Panel workspace, right click with mouse and choose Controls, <em>Buttons &amp; Switches -&gt; Push Button</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig3.jpg"><img class="aligncenter size-full wp-image-232" title="fig3" src="http://redacacia.files.wordpress.com/2010/10/fig3.jpg?w=640" alt="Adding push button"   /></a></em></p>
<p>Now place the <em>Push Button </em>on the Front Panel workspace</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig4.jpg"><img class="aligncenter size-full wp-image-233" title="fig4" src="http://redacacia.files.wordpress.com/2010/10/fig4.jpg?w=640" alt="Push button on Front Panel"   /></a></p>
<p><strong>STEP 5</strong> &#8211; On Window menu of Front Panel choose <em>Show Block Diagram</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig5.jpg"><img class="aligncenter size-full wp-image-234" title="fig5" src="http://redacacia.files.wordpress.com/2010/10/fig5.jpg?w=640" alt=""   /></a></em></p>
<p>Block Diagram window will be opened. It will already contain the Push Button function</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig6.jpg"><img class="aligncenter size-full wp-image-235" title="fig6" src="http://redacacia.files.wordpress.com/2010/10/fig6.jpg?w=640" alt=""   /></a></p>
<p><strong>STEP 6</strong> &#8211; Right click with mouse the Block Diagram workspace and choose <em>Functions &#8211; &gt; Input -&gt; DAQ Assistant</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig7.jpg"><img class="aligncenter size-full wp-image-236" title="fig7" src="http://redacacia.files.wordpress.com/2010/10/fig7.jpg?w=640" alt=""   /></a></em></p>
<p>Place adequately the <em>DAQ Assistant </em>function on the Block Diagram workspace. <em>DAQ Assistant </em>will be immediately initialized</p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig8.jpg"><img class="aligncenter size-full wp-image-237" title="fig8" src="http://redacacia.files.wordpress.com/2010/10/fig8.jpg?w=640" alt=""   /></a></em></p>
<p><strong>STEP 7 </strong>- Create New Express Task window will be opened. Choose <em>Generate Signals</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig9.jpg"><img class="aligncenter size-full wp-image-238" title="fig9" src="http://redacacia.files.wordpress.com/2010/10/fig9.jpg?w=640" alt=""   /></a></em></p>
<p><strong>STEP 8</strong><em> &#8211; </em>A sub-menu will be opened. Choose Digital Output</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig10.jpg"><img class="aligncenter size-full wp-image-242" title="fig10" src="http://redacacia.files.wordpress.com/2010/10/fig10.jpg?w=640" alt=""   /></a><strong>STEP 9 </strong>- Another sub-menu will be opened. Choose <em>Line Output</em>.</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig11.jpg"><img class="aligncenter size-full wp-image-243" title="fig11" src="http://redacacia.files.wordpress.com/2010/10/fig11.jpg?w=640" alt=""   /></a></p>
<p><strong>STEP 10</strong> - A new window will opened. Under <em>Supported Physical Channels</em> choose <em>port0line0</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig12.jpg"><img class="aligncenter size-full wp-image-244" title="fig12" src="http://redacacia.files.wordpress.com/2010/10/fig12.jpg?w=640" alt=""   /></a></em></p>
<p>Press <em>Finish</em></p>
<p><em> </em></p>
<p><strong>STEP 11 </strong>- A new window of DAQ Assistant will be opened</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig13.jpg"><img class="aligncenter size-full wp-image-245" title="fig13" src="http://redacacia.files.wordpress.com/2010/10/fig13.jpg?w=640" alt=""   /></a></p>
<p>Leave all default values as they are, and press OK.</p>
<p><strong>STEP 12 </strong>- Block Diagram will be opened, and VI will be build.</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig14.jpg"><img class="aligncenter size-full wp-image-246" title="fig14" src="http://redacacia.files.wordpress.com/2010/10/fig14.jpg?w=640" alt=""   /></a><strong>STEP 13 </strong>- Block Diagram will have now configured DAQ device.</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig15.jpg"><img class="aligncenter size-full wp-image-247" title="fig15" src="http://redacacia.files.wordpress.com/2010/10/fig15.jpg?w=640" alt=""   /></a><strong>STEP 14 </strong>- Connect Boolean function with data input of DAQ Assistant</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig16.jpg"><img class="aligncenter size-full wp-image-248" title="fig16" src="http://redacacia.files.wordpress.com/2010/10/fig16.jpg?w=640" alt=""   /></a></p>
<p>The link will be broken with an error message:</p>
<p><strong>“You have connected a scalar type to an array of that type. The type of the source is Boolean (TRUE or FALSE). The type of the sink is 1-D array of Boolean (True or False)”</strong></p>
<p>Hence we need to place the Boolean function in an Array.</p>
<p><strong>STEP 15 </strong>- Press the right button of the mouse on the link, and delete the link</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig17.jpg"><img class="aligncenter size-full wp-image-249" title="fig17" src="http://redacacia.files.wordpress.com/2010/10/fig17.jpg?w=640" alt=""   /></a>The Wire Branch will be removed</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig18.jpg"><img class="aligncenter size-full wp-image-250" title="fig18" src="http://redacacia.files.wordpress.com/2010/10/fig18.jpg?w=640" alt=""   /></a></p>
<p>Before doing anything else, it is safe to save the VI. Under File menu of the Block Diagram, choose Save as and save the VI as switchled_usb6009.vi</p>
<p><strong>STEP 16 </strong>- Press the right button of mouse and choose extra set of Controls clicking the button on the arrow pointing downwards, just below RF Communications controls</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig19.jpg"><img class="aligncenter size-full wp-image-251" title="fig19" src="http://redacacia.files.wordpress.com/2010/10/fig19.jpg?w=640" alt=""   /></a>Choose <em>Modern</em> -&gt; <em>Array, Matrix &amp; Cluster</em> -&gt; <em>Array</em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig20.jpg"><img class="aligncenter size-full wp-image-252" title="fig20" src="http://redacacia.files.wordpress.com/2010/10/fig20.jpg?w=640" alt=""   /></a></em><strong>STEP 17</strong> - Place it on the Front Panel workspace</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig21.jpg"><img class="aligncenter size-full wp-image-253" title="fig21" src="http://redacacia.files.wordpress.com/2010/10/fig21.jpg?w=640" alt=""   /></a></p>
<p>After selecting the Push Button <em>Boolean</em>, drag it and drop into Array box. The Push Button will become part of the Array</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig22.jpg"><img class="aligncenter size-full wp-image-254" title="fig22" src="http://redacacia.files.wordpress.com/2010/10/fig22.jpg?w=640" alt=""   /></a><strong>STEP 18 </strong>- Now select the Block Diagram</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig23.jpg"><img class="aligncenter size-full wp-image-255" title="fig23" src="http://redacacia.files.wordpress.com/2010/10/fig23.jpg?w=640" alt=""   /></a>Connect the new Array function (containing the Boolean <em>Push Button</em>) to <em>data</em> input of <em>DAQ Assistant</em> function. This time the link will show no error.</p>
<p><strong>STEP 19 </strong>- It is a good practise to place the functions within a While Loop with a STOP button.  Right click with mouse button on the Block Diagram, and choose Execution Control &#8211; &gt; While Loop</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig24.jpg"><img class="aligncenter size-full wp-image-256" title="fig24" src="http://redacacia.files.wordpress.com/2010/10/fig24.jpg?w=640" alt=""   /></a></p>
<p>Place the While Loop around Array and DAQ Assistant functions, starting from just on top left of Array function, and ending below DAQ Assistant function allowing automatic placing of stop button that comes with While Loop.</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig25.jpg"></a><a href="http://redacacia.files.wordpress.com/2010/10/fig251.jpg"><img class="aligncenter size-full wp-image-258" title="fig25" src="http://redacacia.files.wordpress.com/2010/10/fig251.jpg?w=640" alt=""   /></a><strong>STEP 20 </strong>- The Front Panel will contain now a STOP button. Place it appropriately and resize it</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig27.jpg"></a><a href="http://redacacia.files.wordpress.com/2010/10/fig26a.jpg"><img class="aligncenter size-full wp-image-260" title="fig26a" src="http://redacacia.files.wordpress.com/2010/10/fig26a.jpg?w=640" alt=""   /></a></p>
<p><strong>STEP 21 </strong>- Hopefully it is all OK now and we can save the VI, in Front Panel with <em>File -&gt;  Save</em></p>
<p><strong>STEP 22</strong><em> &#8211; </em>Press the virtual button run continuously<em> <img src="http://redacacia.files.wordpress.com/2010/10/fig26.jpg?w=24&#038;h=24" alt="" width="24" height="24" /></em></p>
<p><em><a href="http://redacacia.files.wordpress.com/2010/10/fig271.jpg"><img class="aligncenter size-full wp-image-262" title="fig27" src="http://redacacia.files.wordpress.com/2010/10/fig271.jpg?w=640" alt=""   /></a></em></p>
<p>and then press the virtual button and the arrow with light up</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/fig28.jpg"><img class="aligncenter size-full wp-image-263" title="fig28" src="http://redacacia.files.wordpress.com/2010/10/fig28.jpg?w=640" alt=""   /></a></p>
<p>And so will light up the LED in the real circuit</p>
<p><a href="http://redacacia.files.wordpress.com/2010/10/ledon.jpg"><img class="aligncenter size-full wp-image-264" title="ledon" src="http://redacacia.files.wordpress.com/2010/10/ledon.jpg?w=640" alt=""   /></a></p>
<p><strong>Conclusions</strong></p>
<p>With just a couple of electronic components and NI tools, we have build step by step a Virtual Instruments (VI).  It is is is quite easy with the graphic programming language of Labview.</p>
<p>We will next control the <a href="http://redacacia.wordpress.com/2010/10/15/internet-control-of-a-labview-vi-part-ii/">VI from Internet </a>using the tools that Labview offers.<em></em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/225/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=225&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2010/10/14/internet-control-of-a-labview-vi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/usb6009.gif" medium="image" />

		<media:content url="http://redacacia.files.wordpress.com/2010/10/components.jpg" medium="image" />

		<media:content url="http://redacacia.files.wordpress.com/2010/10/circuit1.jpg" medium="image">
			<media:title type="html">circuit</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig1.jpg" medium="image">
			<media:title type="html">fig1</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig2.jpg" medium="image">
			<media:title type="html">fig2</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig3.jpg" medium="image">
			<media:title type="html">fig3</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig4.jpg" medium="image">
			<media:title type="html">fig4</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig5.jpg" medium="image">
			<media:title type="html">fig5</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig6.jpg" medium="image">
			<media:title type="html">fig6</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig7.jpg" medium="image">
			<media:title type="html">fig7</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig8.jpg" medium="image">
			<media:title type="html">fig8</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig9.jpg" medium="image">
			<media:title type="html">fig9</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig10.jpg" medium="image">
			<media:title type="html">fig10</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig11.jpg" medium="image">
			<media:title type="html">fig11</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig12.jpg" medium="image">
			<media:title type="html">fig12</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig13.jpg" medium="image">
			<media:title type="html">fig13</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig14.jpg" medium="image">
			<media:title type="html">fig14</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig15.jpg" medium="image">
			<media:title type="html">fig15</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig16.jpg" medium="image">
			<media:title type="html">fig16</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig17.jpg" medium="image">
			<media:title type="html">fig17</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig18.jpg" medium="image">
			<media:title type="html">fig18</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig19.jpg" medium="image">
			<media:title type="html">fig19</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig20.jpg" medium="image">
			<media:title type="html">fig20</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig21.jpg" medium="image">
			<media:title type="html">fig21</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig22.jpg" medium="image">
			<media:title type="html">fig22</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig23.jpg" medium="image">
			<media:title type="html">fig23</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig24.jpg" medium="image">
			<media:title type="html">fig24</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig251.jpg" medium="image">
			<media:title type="html">fig25</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig26a.jpg" medium="image">
			<media:title type="html">fig26a</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig26.jpg" medium="image" />

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig271.jpg" medium="image">
			<media:title type="html">fig27</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/fig28.jpg" medium="image">
			<media:title type="html">fig28</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/ledon.jpg" medium="image">
			<media:title type="html">ledon</media:title>
		</media:content>
	</item>
		<item>
		<title>Access Control with RFID Tags</title>
		<link>http://redacacia.wordpress.com/2010/10/10/read-rfid-tags-in-processing/</link>
		<comments>http://redacacia.wordpress.com/2010/10/10/read-rfid-tags-in-processing/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 18:32:22 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=208</guid>
		<description><![CDATA[Introduction It is quite easy to read IDs of RFID tags, using Parallax&#8217;s serial or USB RFID card reader. If you have two RFID cards at least, and of course Parallax RFID reader, you can set up, without hassle, the &#8230; <a href="http://redacacia.wordpress.com/2010/10/10/read-rfid-tags-in-processing/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=208&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>It is quite easy to read IDs of RFID tags, using Parallax&#8217;s <a href="http://www.aliatron.com/loja/catalog/advanced_search_result.php?keywords=RFID&amp;search_in_description=1">serial or USB RFID card reader</a>. If you have two RFID cards at least, and of course Parallax RFID reader, you can set up, without hassle, the below described project. This blog contains several articles that show how easy it is, to control and communicate with electronic devices with <a href="http://processing.org">Processing</a>.</p>
<p><strong>Objectives</strong></p>
<p>Read RFID cards, using serial communications of Processing and Parallax RFID Card Reader, and show  useful information on-screen with user interaction.</p>
<p><strong>Pre-Requirements</strong></p>
<p>Installed Processing environment, <a href="http://www.aliatron.com/loja/catalog/advanced_search_result.php?keywords=RFID&amp;search_in_description=1">RFID Card Reader USB #28340</a> from Parallax, at least 2 RFID Cards, and a USB cable for connecting between RFID Card Reader and PC.</p>
<p>&nbsp;</p>
<div id="attachment_209" class="wp-caption aligncenter" style="width: 310px"><a href="http://redacacia.files.wordpress.com/2010/10/rfid_setup.gif"><img class="size-medium wp-image-209" title="RFID_setup" src="http://redacacia.files.wordpress.com/2010/10/rfid_setup.gif?w=300&#038;h=150" alt="" width="300" height="150" /></a><p class="wp-caption-text">The Experimental Set</p></div>
<p>&nbsp;</p>
<p><strong>Connecting to PC</strong></p>
<p>The RFID Card Reader when correctly installed will be shown as a serial device.  Check the port number where the RFID reader is connected in <strong>Control Panel </strong>- &gt; <strong>System</strong><em> &#8211; &gt; </em><strong>Hardware</strong> tab -&gt; <strong>Device Manager</strong> button -&gt; <strong>Ports (COM and LPT)<em>. </em></strong>In this experiment the serial port was COM4. After cheking the port number you just need to take note of it to be introduced into next Processing sketch.</p>
<p><strong>The Processing Sketch</strong></p>
<p>Start a new sketch in <strong>Processing, </strong>and save it as <strong>rfid</strong>.<strong>pde. </strong></p>
<p>The code for <strong>rfid.pde</strong>:</p>
<p><pre class="brush: plain;">

// Sketch code based on the one found in &quot;Reading RFID Tags in Processing&quot; chapter
// of the book Making Things Talk published by O'Reilly

import processing.serial.*;

Serial myPort;
String tagID=&quot;&quot;;

void setup() {
size(350,150);
myPort = new Serial(this, &quot;COM4&quot;, 2400);
myPort.buffer(12);

PFont myFont = createFont(PFont.list()[2], 24);
textFont(myFont);
}

void draw(){
background(0);
text(tagID, width/4 + 12, height/2 - 24);
}

void serialEvent(Serial myPort) {
tagID = trim(myPort.readString());
}

</pre></p>
<p>Make the adequate COM port changes in your sketch line 8 <strong>myPort = new Serial(this, &#8220;COM4&#8243;, 2400);</strong><br />
to your PC&#8217;s installed RFID Card COM port number. Run the sketch and check the TagIDs of both cards. In this case the codes obtained were 34009EA5AF and 0F00296C9FF. The former was chosen as valid card for next sketch. In your case it will be another number.</p>
<p>We will next produce our final sketch. Start a new Sketch in <strong>Processing </strong>and save it as <strong>rfid1.pde</strong></p>
<p>TTS library is required to add voice to the project. <a href="http://www.local-guru.net/blog/pages/ttslib">TTSLib from GuruBlog</a> is used. Install the unzipped file into your <strong>libraries</strong> folder of <strong>Processing.</strong> The library will be imported by Processing. Add image (in this case 100&#215;100 tayeb.jpg is used) to your Processing projects folder, usually found under my Documents\Processing.</p>
<p>Our folder here will be rfid1.</p>
<p>So here is the code for our final <strong>rfid1.pde </strong>sketch:</p>
<p><pre class="brush: plain;">
// Sketch code based on the one found in &quot;Reading RFID Tags in Processing&quot; chapter
// of the book Making Things Talk published by O'Reilly
// Library TTSLib from GuruBlog found at http://www.local-guru.net/blog/pages/ttslib is required

import processing.serial.*;
import guru.ttslib.*;

TTS tts;
Serial myPort;
String tagID=&quot;&quot;;

void setup() {
size(350,150);
myPort = new Serial(this, &quot;COM4&quot;, 2400);
myPort.buffer(12);

PFont myFont = createFont(PFont.list()[2], 24);
textFont(myFont);
smooth();
tts = new TTS();

}

void draw(){
background(0);

if (tagID.equals(&quot;34009EA5AF&quot;)) {
PImage b;
b = loadImage(&quot;tayeb.jpg&quot;);
image(b, 20, 20);
text(tagID, width/2 - 6, height/2 - 24);
text(&quot;TAYEB&quot;, width/2 - 6, height/2);
}
else {
text(tagID, width/4 + 6, height/2 + 12);
}
}
void serialEvent(Serial myPort) {
tagID = trim(myPort.readString());
if (tagID.equals(&quot;34009EA5AF&quot;)) {

tts.speak(&quot;Hi! Welcome Tayeb!&quot;);
}

else {
tts.speak(&quot;Invalid Card!&quot;);
}
}

</pre></p>
<p>Make the adequate changes as shown below in following images:</p>
<p>&nbsp;</p>
<div id="attachment_211" class="wp-caption aligncenter" style="width: 508px"><a href="http://redacacia.files.wordpress.com/2010/10/sketch.gif"><img class="size-full wp-image-211" title="sketch" src="http://redacacia.files.wordpress.com/2010/10/sketch.gif?w=640" alt=""   /></a><p class="wp-caption-text">Port number of installed RFID reader</p></div>
<p>&nbsp;</p>
<div id="attachment_213" class="wp-caption aligncenter" style="width: 508px"><a href="http://redacacia.files.wordpress.com/2010/10/sketch11.gif"><img class="size-full wp-image-213" title="sketch1" src="http://redacacia.files.wordpress.com/2010/10/sketch11.gif?w=640" alt=""   /></a><p class="wp-caption-text">Other required changes</p></div>
<p>&nbsp;</p>
<p>Now run the sketch. If you read the cards you will hear voice. In this case &#8220;Invalid card!&#8221; or &#8220;Hi Welcome Tayeb!&#8221;., or whatever name you have chosen. In our project with sketch code as above, the follow results were drawn on the PC&#8217;s screen:</p>
<p>&nbsp;</p>
<div id="attachment_214" class="wp-caption aligncenter" style="width: 366px"><a href="http://redacacia.files.wordpress.com/2010/10/valid_card.gif"><img class="size-full wp-image-214" title="valid_card" src="http://redacacia.files.wordpress.com/2010/10/valid_card.gif?w=640" alt=""   /></a><p class="wp-caption-text">Valid card</p></div>
<p>&nbsp;</p>
<div id="attachment_215" class="wp-caption aligncenter" style="width: 366px"><a href="http://redacacia.files.wordpress.com/2010/10/invalid_card.gif"><img class="size-full wp-image-215" title="invalid_card" src="http://redacacia.files.wordpress.com/2010/10/invalid_card.gif?w=640" alt=""   /></a><p class="wp-caption-text">Invalid card</p></div>
<p>&nbsp;</p>
<p>In fact any other RFID card, besides the chosen one, will be considered invalid.</p>
<p><strong>Conclusions</strong></p>
<p>Though this actual project is quite simple and the code is not neat, bub it can ve improved. As something extra and quite simple one could add a <a href="http://aliatron.com/loja/catalog/product_info.php?products_id=352">serial controlled relay</a> or another micrcontroller controlled device.</p>
<p>Of course projects with Visual C#, and other programming languages, can be made to talk to RFID cards, and be quite sophisticated. Some useful RFID projects can be attendance control, stock control, livestock identification, etc.</p>
<p>RFIDs are here to stay, and are everywhere these days. It is quite important to learn to work with them.</p>
<p><strong>Acknowledgements</strong></p>
<p>A special thanks is due to Tom Igoe, author of O&#8217;Reilly&#8217;s  book<a href="http://www.amazon.co.uk/Making-Things-Talk-Practical-Connecting/dp/0596510519/ref=cm_cr_pr_pb_t">&#8220;Making Things Talk&#8221;</a> for the code with Processing.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=208&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2010/10/10/read-rfid-tags-in-processing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/rfid_setup.gif?w=300" medium="image">
			<media:title type="html">RFID_setup</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/sketch.gif" medium="image">
			<media:title type="html">sketch</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/sketch11.gif" medium="image">
			<media:title type="html">sketch1</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/valid_card.gif" medium="image">
			<media:title type="html">valid_card</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/10/invalid_card.gif" medium="image">
			<media:title type="html">invalid_card</media:title>
		</media:content>
	</item>
		<item>
		<title>Bluemote &#8211; remote control of a 8051 robot with bluetooth</title>
		<link>http://redacacia.wordpress.com/2010/09/21/bluemote-remote-control-of-a-8051-robot-with-bluetooth/</link>
		<comments>http://redacacia.wordpress.com/2010/09/21/bluemote-remote-control-of-a-8051-robot-with-bluetooth/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 12:34:40 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=183</guid>
		<description><![CDATA[Pedro Vicente About the author: Pedro Vicente, 21 years old,  is a 3rd year Electrical Engineering student at Institutto Superior Tecnico (IST), Lisbon, Portugal. During the Summer of 2010 spent a month at ALIATRON as a trainee, when among other &#8230; <a href="http://redacacia.wordpress.com/2010/09/21/bluemote-remote-control-of-a-8051-robot-with-bluetooth/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=183&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="mceTemp" style="text-align:center;">
<dl class="wp-caption alignleft">
<dt class="wp-caption-dt"><a href="http://redacacia.files.wordpress.com/2010/09/pedro.png"><img class="size-thumbnail wp-image-184" title="Pedro Vicente" src="http://redacacia.files.wordpress.com/2010/09/pedro.png?w=150&#038;h=131" alt="" width="150" height="131" /></a></dt>
<dd class="wp-caption-dd">Pedro Vicente</dd>
</dl>
</div>
<p><strong>About the author: </strong></p>
<p>Pedro Vicente, 21 years old,  is a 3rd year Electrical Engineering student at <a href="http://www.ist.utl.pt/">Institutto Superior Tecnico (IST)</a>, Lisbon, Portugal. During the Summer of 2010 spent a month at <a href="http://www.aliatron.pt">ALIATRON</a> as a trainee, when among other projects did the one being presented here.  His main interestes are obviously electronics and robotics. His hobby is to play music: he plays piano, and trombone. Pedro is also member of a choir group.</p>
<p><strong> </strong><strong>Introduction</strong></p>
<p>The aim of this project was to experiment with a control system using bluetooth communication, firstly with simple PC control, and then with web control, after setting up a webserver.</p>
<p>A practical example was used: a 8051 robot &#8220;<a href="http://aliatron.com/loja/catalog/product_info.php?products_id=475">Robo-51</a>&#8220;, from <a href="http://www.inexglobal.com">Inex</a>, and distributed in Portugal by <a href="http://www.ist.utl.pt/">Aliatron</a>. The bluetooth device used was a serial type &#8220;<a href="http://aliatron.com/loja/catalog/product_info.php?products_id=868">ZX-Bluetooth</a>&#8220;, also from <a href="http://www.inexglobal.com">Inex</a>, and a product sold by <a href="http://www.aliatron.pt">Aliatron</a>.</p>
<p><strong>The Experimental Setup</strong></p>
<p> - Robot-51, <em>Inex</em><br />
-  Zx-Bluetooth, <em>Inex</em><br />
-  Bluetooth Micro Adapter Class I,<em> </em>Sweex<br />
-  BlueSoleil 5.4 (software)<br />
-  Termite 2.4 (software)<br />
-  SerialTerm (software)<br />
-  XAMPP server (software)<br />
-  RIDE 51 V6.1 compiler, <em>Raissonance </em>(software)<br />
-  FLIP V2.2, programmer <em>Atmel </em>(software)</p>
<div class="wp-caption aligncenter" style="width: 310px"><img title="robo51" src="http://redacacia.files.wordpress.com/2010/09/robo51.gif?w=300&#038;h=240" alt="Robo-51" width="300" height="240" /><p class="wp-caption-text">Robo-51 from Inex</p></div>
<div class="wp-caption aligncenter" style="width: 160px"><a href="http://redacacia.files.wordpress.com/2010/09/zx-bluetooth_01.gif"><img title="zx-bluetooth_01" src="http://redacacia.files.wordpress.com/2010/09/zx-bluetooth_01.gif?w=150&#038;h=120" alt="ZX-Bluetooth" width="150" height="120" /></a><p class="wp-caption-text">Serial Bluetooth &quot;ZX-Bluetooth&quot; from Inex</p></div>
<div id="attachment_189" class="wp-caption aligncenter" style="width: 160px"><a href="http://redacacia.files.wordpress.com/2010/09/microadapter.gif"><img class="size-thumbnail wp-image-189" title="microadapter" src="http://redacacia.files.wordpress.com/2010/09/microadapter.gif?w=150&#038;h=143" alt="Bluetooth Micro Adapter" width="150" height="143" /></a><p class="wp-caption-text">Class I Bluetooth Micro Adapter from Sweex</p></div>
<p><strong>The Experiment Itself</strong></p>
<p>An original library of &#8220;Robo-51&#8243; for infrared control was modified to interpret the data received from serial bluetooth device &#8220;ZX-Bluetooth&#8221;. The library named as <strong>remoteb.h,</strong> has the following code:</p>
<p><pre class="brush: plain;">

/*--------------------------------------------------------------------------*/

// Program             : Decode command from Bluetooth

// Description       : receive command from Bluetooth to control robot

// Filename            : remoteb.h

// C compiler         : RIDE 51 V6.1

// Adapted to bluetooth with baudrate 9600 bps by Pedro Vicente

/*--------------------------------------------------------------------------*/

sbit irm_data = P3^2;          // Define port input remote sensor

unsigned char ir_command=0;         // Define for buffer command from Easy remote

/*****************************************************************************/

/****************** Function Delay for baudrate 9600 *************************/

/*****************************************************************************/

void delay_baud9600()      {                              // Delay baudrate 9600 bps

                unsigned int x,a;                                 // Keep for counter loop

                for(x=0;x&lt;1;x++) {

                                for(a=0;a&lt;91;a++);              // Loop for delay 104 us  // inicially at 833 us

                }

}

/*****************************************************************************/

/****************** Function Delay for baudrate 9600(for start bit) **********/

/*****************************************************************************/

void start_9600()  {                                            // Delay baudrate 9600 while start bit

                unsigned int x,a;                                 // Keep for counter loop

                for(x=0;x&lt;1;x++) {

                                for(a=0;a&lt;46;a++);              // Loop for delay 53us //inicially at 416 us

                }

}

/*****************************************************************************/
/************* Service interrupt routine for receive command ******************/
/*****************************************************************************/
void service_ex0(void) interrupt 0 {
unsigned char i;   // Define for counter loop
if(irm_data==0) {   // Check start bit true?
  		start_9600();  		// Delay for start bit
  		for(i=0;i&lt;8;i++)  {		// For loop count 8 time(for receive data 8 bit)
  			delay_baud9600(); 		// Delay for data 1 bit
  			ir_command = ir_command&gt;&gt;1;		// Shift data bit to right 1 time
  			if(irm_data)				// If data bit = high
  			ir_command = ir_command | 0x80;		// Config data bit = &quot;1&quot;
  		}
		delay_baud9600();				// Delay for stop bit
	}
}
/*****************************************************************************/
/************** Function read Command from Bluetooth ***********************/
/*****************************************************************************/
unsigned char get_remote(void) {
	return(ir_command);		// Return command
}
/*****************************************************************************/
/*********************** Function clear command ******************************/
/*****************************************************************************/
void clear_remote() {
	ir_command = 0;         // Clear command
}

/*****************************************************************************/
/*********************** Function initial for Bluetooth ********************/
/*****************************************************************************/
void remote_init(void) {
	irm_data = 1;   	// Configuration input P3.2
	EX0 = 1;        	// Enable External interrupt0
	IT0 = 1;         	 // Detect falling edge
	EA = 1;		// Enable interrupt all
}

</pre></p>
<p>Next a firmwware program in C was written for the 8051 microcontroller in &#8220;Robo-51&#8243;, named as <strong>act19_bl.c</strong>:</p>
<p><pre class="brush: plain;">

/*--------------------------------------------------------------------------*/

// Program: Remote control robot

// Description : Robot controlled by Bluetooth control

//Robot receive command  from bluetooth by serial communication at baudrate 9600 bps 

// Filename: Bluemote.c

// C compiler: RIDE 51 V6.1

/*--------------------------------------------------------------------------*/

#include &lt;C51ac2.h&gt;                          // Header include register of T89C51AC2

#include &lt;delay_robo51.h&gt;              // Module function delay process

#include &lt;dc_motor.h&gt;                      // Module function drive DC motor

#include &lt;remoteb.h&gt;                        // Module function for remote

#include &lt;sound_robo51.h&gt;            // Module function drive sound

#include &lt;lcd_robo51.h&gt;                   // Module function LCD

#define pow 200                                  // Define constant for power drive DC motor

void run_fd(int time_spin) {

                motor_fd(2,pow);                                // Motor channel 2 forward

                motor_fd(1,pow);                                // Motor channel 1 forward

                delay_ms(time_spin);                        // Delay time for robot drive forward

}

void run_bk(int time_spin) {

                motor_bk(2,pow);                               // Motor channel 2 backward

                motor_bk(1,pow);                               // Motor channel 1 backward

                delay_ms(time_spin);                         // Delay time for robot drive backward

}

void turn_left(int time_spin) {

                motor_fd(2,pow);                                // Motor channel 2 forward

                motor_bk(1,pow);                               // Motor channel 1 backward

                delay_ms(time_spin);                         // Delay time for robot spin turn left

}

void turn_right(int time_spin) {

                motor_bk(2,pow);                               // Motor channel 2 backward

                motor_fd(1,pow);                                // Motor channel 1 forward

                delay_ms(time_spin);                         // Delay time for robot spin turn right

}

void main() {

beep();                                                  // Sound beep 1 time

                remote_init();                                       // Initial remote

                lcd_init();                                             // Initial Lcd

                while(1)  {                                            // Infinite loop

                                switch(get_remote()) {       // Check command for receive

                               case 'a'  :run_bk(100);         // Drive robot backward when receive command &quot;a&quot; 

                                               clear_remote();     // Clear command

                                               break;                    // Out from case

                               case 'b' : turn_right(100);                   // Turn right when receive command &quot;b&quot;

                                               clear_remote();                    // Clear command

                                               break;                                    // Out from case

                               case 'c' : turn_left(100);                      // Turn right when receive command &quot;c&quot;

                                               clear_remote();                    // Clear command

                                               break;                                    // Out from case

                               case 'd' : run_fd(100);                         // Turn right when receive command &quot;d&quot;

                                               clear_remote();                    // Clear command

                                               break;                                    // Out from case

                               case 's':  motor_stop(all);                  // robot stop

                                               clear_remote();                    // Clear command

                                               break;                                    // Out from case

                               default:  break;                                    // Out from case

                               }

}

</pre></p>
<p>For more details on the main program, plus programming the robot &#8220;Robo-51,&#8221; and many other applications for the robot, check the <a href="http://www.inexglobal.com/downloads/rb51_e20s.pdf">&#8220;Robo-51&#8243; manual </a> found at Inex’s online site. You will find there the other required libraries which will be needed to be included into the project.</p>
<p>We use the software <a href="http://www.raisonance.com/mcu_downloads.html">RIDE from Raissonance</a> to compile the above *.c file (plus the library *.h), and the Atmel’s software <a href="http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3886">FLIP from Atmel</a> to load the program into the 8051 microcontroller of &#8220;Robo-51&#8243;.</p>
<p>To test the program in 8051, <a href="http://www.windows7download.com/win7-termite/ekejdiwv.html">Termite 2.4</a> and <a href="http://www.comp.lancs.ac.uk/~albrecht/sw/terminal/index.html">SerialTerm</a> were used. Both programs are used to test serial communications in micrcontrollers, and were quite handy in this case. Commands were sent to the robot, by writing on the keyboard. (check below first part of the video)</p>
<p><span style="text-decoration:underline;">Important Note: </span> Set serial ports with baudrate at 9600 bps as ZX-Bluetooth works only at this baud rate. In our case the serial port used was COM2.</p>
<p> The next step would be to make automatic the sending of commands, instead of writting the commands and pressing Click or ENTER. We used the following Visual Basic Scripts (VBS) to send the commands. This VBS  procedure was proposed by Bill Blanton in the <a href="http://us.generation-nt.com/answer/keyboard-redirection-dos-batch-file-help-197975321.html">GNT forum</a>. These VBS send commands with ley letters “d”  for foward, “a” for backward, “c” for turning leftwards, “b” for turning rightwards and “s” for stopping.</p>
<p><pre class="brush: plain;">

/*--------------------------------------------------------------------------*/

// Program: Send letter to serial port

// Description: Send “d” to serial port to move foward

// Filename: fw.vbs

/*--------------------------------------------------------------------------*/

Set oShell = WScript.CreateObject(&quot;WScript.Shell&quot;)

oShell.Run(&quot;C:\r51\serialterm com2 9600&quot;)

WScript.Sleep(500) 'wait (0.5 seconds (# milliseconds))

oShell.Sendkeys &quot;d&quot;

oShell.Sendkeys&quot;{ESC}&quot;

</pre></p>
<p> </p>
<p><pre class="brush: plain;">

/*--------------------------------------------------------------------------*/

// Program: Send letter to serial port

// Description: Send “a” to serial port to move backward

// Filename: bk.vbs

/*--------------------------------------------------------------------------*/

Set oShell = WScript.CreateObject(&quot;WScript.Shell&quot;)

oShell.Run (&quot;C:\r51\serialterm com2 9600&quot;)

WScript.Sleep(500) 'wait (0.5 seconds (# milliseconds))

oShell.Sendkeys &quot;a&quot;

oShell.Sendkeys&quot;{ESC}&quot;

</pre></p>
<p> </p>
<p><pre class="brush: plain;">

/*--------------------------------------------------------------------------*/

// Program: Send letter to serial port

// Description: Send “b” to serial port to turn rigth

// Filename: rg.vbs

/*--------------------------------------------------------------------------*/

Set oShell = WScript.CreateObject(&quot;WScript.Shell&quot;)

oShell.Run (&quot;C:\r51\serialterm com2 9600&quot;)

WScript.Sleep(500) 'wait (0.5 seconds (# milliseconds))

oShell.Sendkeys &quot;b&quot;

oShell.Sendkeys&quot;{ESC}&quot;

</pre></p>
<p> </p>
<p><pre class="brush: plain;">

/*--------------------------------------------------------------------------*/

// Program: Send letter to serial port

// Description: Send “c” to serial port to turn left

// Filename: lf.vbs

/*--------------------------------------------------------------------------*/

Set oShell = WScript.CreateObject(&quot;WScript.Shell&quot;)

oShell.Run (&quot;C:\r51\serialterm com2 9600&quot;)

WScript.Sleep(500) 'wait (0.5 seconds (# milliseconds))

oShell.Sendkeys &quot;c&quot;

oShell.Sendkeys&quot;{ESC}&quot;

</pre></p>
<p> </p>
<p><pre class="brush: plain;">

/*--------------------------------------------------------------------------*/

// Program: Send letter to serial port

// Description: Send “s” to serial port to stop

// Filename: st.vbs

/*--------------------------------------------------------------------------*/

Set oShell = WScript.CreateObject(&quot;WScript.Shell&quot;)

oShell.Run (&quot;C:\r51\serialterm com2 9600&quot;)

WScript.Sleep(500) 'wait (0.5 seconds (# milliseconds))

oShell.Sendkeys &quot;s&quot;

oShell.Sendkeys&quot;{ESC}&quot;
</pre></p>
<p>Having achieved PC control of  &#8220;Robo-51&#8243;, a web server was setup in order to control de robot though Internet. The Internet control of &#8220;Robo-51&#8243; was achieved with an approach based on published work here <a href="https://redacacia.wordpress.com/2010/08/05/internet-control-of-a-picaxe/">Internet Control of a Picaxe</a> by Tayeb Habib.</p>
<p><strong>The main server</strong></p>
<p>A Windows-based <a href="https://redacacia.wordpress.com/2010/08/05/internet-control-of-a-picaxe/www.apachefriends.org/en/xampp-windows.html">XAMPP</a> server was installed in a PC. The server was hooked to a local network with a fixed local IP. The application being situated in a network that had no fixed public IP, <a href="http://www.dyndns.com/">DynDNS</a> services were used. The router routes all external demands to the local fixed IP.</p>
<p>Windows XP and later do not allow easy RS232 control through Internet. To  overcome such a blockage, RS232 control was done through DOS, using SerialTerm as mentioned above. The VB scripts of above were run in php, and used to command &#8220;Robo-51&#8243;. All of following files were placed in c:\xampp\htdocs</p>
<p><strong>index.php</strong></p>
<p><span style="color:#000000;"><pre class="brush: plain;">&lt;? php
echo &quot;&lt;head&gt;&lt;title&gt;Internet Control of a 8051 Robot&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;
&lt;font face=\&quot;arial, sans-serif\&quot; color=&gt;
&lt;h2 align='center'&gt;&lt;font color=\&quot;#4992BB\&quot;&gt;Internet Control of a 8051 Robot&lt;/font&gt;&lt;/h2&gt;
&lt;hr align='center' size=\&quot;4\&quot; color=\&quot;#4992BB\&quot;&gt;&lt;center&gt;
&lt;TABLE WIDTH=150 BORDER=0 CELLPADDING=0&gt;
&lt;TR&gt; &lt;TH COLSPAN=3&gt;&lt;font face=\&quot;arial, verdana\&quot; color=\&quot;#4992BB\&quot;&gt;Bluemote&lt;/font&gt;&lt;/TH&gt; &lt;/TR&gt;
&lt;TR&gt; &lt;TD&gt;&lt;/TD&gt;      &lt;TD&gt;&lt;a href='processing.php?action=fw'&gt;
&lt;img src='forw.gif' border='0'&gt;&lt;/a&gt;&lt;/TD&gt; &lt;TD&gt;&lt;/TD&gt;   &lt;/TR&gt;
&lt;TR&gt; &lt;TD&gt;&lt;a href='processing.php?action=rg'&gt; &lt;img src='right.gif' border='0'&gt;&lt;/a&gt;&lt;/TD&gt;     
&lt;TD&gt; &lt;a href='processing.php?action=st'&gt;&lt;img src='stop.gif' border='0'&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;a href='processing.php?action=lf'&gt; &lt;img src='left.gif' border='0'&gt;&lt;/a&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt; &lt;TD&gt;&lt;/TD&gt;  &lt;TD&gt;&lt;a href='processing.php?action=bk'&gt;
&lt;img src='back.gif' border='0'&gt;&lt;/a&gt;&lt;/TD&gt; &lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;/TABLE&gt;&lt;/center&gt;
&lt;hr align='center' size=\&quot;4\&quot; color=\&quot;#4992BB\&quot;&gt;

&lt;/center&gt;
&lt;/body&gt;

</pre></p>
<p><strong>processing.php</strong></p>
<p><pre class="brush: plain;">

&lt;?php 

//check the GET actions variable to see if something needs to be done 

if (isset($_GET['action'])) { 
//Action has been requested 

  
  if ($_GET['action'] == &quot;fw&quot;) { 

    $page = &quot;index.php&quot;; 

     header(&quot;Refresh: 2; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;); 

     exec ('C:\r51\fw.vbs'); 

      echo &quot;
          &lt;hr align='center' size=\&quot;4\&quot; color=\&quot;#4992BB\&quot;&gt;&lt;center&gt;
      &lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;Moving Forward&lt;/b&gt;&lt;/font&gt;&quot;; 

      } 

     else if ($_GET['action'] == &quot;bk&quot;) { 

     $page = &quot;index.php&quot;; 

     header(&quot;Refresh: 2; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;); 

     exec ('C:\r51\bk.vbs'); 

    echo &quot;
    &lt;hr align='center' size=\&quot;4\&quot; color=\&quot;#4992BB\&quot;&gt;&lt;center&gt;
    &lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;Moving Backward&lt;/b&gt;&lt;/font&gt;&quot;; 
    }
     else if ($_GET['action'] == &quot;st&quot;) { 

     $page = &quot;index.php&quot;; 

     header(&quot;Refresh: 2; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;); 

     exec ('C:\r51\st.vbs'); 

    echo &quot;
    &lt;hr align='center' size=\&quot;4\&quot; color=\&quot;#4992BB\&quot;&gt;&lt;center&gt;
    &lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;Stopping...&lt;/b&gt;&lt;/font&gt;&quot;; 
    }  
     else if ($_GET['action'] == &quot;rg&quot;) { 

     $page = &quot;index.php&quot;; 

     header(&quot;Refresh: 2; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;); 

     exec ('C:\r51\rg.vbs'); 

    echo &quot;
    &lt;hr align='center' size=\&quot;4\&quot; color=\&quot;#4992BB\&quot;&gt;&lt;center&gt;
    &lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;Turning Right&lt;/b&gt;&lt;/font&gt;&quot;; 
    }
     else if ($_GET['action'] == &quot;lf&quot;) { 

     $page = &quot;index.php&quot;; 

     header(&quot;Refresh: 2; URL=\&quot;&quot; . $page . &quot;\&quot;&quot;); 

     exec ('C:\r51\lf.vbs'); 

    echo &quot;
    &lt;hr align='center' size=\&quot;4\&quot; color=\&quot;#4992BB\&quot;&gt;&lt;center&gt;
    &lt;font face=\&quot;arial, sans-serif\&quot;&gt;&lt;b&gt;Turning Left&lt;/b&gt;&lt;/font&gt;&quot;; 
    }  
    }
?&gt;

</pre></p>
<p>Please note that *.vbs files must be in c:\r51  as can be seen in above VB scripts.</p>
<p>Finally the XAMPP server must be tested pointing the browser to <a href="http://localhost">http://localhost</a>. If all is OK the server can be put online.</p>
<p>Hull report is available at:</p>
<p><a href="http://aliatron.com/download/Bluemote_English.pdf">http://aliatron.com/download/Bluemote_English.pdf</a> (18MB)</p>
<p>A simulation of the application (useful to see how the appplication will look like) can be viewed at:</p>
<p><a href="http://aliatron.dynalias.com/r51">http://aliatron.dynalias.com/r51</a></p>
<p>The following video shows the application with &#8220;Robo-51&#8243;:</p>
<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/ZGFYZh66vdA?fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ZGFYZh66vdA?fs=1" type="application/x-shockwave-flash" width="640" height="505" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Acknowledgments</strong></p>
<p>A special thank you is due to Tayeb Habib owner of <a href="http://www.aliatron.pt"><span style="color:#800080;">Aliatron</span></a> and my supervisor for Summer traineeship at that portuguese company. Also I thank my former workmate at Aliatron, Raquel, for all the support and her welcome spirit.</p>
<p><em>Published in RedAcacia by Tayeb</em></p>
<p></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/183/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=183&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2010/09/21/bluemote-remote-control-of-a-8051-robot-with-bluetooth/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/09/pedro.png?w=150" medium="image">
			<media:title type="html">Pedro Vicente</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/09/robo51.gif?w=300" medium="image">
			<media:title type="html">robo51</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/09/zx-bluetooth_01.gif?w=150" medium="image">
			<media:title type="html">zx-bluetooth_01</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/09/microadapter.gif?w=150" medium="image">
			<media:title type="html">microadapter</media:title>
		</media:content>
	</item>
		<item>
		<title>Controlling a robot with bluetooth-enabled cell phone</title>
		<link>http://redacacia.wordpress.com/2010/09/15/controlling-a-robot-with-bluetooth-enabled-cell-phone/</link>
		<comments>http://redacacia.wordpress.com/2010/09/15/controlling-a-robot-with-bluetooth-enabled-cell-phone/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 13:13:48 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=163</guid>
		<description><![CDATA[Tested on Nokia N97 and Blackberry Bold 9700. Introduction After having recently designed a virtual gamepad to control a robot, making use of a serial bluetooth device, I thought why not do the same with a cell phone. My Nokia N97 &#8230; <a href="http://redacacia.wordpress.com/2010/09/15/controlling-a-robot-with-bluetooth-enabled-cell-phone/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=163&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em><strong>Tested on Nokia N97 and Blackberry Bold 9700.</strong></em></p>
<p><strong>Introduction</strong></p>
<p>After having recently designed a <a href="http://redacacia.wordpress.com/2010/09/07/bluemote-a-virtual-gamepad-for-bluetooth-control-of-a-robot/">virtual gamepad</a> to control a robot, making use of a serial bluetooth device, I thought why not do the same with a cell phone.</p>
<p>My <a href="http://europe.nokia.com/find-products/devices/nokia-n97">Nokia N97 </a>has bluetooth and using it to control the robot seemed to be the most attractive proposal.</p>
<p>My first development tool was <a href="http://www.mobilenin.com/pys60/pys60_installation_resources.php">Psy60</a> (Nokia&#8217;s Python), to control the robot, but soon I found out that the bluetooth libraries seemed to be geared towards controlling a PC.</p>
<p>So, effectively having gained experience with <a href="http://processing.org/">Processing</a>, my next immediate thought was to use <a href="http://mobile.processing.org/">Mobile Processing</a>, after having read about a <a href="http://todbot.com/blog/2006/09/12/roombactrl-drive-your-roomba-with-your-cell-phone/">Roomba hacking</a> and a patch for serial bluetooth library.</p>
<p>Please check addenda below: tested and verified on Blackberry Bold 9700.</p>
<p><strong>Required equipment</strong></p>
<p><span style="font-size:13px;font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;"> </span>A 8051 robot &#8220;<a href="http://aliatron.com/loja/catalog/product_info.php?products_id=475">Robo-51</a>&#8221; (could be a robot with any other micrcontroller) with <a href="http://aliatron.com/loja/catalog/product_info.php?products_id=868">ZX-Bluetooth</a> module, running a firmware for bluetooth control (or any other serial control), and PC with Windows and <a href="http://mobile.processing.org/">Mobile Processing</a> software.</p>
<div class="mceTemp mceIEcenter" style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;text-align:center;">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><img class="size-medium wp-image-153" style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;max-width:100%;border:0 none initial;margin:5px;padding:0;" title="robo51" src="http://redacacia.files.wordpress.com/2010/09/robo51.gif?w=300&#038;h=240" alt="Robo-51" width="300" height="240" /></dt>
<dd class="wp-caption-dd">8051-based robot &#8220;Robo-51&#8243;</dd>
</dl>
</div>
<div class="mceTemp mceIEcenter" style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;text-align:center;">
<dl class="wp-caption aligncenter">
<dt class="wp-caption-dt"><a style="color:#0066cc;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;" href="http://redacacia.files.wordpress.com/2010/09/zx-bluetooth_01.gif"><img style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;border:0 none initial;margin:5px;padding:0;" title="zx-bluetooth_01" src="http://redacacia.files.wordpress.com/2010/09/zx-bluetooth_01.gif?w=150&#038;h=120" alt="" width="150" height="120" /></a></dt>
<dd class="wp-caption-dd">Serial bluetooth module &#8220;ZX-Bluetooth&#8221;</dd>
</dl>
</div>
<p>Please check the <a href="http://redacacia.wordpress.com/2010/09/07/bluemote-a-virtual-gamepad-for-bluetooth-control-of-a-robot/">Virtual Gamepad</a> project. The sketch as explained in the first part of code is based on the <a href="http://todbot.com/blog/2006/09/12/roombactrl-drive-your-roomba-with-your-cell-phone/">Roomba hacking</a> and ideas from a <a href="http://nxt-symbian.sourceforge.net">NXT Symbian</a> project.  It uses the <a href="http://roombahacking.com/software/midlet/roombactrl-1.0-src.zip">patched bluetooth</a> library of Roomba project. All the patch does is to allow one to specify short UUIDs when searching bluetooth devices.</p>
<p><strong>Mobile Processing Sketch</strong></p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;">So here is the sketch:</p>
<p><pre class="brush: plain;">
// Based on original code Tic-Tac-Toe code by Francis Li, found at
// http://mobile.processing.org/learning/example.php?name=tictactoe
// and on roombaCtrl by Tod E. Kurt, tod@todbot.com
// http://roombahacking.com, and extra coding ideas from
// Pedro Miguel, ap0cn3t@gmail.com http://nxt-symbian.sourceforge.net
// code adapted for Robo-51 by Tayeb Habib, tayeb.habib@gmail.com
// http://redacacia.wordpress.com (check the site for more projects)
// compatibility tested for Nokia N97

// This needs my patched bluetooth library that allows short UUIDs
// found at http://roombahacking.com

import processing.bluetooth.*;

// state machine sates
final int STATE_START    = 0;
final int STATE_FIND     = 1;
final int STATE_DRIVE    = 2;

// state machine state var
int state;

// bluetooth library
Bluetooth bt;
// discovered services
Service[] services;
// status message
String msg;
// connection to robo51
Client cl;

PFont font;

// ------------------------------------------------------------------
// robo51 opcodes
// ------------------------------------------------------------------

byte[] fwd = new byte[]{ (byte)0x64 };   // ascii key letter &quot;d&quot;
byte[] bwd = new byte[]{ (byte)0x61 };   // ascii key letter &quot;a&quot;
byte[] left = new byte[]{ (byte)0x63 };   // ascii key letter &quot;c&quot;
byte[] right = new byte[]{ (byte)0x62 };   // ascii key letter &quot;b&quot;
byte[] stop = new byte[]{ (byte)0x73  };   // ascii key letter &quot;s&quot;

///
void setup() {
  font = loadFont();
  textFont(font);
  bt = new Bluetooth(this, Bluetooth.UUID_SERIALPORT);
  state = STATE_START;
}

void destroy() {
  background(255);
  fill(0);
  text(&quot;Exiting...&quot;, 2, 2, width - 4, height - 4);
  bt.stop();
}

//
void draw() {
  background(0xcc,0xcc,0xff);

  if (state == STATE_START) {
    fill(0);
    textAlign(LEFT);
    text(&quot;Welcome to Robo-51\n\nPress a key to search the robot&quot;, 2, 2, width - 4, height - 4);
  }
  else if (state == STATE_FIND) {
    fill(0);
    textAlign(LEFT);
    if (services == null) {
      text(&quot;Looking for Robo-51...\n\n&quot; + msg, 2, 2, width-4, height-4);
    }
    else {
      String list = &quot;Ports found:\n&quot;;
      for (int i = 0, len = length(services); i &lt; len; i++)
        list += i + &quot;. &quot; + services[i].device.name + &quot;\n&quot;;
      text(list, 2, 2, width-4, height-4);
    }
  }
  else if (state == STATE_DRIVE) {
    noFill();
    text(&quot;Robo-51 control:\n&quot;+
         &quot;Use arrows to drive\n&quot;+
         &quot;press A, or B, or C, or D to stop\n&quot;+
         msg, 2, 2, width-4, height-4);
  }

}

//
void libraryEvent(Object library, int event, Object data) {
  if (library == bt) {
    switch (event) {
    case Bluetooth.EVENT_DISCOVER_DEVICE:
      msg = &quot;Found device at: &quot; + ((Device) data).address + &quot;...&quot;;
      break;
    case Bluetooth.EVENT_DISCOVER_DEVICE_COMPLETED:
      msg = &quot;Found &quot; + length((Device[]) data) + &quot; devices, looking for serial port...&quot;;
      break;
    case Bluetooth.EVENT_DISCOVER_SERVICE:
      msg = &quot;Found serial port on &quot; + ((Service[]) data)[0].device.address + &quot;...&quot;;
      break;
    case Bluetooth.EVENT_DISCOVER_SERVICE_COMPLETED:
      services = (Service[]) data;
      msg = &quot;Search complete. Pick one.&quot;;
      break;
    case Bluetooth.EVENT_CLIENT_CONNECTED:
      cl = (Client) data;
      msg = &quot;wtf. client connectd.&quot;;
      break;
    }
  }
}

//

//
void keyPressed() {
  if (state == STATE_START) {
    services = null;
    bt.find();
    state = STATE_FIND;
    msg = &quot;Looking for devices...&quot;;
  }
  else if (state == STATE_FIND) {
    if (services != null) {
      if ((key &gt;= '0') &amp;&amp; (key &lt;= '9')) {
        int i = key - '0';
        if (i &lt; length(services)) {
          msg = &quot;connecting...&quot;;
          cl = services[i].connect();
          state = STATE_DRIVE;
          msg = &quot;ready&quot;;
        }
      }
    }
  }
  else if (state == STATE_DRIVE) {

    parse_robo51key(keyCode,key);

  }

}

void parse_robo51key(int akeyCode, int akey) {
  switch(akeyCode) {
    case UP:
      msg = &quot;forward&quot;;
      robo51_send(fwd);
      break;
    case DOWN:
      msg = &quot;backward&quot;;
      robo51_send(bwd);
      break;
    case LEFT:
      msg = &quot;left&quot;;
      robo51_send(left);
      break;
    case RIGHT:
      msg = &quot;right&quot;;
      robo51_send(right);
      break;
    case CENTER:
      msg = &quot;stop&quot;;
      robo51_send(stop);
      break;
    default:
      msg = &quot;stop&quot;;
      robo51_send(stop);
      break;

    } // switch(keyCode)
}

void robo51_send(byte[] buffer){
  cl.write(buffer);
  cl.flush();
}
</pre></p>
<p><strong>Deploying</strong></p>
<p>If you are absolute beginner with Mobile Processing I suggest you follow the tutorial &#8220;<a href="http://workshop.nseries.com/2008/01/how-to-write-apps-with-mobile-processing-on-your-n95/146">How to write apps with Mobile Processing on your N95</a>&#8221; (if the link does not work please check: <a href="http://itp.nyu.edu/~sve204/mobilemedia_spring09/week7.html">Mobile Application Development with Mobile Processing</a>) . The tutorial will teach you how to make simple Mobile Processing applications and to deploy into your cell phone.</p>
<p><strong>The control program</strong></p>
<p><span style="line-height:22px;">The program controls Robo-51 from Inex with the commands:</span></p>
<p><span style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:22px;">Key letter &#8220;d&#8221; foward, &#8220;a&#8221; backwards, &#8220;c&#8221; turn leftwards, &#8220;b&#8221; turn rightwards and &#8220;s&#8221; stop.  The commands are defined in the above sketch under &#8220;Robo-51 opcodes&#8221;. Arrow keys on N97 keyboard control the robot. The key ENTER on the N97 keyboard is used as FIRE button to stop the robot </span></p>
<p><span style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:22px;">When the program is launched, after it identifies the bluetooth devices, SPP device will appear with appropriate number 0, 1, 2 or whatever tag before it. One has to choose SPP with numeric option on N97 keyboard. </span></p>
<p>The firmware that accepts commands in above sketch was written by Pedro Vicente, a Summer vacation trainee in my company <a href="http://aliatron.pt">Aliatron</a>. Pedro has already published <a href="http://redacacia.wordpress.com/2010/09/21/bluemote-remote-control-of-a-8051-robot-with-bluetooth/">his project here</a>. The following video, recently published in youtube by Raquel (Pedro&#8217;s girlfriend), shows &#8220;Robo-51&#8243; in action:</p>
<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/ZGFYZh66vdA?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ZGFYZh66vdA?version=3" type="application/x-shockwave-flash" width="640" height="505" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The program on the PC&#8217;s screen shown in the video is an application written by Pedro that allows web control of Robo-51.</p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;"><span style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:22px;">I hope to next control the robot with a Psy60 program.  When it is done, I will publish it here. I have mentioned N97 as the program was tested with Nokia&#8217;s N97. Perhaps the program will work perfectly in other Nokia cell phones with Symbian OS (N97&#8242;s OS is Symbian).</span></p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><strong>Addenda on 06/07/2011:</strong></p>
<p>I have tested the unaltered jar file made for <strong>Nokia N97, </strong>on my <strong>Blackberry Bold 9700</strong> (v.6.6.0.124) by installing the jar file, after copying it into the cell phone&#8217;s memory. The robot responded well, and moved forward, backward, left and right, and stopped as expected with respective voice indicating the action. All the movements of the robot were made by playing with Blackberry&#8217;s joystick, i.e. track pad. The bluetooth connection of the Blackberry and the robot&#8217;s bluetooth serial module were duly detected. When the bluetooth connection on the Blackberry was not on, the cell phone asked for permission to switch it on, as was expected. Summing up: a fully satisfactory control of the robot is achieved with Blackberry Bold 9700. Implementations in other Bloackberry cell phones should give similar results.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p><strong>Addenda on 09/17/2010:</strong></p>
<p style="line-height:1.5;font-family:Georgia, 'Bitstream Charter', serif;margin-bottom:24px;color:#444444;font-size:16px;"><strong>Adding sound to the robot control</strong></p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;">In my previous project of <a href="http://redacacia.wordpress.com/2010/09/07/bluemote-a-virtual-gamepad-for-bluetooth-control-of-a-robot/">Virtual Gamepad</a> text-to-speech was added and so something similar would be interesting. So, effectively that&#8217;s what I did this time.</p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;"><strong>Text-to-speech</strong></p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;"><span style="color:#000000;">Though Nokia N97 supports text-to-speech, Mobile Processing has no library, as Psy60 has. </span></p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;"><span style="color:#000000;">I didn&#8217;t want to record sounds and make them sound &#8220;robotic&#8221;, so I searched the Web, and found a freeware that does it. Download &#8220;<a href="http://download.cnet.com/TTSReader/3000-7239_4-10686002.html">TTSReader</a>&#8221; and create .wav files for all the commands. All commands can be downloaded here (you will need <a href="http://www.7-zip.org/download.html">7z to uncompress</a>):</span></p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;"><span style="color:#000000;"><a href="http://aliatron.com/download/sound_files.7z">Sound files</a></span></p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;"><span style="color:#000000;">Copy these files into a sub-directory that you will name <em>data </em>in your<em> MobileProcessing</em> project folder (found normally under c:\my documents\.</span></p>
<p style="color:#444444;font-family:Georgia, 'Bitstream Charter', serif;line-height:1.5;font-size:16px;margin-bottom:24px;"><span style="color:#000000;">Now you are ready to follow the above steps with following new <strong>Mobile Processing</strong> <strong>sketch</strong>:</span></p>
<p><pre class="brush: plain;">

// New sketch with sound support
// Based on original code Tic-Tac-Toe code by Francis Li, found at
// http://mobile.processing.org/learning/example.php?name=tictactoe
// and on roombaCtrl by Tod E. Kurt, tod@todbot.com
// http://roombahacking.com, and extra coding ideas from
// Pedro Miguel, ap0cn3t@gmail.com http://nxt-symbian.sourceforge.net
// code adapted for Robo-51 by Tayeb Habib, tayeb.habib@gmail.com
// http://redacacia.wordpress.com (check the site for more projects)
// compatibility tested for Nokia N97

// This needs my patched bluetooth library that allows short UUIDs
// found at http://roombahacking.com and msound library found at
// http://mjs.darkgreenmedia.com/site/

import processing.bluetooth.*;
import mjs.processing.mobile.msound.*;

MSound mySound;

// state machine sates
final int STATE_START    = 0;
final int STATE_FIND     = 1;
final int STATE_DRIVE    = 2;

// state machine state var
int state;

// bluetooth library
Bluetooth bt;
// discovered services
Service[] services;
// status message
String msg;
// connection to robo51
Client cl;
PFont font;

// ------------------------------------------------------------------
// robo51 opcodes
// ------------------------------------------------------------------

byte[] fwd = new byte[]{ (byte)0x64 };   // ascii key letter &quot;d&quot;
byte[] bwd = new byte[]{ (byte)0x61 };   // ascii key letter &quot;a&quot;
byte[] left = new byte[]{ (byte)0x63 };   // ascii key letter &quot;c&quot;
byte[] right = new byte[]{ (byte)0x62 };   // ascii key letter &quot;b&quot;
byte[] stop = new byte[]{ (byte)0x73  };   // ascii key letter &quot;s&quot;

///
void setup() {
  font = loadFont();
  textFont(font);
  bt = new Bluetooth(this, Bluetooth.UUID_SERIALPORT);
  state = STATE_START;
  mySound = MSoundManager.loadSound(&quot;start.wav&quot;);
  mySound.play();
}

void destroy() {
  background(255);
  fill(0);
  text(&quot;Exiting...&quot;, 2, 2, width - 4, height - 4);
  bt.stop();
}

//
void draw() {
  background(0xcc,0xcc,0xff);

  if (state == STATE_START) {
    fill(0);
    textAlign(LEFT);
    text(&quot;Welcome to Robo-51\n\nPress a key to search the robot&quot;, 2, 2, width - 4, height - 4);
  }
  else if (state == STATE_FIND) {
    fill(0);
    textAlign(LEFT);
    if (services == null) {
      text(&quot;Looking for Robo-51...\n\n&quot; + msg, 2, 2, width-4, height-4);
    }
    else {
      String list = &quot;Ports found:\n&quot;;
      for (int i = 0, len = length(services); i &lt; len; i++)
        list += i + &quot;. &quot; + services[i].device.name + &quot;\n&quot;;
      text(list, 2, 2, width-4, height-4);
    }
  }
  else if (state == STATE_DRIVE) {
    noFill();
    text(&quot;Robo-51 control:\n&quot;+
         &quot;Use arrows to drive\n&quot;+
         &quot;press ENTER to stop\n&quot;+
         msg, 2, 2, width-4, height-4);
  }

}

//
void libraryEvent(Object library, int event, Object data) {
  if (library == bt) {
    switch (event) {
    case Bluetooth.EVENT_DISCOVER_DEVICE:
      msg = &quot;Found device at: &quot; + ((Device) data).address + &quot;...&quot;;
      break;
    case Bluetooth.EVENT_DISCOVER_DEVICE_COMPLETED:
      msg = &quot;Found &quot; + length((Device[]) data) + &quot; devices, looking for serial port...&quot;;
      break;
    case Bluetooth.EVENT_DISCOVER_SERVICE:
      msg = &quot;Found serial port on &quot; + ((Service[]) data)[0].device.address + &quot;...&quot;;
      break;
    case Bluetooth.EVENT_DISCOVER_SERVICE_COMPLETED:
      services = (Service[]) data;
      msg = &quot;Search complete. Pick one.&quot;;
      break;
    case Bluetooth.EVENT_CLIENT_CONNECTED:
      cl = (Client) data;
      msg = &quot;wtf. client connectd.&quot;;

      break;
    }
  }
}

//

//
void keyPressed() {
  if (state == STATE_START) {
    services = null;
    bt.find();
    state = STATE_FIND;
    msg = &quot;Looking for devices...&quot;;
  }
  else if (state == STATE_FIND) {
    if (services != null) {
      if ((key &gt;= '0') &amp;&amp; (key &lt;= '9')) {
        int i = key - '0';
        if (i &lt; length(services)) {
          msg = &quot;connecting...&quot;;
          cl = services[i].connect();
          state = STATE_DRIVE;
          msg = &quot;ready&quot;;
        }
      }
    }
  }
  else if (state == STATE_DRIVE) {

    parse_robo51key(keyCode,key);

  }

}

void parse_robo51key(int akeyCode, int akey) {
  switch(akeyCode) {
    case UP:
      mySound = MSoundManager.loadSound(&quot;forward.wav&quot;);
      mySound.play();
      msg = &quot;forward&quot;;
      robo51_send(fwd);
      break;
    case DOWN:
      mySound = MSoundManager.loadSound(&quot;backward.wav&quot;);
      mySound.play();
      msg = &quot;backward&quot;;
      robo51_send(bwd);
      break;
    case LEFT:
      mySound = MSoundManager.loadSound(&quot;left.wav&quot;);
      mySound.play();
      msg = &quot;left&quot;;
      robo51_send(left);
      break;
    case RIGHT:
      mySound = MSoundManager.loadSound(&quot;right.wav&quot;);
      mySound.play();
      msg = &quot;right&quot;;
      robo51_send(right);
      break;
    case FIRE:
      mySound = MSoundManager.loadSound(&quot;stop.wav&quot;);
      mySound.play();
      msg = &quot;stop&quot;;
      robo51_send(stop);
      break;
    default:
      mySound = MSoundManager.loadSound(&quot;stop.wav&quot;);
      mySound.play();
      msg = &quot;stop&quot;;
      robo51_send(stop);
      break;

    } // switch(keyCode)
}

void robo51_send(byte[] buffer){
  cl.write(buffer);
  cl.flush();
}
</pre></p>
<p>You will now need to Export and Deploy! That&#8217;s it!<br />
After installing in your cell phone you will now have a very interactive control. Have fun!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=163&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2010/09/15/controlling-a-robot-with-bluetooth-enabled-cell-phone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/09/robo51.gif?w=300" medium="image">
			<media:title type="html">robo51</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/09/zx-bluetooth_01.gif?w=150" medium="image">
			<media:title type="html">zx-bluetooth_01</media:title>
		</media:content>
	</item>
		<item>
		<title>Bluemote &#8211; A Virtual Gamepad for Bluetooth Control of a Robot</title>
		<link>http://redacacia.wordpress.com/2010/09/07/bluemote-a-virtual-gamepad-for-bluetooth-control-of-a-robot/</link>
		<comments>http://redacacia.wordpress.com/2010/09/07/bluemote-a-virtual-gamepad-for-bluetooth-control-of-a-robot/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 18:12:38 +0000</pubDate>
		<dc:creator>Tayeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redacacia.wordpress.com/?p=150</guid>
		<description><![CDATA[This application was born after a student trainee, Pedro Vicente, spent his Summer at my company Aliatron and did a technical project with a 8051-based robot &#8220;Robo-51&#8243; from Inex . Pedro has already published here in this blog, his work that is based on &#8230; <a href="http://redacacia.wordpress.com/2010/09/07/bluemote-a-virtual-gamepad-for-bluetooth-control-of-a-robot/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=150&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>This application was born after a student trainee, Pedro Vicente, spent his Summer at my company </em><a href="http://www.aliatron.pt"><em>Aliatron</em></a><em> and did a technical project with a 8051-based robot </em><a href="http://aliatron.com/loja/catalog/product_info.php?products_id=475"><em>&#8220;Robo-51&#8243;</em></a><em> from Inex . Pedro has already published here in this blog, his work that is based <a href="http://redacacia.wordpress.com/2010/09/21/bluemote-remote-control-of-a-8051-robot-with-bluetooth/">on remote control of a robot with bluetooth</a>. </em></p>
<p><strong>Objectives:</strong></p>
<p><span style="color:#000000;">Use <a href="http://processing.org">Processing</a> sketch to create a virtual gamepad that controls a bluetooth-enabled robot, in this case a <a href="http://aliatron.com/loja/catalog/product_info.php?products_id=475">Robo-51 </a>from Inex. The virtual gamepad must control the robot using serial communication capabilities of a bluetooth module (<a href="http://aliatron.com/loja/catalog/product_info.php?products_id=868">ZX-Bluetooth</a>). Voice-enable the gamepad with TTS capabilities of Windows.</span></p>
<p><strong>Equipment Setup:</strong></p>
<p>A 8051 robot &#8220;Robo-51&#8243; (could be any other micrcontroller) with ZX-Bluetooth module, running a firmware for bluetooth control (or any other serial control), and PC with Windows and Processing software.</p>
<div class="mceTemp mceIEcenter">
<dt class="wp-caption-dt"></dt>
</div>
<div id="attachment_153" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-153" title="robo51" src="http://redacacia.files.wordpress.com/2010/09/robo51.gif?w=300&#038;h=240" alt="Robo-51" width="300" height="240" /><p class="wp-caption-text">8051-based robot &quot;Robo-51&quot;</p></div>
<div class="wp-caption aligncenter" style="width: 160px"><a href="http://redacacia.files.wordpress.com/2010/09/zx-bluetooth_01.gif"><img title="zx-bluetooth_01" src="http://redacacia.files.wordpress.com/2010/09/zx-bluetooth_01.gif?w=150&#038;h=120" alt="" width="150" height="120" /></a><p class="wp-caption-text">Serial bluetooth module &quot;ZX-Bluetooth&quot;</p></div>
<p><a href="http://redacacia.files.wordpress.com/2010/09/robo51.gif"></a> <strong>Bluemote &#8211; Virtual Gamepad:</strong></p>
<p><span style="color:#000000;">The<strong>  </strong>sketch in Processing named <em>bluemote</em> has the following code:</span></p>
<p><pre class="brush: plain;">

import processing.serial.*;     //Import serial library
import guru.ttslib.*;           //Import tts text-to-voice library
// Based on serial example of Processing 1.2.1. To be used with
// 8051 &quot;Robo-51&quot; from INEX, bluetooth enabled wihZX-Bluetooth 
// Sketch by Tayeb tayeb.habib@gmail.com www.redacacia.wordpress.com
// This sketch uses ttslib for sound, library downloadable at
// www.local-guru.net/blog/pages/ttslib

PImage bg;      // Create object from PImage class
Serial myPort;  // Create object from Serial class
TTS tts;        // Create object from Tts class

void setup()
{
  size(318, 184);                             // Sketch of same size as gamepad image                      
 
  myPort = new Serial(this, &quot;COM5&quot;, 9600);    // Set comm port
  bg = loadImage(&quot;bluemote.jpg&quot;);             // Load bluemote image
  tts = new TTS();                            // Create an instance of the TTS class
  tts.speak(&quot;Hi! I am Robot Fifty-One&quot;);      // Call the speak method
  tts.speak(&quot;I am at your orders! Boss!&quot;);    // Call the speak method
}
void draw() {
  background(bg);                 // Load bluemote gamepad image as background
 
  if ((mouseOverForw() == true) &amp;&amp; mousePressed) {  // If mouse is pressed and over forward button,
    cursor(HAND);                 // Hand cursor
    myPort.write(&quot;d&quot;);            // Send letter d for forward movement of robot
    tts.speak(&quot;Forward&quot;);         // Call the speak method
  }
 
  else if ((mouseOverBack() == true) &amp;&amp; mousePressed) {  // If mouse is pressed and over backward button,
    cursor(HAND);                 // Hand cursor
    myPort.write(&quot;a&quot;);            // Send letter c to turn the robot leftwards
    tts.speak(&quot;Backward&quot;);        // Call the speak method
  }
 
  else if ((mouseOverLeft() == true) &amp;&amp; mousePressed){  // If mouse is pressed and over left button,
    cursor(HAND);                 // Hand cursor
    myPort.write(&quot;c&quot;);            // Send letter c to turn the robot rightwards
    tts.speak(&quot;Left&quot;);            // Call the speak method
   }
  
  else if ((mouseOverRight() == true) &amp;&amp; mousePressed) {  // If mouse is pressed and over right button,
   cursor(HAND);                 // Hand cursor
   myPort.write(&quot;b&quot;);            // Send letter b to turn the robot rightwards
   tts.speak(&quot;Right&quot;);           // Call the speak method
   }
  
  else if ((mouseOverStop() == true) &amp;&amp; mousePressed){  // If mouse is pressed and over stop button,
   cursor(HAND);                 // Hand cursor
   myPort.write(&quot;s&quot;);            // Send letter s to stop the robot
   tts.speak(&quot;Stopping&quot;);        // Call the speak method
   }

  else {
  cursor(HAND);                   // Hand cursor
  }  
}

  boolean mouseOverForw() { // Test if mouse is over control button
  return ((mouseX &gt;= 240) &amp;&amp; (mouseX &lt;= 256) &amp;&amp; (mouseY &gt;= 63) &amp;&amp; (mouseY &lt;= 78));
}
  boolean mouseOverBack() { // Test if mouse is over control button
  return ((mouseX &gt;= 240 ) &amp;&amp; (mouseX &lt;= 256) &amp;&amp; (mouseY &gt;= 106) &amp;&amp; (mouseY &lt;= 121)); 
}
  boolean mouseOverLeft() { // Test if mouse is over control button
  return ((mouseX &gt;= 218) &amp;&amp; (mouseX &lt;= 228) &amp;&amp; (mouseY &gt;= 84) &amp;&amp; (mouseY &lt;= 98)); 
}
  boolean mouseOverRight() { // Test if mouse is over control button
  return ((mouseX &gt;= 272) &amp;&amp; (mouseX &lt;= 287) &amp;&amp; (mouseY &gt;= 74) &amp;&amp; (mouseY &lt;= 96)); 
}      
  boolean mouseOverStop() { // Test if mouse is over stop button
  return ((mouseX &gt;= 47) &amp;&amp; (mouseX &lt;= 108) &amp;&amp; (mouseY &gt;= 78) &amp;&amp; (mouseY &lt;= 132));     
}

</pre></p>
<p>Appropriate changes will be required according to the setup namely:</p>
<p><strong>the serial port:</strong>  in our case it is <em>COM5</em>, in your case it could be another port</p>
<p><strong>the commands:</strong> in our case they are <em>d </em>for forward, <em>a</em> for backwards, <em>c</em> for leftwards, <em>b</em> for rightwards and<em> s </em>for<em> </em>stopping<em>.</em></p>
<p>The<em> </em>sketch calls a TTS library (link shown within the code) and uploads a background image. The gamepad image that has been used for this sketch is:</p>
<p style="text-align:center;"><a href="http://redacacia.files.wordpress.com/2010/09/bluemote.jpg"><img class="aligncenter size-thumbnail wp-image-156" title="bluemote" src="http://redacacia.files.wordpress.com/2010/09/bluemote.jpg?w=150&#038;h=86" alt="Bluemote" width="150" height="86" /></a></p>
<p>Just<strong> </strong>download it and add to your project folder ususally found within c:/my documents/processing</p>
<p><strong>The 8051-robot firmware and bluetooth:</strong></p>
<p>Pedro Vicente, mentioned above, has published here <a href="http://redacacia.wordpress.com/2010/09/21/bluemote-remote-control-of-a-8051-robot-with-bluetooth/">the whole project </a>envolving the 8051-based robot &#8220;Robo-51&#8243; and bluetooth. In fact the virtual gamepad can function through any serial connection to any micrcontroller. The commands and the serial port have to be adapted in the sketch.</p>
<p>View a video of Virtual Gamepad and Robo-51:</p>
<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/QP3fQjwfou4?fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/QP3fQjwfou4?fs=1" type="application/x-shockwave-flash" width="640" height="505" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Conclusions:</strong></p>
<p>Serial communciations library, and other libraries in Processing, offer enormous potential in adding interactivity to electronic projects. Bluemote, the virtual gamepad that has been explained here is an example of how easy it is to make electronic projects to talk and interact with the environment.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/redacacia.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/redacacia.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/redacacia.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/redacacia.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/redacacia.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/redacacia.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/redacacia.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/redacacia.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/redacacia.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/redacacia.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/redacacia.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/redacacia.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/redacacia.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/redacacia.wordpress.com/150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=redacacia.wordpress.com&amp;blog=15033487&amp;post=150&amp;subd=redacacia&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://redacacia.wordpress.com/2010/09/07/bluemote-a-virtual-gamepad-for-bluetooth-control-of-a-robot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<georss:point>38.806652 -9.158292</georss:point>
		<geo:lat>38.806652</geo:lat>
		<geo:long>-9.158292</geo:long>
		<media:content url="http://1.gravatar.com/avatar/b3ae39d26960061832884ad1e346607d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chilopsis</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/09/robo51.gif?w=300" medium="image">
			<media:title type="html">robo51</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/09/zx-bluetooth_01.gif?w=150" medium="image">
			<media:title type="html">zx-bluetooth_01</media:title>
		</media:content>

		<media:content url="http://redacacia.files.wordpress.com/2010/09/bluemote.jpg?w=150" medium="image">
			<media:title type="html">bluemote</media:title>
		</media:content>
	</item>
	</channel>
</rss>
