<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.1" -->
<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/"
	>

<channel>
	<title>Grau goes Color</title>
	<link>http://grauonline.de/wordpress</link>
	<description>A blog on projects with robotic, computer vision and more</description>
	<pubDate>Fri, 11 May 2012 13:03:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>
	<language>en</language>
			<item>
		<title>Alexander&#8217;s car diagnostic software (OBD KW1281)</title>
		<link>http://grauonline.de/wordpress/?p=74</link>
		<comments>http://grauonline.de/wordpress/?p=74#comments</comments>
		<pubDate>Thu, 10 May 2012 09:34:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=74</guid>
		<description><![CDATA[My Audi A4/B5 (1997) and many other old cars use the older OBD KW 1281 protocol - I tried to find any suitable OBD software for my car to speak to my motor and dashboard control units (ECU), however:

wbh-diag 0.89 : seem to work (unstable connection)
monoscan 2.30: seem to work, but does not have &#8217;set [...]]]></description>
			<content:encoded><![CDATA[<p>My Audi A4/B5 (1997) and many other old cars use the older <strong>OBD KW 1281 protocol</strong> - I tried to find any suitable OBD software for my car to speak to my motor and dashboard control units (ECU), however:</p>
<ul>
<li>wbh-diag 0.89 : seem to work (unstable connection)</li>
<li>monoscan 2.30: seem to work, but does not have &#8217;set basic settings&#8217; feature</li>
<li>VAG-COM 3.11/4.09: seem to work (you have to power off/on ignition while connecting as it sends some data before waking up and that confuses my engine ECU)</li>
<li>CarPort 1.3.2: seem to work (you have to power off/on ignition while connecting as it sends some data before waking up and that confuses my engine ECU)</li>
</ul>
<p>So, using the KW1281 protocol, the correct initialization timing (baud 5) is critical, and some software does not wait before waking up the ECU. Finally, I decided to develop something on my own. Note: my software only supports the older KW1281 protocol!</p>
<p><strong>Features of my KW1281 diagnostic software:</strong></p>
<ul>
<li>Read sensors (measurements)</li>
<li>Set basic settings - useful, if you want to start motor ECU throttle adaption</li>
<li>Read errors</li>
<li>Clear errors</li>
<li>Read ROM (does not work for all ECUs)</li>
<li>Showing sensor values in graph</li>
</ul>
<p><strong>What you need:</strong></p>
<ul>
<li>a PC runing Windows (XP/Vista/Win7)</li>
<li>an <strong>USB KKL adapter</strong> (it provides a virtual COM port, for example &#8216;<a href="http://www.autodia.de/produkte/autodia-k409" title="AutoDia K409 USB">AutoDia K409 Profi USB</a>&#8216; - it uses the FTDI chipset to emulate a serial line)</li>
</ul>
<p><strong>Screenshot:<br />
</strong><a href="http://grauonline.de/wordpress/wp-content/uploads/kw1281.jpg" title="kw1281screenshot"><img src="http://grauonline.de/wordpress/wp-content/uploads/kw1281.thumbnail.jpg" alt="kw1281screenshot" /></a></p>
<p><strong>Download: </strong><a href="http://grauonline.de/wordpress/wp-content/uploads/kw12811.zip" title="kw1281">kw1281</a></p>
<p>Please send me your feedback! Thanks <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> If you send your feedback, please always send me the complete debug output.</p>
<p>My car&#8217;s OBD data:</p>
<pre>- Audi A4 B5 1.8, 1997, ADR
- Engine ECU:
     Part Number : 8D0907558B      Component : 1,8L R4/5V  MOTR HS D02
- Dash board ECU
     Part Number : 8D0919860G      Component : B5-KOMBIINSTR.UN4   D01
     Descriptor 5 : IMMO-IDENTNR: AUZ8Z0V5170015</pre>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=74</wfw:commentRss>
		</item>
		<item>
		<title>Über den Wolken&#8230;</title>
		<link>http://grauonline.de/wordpress/?p=73</link>
		<comments>http://grauonline.de/wordpress/?p=73#comments</comments>
		<pubDate>Mon, 16 Jan 2012 10:06:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=73</guid>
		<description><![CDATA[
Naja, nicht ganz 
PS: Ein nettes Spielzeug    (J-3 Cub Ultra Micro RC)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://grauonline.de/wordpress/wp-content/uploads/sky.jpg" title="Über den Wolken"><img src="http://grauonline.de/wordpress/wp-content/uploads/sky.thumbnail.jpg" alt="Über den Wolken" /></a></p>
<p>Naja, nicht ganz <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
PS: Ein nettes Spielzeug <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   (J-3 Cub Ultra Micro RC)</p>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=73</wfw:commentRss>
		</item>
		<item>
		<title>How to fix a specific OS X dynamic loader problem (dyld - 0&#215;80000022)</title>
		<link>http://grauonline.de/wordpress/?p=71</link>
		<comments>http://grauonline.de/wordpress/?p=71#comments</comments>
		<pubDate>Thu, 20 Oct 2011 11:51:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=71</guid>
		<description><![CDATA[The problem: You compile your C code on a OS X 10.6 machine like this:
gcc-4.2 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk ...
When trying to run the executable on a OS X 10.5 machine, you may get this error:
Dyld Error Message:

unknown required load command 0x80000022
The reason is that OS X 10.5 doesn&#8217;t understand the load command  'LC_DYLD_INFO_ONLY' (0&#215;80000022) that [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The problem</strong>: You compile your C code on a OS X 10.6 machine like this:</p>
<pre>gcc-4.2 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk ...</pre>
<p>When trying to run the executable on a OS X 10.5 machine, you may get this error:</p>
<pre>Dyld Error Message:

unknown required load command 0x80000022</pre>
<p>The reason is that OS X 10.5 doesn&#8217;t understand the load command  <code>'LC_DYLD_INFO_ONLY' </code>(<em>0&#215;80000022) that was used by the OS X 10.6 linker.</em></p>
<p><strong>Solution</strong>: Make sure you are using a deployment target by setting the environment variable just before your link command:</p>
<pre>
export MACOSX_DEPLOYMENT_TARGET=10.5

(or   setenv <em>MACOSX_DEPLOYMENT_TARGET=10.5)</em></pre>
<p><em>You can always check the load commands of the executable like this:</em></p>
<p><em></p>
<pre>(without using deployment target)
otool -l binary

Load command 4
cmd LC_DYLD_INFO_ONLY
cmdsize 48
rebase_off 0
rebase_size 0
bind_off 462848
bind_size 1320
weak_bind_off 0
weak_bind_size 0
lazy_bind_off 464168
lazy_bind_size 2624
export_off 466792
export_size 4568</pre>
<pre>
(using deployment target)
otool -l binary

Load command 4
cmd LC_DYLD_INFO
cmdsize 48
rebase_off 0
rebase_size 0
bind_off 466944
bind_size 1400
weak_bind_off 0
weak_bind_size 0
lazy_bind_off 468344
lazy_bind_size 2656
export_off 471000
export_size 4568</pre>
<p></em><br />
Another solution:  <a href="http://software.intel.com/en-us/articles/running-an-intel-compiled-binary-on-older-mac-os-x-system-gives-dyld-unknown-required-load-command-0x80000022/#comment-65685" title="Read this Intel article here.">Read this Intel article here</a> - it may give you another possible solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=71</wfw:commentRss>
		</item>
		<item>
		<title>Using online music services with Ruby</title>
		<link>http://grauonline.de/wordpress/?p=66</link>
		<comments>http://grauonline.de/wordpress/?p=66#comments</comments>
		<pubDate>Tue, 18 Jan 2011 13:06:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming languages]]></category>

		<category><![CDATA[Internet]]></category>

		<category><![CDATA[Ruby On Rails]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=66</guid>
		<description><![CDATA[[Or : Streaming Rhapsody or last.fm with Ruby]
Ruby has excellent libraries (HTTP, SSL, SOAP, XML, etc.) that can be used to write your own music player for streaming music from online services like Rhapsody or last.fm - so why not use them? Here are code snippets to help you getting started! They show you&#8230;

&#8230;how to [...]]]></description>
			<content:encoded><![CDATA[<p>[Or : Streaming Rhapsody or last.fm with Ruby]</p>
<p>Ruby has excellent libraries (HTTP, SSL, SOAP, XML, etc.) that can be used to write your own music player for streaming music from online services like Rhapsody or last.fm - so why not use them? Here are code snippets to help you getting started! They show you&#8230;</p>
<ul>
<li>&#8230;how to make a HTTPS GET or POST request using SSL (https://&#8230;)</li>
<li>&#8230;how to easily parse the XML response of such a request</li>
<li>&#8230;how to stream music data (e.g. MP3) from some HTTP URL and how to pipe that stream data to another process (e.g. mplayer) for playing it back while streaming</li>
<li>&#8230;how to use SOAP requests with custom SSL certificates (https://&#8230;)</li>
<li>&#8230;how to encrypt/decrypt 64-bit DES ECB data</li>
</ul>
<p>My own Ruby (1.8)-based Rhapsody player has 400 lines of Ruby code, my lasm.fm player has 200 lines of Ruby code  -    Do you think other languages can do better <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ?</p>
<p><em><strong>Using HTTPS POST and SSL (HTTPS GET works similar using the Net::HTTP::Get class)</strong></em></p>
<pre>require 'net/http'
require 'net/https'

dict['api_key'] = @apikey
url = "https://someurl"

uri = URI.parse(url)
sock = Net::HTTP.new(uri.host, uri.port)
sock.use_ssl = true

req = Net::HTTP::Post.new(url)
req.set_form_data(dict)
res = sock.start{|http| http.request(req) }
puts res.body</pre>
<p><strong><em>Parsing XML response data</em></strong></p>
<pre>require 'rexml/document'
res = http_post( {'method'=&gt; 'radio.getPlaylist', 'sk' =&gt; @sk })

doc = REXML::Document.new(res)

printf("%-30s %-50s %-40sn", "title", "album", "creator")
doc.elements.each("*/*/*/track") do |element|
  title    = element.elements["title"].text
  album    = element.elements["album"].text
  creator  = element.elements["creator"].text
  location = element.elements["location"].text
  image    = element.elements["image"].text
  printf("%-30s %-50s %-40sn", title, album, creator)
end</pre>
<p><em><strong>Streaming HTTP music data  (e.g. MP3) and piping it to another process (e.g. mplayer)</strong></em></p>
<pre>    uri = URI.parse(url)
    Net::HTTP.start(uri.host) do |http|
      http.request_get(uri.path) do |resp|
        pipe = IO.popen("mplayer -cache 256 -", "w")
        resp.read_body do |segment|
          if segment.length &gt; 0
            pipe.write(segment)
          end
        end
        pipe.close
      end
    end

Of course, you can always pipe using bash..

macbook-pro:~ nero$ lastfm.rb | mplayer -cache 64 -

...however this wouldn't allow you to write something else to STDOUT except the music data.</pre>
<p><em><strong>Using SOAP requests and custom SSL certificates</strong></em></p>
<pre>require 'openssl'
require "rubygems"
gem "httpclient", "2.1.5.2"
gem 'soap4r'
require 'soap/rpc/driver'

driverPlay = SOAP::RPC::Driver.new('https://someurl', 'urn:someurn')
driverPlay.options["protocol.http.ssl_config.verify_mode"] = nil
driverPlay.options["protocol.http.ssl_config.client_cert"] = File.join(@dir, "somefile.cert.pem")
driverPlay.options["protocol.http.ssl_config.client_key"] = File.join(@dir, "somefile.key.pem")
driverPlay.return_response_as_xml = true
# define some method
driverPlay.add_method('startPlaybackSession', 'developerKey', 'cobrandId', 'logon', 'password', 'clientType')</pre>
<p><strong><em>Using 64-bit DES ECB encryption<br />
(the key is to use &#8216;cipher.padding = 0&#8242;  - it took me 2 hours to figure that out &#8230;)</em></strong></p>
<pre>  require 'openssl'
  def testDES
    puts '*** TESTDES ***'
    key         = "x01x23x45x67x89xabxcdxef"
    plain       = "x01x23x45x67x89xabxcdxe7"
    cryptdata   = "xc9x57x44x25x6ax5exd3x1d"

    puts "key      = " + key.unpack("H*").to_s
    puts "plain    = " + plain.unpack("H*").to_s
    #puts OpenSSL::Cipher.ciphers

    puts "encrypt..."
    cipher = OpenSSL::Cipher::Cipher.new('des-ecb')
    cipher.encrypt
    cipher.key = key
    cipher.padding = 0
    res = cipher.update(plain)
    puts "res      = " + res.unpack("H*").to_s
    puts "crypted  = " + cryptdata.unpack("H*").to_s

    puts "decrypt..."
    cipher.decrypt
    res = cipher.update(res) + cipher.final
    puts "res      = " + res.unpack("H*").to_s
    puts "plain    = " + plain.unpack("H*").to_s

    puts "triple..."
    cipher.decrypt
    plain = cipher.update(plain) + cipher.final
    cipher.encrypt
    cipher.key = plain
    plain = cipher.update(plain)
    cipher.decrypt
    cipher.key = key
    res = cipher.update(plain) + cipher.final
    puts "res      = " + res.unpack("H*").to_s
  end</pre>
<pre></pre>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=66</wfw:commentRss>
		</item>
		<item>
		<title>Wie funktioniert eine Digitalkamera und wie baut man eine eigene in 30 Minuten?</title>
		<link>http://grauonline.de/wordpress/?p=65</link>
		<comments>http://grauonline.de/wordpress/?p=65#comments</comments>
		<pubDate>Fri, 17 Dec 2010 10:16:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=65</guid>
		<description><![CDATA[Unter http://www.bigshotcamera.org zeigt die  Columbia University wie eine Digitalkamera funktioniert - man lernt durch Lesen und in Experimenten direkt auf der Website Grundlagen einer Digitalkamera und der digitalen Bildverarbeitung. Desweiteren wird ein Prototyp zum eigenen Zusammenbau einer Digitalkamera gezeigt.
Ein wirklich tolles (Lehr-)Projekt - nicht nur für Kinder! Es sollte mehr solcher Projekte in Lehre und [...]]]></description>
			<content:encoded><![CDATA[<p>Unter <a href="http://www.bigshotcamera.org">http://www.bigshotcamera.org</a> zeigt die  Columbia University wie eine Digitalkamera funktioniert - man lernt durch Lesen und in Experimenten direkt auf der Website Grundlagen einer Digitalkamera und der digitalen Bildverarbeitung. Desweiteren wird ein Prototyp zum eigenen Zusammenbau einer Digitalkamera gezeigt.</p>
<p>Ein wirklich tolles (Lehr-)Projekt - nicht nur für Kinder! Es sollte mehr solcher Projekte in Lehre und Forschung geben!</p>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=65</wfw:commentRss>
		</item>
		<item>
		<title>Leitungsverfolgung im Erdreich</title>
		<link>http://grauonline.de/wordpress/?p=61</link>
		<comments>http://grauonline.de/wordpress/?p=61#comments</comments>
		<pubDate>Wed, 27 Oct 2010 13:21:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Robotic]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=61</guid>
		<description><![CDATA[Fast alle Rasenmähroboter verwenden eine Induktionsschleife (also einen geschlossenen Leiter von Punkt A nach Punkt B), um den Roboter auf das zu mähende Gebiet zu begrenzen - wie findet man aber die Stelle heraus, falls so eine Leitung einmal unterbrochen wurde? Ganz einfach: man baut sich einen &#8220;Cable Tracker&#8221;  &#8230;
Funktionsprinzip: Speist man eine Wechselspannung [...]]]></description>
			<content:encoded><![CDATA[<p>Fast alle Rasenmähroboter verwenden eine Induktionsschleife (also einen geschlossenen Leiter von Punkt A nach Punkt B), um den Roboter auf das zu mähende Gebiet zu begrenzen - wie findet man aber die Stelle heraus, falls so eine Leitung einmal unterbrochen wurde? Ganz einfach: man baut sich einen &#8220;Cable Tracker&#8221; <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> &#8230;</p>
<p><strong>Funktionsprinzip</strong>: Speist man eine Wechselspannung gegen Erde (als Masse) auf den unterbrochenen Leiter, so erzeugt diese ein elektrisches Feld um den Leiter. Dieses Feld kann man mit einer Spule detektieren. Wählt man für das Wechselsignal eine Frequenz von z.B. 400 bis 4000 Hz, so kann man dieses Signal um den Leiter herum mit einem kleinen Verstärker (z.B. Walkman) hörbar machen.</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/cabletracker.png" title="cable tracker"><img src="http://grauonline.de/wordpress/wp-content/uploads/cabletracker.png" alt="cable tracker" /></a></p>
<p><strong>Verwendete Komponenten:</strong></p>
<p>Der Sender:</p>
<ol>
<li>Eine fertige PWM-Motor-Controller Schaltung (min. 30V), gefunden bei eBay (ist quasi ein fertiger Rechtecksignal-Frequenzgenerator mit Verstärker)</li>
<li>Ein Gleichstromnetzteil (30V - Achtung: auf keinen Fall mit höherer Spannung arbeiten)</li>
</ol>
<p>Der Empfänger:</p>
<ol>
<li>Eine Spule mit vielen Windungen aus einem alten 230V-Relais</li>
<li>Ein alter Walkman (oder Mikrofonverstärker)</li>
</ol>
<p><strong>Schritt 1:  Den Sender</strong> <strong>aufbauen</strong></p>
<p>Zunächst wurde der PWM-Controller mit nur 10Volt und einem Lautsprecher als &#8220;Motor&#8221; betrieben, und dabei die fertige PWM-Schaltung durch einen parallel ergänzten Kondensator so eingstellt, dass die Schaltung ein Rechteck-Signal mit gut hörbarer Frequenz erzeugt. Danach wurde der Lautsprecher entfernt, das Netzteil angeschlossen und als &#8220;Last&#8221; das offene Ende der Induktionsschleife und die &#8220;Rückführung&#8221; über einen Erdungsleiter (einfach ein Stahlrohr in die Erde gerammt).</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/cabletracker_sender.jpg" title="cable tracker sender"><img src="http://grauonline.de/wordpress/wp-content/uploads/cabletracker_sender.thumbnail.jpg" alt="cable tracker sender" /></a></p>
<p><strong>Schritt 2: Der Empfänger</strong></p>
<p>Ein alter Walkman wurde geöffnet und anstelle des Tonkopfes eine Spule angeschlosen. Wenn man nun den Walkman betreibt, hört man in der Nähe von Netzteilen/Steckdosen/etc. das typische 50 Hz Brummen - ein Zeichen dafür, dass der Empfänger funktioniert.</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/cabletracker_receiver.jpg" title="cable tracker receiver"><img src="http://grauonline.de/wordpress/wp-content/uploads/cabletracker_receiver.thumbnail.jpg" alt="cable tracker receiver" /></a></p>
<p><strong>Schritt 3: Das Induktionskabel &#8220;abfahren&#8221; </strong></p>
<p>Zum ersten Test nimmt man das Kabel für den Erdungsleiter einfach in die Hand (damit ist der abzufahrende Induktionskabel geerdet). Nun hört man in der Nähe (1-2 m) des Induktionskabels einen Ton, dessen Lautstärke durch Annäherung an das Kabel zunimmt. Genau an der Stelle der Unterbrechung hört der Ton auf und man hat die Stelle der Unterbrechung gefunden.</p>
<p>Viel Spaß beim Nachbauen <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=61</wfw:commentRss>
		</item>
		<item>
		<title>Robot Mower Internals</title>
		<link>http://grauonline.de/wordpress/?p=50</link>
		<comments>http://grauonline.de/wordpress/?p=50#comments</comments>
		<pubDate>Tue, 05 Oct 2010 07:10:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Microcontrollers]]></category>

		<category><![CDATA[Robotic]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=50</guid>
		<description><![CDATA[One year ago, I did purchase a Tianchen TC-G158 robot mower (via ChinaVasion) and this article describes some of the robot&#8217;s electronics internals and how to connect your own microcontroller to the robot mower board so that you can write your own custom software for it.
One primary warning already: Everything that includes opening your robot [...]]]></description>
			<content:encoded><![CDATA[<p>One year ago, I did purchase a <a href="http://www.tianchen-cn.com/" title="Tianchen">Tianchen</a> TC-G158 robot mower (via <a href="http://www.chinavasion.com/product_info.php/pName/robot-lawn-mower-automatic-electric-robomower/" title="China Vision">ChinaVasion</a>) and this article describes some of the robot&#8217;s electronics internals and how to connect your own microcontroller to the <a href="http://grauonline.de/wordpress/wp-content/uploads/unit.jpg" title="robot mower unit">robot mower board</a> so that you can write your own custom software for it.</p>
<p><strong>One primary warning already: </strong>Everything that includes opening your robot will loose your robot&#8217;s guarantee. If you really need to do this (like me), be aware of this.</p>
<p>My purchased Tianchen TC-G158 robot mower has the following components:</p>
<ul>
<li>Main MCU: <a href="http://grauonline.de/wordpress/?p=44" title="STC12C5410AD">STC12C5410AD  </a>(8051 clone, 10K flash memory, 33 Mhz)</li>
<li>Hope RF HM 433 Mhz receiver module (for remote control)</li>
<li>Remote control decoder MCU: STC12C2052AD  (sends remote control key data to main MCU, see protocol below)</li>
<li>Induction unit quad op amp: LM32 (for induction loop inductor amp)</li>
<li>Optical roll ball sensor: HT RBS33 (theta=45 degree , switches off mowing motor above theta degree)</li>
<li>Dual 4-channel mux/demux: 74HC4052D (to read in induction loop inductors and battery sense/rain sensor)</li>
<li>Power MOSFET: IRFZ44N (for mowing motor)</li>
<li>Full bridge driver: L298N (for the left and right motors)</li>
<li>1A step-down simple switch voltage regulator: LM2575S (for main board voltages)</li>
<li>Solid state amp: SR840 (for mowing motor)</li>
<li>Timer: NE555 (for IR modulation?)</li>
<li>Dual op-amp: LM358 (for induction loop inductor)</li>
</ul>
<p>After purchasing, I noticed the robot has a small problem:  when moving from the lower part to the higher part of my garden, it doesn&#8217;t move a straight line - it makes circles of 90 degress and less (due to the heavy lead acid batteries my mower is using) &#8230;</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/robot.png" title="robot mower garden"><img src="http://grauonline.de/wordpress/wp-content/uploads/robot.thumbnail.png" alt="robot mower garden" /></a></p>
<p>So I decided to add some software PID controller to it to control the left-right wheel balance <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> and it solved this specific problem (see videos <a href="http://www.youtube.com/watch?v=SSM72mCFB_o" title="with">with </a>and <a href="http://www.youtube.com/watch?v=C-Y7cKHv7zo" title="without">without</a> balance controller).</p>
<p>Of course, this required writing a new MCU software, and I did choose the Atmel ATMEGA-168 (on a ready <a href="http://shop.myavr.de/" title="myAVR">myAVR</a> board MK2 USB)  as a replacement for the original 8051 MCU.</p>
<p>Here you can see how I managed to connect my Atmel MCU to the old MCU socket (using some DIY adapter):</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/mower_own_microcontroller.JPG" title="robot mower own MCU"><img src="http://grauonline.de/wordpress/wp-content/uploads/mower_own_microcontroller.thumbnail.JPG" alt="robot mower own MCU" /></a></p>
<p>And here you can see how I added photo interruptors (LTH301-07) for the left and right motors to measure the wheel movement (for the left-right wheel balance control):</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/mower_photo_interrupter_right.JPG" title="robot mower right interrupter"><img src="http://grauonline.de/wordpress/wp-content/uploads/mower_photo_interrupter_right.thumbnail.JPG" alt="robot mower right interrupter" /></a></p>
<p>After a while, I noticed that I need something more fancy to upload my new custom software revisions into my mower while sitting comfortable in a chair meters away: <a href="http://grauonline.de/wordpress/?p=40" title="A bluetooth module!">a Bluetooth module!<br />
</a>The bluetooth module extends the ordinary ISP RX/TX serial line (RS232) and also allows me to monitor sensor data and robot state changes (and believe me, this feedback is absolutely necessary for debugging your code&#8230;)</p>
<p>So this is my final system today:</p>
<p>Original board &lt;==&gt; ATMEGA168 &lt;==&gt; ISP (TTL UART) &lt;==&gt; Bluetooth module &lt;~~&gt; PC (Bluetooth dongle)</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/robot_atmega.png" title="robot_atmega.png"><img src="http://grauonline.de/wordpress/wp-content/uploads/robot_atmega.thumbnail.png" alt="robot_atmega.png" /></a></p>
<p>I upload new software builds into the mower via Bluetooth and the serial data of the mower is transmitted via Bluetooth too.<br />
My latest software periodically displays the state of the mower (state, state time, bumper states, IR state, inclination sensor, motor PWM, motor PID controller wxy, motor current, induction coins values, battery state, rain sensor):</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/mowerserial.png" title="mowerserial.png"><img src="http://grauonline.de/wordpress/wp-content/uploads/mowerserial.thumbnail.png" alt="mowerserial.png" /></a></p>
<p>All components I needed for this solution:</p>
<ul>
<li><a href="http://shop.myavr.de/Systemboards/myAVR%20Board%20MK2,%20best%C3%BCckt.htm?sp=article.sp.php&amp;artID=40" title="myAVR microcontroller board">myAVR microntroller board </a>- includes mySmartUSB programmer (ISP)</li>
<li>ATMEGA168 microcontroller (16K flash, operating at 5V)</li>
<li>12 Mhz oscillator</li>
<li><a href="http://grauonline.de/wordpress/?p=40" title="Bluetooth module BTM220">Bluetooth module BTM220</a> , an inverter  74HCT14N for level shift conversion (because my BTM220 operates at 3.3V, I needed a level shift conversion to 5V)</li>
<li>RS232 TTL USB module (to configure the Bluetooth module)</li>
<li>Multiplexer CD74HC4067 (to reduce the number of required pins at the microcontroller)</li>
<li>Two photo sensors to measure the wheel movement (wheel left/right balance control) - later I replaced this by a declination sensor which works great too</li>
</ul>
<p>If you are talent enough, my material should give you a good start for your own experiments and adjustments - Happy mowing <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Resources:</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/mcu_pins.jpg" title="robot mower MCU pins">Main MCU pin description</a></p>
<p>My pseudo-schematics <a href="http://grauonline.de/wordpress/wp-content/uploads/mow1.jpg" title="robot mower schematics 1">(1)</a>, <a href="http://grauonline.de/wordpress/wp-content/uploads/mow2.jpg" title="robot mower schematics 2">(2)</a>  (<strong>Warning</strong>: always measure and verify using your own board - manufacturers often change their layouts and make adjustments, and without measuring you may damage your own board!)</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/remotecontrol.jpg" title="remote control protocol">Remote control protocol</a></p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/robomower.zip" title="robot mower code">My robot mower code</a> (code also describes the MCU socket&lt;-&gt;ATMEGA168 wiring  -  <strong>Warning</strong>:  don&#8217;t expect this code to work at once in your own configuration - you&#8217;ll need to study schematics, your MCU specifications and much more to get it working!)</p>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=50</wfw:commentRss>
		</item>
		<item>
		<title>Pascal is dead - long lives FreePascal!</title>
		<link>http://grauonline.de/wordpress/?p=48</link>
		<comments>http://grauonline.de/wordpress/?p=48#comments</comments>
		<pubDate>Sat, 21 Aug 2010 14:49:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming languages]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=48</guid>
		<description><![CDATA[



You develop software for the consumer market in a professional manner? But you cannot afford a team of 30 developers? Your code changes quickly? And at the end you need to deliver your products to your customers, not just prototypes, right?



Don&#8217;t take me wrong, we have been using several programming languages over the years (including [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://grauonline.de/wordpress/wp-content/uploads/lazarus.png" title="lazarus"><img src="http://grauonline.de/wordpress/wp-content/uploads/lazarus.thumbnail.png" alt="lazarus" /></a></p>
<blockquote>
<blockquote></blockquote>
</blockquote>
<p>You develop software for the consumer market in a professional manner? But you cannot afford a team of 30 developers? Your code changes quickly? And at the end you need to deliver your products to your customers, not just prototypes, right?</p>
<blockquote>
<blockquote></blockquote>
</blockquote>
<p>Don&#8217;t take me wrong, we have been using several programming languages over the years (including C++, Java, Python) and still use them all over the time. I rather think the general idea is that e.g. C++ is not always the right choice - Here&#8217;s what you get if you use FreePascal/Lazarus:</p>
<ul>
<li>FreePascal is *not* just Pascal - you get a 100% programming <strong>OO-language</strong> with objects, classes, generics, interfaces, type-saftety and a <strong>clean </strong>and <strong>easy syntax</strong> like Java or C# - everything in a compiler.<br />
You might ask: Does it have the same quality like gcc or VC++? We think: YES.</li>
<li>FreePascal is <strong>multi-platform</strong> - after you wrote your application for Windows, it will run without modifications on the Mac - natively.</li>
<li>FreePascal is <strong>extendable</strong> - you can easily add shared libraries written in C or any other language.</li>
<li>Lazarus is *not* just another IDE - you get a multi-platform <strong>integrated source code editor</strong> including syntax checking, code completion, refactoring tools, and with an integrated <strong>WYSIWYG user interface editor </strong>for managing your application&#8217;s user interface:  menus, windows, text labels, edit fields, buttons, etc. - including &#8216;layout manager&#8217; - everything with full preview and without recompiling your code!</li>
<li>Lazarus LCL (component library) is a <strong>multi-platform</strong>, <strong>Unicode</strong>-capable GUI library - after you designed your user interface on Window, it will run without any modifications on the Mac.<br />
You might ask: Does this LCL have the quality of something like wxWidgets or QT?  We think: YES.</li>
<li>The &#8216;<strong>edit-compile-run</strong>&#8216; cycle is *<strong>fast</strong>* - you don&#8217;t have to wait for the executables, they are just there after hitting the compilation button.</li>
<li>Needless to say: it is <strong>Open Source</strong> - If you find a bug, it&#8217;s often easy to fix it yourself. Plus, the source of your issue is just a click away (CTRL+mouse click shows the IDE/GUI library code of the clicked method).<br />
It comes with a <strong>modified GPL license</strong> which means you are fully allowed to<strong> build and ship your commerical applications </strong>with it, and of course without having to ship your own source code.</li>
</ul>
<p>Enough to  say - try it out yourself:</p>
<ol>
<li>Download the Lazarus package (already includes the compiler) <a href="http://www.freepascal.org" title="http://www.freepascal.org"><br />
</a><a href="http://www.lazarus.freepascal.org/" title="http://www.lazarus.freepascal.org/">http://www.lazarus.freepascal.org/<br />
</a><a href="http://www.freepascal.org" title="http://www.freepascal.org">http://www.freepascal.org/</a></li>
<li><a href="http://www.freepascal.org/docs-html/ref/ref.html" title="http://www.freepascal.org/docs-html/ref/ref.html">Start learning the language</a> (like you would do with C#, Objective-C, Smalltalk or something else)</li>
<li><a href="http://www.youtube.com/results?search_query=lazarus+freepascal&amp;aq=f" title="http://www.youtube.com/results?search_query=lazarus+freepascal&amp;aq=f">Watch the YouTube tutorial videos</a></li>
<li><a href="http://www.grauonline.de/slides/lazarus.html" title="http://www.grauonline.de/slides/lazarus.html">Read our FreePascal/Lazarus success story :-)&#8230;</a></li>
</ol>
<p>Do you need someone else to develop the application for you using FreePascal? <a href="http://grauonline.de/cmsimple2_6/en/?Services:Free_Pascal_Programming_Services" title="http://grauonline.de/cmsimple2_6/en/?Services:Free_Pascal_Programming_Services">Then don&#8217;t hesitate to ask us!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=48</wfw:commentRss>
		</item>
		<item>
		<title>GDB/FreePascal - How a debugger can trigger on variable corruption</title>
		<link>http://grauonline.de/wordpress/?p=47</link>
		<comments>http://grauonline.de/wordpress/?p=47#comments</comments>
		<pubDate>Fri, 16 Jul 2010 08:45:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming languages]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=47</guid>
		<description><![CDATA[Problem: Some variable is overwritten in your program and you need to find the location where this will happen.
Example: As you can see from the program output, the variable &#8216;otherdata&#8217; has been corrupted by the variable &#8216;data. Imagine, between the corruption and using again the variable &#8216;otherdata&#8217; million of code lines could be executed!

program project1;
type [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem: </strong>Some variable is overwritten in your program and you need to find the location where this will happen.</p>
<p><strong>Example: </strong>As you can see from the program output, the variable &#8216;otherdata&#8217; has been corrupted by the variable &#8216;data. Imagine, between the corruption and using again the variable &#8216;otherdata&#8217; million of code lines could be executed!</p>
<pre>
program project1;
type p64 = ^int64;

procedure testme;
var
  otherdata: integer;
  data: integer;
begin
  writeln('data=',hexStr(data, 8));
  writeln('otherdata=',hexStr(otherdata, 8));
  writeln;

  p64(@data)^:=$00AABBBBCCCCDDDD;  // overwrites otherdata
  writeln('dummy');
  writeln('dummy');
  writeln('data=',hexStr(data, 8));
  writeln('otherdata=',hexStr(otherdata, 8));
end;

begin
  testme();
end.

C:Projectsfrtestdebugger&gt;project1.exe

data=7FFDB000
otherdata=0042C294
dummy
dummy
data=CCCCDDDD
otherdata=00AABBBB</pre>
<p><strong><br />
Solution: </strong>GDB has the ability to &#8216;<strong>watch</strong>&#8216; for variable changes and trigger them! In this example, it will stop execution at the line that corrupts the OTHERDATA variable.</p>
<p><em>C:\Projects\fr\test\debugger&gt;gdb project1.exe</em></p>
<p>GNU gdb 6.8<br />
Copyright (C) 2008 Free Software Foundation, Inc.<br />
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;<br />
This is free software: you are free to change and redistribute it.<br />
There is NO WARRANTY, to the extent permitted by law.  Type &#8220;show copying&#8221;<br />
and &#8220;show warranty&#8221; for details.<br />
This GDB was configured as &#8220;i686-pc-mingw32&#8243;&#8230;<br />
(gdb)</p>
<p><em>(gdb) <strong>break TESTME</strong></em><br />
Breakpoint 1 at 0&#215;4014ff: file project1.lpr, line 23.</p>
<p>Breakpoint 1, TESTME () at project1.lpr:23<br />
23        writeln(&#8217;data=&#8217;,hexStr(data, 8));</p>
<p><em>(gdb) <strong>watch OTHERDATA</strong></em><br />
Hardware watchpoint 2: OTHERDATA</p>
<p><em>(gdb) <strong>continue</strong></em><br />
Continuing.<br />
data=7FFDC000<br />
otherdata=0042C294</p>
<p><strong>Hardware watchpoint 2: OTHERDATA</strong></p>
<p><strong>Old value = 4375188<br />
New value = 11189179<br />
</strong>TESTME () at project1.lpr:27<br />
27        writeln(&#8217;dummy&#8217;);</p>
<p>Hopefully this feature will get into Lazarus soon <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=47</wfw:commentRss>
		</item>
		<item>
		<title>8051 Quickstart using STC MCU</title>
		<link>http://grauonline.de/wordpress/?p=44</link>
		<comments>http://grauonline.de/wordpress/?p=44#comments</comments>
		<pubDate>Fri, 09 Jul 2010 12:04:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Microcontrollers]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grauonline.de/wordpress/?p=44</guid>
		<description><![CDATA[This article describes the first steps how you start programming a 8051 compatible MCU (aka C51), in this case the STC12C5412AD using a USB-to-TTL adaptor.

Why 8051/C51 ?


very popular (you can find plenty of code examples)
simple to program (simple register maps etc.)
cheap
Todays 8051 compatible MCUs have most needed integrated (flash memory, EEPROM, ADC, UART, PWM, &#8230;)
almost [...]]]></description>
			<content:encoded><![CDATA[<p>This article describes the first steps how you start programming a 8051 compatible MCU (aka C51), in this case the STC12C5412AD using a USB-to-TTL adaptor.</p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/stc_usb.jpg" title="stc_usb.jpg"><img src="http://grauonline.de/wordpress/wp-content/uploads/stc_usb.jpg" alt="stc_usb.jpg" /></a></p>
<p><strong>Why 8051/C51 ?<br />
</strong></p>
<ul>
<li>very popular (you can find plenty of code examples)</li>
<li>simple to program (simple register maps etc.)</li>
<li>cheap</li>
<li>Todays 8051 compatible MCUs have most needed integrated (flash memory, EEPROM, ADC, UART, PWM, &#8230;)</li>
<li>almost nothing has changed since its beginning (same registers - the 1980&#8217;s code you find still works)</li>
</ul>
<p><strong><br />
Why STC MCU?</strong></p>
<ul>
<li>cheap</li>
<li>easy to flash: no external programmer is required - TX/RX line is used to flash the MCU</li>
</ul>
<p><strong>What you need:</strong></p>
<ul>
<li><a href="http://www.mcu-memory.com/" title="http://www.mcu-memory.com/">STC MCU </a>(<a href="http://www.mcu-memory.com/datasheet/stc/STC-AD-PDF/STC12C5410AD.pdf" title="STC12C5410AD">STC12C5410AD</a>, STC12C5412AD, STC12C5620AD, &#8230;) - here we using the LQFP-32 pins version (right chip in the picture above)</li>
<li>USB-to-TTL (5V) adaptor like in the picture above (these can be found easily via eBay) - my adaptor uses the popular CP2102 USB-to-UART bridge</li>
<li>Wire, adaptor board, &#8230;</li>
<li>a PC</li>
<li>a book about 8051 programming (STC doesn&#8217;t provide a real 8051 programming reference paper, however this isn&#8217;t needed as their MCUs are 100% compatible to the original 8051 generic MCU programming !)</li>
</ul>
<p><strong>Steps:</strong></p>
<ol>
<li>Connect the STC MCU to the USB-to-TTL adaptor:<br />
USB-adaptor <strong>TX</strong> &lt;&#8212;&gt; MCU <strong>RX</strong><br />
USB-adaptor <strong>RX</strong> &lt;&#8212;&gt; MCU <strong>TX</strong><br />
USB-adaptor <strong>+5V </strong>&lt;&#8212;&gt;  MCU <strong>VCC</strong><br />
USB-adaptor <strong>GND</strong> &lt;&#8212;&gt; MCU <strong>GND</strong><br />
That&#8217;s too easy isn&#8217;t it? <img src='http://grauonline.de/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li><a href="http://www.mcu-memory.com/datasheet/stc/stc-isp-v4.80/stc-isp-v4.80-not-setup.EXE" title="Download STC ISP software v4.80 (Chinese)">Download STC ISP software v4.80 (Chinese user interface) </a>- I needed v4.80 for my MCU, newer MCUs need newer ISP versions!</li>
<li><a href="https://www.keil.com/demo/eval/c51.htm" title="Download Keil uVison IDE and compiler (evaluation)">Download Keil uVision IDE and Compiler (evaluation)<br />
</a></li>
<li>Install uVision, create a new project &#8220;Atmel AT89S52&#8243;, no startup file. Under Project options, set OSC frequency, and check &#8220;hex file&#8221; output.</li>
<li>In uVision, create a new file (test1.c), and add it to the project.  Write your first MCU program in this file.</li>
<li>Add the corresponding STC MCU header file to your project and include it (e.g. STC12C5410AD.H or STC12C5620AD.H). They contain the port and memory definitions for your type of MCU. You can find them in the download below.</li>
<li>Compile to .hex file</li>
<li>Upload .hex file using the ISP software.  <strong>Important: </strong>the STC MCU automatically starts reading and flashing the program via RX line when a certain sequence is sent at start up - therefore, you first need to start the &#8216;Download&#8217; in the ISP software, and <strong>_after_</strong> that turn on the MCU !  Also, both the ISP software and MCU will automatically handshake a good baud rate  (e.g. if the internal 6 Mhz OSC is used, the ISP software will probe a &#8216;good&#8217; baud rate, so that the MCU will start downloading).</li>
</ol>
<p><strong>Downloads:</strong></p>
<p><a href="http://grauonline.de/wordpress/wp-content/uploads/stc_demo.zip" title="stc_demo.zip">stc_demo.zip </a><br />
(shows how to initialize the UART, ADC and successively sends the value of ADC0 via UART to the PC)</p>
]]></content:encoded>
			<wfw:commentRss>http://grauonline.de/wordpress/?feed=rss2&amp;p=44</wfw:commentRss>
		</item>
	</channel>
</rss>

