<?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>Tech Toy Hacks</title>
	<atom:link href="http://blog.perquin.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.perquin.com</link>
	<description>A loose collection of hardware/software projects.</description>
	<lastBuildDate>Mon, 03 Sep 2012 15:35:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>AR Drone USB Drive</title>
		<link>http://blog.perquin.com/blog/ar-drone-usb-drive/</link>
		<comments>http://blog.perquin.com/blog/ar-drone-usb-drive/#comments</comments>
		<pubDate>Mon, 03 Sep 2012 11:49:48 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[AR.Drone Parrot]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=224</guid>
		<description><![CDATA[The file below contains the precompiled modules to use an usb drive on the AR.Drone v1.0. It has been tested to work with firmware 1.11.3 and 1.3.3 Download usb-drive.tar.gz To install, ftp usb-drive.tar.gz to the drone&#8217;s /data/video directory, then open a telnet session to the drone and execute: cd /data/video tar xzf usb-drive.tar.gz /data/video/usb-drive/load.sh The load.sh <a href='http://blog.perquin.com/blog/ar-drone-usb-drive/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The file below contains the precompiled modules to use an usb drive on the AR.Drone v1.0. It has been tested to work with firmware 1.11.3 and 1.3.3</p>
<p><a href="http://blog.perquin.com/wp-content/uploads/2012/09/usb-drive.tar.gz">Download usb-drive.tar.gz</a></p>
<p>To install, ftp usb-drive.tar.gz to the drone&#8217;s /data/video directory, then open a telnet session to the drone and execute:<br />
cd /data/video<br />
tar xzf usb-drive.tar.gz<br />
/data/video/usb-drive/load.sh</p>
<p>The load.sh file and the recipe to create the the .ko binaries was found here:<br />
<a href="http://taghof.github.com/Navigation-for-Robots-with-WIFI-and-CV/blog/2012/01/12/Enabling-The-Drone-USB-Port/">http://taghof.github.com/Navigation-for-Robots-with-WIFI-and-CV/blog/2012/01/12/Enabling-The-Drone-USB-Port/</a><br />
Thanks Morten Daugaard and Thomas Vrang Thyregod!</p>
<p>Note: on my drone setting pin 127 did not enable the +5V on the USB connector, I probably blew up the pin in previous experiments!!! So, instead I used the +5V from pin1 on the navboard connector. This works, but only if the USB Stick is inserted after running the load.sh script&#8230;</p>
<p><a href="http://blog.perquin.com/wp-content/uploads/2012/09/usb-drive.png"><img class="alignnone size-full wp-image-226" title="usb-drive" src="http://blog.perquin.com/wp-content/uploads/2012/09/usb-drive.png" alt="" width="677" height="666" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/ar-drone-usb-drive/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AR Drone program.elf Replacement</title>
		<link>http://blog.perquin.com/blog/ar-drone-program-elf-replacement/</link>
		<comments>http://blog.perquin.com/blog/ar-drone-program-elf-replacement/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 23:22:25 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[AR.Drone Parrot]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=57</guid>
		<description><![CDATA[This project provides an open source firmware for the AR.Drone quadrocopter by Parrot. WARNING: This project is not supported nor endorsed by Parrot S.A., using this sofware will most likely void your warranty and might destroy your drone or make it fly away into deep space. Use at your own risk. Click here to download the <a href='http://blog.perquin.com/blog/ar-drone-program-elf-replacement/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>This project provides an open source firmware for the AR.Drone quadrocopter by Parrot.</p>
<p><strong>WARNING:</strong> This project is not supported nor endorsed by Parrot S.A., using this sofware will most likely void your warranty and might destroy your drone or make it fly away into deep space. Use at your own risk.</p>
<p><a href="http://blog.perquin.com/prj/ardrone/CustomFirmwareArDrone.zip">Click here to download the Custom Firmware</a> or <a href="https://github.com/ardrone/ardrone">browse the source code on github</a></p>
<p>The new firmware for the drone is called &#8216;fly&#8217;. Upon start it will listen on UDP port 7777, waiting for the PC based controller called &#8216;OpenFlight&#8217; to connect. Once OpenFlight connects, &#8216;fly&#8217; kills the Parrot firmware &#8216;program.elf&#8217; and takes control of the drone. Now you can fly the drone with the PC keyboard. OpenFlight logs the flight data to a file called YYYYMMDDHHMMSS_navlog.csv.</p>
<h2>Known Issues</h2>
<ul>
<li>The PID controller parameters have not been optimized yet and currently only use &#8216;P&#8217; parameters. In particular the height controller will probably settle below the target height, or the drone might not have enough power to take off.</li>
<li>The OpenFlight user interface is very rudimentary.</li>
<li>No soft landing function is implemented. In order to land: fly the drone to minimum altitude and then switch off the motors.</li>
<li>&#8216;Flat Trim&#8217; parameters are not saved and are estimated after OpenFlight connects. Place the drone on a horizontal surface before connecting with OpenFlight.</li>
<li>No battery voltage monitoring. The drone will fall out of the sky once the battery is drained.</li>
</ul>
<h2>Install</h2>
<p>1) FTP the folder ardrone/bin to your drone</p>
<p>2) Open a telnet session to your drone and execute:<br />
# chmod 777 /data/video/bin/*<br />
# /data/video/bin/fly</p>
<p>3) On your pc, start OpenFlight.exe and follow the instructions on screen.</p>
<p>4) (Optional) Execute the following command to make &#8216;fly&#8217; start everytime you powerup the drone:<br />
# echo -e &#8220;\n\n/data/video/bin/fly &amp;&#8221; &gt;&gt; /etc/init.d/rcS</p>
<p>Other telnet commandline demo programs on the drone are:<br />
You&#8217;ll need to execute `killall program.elf` before using these programs!<br />
# /data/video/bin/navboard          &#8211; to see the navboard raw sensor data (3-axis accelleration, 3-axis gyro, sonar echos)<br />
# /data/video/bin/attitude          &#8211; to see the navboard attitude data (pitch angle, roll angle, yaw angle, height)<br />
# /data/video/bin/motorboard        &#8211; to control the motors/leds<br />
# /data/video/bin/vbat              &#8211; to see the on board voltages<br />
# /data/video/bin/video             &#8211; turns the drone into a giant optical mouse, keep it about 1 meter above ground and move it parallel to the ground. The program should report the movement.</p>
<h2>Directories</h2>
<p>ardrone/bin        &#8211; Pre-compiled binaries. FTP these files to your drone and run them in a telnet session.<br />
ardrone/fly        &#8211; Custom firmware to fly the drone, the controller is in directory /pc/OpenFlight<br />
ardrone/navboard   &#8211; Navboard driver and demo getting raw data from the navboard and converting it to realworld units<br />
ardrone/attitude   &#8211; Attitude driver and demo calculating attitude (pitch,roll,yaw and height) estimates from navboard data<br />
ardrone/motorboard &#8211; Motorboard driver and demo control of the 4 motors and leds<br />
ardrone/vbat       &#8211; Battery voltage driver and demo<br />
ardrone/gpio       &#8211; GPIO driver and demo<br />
ardrone/video      &#8211; Video driver and demo (needs start&amp;kill of program.elf to init the video)<br />
ardrone/util       &#8211; Utilities<br />
pc/OpenFlight      &#8211; C# controller for /ardrone/bin/fly</p>
<h2>Compiling</h2>
<p>For ardrone source code:<br />
1) Download and install arm-2011.03-41-arm-none-linux-gnueabi.exe &#8220;Sourcery G++ Lite 2011.03-41 for ARM GNU/Linux&#8221; from <a href="http://www.codesourcery.com/sgpp/lite/arm/portal/release1803">http://www.codesourcery.com/sgpp/lite/arm/portal/release1803</a><br />
2) On Windows: open a command prompt and cd to one of the directories<br />
3) Run the make.bat batch file to compile the program in that directory</p>
<p>For pc source code<br />
1) Download and install Visual Studio C# 2010 Express<br />
2) Open pc/OpenFlight.sln</p>
<h2>Changelog</h2>
<p>19-Sep-2011 V03 Added ardrone/fly and pc/OpenFlight<br />
20-Jul-2011 V02 Added video<br />
17-Jul-2011 V01 Initial release</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/ar-drone-program-elf-replacement/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>AR Drone Versions</title>
		<link>http://blog.perquin.com/blog/ar-drone-versions/</link>
		<comments>http://blog.perquin.com/blog/ar-drone-versions/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 09:54:41 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[AR.Drone Parrot]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=169</guid>
		<description><![CDATA[Below are the Software and Hardware versions of the AR Drone v1.0 that I used for the experiments on this site. The linux version is 2.6.26.47. Software Versions Firmware Release-Date Navboard Motor SDK FreeFlight-App 1.11.3 02-08-2012? 4.70 1.42 ? 1.9.3 1.7.4 26-07-2011 4.65 1.20 1.8 1.9 1.6.6 25-05-2011 4.62 1.16 1.7 1.8 1.5.1 24-02-2011 4.58 1.15 1.6 1.7.1 <a href='http://blog.perquin.com/blog/ar-drone-versions/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Below are the Software and Hardware versions of the AR Drone v1.0 that I used for the experiments on this site. The linux version is 2.6.26.47.</p>
<h2>Software Versions</h2>
<pre>Firmware Release-Date Navboard Motor SDK FreeFlight-App
  1.11.3   02-08-2012?    4.70  1.42   ?   1.9.3
   1.7.4   26-07-2011     4.65  1.20 1.8     1.9
   1.6.6   25-05-2011     4.62  1.16 1.7     1.8
   1.5.1   24-02-2011     4.58  1.15 1.6   1.7.1
   1.4.7            ?     4.58  1.11   ?       ?
   1.3.3   04-10-2010     4.55  1.11 1.5     1.5
   1.0.4   23-07-2010?       ?     ?   ?       ?</pre>
<h2>Hardware Versions</h2>
<pre>Drone v1.0: 11.0
Navboard:    6.0
Motorboard:  3.0 (Motor Type/Supplier is 1.1 or 2.2)</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/ar-drone-versions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AR Drone Video</title>
		<link>http://blog.perquin.com/blog/ar-drone-video/</link>
		<comments>http://blog.perquin.com/blog/ar-drone-video/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 12:50:32 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[AR.Drone Parrot]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=151</guid>
		<description><![CDATA[The front camera is an OmniVision ov7725 and the datasheet is available on the web. The bottom camera is a &#8220;cresyn qcif&#8221;, I could not find further information for this camera. You can download a on-board c program (source+binary) to convert the drone into a giant optical mouse. Hold the drone at a fix distance above <a href='http://blog.perquin.com/blog/ar-drone-video/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The front camera is an OmniVision ov7725 and the datasheet is available on the web.</p>
<p>The bottom camera is a &#8220;cresyn qcif&#8221;, I could not find further information for this camera.</p>
<p>You can <a href="http://blog.perquin.com/prj/ardrone/CustomFirmwareArDrone.zip">download a on-board c program (source+binary)</a> to convert the drone into a giant optical mouse. Hold the drone at a fix distance above ground and the program will report the movement in the horizontal plane.</p>
<h2>i2c bus</h2>
<p>The cameras are configured via the i2c bus. The front camera is on /dev/i2c-1 address 0&#215;21, the bottom camera is on /dev/i2c-0 address 0x5d.</p>
<h2>Bottom Camera Initialization</h2>
<pre>i2cset -y 0 0x49 0x0a 0x85     - sets Vdd4 to 3.0V
gpio 59 -d ho 1                - set CE enabled</pre>
<p>After this the camara is visible on /dev/i2c-0 address 0x5d. Now send configuration via i2c. The configuration sent over the i2c bus can be extracted from a &#8220;strace&#8221; of program.elf, but I did not dig furter into this.</p>
<h2>Front Camera Initialization</h2>
<pre>gpio 101 -d ho 0      - set PWDN_H 1=power down,0=active
gpio 109 -d ho 1      - set CE_H 1=enabled,0=not enabled</pre>
<p>However: This still does not make the camera visible on the i2c bus. Running program.elf does make it visible on the bus, after which &#8220;gpio 101 -d ho 1&#8243;, &#8220;gpio 101 -d i&#8221;,  &#8221;gpio 109 -d ho 0&#8243;, or &#8220;gpio 109 -d i&#8221; will make it disappear from the i2c bus.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/ar-drone-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AR Drone GPIO</title>
		<link>http://blog.perquin.com/blog/ar-drone-gpio/</link>
		<comments>http://blog.perquin.com/blog/ar-drone-gpio/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 18:09:02 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[AR.Drone Parrot]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=97</guid>
		<description><![CDATA[This blog page is dedicated to the GPIOs of the AR Drone. You can download a custom GPIO driver here. nr I/O Description 29 O ??? disable NAND flash write protection on P6 dev 1=disable write prot (FC6050 Parrot platform) fc6050.c 34 O ??? disable NAND flash write protection on P6 dev 1=disable write prot <a href='http://blog.perquin.com/blog/ar-drone-gpio/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>This blog page is dedicated to the GPIOs of the AR Drone. You can download a custom GPIO driver <a href="http://blog.perquin.com/prj/ardrone/CustomFirmwareArDrone.zip">here</a>.</p>
<pre><strong>nr I/O Description
</strong> 29 O ??? disable NAND flash write protection on P6 dev 1=disable write prot (FC6050 Parrot platform) fc6050.c
 34 O ??? disable NAND flash write protection on P6 dev 1=disable write prot
 43 O ??? Reset_Wlan 1=reset
 59 O Camera1 (Facing Down) CE 1=enabled,0=not enabled
 63 O Red LED 0=off,1=on
 64 O Green LED 0=off,1=on
 68 O Motor1 /Select 0=selected,1=deselected
 69 O Motor2 /Select 0=selected,1=deselected
 70 O Motor3 /Select 0=selected,1=deselected
 71 O Motor4 /Select 0=selected,1=deselected
 89 ? ??? CAM0_VSYNC
101 O Camera0 (Horizontal) PWDN_H 1=power down,0=active
106 I Motor Cutout
107 O Motor Enable 1=Enable
108 I Reset Button 0=unpressed,1=pressed
109 O Camera0 (Horizontal) CE_H 1=enabled,0=not enabled
127 O USB Connector Pin1 - Vusb
130 O Navboard Connector Pin2 - PGED2
131 O Navboard Connector Pin4 - PGEC2
132 O Navboard Connector Pin6 - /MCLR
158 I Pair Button 0=unpressed,1=pressed</pre>
<div id="_mcePaste" class="mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;">﻿</div>
<h2>Extension Port Pinout</h2>
<pre>Pin1 Vusb +5V (USB red)
Pin2 Vbat +11.7
Pin3 USB D- (USB white)
Pin4 RX (Serial data input to Drone)
Pin5 USB D+ (USB green)
Pin6 TX (Serial data output from Drone)
Pin7 GRD (USB black)
Pin8 No Pin</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/ar-drone-gpio/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AR Drone i2c</title>
		<link>http://blog.perquin.com/blog/ar-drone-i2c/</link>
		<comments>http://blog.perquin.com/blog/ar-drone-i2c/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 18:06:48 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[AR.Drone Parrot]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=101</guid>
		<description><![CDATA[This blog page is dedicated to the I2C components of the AR Drone. You can download a custom i2c driver for the voltage measurements of the PMAAC here. /dev/i2c-0 0&#215;49 Atmel AT73C246 ﻿﻿﻿Power Management and Analog Companions (PMAAC) 0&#215;50 24C32WI eeprom﻿ 0x5d Bottom camera /dev/i2c-1  0&#215;21 Horizontal Camera &#8211; OmniVision ov7725 References http://awesome-drone.blogspot.com/2011/01/i2c-tools-for-ardrone.html]]></description>
			<content:encoded><![CDATA[<p>This blog page is dedicated to the I2C components of the AR Drone. You can download a custom i2c driver for the voltage measurements of the PMAAC <a href="http://blog.perquin.com/prj/ardrone/CustomFirmwareArDrone.zip">here</a>.</p>
<h2><strong>/dev/i2c-0</strong></h2>
<p>0&#215;49 Atmel AT73C246 ﻿﻿﻿Power Management and Analog Companions (PMAAC)<br />
0&#215;50 24C32WI eeprom﻿<br />
0x5d Bottom camera</p>
<h2><strong>/dev/i2c-1</strong></h2>
<p> 0&#215;21 Horizontal Camera &#8211; OmniVision ov7725</p>
<h2>References</h2>
<p><a href="http://awesome-drone.blogspot.com/2011/01/i2c-tools-for-ardrone.html">http://awesome-drone.blogspot.com/2011/01/i2c-tools-for-ardrone.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/ar-drone-i2c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AR Drone Navigation Board</title>
		<link>http://blog.perquin.com/blog/ar-drone-navboard/</link>
		<comments>http://blog.perquin.com/blog/ar-drone-navboard/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 10:19:01 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[AR.Drone Parrot]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=69</guid>
		<description><![CDATA[This blog page is dedicated to the NavBoard of the AR Drone. You can download an on-drone c program (source+compiled) to convert raw NavData into physical angle, rotation rate, height and temperature values. Navboard Init The following script  starts the navigation board data stream without first starting &#38; killing program.elf. The script has been tested on an AR.Drone with <a href='http://blog.perquin.com/blog/ar-drone-navboard/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>This blog page is dedicated to the NavBoard of the AR Drone.</p>
<p>You can <a href="http://blog.perquin.com/prj/ardrone/CustomFirmwareArDrone.zip">download an on-drone c program (source+compiled)</a> to convert raw NavData into physical angle, rotation rate, height and temperature values.</p>
<h2>Navboard Init</h2>
<p>The following script  starts the navigation board data stream without first starting &amp; killing program.elf. The script has been tested on an AR.Drone with firmware 1.7.4 and 1.3.3 and navboard hardware version 0xc0. I.e. the reply to command 15 is 0xc0.</p>
<p>The stty command sets up the serial port. The gpio command switches the /RESET pin of the navboard to high, and the echo command instructs the navboard to start the data stream. </p>
<pre>stty -F /dev/ttyPA2 460800 -parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
gpio 132 -d ho 1
echo -en "\x01" &gt; /dev/ttyPA2</pre>
<p>After this initialization the following command gets a navboard data packet:</p>
<pre>dd if=/dev/ttyPA2 count=1 bs=46 | hexdump -C</pre>
<h2>Navboard Data Packet</h2>
<p>After the navboard has been initialized and acquisition has been started, it sends a 46 byte data frame every 5ms (200Hz) over serial port /dev/ttyPA2. The structure of a data frame is:</p>
<pre> u16 size;                // +0x00 Size of the following data (always 0x2C)
 u16 seq;                 // +0x02 Sequence number, increases every update
 u16 acc[3];              // +0x04 Raw data (10-bit) of the accelerometers multiplied by 4
 u16 gyro[3];             // +0x0A Raw data for the gyros, 12-bit A/D converted voltage of the gyros. X,Y=IDG, Z=Epson 
 u16 gyro_110[2];         // +0x10 4.5x Raw data (IDG), gyro values with another resolution (see IDG-500 datasheet) 
 u16 acc_temp;            // +0x14 Accs temperature -- startup value 120 @ 25C, rising to 143
 u16 gyro_temp;           // +0x16 XYGyro temperature (IDG), 12-bit A/D converted voltage of IDG's temperature sensor -- startup value 1532 @ 25C, rising to 1572
 u16 vrefEpson;           // +0x18 ZGyro v_ref (Epson), 12-bit A/D converted reference voltage of the Epson sensor 
 u16 vrefIDG;             // +0x1A XYGyro v_ref (IDG), 12-bit A/D converted reference voltage of the IDG sensor  
 u16 us_echo;             // +0x1C bit15=1 echo pulse transmitted, bit14-0 first echo. Value 30 = 1cm. min value: 784 = 26cm
 u16 checksum;            // +0x1E Checksum = sum of all values except checksum (22 values)
 u16 us_echo_start;       // +0x20 Array with starts of echos (8 array values @ 25Hz, 9 values @ 22.22Hz)
 u16 us_echo_end;         // +0x22 Array with ends of echos   (8 array values @ 25Hz, 9 values @ 22.22Hz)
 u16 us_association_echo; // +0x24 Ultrasonic parameter -- maybe echo number starting with 0. max value 3758. examples: 0,1,2,3,4,5,6,7  ; 0,1,2,3,4,86,6,9
 u16 us_distance_echo;    // +0x26 Ultrasonic parameter -- no clear pattern
 u16 us_courbe_temps;     // +0x28 Ultrasonic parameter -- counts up from 0 to approx 24346 in 192 sample cycles of which 12 cylces have value 0
 u16 us_courbe_valeur;    // +0x2A Ultrasonic parameter -- value between 0 and 4000, no clear pattern. 192 sample cycles of which 12 cylces have value 0
 u16 us_courbe_ref;       // +0x2C Ultrasonic parameter -- coutns down from 4000 to 0 in 192 sample cycles of which 12 cylces have value 0</pre>
<h2>Navboard Commands</h2>
<p>The following lists the commands that can be sent to the navboard. The list is obtained from ARDrone_SDK_Version_1_7_20110525\ARDroneLib\Soft\Common\ardrone_common_config.h</p>
<pre>ADC_CMD_STARTACQ                = 1,  /**command to start acquisition with ADC                             **/
ADC_CMD_STOPACQ                 = 2,  /**command to stop acquisition with ADC                              **/
ADC_CMD_RESYNC                  = 3,  /**command to resync acquisition with ADC                            **/
ADC_CMD_TEST                    = 4,  /**command to ADC send a test frame (123456)                         **/
ADC_CMD_VERSION                 = 5,  /**command to ADC send his number : version (MSB) subversion (LSB) **/
   Example: reply to cmd 5 is 0x37 00 04 00 &lt;--&gt; version 4.37
ADC_CMD_SELECT_ULTRASOUND_22Hz  = 7,  /**set the ultrasound at 22,22Hz                                      **/
ADC_CMD_SELECT_ULTRASOUND_25Hz  = 8,  /**set the ultrasound at 25Hz                                         **/
ADC_CMD_SEND_CALIBRE            = 13, /**command to ADC to send the calibration                             **/
ADC_CMD_RECEVED_CALIBRE         = 14, /**command to ADC to receved a new calibration                        **/
ADC_CMD_GET_HARD_VERSION        = 15, /**get the hard version of the navboard                               **/
   Example: reply to cmd 15 is 0xc0 &lt;--&gt; version 11.0
ADC_CMD_ACTIVE_SEPARATION       = 16, /**enabled the separation of sources ultrasound                       **/
ADC_CMD_STOP_SEPARATION         = 17, /**disables the ultrasound source separation                          **/
ADC_CMD_RECEVED_PROD            = 18, /**command to ADC to receved the prod data                            **/
ADC_CMD_SEND_PROD               = 19, /**command to ADC to send the prod data                               **/
ADC_CMD_ACTIVE_ETALONAGE        = 20, /**command to ADC to send PWM ultrasond in continue                   **/
ADC_CMD_ACTIVE_ULTRASON         = 21, /**command to ADC to stop send PWM ultrasond in continue              **/
ADC_CMD_ACTIVE_TEST_ULTRASON    = 22, /**teste de la perturbation de l'ultrason par le wifi                 **/</pre>
<h2>Navboard Connector Pinout</h2>
<pre>1 : +Vcc (5v)
2 : PGED2/RP10(1)/CN16/PMD2/RB10 (8) (ICSP)  &lt;--&gt; GPIO 130
3 : Txd (to Navboard)
4 : PGEC2/RP11(1)/CN15/PMD1/RB11 (9) (ICSP)  &lt;--&gt; GPIO 131
5 : Rxd (from Navboard)
6 : /MCLEAR (18)                             &lt;--&gt; GPIO 132
7 : GND
8 : GND</pre>
<h2>References</h2>
<p><a href="http://embedded-software.blogspot.com/2011/01/reading-navigation-data-directly-from.html">http://embedded-software.blogspot.com/2011/01/reading-navigation-data-directly-from.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/ar-drone-navboard/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AR Drone Motor Controller</title>
		<link>http://blog.perquin.com/blog/ardrone-motor-controller/</link>
		<comments>http://blog.perquin.com/blog/ardrone-motor-controller/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 00:00:15 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[AR.Drone Parrot]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=47</guid>
		<description><![CDATA[This blog page is dedicated to the motors of the AR Drone. You can download an on-drone c program (source+compiled) to control the motors and leds. Pinout Pin 1 Battery 11.4V Pin 2 VCC 5V (ATMega8a VCC Pin4+5) Pin 3 TX+RX (ATmega8a Pin30+31) Pin 4 IRQ to main board (ATmega8a PC3 Pin26) Pin 5 GND Pin <a href='http://blog.perquin.com/blog/ardrone-motor-controller/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>This blog page is dedicated to the motors of the AR Drone.</p>
<p>You can <a href="http://blog.perquin.com/prj/ardrone/CustomFirmwareArDrone.zip">download an on-drone c program (source+compiled)</a> to control the motors and leds.</p>
<h2>Pinout</h2>
<pre>Pin 1 Battery 11.4V
Pin 2 VCC 5V (ATMega8a VCC Pin4+5)
Pin 3 TX+RX (ATmega8a Pin30+31)
Pin 4 IRQ to main board (ATmega8a PC3 Pin26)
Pin 5 GND

Pin 1 Red
Pin 2 White
Pin 3 Motor1=Yellow,M2=Orange,M3=Blue,M4=Green
Pin 4 Motor1=Purple,M2=Gray,M3=Brown,M4=Pink
Pin 5 Black</pre>
<h2>IRQ</h2>
<p>Whenever the motor controller detects a problem, it will stop running and toggles the IRQ pin. A rising edge to 5v on the IRQ pin sets GPIO 106 (i.e. `gpio 106 -r` returns 1). Pin 106 can be reset to 0 by toggling GPIO 107, i.e. `gpio 107 -d ho 0; gpio 107 -d ho 1`.</p>
<p>In other words this is a flipflop circuit, with Set=IRQ, Reset=GPIO107 and Data=GPIO106.</p>
<h2>GPIO</h2>
<pre>gpio 68 -d i = select motor1
gpio 68 -d ho 0 = deselect motor1
gpio 69 -d i = select motor2
gpio 69 -d ho 0 = deselect motor2
gpio 70 -d i = select motor3
gpio 70 -d ho 0 = deselect motor3
gpio 71 -d i = select motor4
gpio 71 -d ho 0 = deselect motor4
gpio 106 -i = IRQ input, 1=IRQ requested
gpio 107 -d ho 0; gpio 107 -d ho 1 = reset GPIO 106 to 0</pre>
<h2>Serial Communication</h2>
<p>Baud rate: 115200, 8n1</p>
<h3>Unicast Commands</h3>
<p>Configuiration sent to single motor. The motor is selected with GPIO 68 to 71.</p>
<pre>write -&gt; reply in hex, null means no reply
E0 -&gt; status             : get status 00=ok, 50=need reflash
if(status==50){
 71 64bytes 70 -&gt; null    : program flash, repeated 120 times (120 blocks of 64bytes = 7920bytes)
 91 -&gt; 120 bytes          : get 120 checksums of 64 byte flash blocks
 A1 -&gt; A0 FF              : set status OK (command send after command 91)
}
01 or 02,03,04 -&gt; null    : assign as motor1,2,3,4
40 -&gt; 11 bytes            : check versions (eg 01 0b 03 00 01 01 0a 0a 1a 0a 0a = soft version 1.11, hard version 3.0, supplier 1.1, lot number 10/10, FVT1 26/10/10)</pre>
<h3>Multicast commands</h3>
<p>Sent to all motors.</p>
<pre>A0 A0 A0 A0 A0 A0 -&gt; null : start of multicast
2x xx xx xx xx -&gt; null    : set speeds sent every 5ms
89 or 8A,8B,8X -&gt; 28 2f   : check motor1,2,3,4 alive - sent one command every 25 frames (i.e. every 125ms one motor, same motor every 500ms)
6x xx,7x xx -&gt; null       : set leds bit5=Red Rear Left, bit6=Green Rear Left, bit7=Red Rear Right, bit8=Green Rear Right, bit9=Red Front Right, bit10=Green Front Right, bit11=Red Front Left, bit12=Green Front Left  (011grgrg rgrxxxx)</pre>
<h2>Init Sequence</h2>
<p>(as used by program.elf)</p>
<p>for x=1 to 4<br />
    CSx_ Low<br />
    TX E0, RX 2 bytes<br />
    TX 91, RX 121 bytes<br />
    TX A1, RX 3 bytes<br />
    TX 00+x, RX 1 byte<br />
    TX 40, RX 12 bytes<br />
    CSx_ High<br />
    wait 500ms<br />
end for<br />
for x=1 to 4<br />
    CSx_ Low<br />
    TX E0, RX 2 bytes<br />
    TX 00+x, RX 1 byte<br />
    TX 40, RX 12 bytes<br />
    CSx_ High<br />
end for<br />
wait 500ms<br />
CS1_,CS2_,CS3_,CS4_ Low (select all)<br />
for x=1 to 6<br />
    TX A0 -&gt; RX 1 byte<br />
end for</p>
<h2>Set Speeds</h2>
<p>001aaaaa aaaabbbb bbbbbccc ccccccdd ddddddd0<br />
a,b,c,d = 9 bits for motor 1,2,3,4 (msb first)<br />
transmitted every 5ms (200Hz)<br />
every 80ms send 2x + one 8x code</p>
<h1>References</h1>
<p><a href="http://fenrir.naruoka.org/archives/000805.html">http://fenrir.naruoka.org/archives/000805.html</a></p>
<p><a href="http://www.ardrone-flyers.com/forum/viewtopic.php?f=13&amp;t=1025&amp;start=15">http://www.ardrone-flyers.com/forum/viewtopic.php?f=13&amp;t=1025&amp;start=15</a></p>
<h1>Test Script</h1>
<p>The following script initializes the motor and starts the control loop. The control loop flashes all leds. The script has been tested as replacement for program.elf on a AR.Drone with firmware version 1.7.4 and 1.3.3, motor software version 1.20 and 1.11, motor hardware version 3.0, motor supplier 1.1 and 2.2.</p>
<pre>#set baud rate
stty -F /dev/ttyPA1 115200

#reset IRQ flipflop - on error 106 read 1, this code resets 106 to 0
gpio 106 -d i
gpio 107 -d ho 0
gpio 107 -d ho 1

#all select lines inactive
gpio 68 -d ho 1
gpio 69 -d ho 1
gpio 70 -d ho 1
gpio 72 -d ho 1

#configure motor1
gpio 68 -d i
echo -en "\xe0" &gt; /dev/ttyPA1
usleep 100
echo -en "\x01" &gt; /dev/ttyPA1
usleep 100
echo -en "\x40" &gt; /dev/ttyPA1
usleep 100
gpio 68 -d ho 1

#configure motor2
gpio 69 -d i
echo -en "\xe0" &gt; /dev/ttyPA1
usleep 100
echo -en "\x02" &gt; /dev/ttyPA1
usleep 100
echo -en "\x40" &gt; /dev/ttyPA1
usleep 100
gpio 69 -d ho 1

#configure motor3
gpio 70 -d i
echo -en "\xe0" &gt; /dev/ttyPA1
usleep 100
echo -en "\x03" &gt; /dev/ttyPA1
usleep 100
echo -en "\x40" &gt; /dev/ttyPA1
usleep 100
gpio 70 -d ho 1

#configure motor4
gpio 71 -d i
echo -en "\xe0" &gt; /dev/ttyPA1
usleep 100
echo -en "\x04" &gt; /dev/ttyPA1
usleep 100
echo -en "\x40" &gt; /dev/ttyPA1
usleep 100
gpio 71 -d ho 1

#all select lines active
gpio 68 -d i
gpio 69 -d i
gpio 70 -d i
gpio 71 -d i

#start multicast
echo -en "\xa0" &gt; /dev/ttyPA1
usleep 100
echo -en "\xa0" &gt; /dev/ttyPA1
usleep 100
echo -en "\xa0" &gt; /dev/ttyPA1
usleep 100
echo -en "\xa0" &gt; /dev/ttyPA1
usleep 100
echo -en "\xa0" &gt; /dev/ttyPA1
usleep 100
echo -en "\xa0" &gt; /dev/ttyPA1
usleep 100

#reset IRQ flipflop - on error 106 read 1, this code resets 106 to 0
gpio 106 -d i
gpio 107 -d ho 0
gpio 107 -d ho 1

#multicast loop
while true
do

echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
#all leds orange
echo -en "\x7f\xf0" &gt;/dev/ttyPA1

echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
echo -en "\x20\x00\x00\x00\x00" &gt;/dev/ttyPA1
usleep 5000
#all leds off
echo -en "\x60\x00" &gt;/dev/ttyPA1

done</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/ardrone-motor-controller/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>OpenSense</title>
		<link>http://blog.perquin.com/blog/opensense/</link>
		<comments>http://blog.perquin.com/blog/opensense/#comments</comments>
		<pubDate>Sun, 08 Jan 2006 02:00:38 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[OpenSense]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=29</guid>
		<description><![CDATA[A set of sensor and actuator modules for mobile robots. The modules are build using AVR ATMega microcontrollers and use a minimum of external component. The microcontrollers are programmed in C (GCC) to allow for easy modification of the code. I2C is used to communicate between the modules, the modules are interconnected with only 4 <a href='http://blog.perquin.com/blog/opensense/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>A set of sensor and actuator modules for mobile robots. The modules are build using AVR ATMega microcontrollers and use a minimum of external component. The microcontrollers are programmed in C (GCC) to allow for easy modification of the code. I2C is used to communicate between the modules, the modules are interconnected with only 4 wires. The i2cMaster module can be used to control the modules via a serial interface. The actual module code and the bus interface code are split in two separate source files, it is also possible to rebuild the code for use with a different communicatio interface.</p>
<h2>License</h2>
<p>This project is under the GPL license, see the LICENSE.txt file for details.</p>
<h2>Download</h2>
<p>Click <a href="/prj/opensense/download.html">here</a> to download OpenSense.</p>
<h2>Available modules</h2>
<table border="1" cellspacing="0">
<tbody>
<tr>
<th>Module</th>
<th>Status</th>
<th>Description</th>
</tr>
<tr>
<td><a title="OpenSense I2cMaster" href="http://blog.perquin.com/blog/opensense-i2cmaster/">I2cMaster</a></td>
<td>Works</td>
<td>Acts as a interface between the i2c module bus and the external serial bus.</td>
</tr>
<tr>
<td>Servo</td>
<td>Works</td>
<td>Actuator for up to 16 hobby servos inclusive speed control.</td>
</tr>
<tr>
<td><a title="OpenSense Sonar" href="http://blog.perquin.com/blog/opensense-sonar/">Sonar</a></td>
<td>Works</td>
<td>Sonar distance sensor for up to 8 sonar units.</td>
</tr>
<tr>
<td>Motor</td>
<td>Works</td>
<td>Synchonized and PID speed controlled actuator for a two DC motor differential drive robot with encoders.</td>
</tr>
<tr>
<td>DockTx</td>
<td>Works</td>
<td>Docking station IR transmitter.</td>
</tr>
<tr>
<td>DockRx</td>
<td>Works</td>
<td>Docking station IR receiver.</td>
</tr>
<tr>
<td>RcReceiver</td>
<td>Works</td>
<td>Decodes signals from a RC-Receiver.</td>
</tr>
<tr>
<td>RcReceiverMaster</td>
<td>Works</td>
<td>I2c bus master, decodes RC-Receiver signals and drives DC motor and servos. Mainly for demostration purposes: it digitize the RC-Receiver servo PWM signals, sends them via i2c to the servo module which converts them back to servo PWM signals. Easier is of course to directly connect the servo to the RC-Receiver.</td>
</tr>
<tr>
<td>LCD</td>
<td>Works</td>
<td>Drives a character LCD display. Currently integrated in modI2cMaster, not individual i2c module yet.</td>
</tr>
<tr>
<td>Battery</td>
<td>Planned</td>
<td>Monitoring of discharge/charge current, voltage and Ah.</td>
</tr>
<tr>
<td>IrDistance</td>
<td>Planned</td>
<td>Drives up to 5 Sharp GP2D12 (10-80cm) / GP2Y0A02YK (20-150cm) / GP2D120 (4-30cm) IR distance sensors.</td>
</tr>
<tr>
<td>IrRemote</td>
<td>Planned</td>
<td>Receive commands from a IR remote control.</td>
</tr>
<tr>
<td>Radio</td>
<td>Planned</td>
<td>Receive/Transmit via low cost 433 MHz radio modules.</td>
</tr>
</tbody>
</table>
<h2>Files and Directories</h2>
<p><em>doc</em> The documentation is in the &#8216;doc&#8217; directory.</p>
<p><em>modXXX</em> contain the source code and Makefile for a specific module. Run &#8216;make&#8217; in a mod subdirectory to compile the source code and program the microcontroller.</p>
<p><em>lib</em> contains shared libraries. The libraries are the actual workhorses of the modules, each module is actually a i2c wrapper around the library code. It&#8217;s is therefor possible to combine several libraries into a single module, as long as the libraries don&#8217;t exclusively use the same resources such as timers or interrupts. For example the i2cMaster module includes the lcd.c library to implement a lcd driver as well.<br />
<em>vb_HexTerm</em> Contains a terminal program written in VB6 to communicate with i2cMaster. Functioning but needs some cleanup work. In the send box type &#8216;s&#8217; and hit enter to scan the i2c bus. Note: all input is decimal, so &#8216;r 170 10 4&#8242; reads 4 bytes from slave AA (=170) command 0A (=10).</p>
<h2>Software and Hardware Setup</h2>
<li>Download <a href="http://prj.perquin.com/opensense/download.html">OpenSense</a> and <a href="http://winavr.sourceforge.net/">WinAVR</a>.</li>
<li>If you do not have a programmer, solder together this very simple STK200 compatible parallel port programmer:<br />
<table border="1" cellspacing="0">
<tbody>
<tr>
<th>Wire</th>
<th>Par-Port Pin</th>
<th>ATMega Signal</th>
<th>AtMega8 (DIP) Pin</th>
<th>AtMega16 and 32 (DIP) Pin</th>
</tr>
<tr>
<td>1</td>
<td>25</td>
<td>Grd</td>
<td>8</td>
<td>11</td>
</tr>
<tr>
<td>2</td>
<td>8</td>
<td>SCK</td>
<td>19</td>
<td>8</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>MISO</td>
<td>18</td>
<td>7</td>
</tr>
<tr>
<td>4</td>
<td>7</td>
<td>MOSI</td>
<td>17</td>
<td>6</td>
</tr>
<tr>
<td>5</td>
<td>10</td>
<td>/Reset</td>
<td>1</td>
<td>9</td>
</tr>
<tr>
<td> </td>
<td>connect 2 to 12</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>connect 3 to 11</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
</li>
<li>Connect the programmer to an ATMega8 and apply VCC.</li>
<li>Run &#8220;avrdude -p m8 -c stk200 -t&#8221; from a DOS prompt.</li>
<li>For 8Mhz internal oscillator enter commands: &#8220;write lfuse 0 0x0d1&#8243; and &#8220;write hfuse 0 0xe4&#8243;</li>
<li>Or, for external crystal oscillator enter commands: &#8220;write lfuse 0 0x0d1&#8243; and &#8220;write hfuse 0 0xef&#8221;</li>
<li>Type &#8220;quit&#8221; to exit avrdude</li>
<li>cd to one of the pq-module directories</li>
<li>Type &#8220;make&#8221; and the module will be compiled and programmed on the microcontroller.<br />
<h2>Why AVR ATMega?</h2>
</li>
<li>Low cost: 8k flash 1k ram for less than $4 each.</li>
<li>Availability: Can be easily procured in small quantities.</li>
<li>DIP versions for easy prototyping (bread board).</li>
<li>Low cost programmers available.</li>
<li>Opensource C compiler (GCC) available.</li>
<li>Opensource development toolchaing (WinAVR) available.</li>
<li>Large developer community with loads of examples.</li>
<li>C-friendly architecture: stack, single linear RAM and Flash spaces.</li>
<li>Full range of periphirals: on-chip oscillator, timers, uart, i2c, adc, hardware 8x8bit multipicator, etc.</li>
<li>High speed processing: up to 24 MIPS with ATMega8x devices.<br />
<h2>Programming Style</h2>
<p>The programs are designed for small devices, usually 8k flash. I tried both to keep the number of files to a minimum and the Makefiles as uniform and simple as possible. I opted to directly include the library c files in the code usually without using header files. Precompiler #define directives and macros are used to steer the properties of the individual modules. Read the library source file to get a list of the available options. All functions, macros and defines in a library are prefixed with a 3-5 character prefix followed by an underscore. For example all mot_XXX functions are in the motor.c library.</p>
<h2>I2C interface</h2>
<p>One address (0xFF) has been reserved for default functionalty in each module:</li>
<li>Set the I2C SLA address</li>
<li>Set the I2C bus speed</li>
<li>Enable/disable interrupts.</li>
<li>Reset</li>
<li>Read module configuration and save the configuration to eeprom<br />
<table border="1" cellspacing="0">
<tbody>
<tr>
<th>I2C Command</th>
<th>Description</th>
</tr>
<tr>
<td>r ff 00 00</td>
<td>Get 16 char device string (shortcut= r ff)</td>
</tr>
<tr>
<td>r ff 01 00</td>
<td>Get 2 byte twipq library verson (major,minor) (shortcut=r ff 01)</td>
</tr>
<tr>
<td>w ff 02 00 &lt;newsla&gt;</td>
<td>Set slave i2c address to newsla</td>
</tr>
<tr>
<td>r ff 02 01</td>
<td>Get interrupts status : 1=send interrupts to busmaster, 0=disable interrupts</td>
</tr>
<tr>
<td>w ff 02 01 &lt;0|1&gt;</td>
<td>Set interrupts status : 1=send interrupts to busmaster, 0=disable interrupts</td>
</tr>
<tr>
<td>r ff 02 02</td>
<td>Get i2c speed as multiple of 10kbaud</td>
</tr>
<tr>
<td>w ff 02 02 &lt;speed&gt;</td>
<td>set i2c speed as multiple of 10kbaud</td>
</tr>
<tr>
<td>r ff 03 &lt;adr&gt;</td>
<td>Read user eeprom, see module documentation for details.</td>
</tr>
<tr>
<td>w ff 03 &lt;adr&gt; &lt;val&gt;</td>
<td>Write user eeprom, see module documentation for details.</td>
</tr>
<tr>
<td>w ff 04</td>
<td>Reset device (required after changed in configuration)</td>
</tr>
<tr>
<td>w ff 05</td>
<td>Clear eeprom + reset + load defaults</td>
</tr>
</tbody>
</table>
</li>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/opensense/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSense I2cMaster</title>
		<link>http://blog.perquin.com/blog/opensense-i2cmaster/</link>
		<comments>http://blog.perquin.com/blog/opensense-i2cmaster/#comments</comments>
		<pubDate>Sun, 08 Jan 2006 01:00:53 +0000</pubDate>
		<dc:creator>hugo</dc:creator>
				<category><![CDATA[OpenSense]]></category>

		<guid isPermaLink="false">http://blog.perquin.com/?p=31</guid>
		<description><![CDATA[Converts commands received on the serial interface to i2c commands. The HexTerm program in the vb_HexTerm directory is a simple client for the I2cMaster serial protocol. Default setup is for an ATMega8-16 with an 14.7456MHz crystal, serial port at 8-N-1 115200 baud. Serial Transmission Protocol Each message is terminiated with an 0x0a byte, 0x0a is <a href='http://blog.perquin.com/blog/opensense-i2cmaster/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Converts commands received on the serial interface to i2c commands. The HexTerm program in the vb_HexTerm directory is a simple client for the I2cMaster serial protocol. Default setup is for an ATMega8-16 with an 14.7456MHz crystal, serial port at 8-N-1 115200 baud.</p>
<h2>Serial Transmission Protocol</h2>
<p>Each message is terminiated with an 0x0a byte, 0x0a is a newline character (&#8216;\n&#8217;, decimal 10). The backslash (&#8216;\&#8217;) character is used as escape character. Unlike normal c-style escaping the second character needs to be the inverse of the character to be transmitted. So, if 0x0a appears in the message itself it is escaped as: 0x5c 0xf5. Here is 0x5c the backslash character (&#8216;\&#8217;, decimal 92) and 0xf5 the bit inverse of 0x0a. The backslash character is escaped as 0x5c 0xa3, a backslash followed by the bit inverse of a backslash.</p>
<p>This protocol was chosen because it can be easily encoded and decoded and it allows for quick resync when a transmission got corrupted. For the sake keeping things simple and for saving processor time no error checking was included.</p>
<h2>Serial commands</h2>
<p>The following commands can be sent over the serial interface.</p>
<p></p>
<p><b>s</b><br />
Perform a i2c bus scan, returns an &#8216;s&#8217; message for each device found on the i2c bus.</p>
<p>Example: i2c bus scan<br />
Transmit serial data to i2cMaster: 73 0A<br />
73 is &#8216;s&#8217;, instructs i2cMaster do a i2c bus scan.<br />
0A terminates the message.</p>
<p>Received reply from i2cMaster: 73 AC 53 65 72 76 6F 31 36 20 20 32 2E 30 30 33 0A<br />
In ascii: 73=&#8217;s&#8217; AC=slave-address  &#8220;Servo16  1.003&#8243; 0A=end-of-message<br />
In words: at slave address AC is a Servo16 module with version 1.003 connected.</p>
<p>
<b>w &lt;SLA&gt; &lt;cmd&gt; [arg1] [arg2] [arg3] [arg4] [arg5] [arg6] [arg7] [arg8]</b><br />
Write cmd and arguments to slave SLA, the arguments are optional</p>
<p>Example: Set servo 2 to center position<br />
Transmit serial data to i2cMaster: 77 AC 02 80 0A<br />
77 is &#8216;w&#8217;, instructs i2cMaster to write to the i2c bus.<br />
AC is the slave address of the servo module.<br />
02 selects servo 2.<br />
80 sets servo 2 to position 128.<br />
0A terminates the message.</p>
<p>Received reply from i2cMaster: 77 AC 02 80 0A<br />
This is the echo of the command sent.</p>
<p>The actual data send over the i2c bus is &#8220;start AC 02 80 stop&#8221;.</p>
<p>
<b>r &lt;SLA&gt; &lt;cmd&gt; [arg1] [arg2] [arg3] [arg4] [arg5] [arg6] [arg7] [arg8] &lt;ReadLen&gt;</b><br />
Read &lt;ReadLen&gt; bytes from slave SLA, the arguments are optional<br />
Reply: r &lt;CmdLen&gt; &lt;SLA&gt; &lt;cmd&gt; [arg1] [arg2] .. [arg7] [read1] [read2] .. [read(ReadLen)]<br />
The issued read command is echoed back, with the read bytes appended. CmdLen is the length of the issued read command (not counting &lt;ReadLen&gt;.</p>
<p>Example: Get the servo position of servo 3 and 4<br />
Transmit serial data to i2cMaster: 72 AC 03 02 0A<br />
72 is &#8216;r&#8217;, instructs i2cMaster to read from the i2c bus.<br />
AC is the slave address of the servo module.<br />
03 selects servo 3.<br />
01 read two bytes.<br />
0A terminates the message.</p>
<p>Serial data received from i2cMaster: 72 02 AC 02 40 50 0A<br />
72 is &#8216;r&#8217;<br />
02 number of bytes in the read command.<br />
AC is the slave address of the servo module.<br />
02 the module command sent.<br />
40 first read byte, position of servo 3.<br />
50 second read byte, position of servo 4<br />
0A terminates the answer.<br />
Also servo 3 is at position 40 hex and servo 4 is at 50 hex.</p>
<p>The actual data send over the i2c bus is &#8220;start AC 03 repeated-start AD 40 50 stop&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.perquin.com/blog/opensense-i2cmaster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
