<?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/"
	>

<channel>
	<title>derxen Blog &#187; Technik</title>
	<atom:link href="http://www.derxen.de/blog/category/technik/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.derxen.de/blog</link>
	<description>systematisch, funktionell, kreativ</description>
	<lastBuildDate>Thu, 10 Jul 2014 13:10:35 +0000</lastBuildDate>
	<language>de-DE</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Lego Lagersystem</title>
		<link>http://www.derxen.de/blog/2012/technik/lego-lagersystem/</link>
		<comments>http://www.derxen.de/blog/2012/technik/lego-lagersystem/#comments</comments>
		<pubDate>Sat, 06 Oct 2012 17:58:47 +0000</pubDate>
		<dc:creator><![CDATA[Heinrich]]></dc:creator>
				<category><![CDATA[Technik]]></category>

		<guid isPermaLink="false">http://www.derxen.de/blog/?p=1973</guid>
		<description><![CDATA[Dies ist ein Lagerroboter, der über USB am Computer angeschlossen ist. Er holt Dinge auf Befehl des Computers herbei. Umgesetzt mit Lego, einer Conrad-Relais-Karte und einem H-Tronic Spannungsmesser . Programmiert in JAVA mit Eclipse.]]></description>
				<content:encoded><![CDATA[<div id="attachment_1981" style="width: 190px" class="wp-caption alignleft"><a href="http://www.derxen.de/blog/wp-content/uploads/2012/10/elektronik.jpg"><img class="size-medium wp-image-1981 " title="elektronik" src="http://www.derxen.de/blog/wp-content/uploads/2012/10/elektronik-300x225.jpg" alt="Lego Lagersystem Elektronik" width="180" height="135" /></a><p class="wp-caption-text">Lego Lagersystem Elektronik</p></div>
<p>Dies ist ein Lagerroboter, der über USB am Computer angeschlossen ist. Er holt Dinge auf Befehl des Computers herbei. Umgesetzt mit Lego, einer <a title="Conrad-Relaiskarte mit JAVA steuern" href="http://www.derxen.de/blog/2011/top-thema/relaiskarte-mit-java-steuern/">Conrad-Relais-Karte</a> und einem <a title="H-TRONIC USB Datenerfassungssystem per JAVA (HB627)" href="http://www.derxen.de/blog/2011/top-thema/h-tronic-usb-datenerfassungssystem-per-java-hb627/">H-Tronic Spannungsmesser</a> . Programmiert in JAVA mit Eclipse.</p>
<iframe width="460" height="330" src="http://www.youtube.com/embed/pXf90wwnjmg?rel=0" frameborder="0" allowfullscreen></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.derxen.de/blog/2012/technik/lego-lagersystem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Atmel AT90USBKey 2 mit LCD-Display</title>
		<link>http://www.derxen.de/blog/2012/technik/atmel-at90-usb-key-2-mit-lcd-display/</link>
		<comments>http://www.derxen.de/blog/2012/technik/atmel-at90-usb-key-2-mit-lcd-display/#comments</comments>
		<pubDate>Mon, 24 Sep 2012 12:55:43 +0000</pubDate>
		<dc:creator><![CDATA[Heinrich]]></dc:creator>
				<category><![CDATA[Technik]]></category>

		<guid isPermaLink="false">http://www.derxen.de/blog/?p=1930</guid>
		<description><![CDATA[Im folgenden findet ihr eine kurze Dokumentation darüber, wie man ein AT90-Chip mit einem LCD-Display kombinieren und programmieren kann. Ziel ist es, mit dem AT90 einen eigenen Text auf dem LCD-Display anzuzeigen. Die Komponenten Um die Komponenten (Gleichmann GE-C1602B-TMI-JT/R und Atmel AT90USBKey) zweckmäßig miteinander verbinden zu können, ist eine Steckplatine hilfreich. So erspart man sich das Löten. [&#8230;]]]></description>
				<content:encoded><![CDATA[<div id="attachment_1932" style="width: 190px" class="wp-caption alignleft"><a href="http://www.derxen.de/blog/wp-content/uploads/2012/09/Top_HD.jpg"><img class="size-medium wp-image-1932" title="Atmel AT90 mit Gleichmann LCD" src="http://www.derxen.de/blog/wp-content/uploads/2012/09/Top_HD-300x225.jpg" alt="Atmel AT90 mit Gleichmann LCD" width="180" height="135" /></a><p class="wp-caption-text">Atmel AT90 USB Key 2 mit LCD-Display</p></div>
<p>Im folgenden findet ihr eine kurze Dokumentation darüber, wie man ein AT90-Chip mit einem LCD-Display kombinieren und programmieren kann.</p>
<p>Ziel ist es, mit dem AT90 einen eigenen Text auf dem LCD-Display anzuzeigen.</p>
<p><strong>Die Komponenten</strong></p>
<p>Um die Komponenten (<a title="Gleichmann GE-C1602B-TMI-JT/R" href="http://www.conrad.de/ce/de/product/183045/Alphanumerisches-LCD-Modul-Gleichmann-GE-C1602B-TMI-JTR-Zeichenformat-16-x-2-Zeichenhoehe-555-mm-Blau-Weiss/SHOP_AREA_17651&amp;promotionareaSearchDetail=005">Gleichmann GE-C1602B-TMI-JT/R</a> und <a title="Atmel AT90USBKey" href="http://www.conrad.de/ce/de/product/155248/Evaluation-Board-AT90USBKey-Atmel-AT90USBKey/SHOP_AREA_29142&amp;promotionareaSearchDetail=005" target="_blank">Atmel AT90USBKey</a>) zweckmäßig miteinander verbinden zu können, ist eine <a title="Steckplatine" href="http://www.conrad.de/ce/de/product/526819/Steckplatine-EIC-801-Steckplatine-L-x-B-x-H-84-x-54-x-85-mm-Anzahl-Polklemmen-100/SHOP_AREA_14742&amp;promotionareaSearchDetail=005">Steckplatine</a> hilfreich. So erspart man sich das Löten.</p>
<div id="attachment_1935" style="width: 190px" class="wp-caption alignleft"><a href="http://www.derxen.de/blog/wp-content/uploads/2012/09/Ports_HD.jpg"><img class="size-medium wp-image-1935 " title="AT90 Ports" src="http://www.derxen.de/blog/wp-content/uploads/2012/09/Ports_HD-300x225.jpg" alt="AT90 Ports" width="180" height="135" /></a><p class="wp-caption-text">AT90 Ports</p></div>
<p><strong>Der Aufbau</strong></p>
<p>Leider sind die Ports am AT90 von den Dimensionen her von Atmel etwas unglücklich gewählt. Ich habe keine passenden Stiftleisten gefunden, die man als Aufsatz benutzen könnte.</p>
<p>Stattdessen habe ich einfach ein Kupferkabel benutzt, welches dem Durchmesser der Ports entspricht. Anschließend habe ich die Kabel mit einer Heißklebepistole miteinander verschmolzen. So ist eine halbwegs feste und kostengünstige Verbindung gegeben, die sich für Testzwecke sehr gut eignet.</p>
<div id="attachment_1940" style="width: 190px" class="wp-caption alignleft"><a href="http://www.derxen.de/blog/wp-content/uploads/2012/09/Display_HD.jpg"><img class="size-medium wp-image-1940" title="LCD-Display Ports" src="http://www.derxen.de/blog/wp-content/uploads/2012/09/Display_HD-300x225.jpg" alt="LCD-Display Ports" width="180" height="135" /></a><p class="wp-caption-text">LCD-Display Ports</p></div>
<p>Das LCD-Display habe ich direkt auf die Steckplatine gesetzt, da sich das Rastermaß der Steckplatine mit den Abständen der LCD-Ports deckt. Kleiner Tipp: Die Drahtstücke je ein bischen verbiegen und danach einzeln einsetzen. So drücken sich die Drähte gut an die Portkontakte des LCDs.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>Die Programmierung</strong></p>
<p>Wenn ihr den Quellcode einfach kopieren wollt, dann müsst ihr folgende Portverbindungen einhalten (je linke Spalte mit rechter Spalte verbinden):</p>
<div style="float: left; padding: 0px 15px 0px 0px;">
<table>
<tbody>
<tr>
<th>AT90</th>
<th>LCD</th>
</tr>
<tr>
<td>PC0</td>
<td>Vss</td>
</tr>
<tr>
<td>PC1</td>
<td>Vdd</td>
</tr>
<tr>
<td>PC2</td>
<td>V0</td>
</tr>
<tr>
<td>PC3</td>
<td>RS</td>
</tr>
<tr>
<td>PC4</td>
<td>R/W</td>
</tr>
<tr>
<td>PC5</td>
<td>E</td>
</tr>
<tr>
<td>PC6</td>
<td>A</td>
</tr>
<tr>
<td>PC7</td>
<td>K</td>
</tr>
<tr>
<td>PD1</td>
<td>DB4</td>
</tr>
<tr>
<td>PD2</td>
<td>DB5</td>
</tr>
<tr>
<td>PD3</td>
<td>DB6</td>
</tr>
<tr>
<td>PD4</td>
<td>DB7</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Top-Ansicht von AT90-USBKey2</strong></p>
<p><a href="http://www.derxen.de/blog/wp-content/uploads/2012/09/at90-ports-pins1.png"><img class="alignleft size-medium wp-image-1947" title="at90-ports-pins" src="http://www.derxen.de/blog/wp-content/uploads/2012/09/at90-ports-pins1-300x100.png" alt="" width="300" height="100" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Beispiel: PC0 = Port C Pin 0</p>
<p>Die Bezeichnungen für die LCD-Ports finden sich im <a href="http://www.produktinfo.conrad.com/datenblaetter/175000-199999/183045-da-01-en-LCD_MODUL_16X2_LED_GE_C1602B_TMI_JT_R.pdf" target="_blank">Handbuch</a>.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>Übersicht der Funktionen (C-Quellcode kann unten heruntergeladen werden)</strong></p>
<p>Um etwas auf den LCD zu schreiben, braucht man lediglich folgende Funktion, die sehr einfach zu benutzen ist:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	
	watchdog_off<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//LCD-Init</span>
	init_board_for_lcd<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	lcd_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	lcd_show_strpos<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Joystickeingabe:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//0x00 bezeichnet hierbei die Stelle, an der der Text</span>
        <span style="color: #666666; font-style: italic;">//im LCD-Display eingefügt werden soll.</span>
        <span style="color: #666666; font-style: italic;">//0x00 = 1. Zeile 1. Stelle</span>
        <span style="color: #666666; font-style: italic;">//0x05 = 1. Zeile 6. Stelle</span>
        <span style="color: #666666; font-style: italic;">//0x0A = 1. Zeile 11. Stelle</span>
        <span style="color: #666666; font-style: italic;">//0x45 = 2. Zeile 6. Stelle</span>
        <span style="color: #666666; font-style: italic;">//0x4A = 2. Zeile 11. Stelle</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Wenn jemand andere Ports verwenden möchte, muss dementsprechend die config.h anpassen.</p>
<p>Fall jemand den Quellcode anpassen/erweitern möchte, hier eine kurze Funktionsübersicht:</p>
<table>
<tbody>
<tr>
<th>Funktion</th>
<th>Wirkung</th>
</tr>
<tr>
<td>lcd_show_strpos(uint8_t pos, char *data)</td>
<td>Schreibt einen String an die Position pos</td>
</tr>
<tr>
<td>lcd_show_string(char *data)</td>
<td>Schreibt einen String hinter die zuletzt beschriebene Position</td>
</tr>
<tr>
<td>lcd_show_char(uint8_t data)</td>
<td>Schreibt einen Buchstaben hinter die zuletzt beschriebene Position</td>
</tr>
<tr>
<td>lcd_cmd_setcurser(uint8_t data)</td>
<td>Ändert die Curserposition (wo soll das nächste Zeichen geschrieben werden)</td>
</tr>
<tr>
<td>lcd_cmd_cleardisplay()</td>
<td>Löscht den Displaytext</td>
</tr>
<tr>
<td>lcd_cmd(uint8_t data)</td>
<td>Sendet ein 8bit-Command an den LCD-Chip</td>
</tr>
<tr>
<td>lcd_sende_bits(uint8_t data)</td>
<td>Sendet 4bit an LCD</td>
</tr>
<tr>
<td>lcd_flanke()</td>
<td>Es werden die bits gelesen, die durch lcd_sende_bits() angelegt wurden</td>
</tr>
<tr>
<td>lcd_init()</td>
<td>Initialisierung des LCDs (Parameter in der config.h)</td>
</tr>
<tr>
<td>init_board_for_lcd()</td>
<td>Initialisierung des AT90 (Parameter in der config.h)</td>
</tr>
</tbody>
</table>
<p><strong><a href="http://www.derxen.de/blog/wp-content/uploads/2012/09/AT90USB-KEY2_.zip"><strong>» Download: AVR-Projekt: AT90USBKey 2 mit Gleichmann LCD-Display</strong></a></strong></p>
<p>&nbsp;</p>
<p><strong>Programm-Code auf das AT90 Board aufspielen</strong></p>
<p>&#8211; Stelle sicher, dass das AT90-Board resettet ist. Sicherheitshalber nochmal einen Reset durchführen:<br />
Zuerst HWB-Knopf (auf der Platine) drücken und gedrückt halten, dann RST drücken, während man noch HWB gedrückt hält. Anschließend RST loslassen und danach HWB loslassen.</p>
<p>&#8211; Dann muss das Projekt in AVR compiliert werden (z.B. über F7). Anschließend öffnet man FLIP (hier V3.4.5) und wählt:</p>
<p>&#8211; &#8222;Select a Communication Medium (zweites Icon von links)&#8220; -&gt; &#8222;USB&#8220; (Kann unter Win7 Probleme machen, bei mir hat es auf WinXP aber funktioniert)</p>
<p>&#8211; &#8222;Load HEX File (drittes Icon von Rechts)&#8220; -&gt; die zuvor kompilierte HEX-Datei suchen (hier: $projektordner/default/test.hex</p>
<p>&#8211; Unter &#8222;Operations Flow&#8220; müssen alle Häkchen angewählt werden</p>
<p>&#8211; Drücke Run und dann Start Application (+Reset)</p>
<p>Jetzt müsste der gewünschte Text auf dem LCD-Display zu sehen sein.</p>
<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.derxen.de/blog/2012/technik/atmel-at90-usb-key-2-mit-lcd-display/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.vmf-Tools Beta</title>
		<link>http://www.derxen.de/blog/2012/technik/vmf-tools-beta/</link>
		<comments>http://www.derxen.de/blog/2012/technik/vmf-tools-beta/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 11:52:00 +0000</pubDate>
		<dc:creator><![CDATA[Heinrich]]></dc:creator>
				<category><![CDATA[Technik]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[Hammer]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[vmf]]></category>

		<guid isPermaLink="false">http://www.derxen.de/blog/?p=1907</guid>
		<description><![CDATA[Hier ein Projekt von mir aus dem Jahr 2009: An wen richtet sich vmf.Tools? An alle, die mit dem Valve-Hammer-Editor der Source-Engine arbeiten. &#160; &#160; &#160; Was bringt mir dabei vmf.Tools? Die aktuelle Beta-Version von vmf.Tools bietet dir einen Entity-Konstrukt-Duplikator direkt im Browser. Bitte was? Stell dir vor, du hast ein Entity-Konstrukt erstellt &#8211; zum [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.derxen.de/vmftools/?sec=beispiel" target="_blank"><img class="  alignleft" src="http://theiro.vs120029.hl-users.com/vmftools/template/aboutvmftools/bild2_thumb.jpg" alt="" width="200" height="154" /></a></p>
<p><strong>Hier ein Projekt von mir aus dem Jahr 2009:</strong></p>
<p>An wen richtet sich vmf.Tools?<br />
An alle, die mit dem Valve-Hammer-Editor der Source-Engine arbeiten.<a href="http://developer.valvesoftware.com/wiki/Main_Page"><img class="alignnone" style="border-image: initial; border: 0px initial initial;" src="http://developer.valvesoftware.com/w/images/2/23/SourceLogo.gif" border="0" alt="" width="168" height="64" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h4>Was bringt mir dabei vmf.Tools?</h4>
<p>Die aktuelle Beta-Version von vmf.Tools bietet dir einen Entity-Konstrukt-Duplikator direkt im Browser.</p>
<h4>Bitte was?</h4>
<p>Stell dir vor, du hast ein Entity-Konstrukt erstellt &#8211; zum Beispiel eine schwingende Lampe, die an einem Seil hängt, ein dynamisch Licht hat und zerstörbar ist. Um ein derartiges Konstrukt zu erstellen, benötigt es viele Arbeitsschritte. Am Ende hat man viele viele Entities, mit Namen, Parent, Outputs usw.<br />
Will man diese Lampe nun ein zweites mal im Level haben, so reicht es nicht aus, das Konstrukt per Copy&amp;Paste zu kopieren, sondern man muss auch alle Parameter per Hand anpassen, damit das zweite Konstrukt unabhängig vom ersten funktionieren kann.<br />
<em>Hier hilft vmf.Tools aus</em>. Mit vmf.Tools wird einem die lästige Kopierarbeit abgenommen. Es muss nur einmal ein Template-Konstrukt erstellt werden, welches dann dupliziert werden kann. Die Parameter Name, Parent, Outputs usw. werden automatisch angepasst, so dass sich keiner der Duplikate nachher mit einem anderen überschneiden wird.<br />
So kann man die schwingende Lampe 10 mal (und auch öfter) duplizieren und an verschiedenen Orten der Map einfügen.</p>
<h4>Was muss ich dabei beachten?</h4>
<p>Das Entity-Konstrukt, dass du duplizieren möchtest, muss in einer eigenen .vmf-Datei abgespeichert werden. Nur das Konstrukt, nichts anderes. Anschließend lädst du die Datei hier hoch und konfigurierst das Programm nach deinen Ansprüchen.<br />
<strong>Dabei ist es egal,</strong> ob das Konstrukt aus World-Brushes, Displacements, Brushentities und/oder Pointentities besteht.<br />
<strong>Aufgrund der Betaversion</strong> MUSS in dieser Datei mindestens ein World-Brush UND ein Entity vorhanden sein, ansonsten erzeugt das Programm einen falschen Code.</p>
<h4>Ist vmf.Tools auf bestimmte Source-Mods begrenzt?</h4>
<p>Eigentlich nein. vmf.Tools wurde erfolgeich mit Half-Life 2 Maps getestet. Mit welchen verschiedenen Abwandlungen der Source-Engine das Programm noch zurecht kommt, ist nicht getestet. Theoretisch muss vmf.Tools mit allen Mods zurechtkommen (auch Custom-Entities sind kein Problem), da der Syntax der .vmf-Dateien von Valve &#8222;genormt&#8220; ist.</p>
<p><strong>Weblinks:<br />
</strong></p>
<ul>
<li><a title=".vmf-Tools" href="http://www.derxen.de/vmftools" target="_blank">.vmf-Tools aufrufen</a></li>
<li><a title="Beispiel anhand einer Bilderserie" href="http://www.derxen.de/vmftools/?sec=beispiel" target="_blank">Beispiel aufrufen</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.derxen.de/blog/2012/technik/vmf-tools-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Widerstandsmessung Conradrelaiskarte</title>
		<link>http://www.derxen.de/blog/2011/technik/widerstandsmessung-conradrelaiskarte/</link>
		<comments>http://www.derxen.de/blog/2011/technik/widerstandsmessung-conradrelaiskarte/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 15:40:19 +0000</pubDate>
		<dc:creator><![CDATA[Heinrich]]></dc:creator>
				<category><![CDATA[Technik]]></category>
		<category><![CDATA[Relaiskarte]]></category>
		<category><![CDATA[Widerstand]]></category>

		<guid isPermaLink="false">http://www.derxen.de/blog/?p=1868</guid>
		<description><![CDATA[Siehe auch: Conrad-Relaiskarte mit JAVA steuern . Da das Handbuch mir nichts über den Widerstand der Relaiskarte verraten hat, musste ich eine eigene Messung vornehmen, um eben jenes herauszufinden. In der Graphik seht ihr die Messreihe als Graphen. . Der Widerstand ist abhängig von der Anzahl n der eingeschalteten Relais. Bei n=0 Relais ist der Widerstand [&#8230;]]]></description>
				<content:encoded><![CDATA[<div style="width: 142px" class="wp-caption alignleft"><a href="http://www.google.de/products/catalog?q=conrad+relaiskarte&amp;hl=de&amp;client=firefox-a&amp;hs=4ja&amp;rls=org.mozilla:de:official&amp;prmd=ivns&amp;biw=1366&amp;bih=613&amp;um=1&amp;ie=UTF-8&amp;tbm=shop&amp;cid=4659892043775063980&amp;sa=X&amp;ei=uYhGTu-vKpGG-wbN2YDuBg&amp;ved=0CEIQ8wIwAA"><img class=" " title="Conrad Relaiskarte" src="http://lh3.googleusercontent.com/public/IixvUL-7aGVgYxvgetyIlEig8dWeQ25_Vb-rD_uBnzpWo6o8zlGqCgDLtCobsBsj96MTMPeia6zjRgtZhd86n7WgElmBMCZJm0KctvVki74GEGgmH0c_6IYN3Sm-yDmPrv4ao2BQpKgU-B2VQX1EYjojVgaJsJQphiq-Dnh-03qgV8DYwGdynofshJtOY7OofOx6Hd8Y4Q8plU544UDV37I-QsppEafOtpV-257sph37" alt="Conrad Relaiskarte" width="132" height="132" /></a><p class="wp-caption-text">Wie groß ist der Widerstand der Conrad-Relaiskarte? (Bildquelle: Google)</p></div>
<div>Siehe auch: <a title="Conrad-Relaiskarte mit JAVA steuern" href="http://www.derxen.de/blog/2011/top-thema/relaiskarte-mit-java-steuern/">Conrad-Relaiskarte mit JAVA steuern</a></div>
<div>.</div>
<div>Da das Handbuch mir nichts über den Widerstand der Relaiskarte verraten hat, musste ich eine eigene Messung vornehmen, um eben jenes herauszufinden. In der Graphik seht ihr die Messreihe als Graphen.</div>
<div>.</div>
<div>Der Widerstand ist abhängig von der Anzahl n der eingeschalteten Relais. Bei n=0 Relais ist der Widerstand am höchsten. Werden Relais eingeschaltet, sinkt der Gesamt-Widerstand der Relaiskarte.</div>
<div>
<p><a href="http://www.derxen.de/blog/wp-content/uploads/2011/12/WiderstandskennlinieCR1.png"><img class="alignnone size-medium wp-image-1877" style="padding-bottom: 40px;" title="WiderstandskennlinieCR" src="http://www.derxen.de/blog/wp-content/uploads/2011/12/WiderstandskennlinieCR1-300x180.png" alt="" width="300" height="180" /></a></p>
<p>&nbsp;</p>
</div>
<p><strong><br />
</strong></p>
<div style="clear: both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.derxen.de/blog/2011/technik/widerstandsmessung-conradrelaiskarte/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>H-TRONIC USB Datenerfassungssystem per JAVA (HB627)</title>
		<link>http://www.derxen.de/blog/2011/technik/h-tronic-usb-datenerfassungssystem-per-java-hb627/</link>
		<comments>http://www.derxen.de/blog/2011/technik/h-tronic-usb-datenerfassungssystem-per-java-hb627/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 14:52:52 +0000</pubDate>
		<dc:creator><![CDATA[Heinrich]]></dc:creator>
				<category><![CDATA[Technik]]></category>
		<category><![CDATA[Datenerfassungssystem]]></category>
		<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Schnittstelle]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://www.derxen.de/blog/?p=1825</guid>
		<description><![CDATA[H-TRONIC USB 12-Bit-Datenerfassungssystem (HB627) mit JAVA steuern Update 18.03.2012: Absturzursache behoben (falls nicht alle Bytes empfangen wurden und die ArrayList nicht die erwartete Länge bekam). Der Code hier im Artikel wurde dementsprechend auch aktualisiert. Mit dieser Platine kann man 8 verschiedene analoge Signale im Spannungsbereich von 0 bis 4095 mV messen. Dies tut die Karte [&#8230;]]]></description>
				<content:encoded><![CDATA[<div style="width: 230px" class="wp-caption alignleft"><a href="http://www.google.de/products/catalog?q=H-Tronic+12+Bit+USB-Datenerfassungssystem&amp;hl=de&amp;client=firefox-a&amp;hs=mlJ&amp;rls=org.mozilla:de:official&amp;prmd=ivns&amp;biw=1366&amp;bih=613&amp;um=1&amp;ie=UTF-8&amp;tbm=shop&amp;cid=10500545739129634256&amp;sa=X&amp;ei=szx3TtbSMs74sgakqOyWCw&amp;ved=0CEgQ8wIwAA"><img src="http://lh3.googleusercontent.com/public/kwLklZrJ7lN1_9FVp_mUZasNv-Ax4NzFwk6jySRTXmbf1FjIUWW9fQcNDmlfY6kah8atl8fQbGjAuXYHoakLO4OLXHqNZA6Ik3TKejmcy9w1Pl_iCdJLr7xIcUH7dYiodlLTvwuWf7mVXF9iUJH7GaAlLe-xFwVTat8ete-Si4v-kj_pCJJtA8I35Ouz2v9iAkxBhNRgZkL2j0iRigikf3wJRdPSHO9wVVIWzrHR3KEW3CSfr3aD92RCJL1bNCw_TNx19k15h8qVu-nad9AmQ1jhPQ" alt="H-TRONIC USB 12-Bit-Datenerfassungssystem Baustein (Quelle: Google)" width="220" height="220" /></a><p class="wp-caption-text">H-TRONIC USB 12-Bit-Datenerfassungssystem Baustein (Quelle: Google)</p></div>
<p><strong>H-TRONIC USB 12-Bit-Datenerfassungssystem (HB627) mit JAVA steuern</strong></p>
<p><strong>Update 18.03.2012:</strong> Absturzursache behoben (falls nicht alle Bytes empfangen wurden und die ArrayList nicht die erwartete Länge bekam). Der Code hier im Artikel wurde dementsprechend auch aktualisiert.</p>
<p>Mit dieser Platine kann man 8 verschiedene analoge Signale im Spannungsbereich von 0 bis 4095 mV messen. Dies tut die Karte im Grunde auch sehr zuverlässig, jedoch kann man sich, gerade als JAVA-Nutzer, an einigen Ecken der Lieferung ärgern. Dazu später mehr.</p>
<p><strong>Das Prinzip</strong></p>
<p>Wir senden eine Byte-Folge an die Karte (Befehl) und erhalten die aktuellen Spannungswerte als Antwort zurück. Laut Handbuch geht das 300x in der Sekunde, bei mir läuft die Karte allerdings erst bei höchstens 75 Abfragen in der Sekunde stabil, was aber (im Grunde)* immer noch sehr schnell ist.<strong><br />
</strong></p>
<p><strong>Pro-Argumente</strong></p>
<ul>
<li>Messungen (im Grunde)* sehr genau</li>
<li>Arbeitet (im Grunde)* sehr schnell</li>
<li>Gute Verarbeitung</li>
</ul>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong>Contra-Argumente</strong></p>
<ul>
<li>(*) Nur unter ideal-Voraussetzungen: Wenn an einem Kontakt kein geschlossener Stromkreis mit einer gewissen Spannung anliegt, so bekommt man für diesen Kontakt einen &#8222;Zufallswert&#8220; als Spannung geliefert. So muss man durch eine Messreihe unerwünschte Messergebnisse erfassen und rausfiltern. Das erhöht den Arbeitsaufwand für einen brauchbare Messreihe. Dieser Fehler der Karte ist besonders ärgerlich, wenn man (wie ich) eben messen will, ob ein Stromkreis geschlossen oder offen ist.<strong> </strong></li>
<li>Kein Stecker mitgeliefert</li>
<li>Karte kann nicht Kaskadiert werden (mehrere in &#8222;Reihe&#8220; schalten und über einen USB-Port steuern)</li>
<li>Handbuch / Dokumentation sehr mager</li>
</ul>
<div id="attachment_1835" style="width: 190px" class="wp-caption alignleft"><a href="http://www.derxen.de/blog/wp-content/uploads/2011/09/hb627-messreihe.png"><img class="size-medium wp-image-1835 " title="hb627-messreihe" src="http://www.derxen.de/blog/wp-content/uploads/2011/09/hb627-messreihe-300x151.png" alt="Mitgeliefertes Beispielprogramm: Liegt keine Spannung an, so erhalten wir willkürliche Spannungswerte. An Kontakt 8 liegt eine konstante Spannung an." width="180" height="91" /></a><p class="wp-caption-text">Mitgeliefertes Beispielprogramm: Liegt keine Spannung an, so erhalten wir willkürliche Spannungswerte. An Kontakt 8 liegt eine konstante Spannung an.</p></div>
<div style="clear: both;">.</div>
<p><strong>Anwendung der JAVA-Klasse</strong></p>
<p><strong>Die im folgenden beschriebene JAVA-Klasse braucht KEINE &#8222;Idealvoraussetzungen&#8220; (wie unter Contra (*) beschrieben). Der Preis dafür ist lediglich, dass die Abfrage etwas länger dauert.</strong> Das Prinzip: Es werden mehrere Messungen (cfg: &#8222;newLaps&#8220;) unmittelbar hintereinander ausgeführt und verglichen: Sind stark schwankende Werte gemessen worden, so geht die Klasse davon aus, dass dort keine Spannung anliegt (es werden willkürliche Messwerte gesendet, ein Bug der Mess-Karte!). Bewegen sich die Schwankungen allerdings innerhalb eines bestimmten Intervalls (cfg: &#8222;newTolerance&#8220;), so wird diese Spannung als richtig bzw. zuverlässig interpretiert. Ferner kann man einstellen, welche Spannung mindestens anliegen muss, um als richtig gewertet zu werden. Die im unteren Beispiel verwendete Konfigurationseinstellung hat bei mir mit (wahrscheinlich)** 100%iger Genauigkeit die richtigen Messwerte geliefert.</p>
<p>(** Nach tausenden Messdurchläufen keine Abweichung der Messwerte von den realen Umständen)</p>
<p>Zunächst müssen wir bei Nutzung von Windows 7 die RXTXcomm.jar eingebunden haben. Wie das geht, könnt ihr im Artikel zur <a title="Conrad-Relaiskarte mit JAVA steuern" href="http://www.derxen.de/blog/2011/top-thema/relaiskarte-mit-java-steuern/">Relaiskarte</a> nachlesen. Danach können wir die Klassen verwenden. Hier einen kleinen Crashkurs zu meiner Klasse:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>	
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//VERBINDUNG AUFBAUEN</span>
		HB627 hb627 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HB627<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;COM19&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">//KLASSE KONFIGURIEREN</span>
		<span style="color: #666666; font-style: italic;">//hb627.setCfg(newSleepTime, newLaps, newTolerance, newMinimumMV);</span>
		<span style="color: #666666; font-style: italic;">//STANDARDEINSTELLUNGEN:</span>
		<span style="color: #666666; font-style: italic;">//newLaps = 5; //Wieviele Messrunden soll eine Messung (ein Race) surchlaufen, bevor entschieden wird, ob der Port einen zuverlässigen Wert übermittelt hat? (je mehr, desto zuverlässiger); Wert = 1 setzen, wenn keine Messreihe vorgenommen werden soll, sondern im &quot;klassischen&quot; Sinne gemessen werden soll</span>
		<span style="color: #666666; font-style: italic;">//newTolerance = 25; //in mV. Wie hoch darf die Durchschnitts-Differenz zwischen den Messrunden-Werten eines einzelnen Mess-Ports höchstens sein, um noch als zuverlässiges Ergebnis eingestuft zu werden.</span>
		<span style="color: #666666; font-style: italic;">//newSleepTime = 16; //Wie lange soll nach jedem Kommando (nach jeder Runde [lap]) gewartet werden?</span>
		<span style="color: #666666; font-style: italic;">//newMinimumMV = 1500; //Welchen Wert muss die Messung mindestens haben, um ÜBERHAUPT berücksichtigt zu werden?</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">//ALLE PORTS GLEICHZEITIG LESEN / MESSEN</span>
		<span style="color: #666666; font-style: italic;">//Wo liegt eine konstante Spannung an?</span>
		<span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> resultB <span style="color: #339933;">=</span> hb627.<span style="color: #006633;">readAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	        <span style="color: #666666; font-style: italic;">//Wie hoch sind die anliegenden Spannungen? (vorher muss &quot;readAll&quot; oder &quot;read&quot; aufgerufen worden sein)</span>
		<span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> voltages <span style="color: #339933;">=</span> hb627.<span style="color: #006633;">getVoltage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">//Ergebnisse ausgeben	</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j<span style="color: #339933;">&lt;</span>resultB.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>resultB<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>voltages<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
                 <span style="color: #666666; font-style: italic;">//PORTS EINZELN LESEN / MESSEN</span>
                        <span style="color: #000066; font-weight: bold;">boolean</span> result <span style="color: #339933;">=</span> hb627.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> voltages <span style="color: #339933;">=</span> hb627.<span style="color: #006633;">getVoltage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>voltages<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Der Quellcode der JAVA-Klasse</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">gnu.io.CommPortIdentifier</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">gnu.io.SerialPort</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">gnu.io.SerialPortEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">gnu.io.SerialPortEventListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.BufferedOutputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.OutputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.TooManyListenersException</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HB627 <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> CommPortIdentifier commPortIdentifier<span style="color: #339933;">;</span> 
	<span style="color: #000000; font-weight: bold;">private</span> SerialPort serialPort<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">OutputStream</span> outputStream<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">BufferedOutputStream</span> out<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">InputStream</span> inputStream<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> cfg_laps<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> cfg_tolerance<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> sleepTime<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> mVschwelle<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> commando<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//letztes durchgeführtes commando</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> lap<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//aktuelle runde im rennen (race) (jedes race liefert ein Messergebnis in form von true oder false zurück)</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> ArrayList<span style="color: #339933;">&lt;</span>Integer<span style="color: #339933;">&gt;</span> finalResults<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> ArrayList<span style="color: #339933;">&lt;</span>byte<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span> respondResults<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> booleanResults<span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #666666; font-style: italic;">//KONSTRUKTOR: VERBINDUNG MIT EMPFAENGERKARTE HERSTELLEN (z.B. comName = &quot;COM17&quot; )</span>
	HB627<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> comName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		booleanResults <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		cfg_laps <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Wieviele Messrunden soll eine Messung (ein Race) surchlaufen, bevor entschieden wird, ob der Port einen zuverlässigen Wert übermittelt hat? (je mehr, desto zuverlässiger)</span>
		cfg_tolerance <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//in mV. Wie hoch darf die Durchschnitts-Differenz zwischen den Messrunden-Werten eines einzelnen Mess-Ports höchstens sein, um noch als zuverlässiges Ergebnis eingestuft zu werden.</span>
		sleepTime <span style="color: #339933;">=</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Wie lange soll nach jedem Kommando (nach jeder Runde [lap]) gewartet werden?</span>
		mVschwelle <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1500</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Welchen Wert muss die Messung mindestens haben, um ÜBERHAUPT berücksichtigt zu werden?</span>
&nbsp;
		finalResults <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Integer<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		respondResults <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>byte<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">//COM-PORT-OPEN</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>Main.<span style="color: #006633;">simulation</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
			<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
				commPortIdentifier <span style="color: #339933;">=</span> CommPortIdentifier.<span style="color: #006633;">getPortIdentifier</span><span style="color: #009900;">&#40;</span>comName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				serialPort <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>SerialPort<span style="color: #009900;">&#41;</span> commPortIdentifier.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span>comName,<span style="color: #cc66cc;">2000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				serialPort.<span style="color: #006633;">setSerialPortParams</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">19200</span>, SerialPort.<span style="color: #006633;">DATABITS_8</span>, SerialPort.<span style="color: #006633;">STOPBITS_1</span>, SerialPort.<span style="color: #006633;">PARITY_NONE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				outputStream <span style="color: #339933;">=</span> serialPort.<span style="color: #006633;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				out <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedOutputStream</span><span style="color: #009900;">&#40;</span>outputStream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Connected to &quot;</span> <span style="color: #339933;">+</span> comName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
			 <span style="color: #009900;">&#125;</span>
			 <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> exc<span style="color: #009900;">&#41;</span>
			 <span style="color: #009900;">&#123;</span>
				 <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Fehler Outputstream :&quot;</span><span style="color: #339933;">+</span>exc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			
			 <span style="color: #009900;">&#125;</span>
&nbsp;
			 <span style="color: #666666; font-style: italic;">//INPUT-STREAM</span>
			 <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
				inputStream <span style="color: #339933;">=</span> serialPort.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Inputstream open &quot;</span> <span style="color: #339933;">+</span> comName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			 <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> exc<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Fehler Inputstream :&quot;</span><span style="color: #339933;">+</span>exc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			 <span style="color: #009900;">&#125;</span>
			 <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
					serialPort.<span style="color: #006633;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> serialPortEventListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Add Eventlistener &quot;</span> <span style="color: #339933;">+</span> comName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">TooManyListenersException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;TooManyListenersException für Serialport&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				serialPort.<span style="color: #006633;">notifyOnDataAvailable</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>	
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">void</span> setCfg<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> newSleepTime, <span style="color: #000066; font-weight: bold;">int</span> newLaps, <span style="color: #000066; font-weight: bold;">int</span> newTolerance, <span style="color: #000066; font-weight: bold;">int</span> newMinimumMV<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		sleepTime <span style="color: #339933;">=</span> newSleepTime<span style="color: #339933;">;</span>
		cfg_laps <span style="color: #339933;">=</span> newLaps<span style="color: #339933;">;</span>
		cfg_tolerance <span style="color: #339933;">=</span> newTolerance<span style="color: #339933;">;</span>
		mVschwelle <span style="color: #339933;">=</span> newMinimumMV<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">int</span> getSleepTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> sleepTime<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//KOMMANDO-METHODE</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> cmd<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> third<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		commando <span style="color: #339933;">=</span> third<span style="color: #339933;">;</span>
		lap<span style="color: #339933;">++;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//KOMMANDOS IN ARRAY SCHREIBEN</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Datenpaket schnüren </span>
		<span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> sendData <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		sendData<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#41;</span> <span style="color: #cc66cc;">99</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//byte0_array[0];</span>
		sendData<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#41;</span> <span style="color: #cc66cc;">48</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//cmd;</span>
		sendData<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">48</span><span style="color: #339933;">+</span>third<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//(cmd ^ sendData[0]);</span>
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">//DATEN SENDEN</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>Main.<span style="color: #006633;">simulation</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
				out.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>sendData, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				out.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">//System.out.println(&quot;Data send: First &quot; + sendData[0] + &quot;; second &quot; + sendData[1] + &quot;; third &quot; + sendData[2] + &quot; &quot;);</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;No data sended&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//WARTEN</span>
			<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">//System.out.println(&quot;wait &quot; + sleepTime + &quot;ms&quot;);</span>
				<span style="color: #003399;">Thread</span>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span>sleepTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">InterruptedException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Sleeping failed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//VERBINDUNG ZUR HB627-KARTE BEENDEN</span>
	<span style="color: #000066; font-weight: bold;">void</span> close<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>Main.<span style="color: #006633;">simulation</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			serialPort.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Connection closed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//EINGEHENDES SIGNAL AUS HIGH-BYTE UND LOW-BYTE UMRECHNEN</span>
	<span style="color: #000066; font-weight: bold;">int</span> parseResponse<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span> highByte, <span style="color: #000066; font-weight: bold;">byte</span> lowByte<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> intHB <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> intLB <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//In positive Zahlen parsen</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>highByte <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			intHB <span style="color: #339933;">=</span> <span style="color: #cc66cc;">256</span> <span style="color: #339933;">+</span> highByte<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			intHB <span style="color: #339933;">=</span> highByte<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>lowByte <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			intLB <span style="color: #339933;">=</span> <span style="color: #cc66cc;">256</span> <span style="color: #339933;">+</span> lowByte<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			intLB <span style="color: #339933;">=</span> lowByte<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//IN FERTGE ZAHL UMRECHNEN</span>
		<span style="color: #000066; font-weight: bold;">int</span> result <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>intHB<span style="color: #339933;">*</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> intLB<span style="color: #339933;">*</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//LOW-BYTE WIRD zZ IGNORIERT!</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//NEUES RENNEN / NEUE MESSUNG: GRUNDLAGE SCHAFFEN (Vergleichswerte zurücksetzen)</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> newRace<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		respondResults.<span style="color: #006633;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		finalResults.<span style="color: #006633;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		lap <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>booleanResults.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			booleanResults<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//EINEN PORT LESEN/MESSEN</span>
	<span style="color: #000066; font-weight: bold;">boolean</span> read<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> port<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		newRace<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>cfg_laps<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			cmd<span style="color: #009900;">&#40;</span>port<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>finalResults.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>				
			<span style="color: #666666; font-style: italic;">//System.out.println(&quot;FR: &quot; + finalResults.get(0));</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">/*System.out.println(&quot; &quot;);
			for (int k = 0;k&lt;finalResults.size();k++) {
				System.out.print(finalResults.get(k) + &quot; &quot;);
			}*/</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//hat der messwert die mindest-volt-schwelle erreicht?</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//if (finalResults.get(0) &gt;= mVschwelle || true) {</span>
&nbsp;
				<span style="color: #000066; font-weight: bold;">int</span> durchschnitt <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">int</span> differenz <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">int</span> high<span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">//durchschnitt ausrechnen</span>
&nbsp;
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>finalResults.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">+</span>cfg_laps<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>finalResults.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900;">&#40;</span>cfg_laps<span style="color: #339933;">*</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>cfg_laps<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						durchschnitt <span style="color: #339933;">+=</span> finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
					durchschnitt <span style="color: #339933;">=</span> durchschnitt<span style="color: #339933;">/</span>cfg_laps<span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #666666; font-style: italic;">//Checken, ob höchstdifferenz eingehalten wird</span>
					<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>cfg_laps<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
						high <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>durchschnitt <span style="color: #339933;">&gt;</span> finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>high<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							differenz <span style="color: #339933;">+=</span> durchschnitt<span style="color: #339933;">-</span>finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>high<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
							differenz <span style="color: #339933;">+=</span> finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>high<span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>durchschnitt<span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>differenz<span style="color: #339933;">/</span>cfg_laps<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> cfg_tolerance <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;!tolerance: &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>differenz<span style="color: #339933;">/</span>cfg_laps<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;tolerance: &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>differenz<span style="color: #339933;">/</span>cfg_laps<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						booleanResults<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
						<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Notice: (Array-Fehler)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #666666; font-style: italic;">//} else {</span>
		<span style="color: #666666; font-style: italic;">//	return false;</span>
		<span style="color: #666666; font-style: italic;">//}		</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//ALLE PORTS LESEN/MESSEN</span>
	<span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> readAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		newRace<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>cfg_laps<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			cmd<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> result <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">false</span>,<span style="color: #000066; font-weight: bold;">false</span>,<span style="color: #000066; font-weight: bold;">false</span>,<span style="color: #000066; font-weight: bold;">false</span>,<span style="color: #000066; font-weight: bold;">false</span>,<span style="color: #000066; font-weight: bold;">false</span>,<span style="color: #000066; font-weight: bold;">false</span>,<span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> 
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>finalResults.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>				
&nbsp;
&nbsp;
			<span style="color: #666666; font-style: italic;">/*System.out.println(&quot; &quot;);
			for (int k = 0;k&lt;finalResults.size();k++) {
				System.out.print(finalResults.get(k) + &quot; &quot;);
			}*/</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">//System.out.println(&quot;FR &quot;+(i+1)+&quot;: &quot; + finalResults.get(i));</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> mVschwelle<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
					<span style="color: #000066; font-weight: bold;">int</span> durchschnitt <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
					<span style="color: #000066; font-weight: bold;">int</span> differenz <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
					<span style="color: #000066; font-weight: bold;">int</span> high<span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #666666; font-style: italic;">//durchschnitt ausrechnen</span>
					<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j<span style="color: #339933;">&lt;</span>cfg_laps<span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						durchschnitt <span style="color: #339933;">+=</span> finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>j<span style="color: #339933;">*</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					durchschnitt <span style="color: #339933;">=</span> durchschnitt<span style="color: #339933;">/</span>cfg_laps<span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #666666; font-style: italic;">//Checken, ob höchstdifferenz eingehalten wird</span>
					<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j<span style="color: #339933;">&lt;</span>cfg_laps<span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						high <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">*</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>i<span style="color: #339933;">;</span>
&nbsp;
						<span style="color: #666666; font-style: italic;">/*if (i==7) {
							System.out.println(durchschnitt + &quot; dif &quot; + finalResults.get(high));
						}*/</span>
&nbsp;
						<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>durchschnitt <span style="color: #339933;">&gt;</span> finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>high<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							differenz <span style="color: #339933;">+=</span> durchschnitt<span style="color: #339933;">-</span>finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>high<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
							differenz <span style="color: #339933;">+=</span> finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>high<span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>durchschnitt<span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>differenz<span style="color: #339933;">/</span>cfg_laps<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> cfg_tolerance <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #666666; font-style: italic;">//System.out.println(&quot;!tolerance: &quot; + (differenz/cfg_laps));</span>
						result<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #666666; font-style: italic;">//System.out.println(&quot;tolerance: &quot; + (differenz/cfg_laps));</span>
						booleanResults<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
						result<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//MESSWERTE IN mV-Ausgeben</span>
	<span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getVoltage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> result <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>booleanResults<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				result<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> finalResults.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				result<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//DATEN EMPFANGEN &amp; VERARBEITEN</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> serialPortDataAvailable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> data <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">17</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
			<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>inputStream.<span style="color: #006633;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
				inputStream.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span>data, <span style="color: #cc66cc;">0</span>, data.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">//System.out.println(&quot;[] &quot;+data[0]+&quot; &quot;+data[1]+&quot; &quot;+data[2]+&quot; &quot;+data[3]+&quot; &quot;+data[4]+&quot; &quot;+data[5]+&quot; &quot;+data[6]+&quot; &quot;+data[7]+&quot; &quot;+data[8]+&quot; &quot;+data[9]+&quot; &quot;+data[10]+&quot; &quot;+data[11]+&quot; &quot;+data[12]+&quot; &quot;+data[13]+&quot; &quot;+data[14]+&quot; &quot;+data[15]+&quot; &quot;+data[16]+&quot;&quot;);</span>
&nbsp;
				<span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> currentbytes <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">int</span> currentvoltage<span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000066; font-weight: bold;">int</span> fb<span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">int</span> sb<span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #009900;">&#40;</span>data.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
					fb <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
					sb <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">*</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sb <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">17</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>commando <span style="color: #339933;">==</span> <span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						currentbytes<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> data<span style="color: #009900;">&#91;</span>sb<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
						currentbytes<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> data<span style="color: #009900;">&#91;</span>fb<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
						currentbytes<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> data<span style="color: #009900;">&#91;</span>sb<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
						currentbytes<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> data<span style="color: #009900;">&#91;</span>fb<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
&nbsp;
					currentvoltage <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">parseResponse</span><span style="color: #009900;">&#40;</span>currentbytes<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>, currentbytes<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					respondResults.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>currentbytes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					finalResults.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>currentvoltage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
					<span style="color: #666666; font-style: italic;">//System.out.print(currentvoltage + &quot;(&quot; +fb+ &quot;&quot; +sb+ &quot;): &quot; + data[fb] + &quot;/ &quot; + data[sb] +&quot; || &quot;);</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #666666; font-style: italic;">//System.out.println(&quot; &quot;);</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;!!! Data could not be recieved !!!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">class</span> serialPortEventListener <span style="color: #000000; font-weight: bold;">implements</span> SerialPortEventListener <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> serialEvent<span style="color: #009900;">&#40;</span>SerialPortEvent event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getEventType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">case</span> SerialPortEvent.<span style="color: #006633;">DATA_AVAILABLE</span><span style="color: #339933;">:</span>
				serialPortDataAvailable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">case</span> SerialPortEvent.<span style="color: #006633;">BI</span><span style="color: #339933;">:</span>
			<span style="color: #000000; font-weight: bold;">case</span> SerialPortEvent.<span style="color: #006633;">CD</span><span style="color: #339933;">:</span>
			<span style="color: #000000; font-weight: bold;">case</span> SerialPortEvent.<span style="color: #006633;">CTS</span><span style="color: #339933;">:</span>
			<span style="color: #000000; font-weight: bold;">case</span> SerialPortEvent.<span style="color: #006633;">DSR</span><span style="color: #339933;">:</span>
			<span style="color: #000000; font-weight: bold;">case</span> SerialPortEvent.<span style="color: #006633;">FE</span><span style="color: #339933;">:</span>
			<span style="color: #000000; font-weight: bold;">case</span> SerialPortEvent.<span style="color: #006633;">OUTPUT_BUFFER_EMPTY</span><span style="color: #339933;">:</span>
			<span style="color: #000000; font-weight: bold;">case</span> SerialPortEvent.<span style="color: #006633;">PE</span><span style="color: #339933;">:</span>
			<span style="color: #000000; font-weight: bold;">case</span> SerialPortEvent.<span style="color: #006633;">RI</span><span style="color: #339933;">:</span>
			<span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>	
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Bekannte / Mögliche Schwachstellen / Bugs in der Klasse</strong></pre>
<ul>
<li>Ich habe nicht geprüft (da in meinem Anwendungsbereich unerheblich) ob die gemessenen Spannungswerte (&#8222;getVoltage()&#8220;) den realen Spannungswerten entsprechen. Eventuell ergibt sich die tatsächliche Spannung erst nach durch die Differenz von 4095&#8230; oder auch nicht. Ausgeschlossen werden kann ist, dass &#8222;getVoltage()&#8220; falsche ergebnisse liefert. Man muss diese eben nur richtig interpretieren können.</li>
<li>Die Umrechnung von High-Byte und Lowbyte (Antwort von der Empfängerkarte) ist möglicherweise unvollständig, jedoch ausreichend (für meine Zwecke). Für eine Umrechnung unter berücksichtigung des Low-Bytes fehlt mir bisher die korrekte Formel, die sich auch nicht aus dem Handbuch ergibt. Sobald ich in diesem Punkt weiter bin, werde ich das im Kommentarbereich ergänzen.</li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.derxen.de/blog/2011/technik/h-tronic-usb-datenerfassungssystem-per-java-hb627/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
