tag:blogger.com,1999:blog-42376782615942859092024-02-25T16:13:15.243-05:00Sailboat InstrumentsUnknownnoreply@blogger.comBlogger59125tag:blogger.com,1999:blog-4237678261594285909.post-5687123503044544932024-01-08T16:16:00.000-05:002024-01-08T16:16:28.462-05:00New 10 Hz Marine Compass (Part1 - Hardware)<p>This is a revised design of a small tilt-compensated compass previously <a href="https://sailboatinstruments.blogspot.com/2014/08/a-low-cost-marine-compass-part-1.html">described </a> in this blog (the compass was based on the Pololu LSM303D carrier board that has been discontinued).</p><p>The new design uses separate Pololu carrier boards for the LIS3MDL magnetometer and for the LSM6DSO accelerometer. Pololu also sells a carrier board combining the 2 chips, but the board does not expose all the SPI and interrupt pins that I use in my implementation.</p><p>The 2 carrier boards are hard-wired to an Arduino Pro Mini 328 - 3.3V/8MHz from Sparkfun.</p><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcQNpXi8l0w4KUw8Oc80bWQeHxwVd2rtz4Qp4XXZR89EoJ6-N93x0D0kfrpBkzvuBlPNCfMpS8Z6n3RQvfy0hvtKdYi4nZQzMeFkcjcfJZ4L6EYXgXrOqKPJA6ZeTmIcVOCV55VwuCq8MR7iwNxtaIox1DnmsOP-fmskaDyn6Zh8yWzOjlqf7fOrpYQ75O/s1710/15a.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="843" data-original-width="1710" height="158" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcQNpXi8l0w4KUw8Oc80bWQeHxwVd2rtz4Qp4XXZR89EoJ6-N93x0D0kfrpBkzvuBlPNCfMpS8Z6n3RQvfy0hvtKdYi4nZQzMeFkcjcfJZ4L6EYXgXrOqKPJA6ZeTmIcVOCV55VwuCq8MR7iwNxtaIox1DnmsOP-fmskaDyn6Zh8yWzOjlqf7fOrpYQ75O/w320-h158/15a.jpg" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPO3qT9NX_RyUejQx2J4n1My3qbLGsAp0Jn1OphIMrslkX1YeHlSlyGboB0zXs1lbdWBFRI8oJBCmPUzdQL9pgtaVJUDtCBfP4UHmlcqWtsnbErU-llsN7vEN5OCOQnLmldKQZtN8H_NpfGVqhUjmOvTKpwhhCGVPf8um0dwL_gFaawKrJatpxNEdueic4/s1711/59c.jpg" style="clear: right; display: inline; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" data-original-height="843" data-original-width="1711" height="158" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPO3qT9NX_RyUejQx2J4n1My3qbLGsAp0Jn1OphIMrslkX1YeHlSlyGboB0zXs1lbdWBFRI8oJBCmPUzdQL9pgtaVJUDtCBfP4UHmlcqWtsnbErU-llsN7vEN5OCOQnLmldKQZtN8H_NpfGVqhUjmOvTKpwhhCGVPf8um0dwL_gFaawKrJatpxNEdueic4/w320-h158/59c.jpg" width="320" /></a><br /><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div>With the LIS3MDL magnetometer, it is now possible to get an output data rate of 10 Hz in the highest performance mode. The previous LSM303D magnetometer was limited to 6.5 Hz in its high performance mode.</div><p>Here is the wiring diagram for SPI communication. The FTDI breakout is used to program the Pro Mini and to read the magnetometer and accelerometer raw data during the calibration step.</p><p><br /></p><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody><tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJpoZz0T6eKs7gKL8f0ra7rwIwdWKiwfOSzybISVg72Mu1X6_aHYOJz6oeObo52dVanZ858FdpiPc20Vrdw18V3Q6PCI2Bwy83LclFSBuYGcQZnrf5C6Vjt1o3laKD-l8mhSjMDu8zgifMRLYd4MutSDep0UFJNmtFEr-lL1x4_D1DpUJ9DcQ6jv4xaJza/s882/raccords.jpg" style="margin-left: auto; margin-right: auto;"><span style="color: black;"><img border="0" data-original-height="882" data-original-width="543" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJpoZz0T6eKs7gKL8f0ra7rwIwdWKiwfOSzybISVg72Mu1X6_aHYOJz6oeObo52dVanZ858FdpiPc20Vrdw18V3Q6PCI2Bwy83LclFSBuYGcQZnrf5C6Vjt1o3laKD-l8mhSjMDu8zgifMRLYd4MutSDep0UFJNmtFEr-lL1x4_D1DpUJ9DcQ6jv4xaJza/w394-h640/raccords.jpg" width="394" /></span></a></td></tr><tr><td class="tr-caption" style="text-align: center;"></td></tr></tbody></table>The long ribbon cable is required during calibration so that the compass can be moved around at a safe distance from the breakout and the laptop to avoid magnetic interference. After calibration, the ribbon cable is used to power the compass (3.3V) and to transmit the tilt-compensated heading and the heel angle through the serial link to whatever instrument that needs it.<div><p><br /></p></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4237678261594285909.post-53889113944270444282016-10-28T12:01:00.000-04:002016-10-28T12:01:07.079-04:00Live GPS Tracking for Club Regattas (Step 1)<div class="MsoNormal">
Live GPS tracking is already a standard feature at major
sailing events.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8mkFqpcS1eaCTKh3JzDKXUjQuhCKeCwiS_TX2JBP_Cjla5MNwwuhD0a-nHi4IZV4kMx2B0DfLIu61Q_TtBOl8Ieju1PGtfma1-ukj7ug1rYLwmqVSg9uTTs3NYFBdgB_xy2x39AHN7IVG/s1600/tablet.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8mkFqpcS1eaCTKh3JzDKXUjQuhCKeCwiS_TX2JBP_Cjla5MNwwuhD0a-nHi4IZV4kMx2B0DfLIu61Q_TtBOl8Ieju1PGtfma1-ukj7ug1rYLwmqVSg9uTTs3NYFBdgB_xy2x39AHN7IVG/s320/tablet.jpg" width="303" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Each contestant is provided with a GPS tracker that
communicates wirelessly with some remote station. Three technologies are being used for the transmission of
data: satellite, GPRS (cellular) and UHF radio.</div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<ul>
<li>Satellite communication is used for offshore racing and will
not be discussed here.</li>
</ul>
<o:p></o:p><br />
<div class="MsoNormal">
<br /></div>
<br />
<div class="MsoNormal">
</div>
<ul>
<li>GPRS requires cellular coverage in the race area, and individual
SIM card and mobile phone plan for each tracker. It is extensively used in a
wide range of sporting events. An exemple of GPRS in sailing is the TracTrac
offering. Here is a picture of their tracker and charging units:</li>
</ul>
<o:p></o:p><br />
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibv9vx3C05UiQhzv7eVraK6H9ZhJi9jvpmXIPnMrPOcc1meEEnxSSD4juhwYm1iAT6FJV3nnKEgXCO3jqnu8w56G9rCCejvoaVWnDauXuDklQZST_IbfCeU0w6r8u6wPPqm2-3RzxlK0q_/s1600/tractrac.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibv9vx3C05UiQhzv7eVraK6H9ZhJi9jvpmXIPnMrPOcc1meEEnxSSD4juhwYm1iAT6FJV3nnKEgXCO3jqnu8w56G9rCCejvoaVWnDauXuDklQZST_IbfCeU0w6r8u6wPPqm2-3RzxlK0q_/s320/tractrac.jpg" width="320" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<ul>
<li>UHF radio links are more flexible, but apply to shorter ranges,
typical of what we find in local club events. This is what has been used in the
recent Rio Olympics sailing events, with Swiss Timing as the technology
provider. Here is picture of their tracker and charging units:</li>
</ul>
<br />
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_ij8_Y9oKdlYr65B5Pl0Dig9HSeHXC3o48ZHzgPhYNTvvvwGJpsAcw2_0B05MYC5QXZbYhvTS64Os1m-IRpl9Z2PE2qSIP38pN1ee5lcEL0LBjpG8k57TDNemQKYWea0abdwYMqaCDE-p/s1600/swiss.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="132" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_ij8_Y9oKdlYr65B5Pl0Dig9HSeHXC3o48ZHzgPhYNTvvvwGJpsAcw2_0B05MYC5QXZbYhvTS64Os1m-IRpl9Z2PE2qSIP38pN1ee5lcEL0LBjpG8k57TDNemQKYWea0abdwYMqaCDE-p/s400/swiss.jpg" width="400" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b>Application to club
sailing events<o:p></o:p></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
I have been looking at a way to bring GPS tracking to local
sailing clubs, along the following parameters.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
- all boats are always within 1.5 nautical mile of the
committee boat<o:p></o:p></div>
<div class="MsoNormal">
- the committee boat is within 5 nautical miles of the
clubhouse<o:p></o:p></div>
<div class="MsoNormal">
- each boat reports its position, speed and heading at short
intervals (1 second typical)<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
For the last parameter, the data (GPS position, SOG and COG)
can all be incoded in 9 bytes. For example, the following NMEA sentence from
the GPS:<o:p></o:p></div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
$GPRMC,180846.600,A,4659.8765,N,07058.4321,W,12.00,270.00,050210,,,D*77<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
can be sent as 4 integers:
598755 (Longitude, 3 bytes), 584321 (Latitude, 3 bytes), 120 (SOG, 1
byte) and 2700 (COG, 2 bytes).<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
In this post, we look at the communication between the
committee boat and the contestant boats, in order to provide a live display of
the race in the committee boat. Communication with the clubhouse and the live
broadcasting of the event on the internet will be discussed later. <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b>Preferred technology:
LoRa radios in the 915 MHz band<o:p></o:p></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
“Long Range (LoRa)” packet radios appear well suited to meet
the objectives of this kind of project. For range tests, I have used 2 Adafruit
Feather M0 RFM95 radios, featuring a Semtech LoRa transceiver.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQbQsOl_JLvSyx_X79HDf6NDFP5eZqsRvbfKzbunic4zqm1UVya6NkQlxLE-pk3-Zy6DfX5gmDwTw-Rv-t6q_J_QR13NRO5n4sXJq09SEvRPcRKZp26r_hZ92Yw3n7Cm6ajBzgMaKrxq-0/s1600/ada_lora.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="272" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQbQsOl_JLvSyx_X79HDf6NDFP5eZqsRvbfKzbunic4zqm1UVya6NkQlxLE-pk3-Zy6DfX5gmDwTw-Rv-t6q_J_QR13NRO5n4sXJq09SEvRPcRKZp26r_hZ92Yw3n7Cm6ajBzgMaKrxq-0/s320/ada_lora.jpg" width="320" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Technical details can be found in the following in Semtech’s
LoRa Modem Designer’s Guide.</div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
<a href="https://www.semtech.com/images/datasheet/LoraDesignGuide_STD.pdf">https://www.semtech.com/images/datasheet/LoraDesignGuide_STD.pdf</a><o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Semtech also provides a useful LoRa Calculator Tool, under
the tab ‘Docs & Resources’.<o:p></o:p></div>
<div class="MsoNormal">
<a href="http://www.semtech.com/wireless-rf/rf-transceivers/sx1272/">http://www.semtech.com/wireless-rf/rf-transceivers/sx1272/</a><o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The Semtech tool can be used to calculate the ‘Time on Air’
required to transmitting the 9 bytes packets. In the following example, the LoRa radio is configured with
the following settings:</div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
- Spreading Factor : 6<o:p></o:p></div>
<div class="MsoNormal">
- Bandwidth : 125 kHz<o:p></o:p></div>
<div class="MsoNormal">
- Coding Rate : 4/5<o:p></o:p></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
- No Explicit Header<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRAn_vwqZeOBukrs6ByjbbM_arZ3WcNN4xjZi5UQ4QEwGHe-9p9MPfyme5PEiB5wU7biAvJo_5FmWSxfBVbPaKUsnZsGHcJO3Btl_WIqiC5fQA6MuhmdgjDh0cC1Cf1wQvDOsMP42OKxNi/s1600/tool.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="287" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRAn_vwqZeOBukrs6ByjbbM_arZ3WcNN4xjZi5UQ4QEwGHe-9p9MPfyme5PEiB5wU7biAvJo_5FmWSxfBVbPaKUsnZsGHcJO3Btl_WIqiC5fQA6MuhmdgjDh0cC1Cf1wQvDOsMP42OKxNi/s400/tool.jpg" width="400" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
For these conditions, the ‘Time on Air’ is 18.04 ms, with an
equivalent bitrate of 9375 bps. This means that up to 50 boats could be sampled
each second for their position, COG and SOG from a single transceiver on the
committee boat.<o:p></o:p></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b>LoRa range tests<o:p></o:p></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p>
</o:p></div>
<div class="MsoNormal">
Two prototype transceivers have been assembled to test the
communication range over water. The Adafruit modules have been programmed with the
RadioHead software recommended on the Adafruit site.</div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgne_zQyuZDa-fbdsLdzKDZ_IABqnJ_OCWHvs-qa2HGbl77QzXCSji1g35hawGOE3SN6d1t_i1xrTjs6V3KRxOVfxeTZeW2EUBs6Mm5JxZBPKu1mk4BrAUIiC-rxs_sSVmfZ3lAkAqWUIT1/s1600/both.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgne_zQyuZDa-fbdsLdzKDZ_IABqnJ_OCWHvs-qa2HGbl77QzXCSji1g35hawGOE3SN6d1t_i1xrTjs6V3KRxOVfxeTZeW2EUBs6Mm5JxZBPKu1mk4BrAUIiC-rxs_sSVmfZ3lAkAqWUIT1/s400/both.jpg" width="293" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
With a 3 dBi half-wave dipole antenna in each module (as shown
above), reliable communications have been obtained up to 1.75 nautical mile, with
spotty communications up to 1.9 nautical mile. With simple wire antennas,
the reliable range is reduced to 0.75 nautical mile. With a higher gain antenna
on the committee boat transceiver (like 6 dBi), the range could be further
extended, or the antenna gain on the trackers could maybe be relaxed, allowing
smaller antennas.</div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
These tests thus confirm the feasibility of the LoRa
approach.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b>Further steps<o:p></o:p></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The next steps that are being considered are :<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
- to build a small
inventory of waterproof trackers, and develop an application to visualise the
boat positions aboard the committee boat<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
- to develop the
communication link between the committee boat and the clubhouse (GPRS cellular
network or more powerful radio)<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
- from the clubhouse, to broadcast the live data on a web
site, allowing display on local TV set and any mobile device.<o:p></o:p></div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
Unknownnoreply@blogger.com8tag:blogger.com,1999:blog-4237678261594285909.post-55234125609942860252016-04-14T00:32:00.001-04:002016-04-14T00:38:24.922-04:00Building your own NMEA 2000 Device<div class="MsoNormal">
The hard work has already been done, first by the pioneering
efforts of Kees Verruijt at <a href="https://github.com/canboat">canboat</a> , and now by the development of a <a href="https://github.com/ttlappalainen">NMEA2000 Arduino library</a> by Timo Lappalainen.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<br />
<div class="MsoNormal">
I am using the NMEA2000 library with an Arduino Due board. The
Due has a built-in CAN controller (in fact 2 of them), missing only an external
CAN transceiver to get attached to a N2K backbone. With the arrangement
described below, I first ran the library example ‘TemperatureMonitor’, sending 2
fixed temperature values to the N2K network. The result can be seen in the
following screen capture of the B&G Touch 7 display, showing the sea and
cabin temperature values sent by this example.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjhFpPjv26OvwjSyBaxLWV197BP43NMud8fKNIuzx_RTqDbSxptpmIfFIXTdXznwnXfPh2jgfM1s2Y4N_54d60rykV1PsSbHrkU32QjajVD3D_2TZmFKZWc7X_O97yTaxp9Kd9lzcm71Qy/s1600/shot126.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjhFpPjv26OvwjSyBaxLWV197BP43NMud8fKNIuzx_RTqDbSxptpmIfFIXTdXznwnXfPh2jgfM1s2Y4N_54d60rykV1PsSbHrkU32QjajVD3D_2TZmFKZWc7X_O97yTaxp9Kd9lzcm71Qy/s200/shot126.png" width="200" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
I then proceeded to develop a replacement for the Actisense
NGW-1, which translates fast NMEA 0183 heading sentences to their equivalent
N2K PGN. For this, I also made use of the <a href="http://arduiniana.org/libraries/tinygpsplus/">TinyGPS++</a> library, which takes care
of parsing the NMEA 0183 sentences. <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7t1-cNk5K5-VZ8jyycmZd73SQquvVqkoHNJ_6CNtscfSnid5ak30ArBpMsUVHoWLw0lQA4-5CBzROn6vyPI3Rg6BMSU_omp1578kQbpggTySwf9COGJN22JUIKTsASAOy1r9irl5pvSDK/s1600/converter.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7t1-cNk5K5-VZ8jyycmZd73SQquvVqkoHNJ_6CNtscfSnid5ak30ArBpMsUVHoWLw0lQA4-5CBzROn6vyPI3Rg6BMSU_omp1578kQbpggTySwf9COGJN22JUIKTsASAOy1r9irl5pvSDK/s400/converter.jpg" width="261" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
All this is done with a deceptively short Arduino sketch (‘Heading
Converter’), which I reproduce in its entirety here.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">// Convert fast heading data from NMEA 0183 to NMEA 2000</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">#include <Arduino.h></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">#include <NMEA2000_CAN.h></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">#include <N2kMessages.h></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">#include <TinyGPS++.h></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">TinyGPSPlus gps;</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">TinyGPSCustom heading(gps, "HCHDG", 1); // $HCHDG sentence, 1st element</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">void setup() {</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Serial2.begin(9600);</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> NMEA2000.SetProductInformation("00000001", 100,"Heading converter", "1.0.0.11 (2016-04-13)", "1.0.0.0 (2016-04-13)");</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> NMEA2000.SetDeviceInformation(1, 140, 60, 2046);</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> NMEA2000.SetForwardOwnMessages();</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,22);</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> NMEA2000.EnableForward(false);</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> NMEA2000.Open();</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">}</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">void loop() </span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">{</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> tN2kMsg N2kMsg;</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> if (heading.isUpdated())</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> {</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> SetN2kMagneticHeading(N2kMsg, 1, DegToRad(atof(heading.value())));</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> NMEA2000.SendMsg(N2kMsg);</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> NMEA2000.ParseMessages(); </span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> }</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> </span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> while (Serial2.available() > 0)</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> gps.encode(Serial2.read());</span></div>
<div class="MsoNormal">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">}</span></div>
<div>
<br /></div>
Unknownnoreply@blogger.com11tag:blogger.com,1999:blog-4237678261594285909.post-90097899318880777412016-04-05T23:37:00.001-04:002016-04-05T23:37:50.605-04:00NMEA 2000 for Radar Overlay<div class="MsoNormal">
Radar overlay means displaying the radar image directly on
the chart. This is a nice feature to have with the 3G radar, as it also permits
to experiment with MARPA. But it complicates somewhat the installation, as it
requires sending 10 Hz heading values to the radar through a NMEA 2000 network.
So here is how I ended doing it.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8f3Pzc3UM4D3wFInKA2V8G3RB7r9G7WTTbcd7mDXL_jJOa4-gztqkiUmBNFUND4dN2dw691oVvTi-5__349nfzYRW75rQjjgyUesJzMorWPYL0bFrDHSR84POhUBBCzUsJ25BMLWeiNls/s1600/overlay.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8f3Pzc3UM4D3wFInKA2V8G3RB7r9G7WTTbcd7mDXL_jJOa4-gztqkiUmBNFUND4dN2dw691oVvTi-5__349nfzYRW75rQjjgyUesJzMorWPYL0bFrDHSR84POhUBBCzUsJ25BMLWeiNls/s400/overlay.jpg" width="367" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
As explained in my <a href="http://sailboatinstruments.blogspot.ca/2016/01/interfacing-b-zeus-touch-7-display.html">last post</a>, I was already sending the NMEA
0183 HDG sentence directly to the Zeus T7 display, among other NMEA 0183 sentences
(VHW, MWV, and MWD). I have now isolated the HDG sentence to a separate serial
port, and sending it at 10 Hz to an Actisense NGW-1, which converts it to the
equivalent N2K 127250 PGN (Vessel Heading), now available both to the T7
display and to the radar through my basic N2K network.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Other than the Actisense NGW-1, there are 2 other options to
make the heading conversion from NMEA 0183 to N2K:<o:p></o:p></div>
<div class="MsoNormal">
- using
the Navico AT10 HD converter;<o:p></o:p></div>
<div class="MsoNormal">
- using
a DIY converter based on the Arduino Due board (more on this in a future post).<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The Actisense NGT-1 is used to monitor the N2K network. It
confirmed that the 127250 PGN is effectively transmitted at the required 10 Hz
rate. <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
The WIFI-1 router is used to remotely view and control the
display from a phone or tablet. It also broadcasts the most common NMEA 0183
sentences that the display makes available on the Ethernet network (also more
on this later).<o:p></o:p></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4237678261594285909.post-72824387665715449382016-01-31T11:56:00.000-05:002016-02-03T15:09:12.837-05:00Interfacing a B&G Zeus Touch 7 Display<div class="MsoNormal">
I am planning the installation of a B&G Broadband 3G radar,
using a Zeus Touch 7 (T7) for display. I have now received the display that
will also act as a chartplotter. So it was natural for me to check if I could
use the T7 Sailsteer feature, by using my own data.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
It happens that the T7 has an input for NMEA0183 data. My
system produces a 10 Hz stream of binary data that I have to convert to NMEA
sentences supported by the display. The conversion is done by a SAMD21 32-bit
microprocessor, connected to the display through a MAX3232 converter. Note that
the T7 has its own internal GPS, so that I don’t need to convert and send the
GPS data from my system.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Here is the schematics and wiring used. Each NMEA sentence
is sent once per second, through the NMEA 0183 Talker port (orange and green
wires), using a baud rate of 38400.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFicE_1cOQFBWDJZE3hPuuD7r-jUB75r5TTDQFaMeyWVtiphyphenhyphen9V7Gml3TyXGS4_Niu8kSpEx0vBpXHcIZknmPDNQslqPMPmbi_EX-aqXVY9kUPxZCgghgKPbnCXtntbqhnHdrW1j9kQbgv/s1600/bandg1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFicE_1cOQFBWDJZE3hPuuD7r-jUB75r5TTDQFaMeyWVtiphyphenhyphen9V7Gml3TyXGS4_Niu8kSpEx0vBpXHcIZknmPDNQslqPMPmbi_EX-aqXVY9kUPxZCgghgKPbnCXtntbqhnHdrW1j9kQbgv/s400/bandg1.jpg" width="255" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br />
<o:p></o:p><br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg64iYDEjrBuZWnR8Jz4jhx5HQLc2ScGV9ApOn70NFYJ7BF4aMJd_QIF9GrlRpviY4i1yV2KJO2ZK9pgAD1AY6AW20e1oiQsFi1GjR_RMi2uHmM0VOUuzZ2bl_tRPasmIjx3HnW1qh4MYVt/s1600/bandg2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg64iYDEjrBuZWnR8Jz4jhx5HQLc2ScGV9ApOn70NFYJ7BF4aMJd_QIF9GrlRpviY4i1yV2KJO2ZK9pgAD1AY6AW20e1oiQsFi1GjR_RMi2uHmM0VOUuzZ2bl_tRPasmIjx3HnW1qh4MYVt/s400/bandg2.jpg" width="400" /></a></div>
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
To test the behaviour of this setup, I used an example presented
in an <a href="http://sailboatinstruments.blogspot.ca/2011/02/leeway-calibration-part-3.html">earlier post</a>. I reproduce here the data from this example for
convenience.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg09nnCFCfE9Y8fsEFRn1SFZodp16G3Qe_Dgj56hNzbXPLxr0b6tzkGavvN9jq8j7WYxEKz_ASH0VdRwki2_wqQCiPcaWBkWT6_l30nrH2DymO5dttz8t1ZyvFboJmsgGdGM3KQ208ngt7e/s1600/bandg3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg09nnCFCfE9Y8fsEFRn1SFZodp16G3Qe_Dgj56hNzbXPLxr0b6tzkGavvN9jq8j7WYxEKz_ASH0VdRwki2_wqQCiPcaWBkWT6_l30nrH2DymO5dttz8t1ZyvFboJmsgGdGM3KQ208ngt7e/s400/bandg3.jpg" width="357" /></a></div>
<o:p></o:p><br />
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJlmvUhNqJdgacG6Blt2YhNJje9JjIHIQxOW2IHOwhS-ms3ltzj_1DIolHzIiMQ6mnq55VsbtV6_ZVlFjt534G1wUdTR0UPGO0u3GL2YuiHtTn6cpKYY0NwfeXeADt8vVuJWChXf7U5rwX/s1600/bandg4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="268" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJlmvUhNqJdgacG6Blt2YhNJje9JjIHIQxOW2IHOwhS-ms3ltzj_1DIolHzIiMQ6mnq55VsbtV6_ZVlFjt534G1wUdTR0UPGO0u3GL2YuiHtTn6cpKYY0NwfeXeADt8vVuJWChXf7U5rwX/s400/bandg4.jpg" width="400" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
As a first test (System A of the example), I send continuously
the 4 following inputs:<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Heading : 0.0 deg <o:p></o:p></div>
<div class="MsoNormal">
Boat Speed : 6.0 knots<o:p></o:p></div>
<div class="MsoNormal">
Apparent Wind Angle (AWA) : -26.71 deg (-26.71 + 360 = 333.29)<o:p></o:p></div>
<div class="MsoNormal">
Apparent Wind Speed (AWS) : 16.43 knots<o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: "courier new";"> $HCHDG,0.0,,E,,W*50</span><o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: "courier new";"> $IIVHW,,T,,M,6.0,N,,K*7D</span><o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: "courier new";"> $WIMWV,333.29,R,16.43,N,A*1B</span><o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
This corresponds to the basic inputs that the display would receive
if it was directly connected to sensors (masthead unit, speed log and
electronic compass). So the display is left calculating the following outputs:
TWA, TWS, VMG and tide current. Here is a screen capture of the display for
these conditions.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcNbitDD7X4ieLQdBJbc4n8_85yey9ot1IEmVw4eoKr7Qd927k_51IaOVnQQTPRd6II9BgEplEFqQlgMzG3V0-pKqXrH3z7hmHQMqtmFnfAOCbRdj7cn0nTIYLJl-nDdaBFVwGAITOUYEf/s1600/bandg5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcNbitDD7X4ieLQdBJbc4n8_85yey9ot1IEmVw4eoKr7Qd927k_51IaOVnQQTPRd6II9BgEplEFqQlgMzG3V0-pKqXrH3z7hmHQMqtmFnfAOCbRdj7cn0nTIYLJl-nDdaBFVwGAITOUYEf/s320/bandg5.jpg" width="320" /></a></div>
<br />
<div class="MsoNormal">
<o:p> </o:p> </div>
<div class="MsoNormal">
The calculated outputs of the display correspond exactly to
those of the basic System A example. It is interesting to note that the display
has correctly calculated a front current of 6 knots, as its GPS gives him a 0.0
knot SOG (the test is made at home, and the home does not move!). <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
But we know from the example that these results suffer from
2 problems: the AWA is not corrected for heeling, and the leeway is not
considered. In the second test (System B), I send instead the AWA corrected for heeling (available from my
system).<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Heading : 0.0 deg <o:p></o:p></div>
<div class="MsoNormal">
Boat Speed : 6.0 knots<o:p></o:p></div>
<div class="MsoNormal">
Apparent Wind Angle (AWA) : -28.17 deg (-28.17 + 360 = 331.83)<o:p></o:p></div>
<div class="MsoNormal">
Apparent Wind Speed (AWS) : 16.43 knots<o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: "courier new";"> $HCHDG,0.0,,E,,W*50</span><o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: "courier new";"> $IIVHW,,T,,M,6.0,N,,K*7D</span><o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: "courier new";"> $WIMWV,331.83,R,16.43,N,A*19</span><o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Here again, the values calculated by the display agree with the
results of the example for System B.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzzvUXLQARgIyVSOGF0Ga_Gzisxa3KjZ9iObeswdAH-03MGr5aXo6OQrHTBVnVvFIkI-gdHUWcGDnJKo2ydwhlijMHnR6fGNOmT6b4Zg9yrfVAVsYPPB3ttEknVBCL49ePRWCP9w7TpiTq/s1600/bandg6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzzvUXLQARgIyVSOGF0Ga_Gzisxa3KjZ9iObeswdAH-03MGr5aXo6OQrHTBVnVvFIkI-gdHUWcGDnJKo2ydwhlijMHnR6fGNOmT6b4Zg9yrfVAVsYPPB3ttEknVBCL49ePRWCP9w7TpiTq/s320/bandg6.jpg" width="320" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
In the third test (System C, corrected for leeway), I send
these additional inputs correctly calculated by my system (instead of letting
the T7 make these calculations):<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
True Wind Angle: -45.0
deg (-45.0 + 360 = 315.0)<o:p></o:p></div>
<div class="MsoNormal">
True Wind speed: 12.0
knots<o:p></o:p></div>
<div class="MsoNormal">
Wind Direction: 315.0 deg<o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: "courier new";"> $WIMWV,315.0,T,12.0,N,A*11</span><o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: "courier new";"> $WIMWD,,T,315.0,M,,N,,M*73</span><o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
I cannot send the result of my VMG calculation because the
VPW NMEA sentence is not supported by the T7, so that the VMG calculation is
left to the display.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxgUn9_ZoBP_eAM_FS0HhOkfswEr0SGhRBmLYJppG8oE3zX_rpilUQn7bvgcSufxX67V4o2qtp61_sJfja0QjcQ8Ao02k6F6ZugN3Q1SMOqj4zOyeB1PWBDByWhdxEgBr7gzsGtRScxkCa/s1600/bandg7.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxgUn9_ZoBP_eAM_FS0HhOkfswEr0SGhRBmLYJppG8oE3zX_rpilUQn7bvgcSufxX67V4o2qtp61_sJfja0QjcQ8Ao02k6F6ZugN3Q1SMOqj4zOyeB1PWBDByWhdxEgBr7gzsGtRScxkCa/s320/bandg7.jpg" width="320" /></a></div>
<o:p></o:p><br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Here we see that the VMG value is not calculated correctly
by the display. This is not surprising as the display has no information on the
leeway. To do so and to reproduce all the correct data, this system would have
to be completed by the B&G H5000 computer.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
But despite this problem that may somewhat affect the
resulting calculated laylines, I expect that the Sailsteer feature will still
be very useful in practice, as it takes in account the tide current values in
its calculations. This is a much more important correction in my sailing area
characterized by strong tidal streams.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
For now, the erroneous calculated VMG value will not be displayed on the T7, to avoid confusion with the correct value displayed on my tablet. <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<br />Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4237678261594285909.post-52294666975824220282015-01-08T14:36:00.000-05:002015-02-20T15:04:15.452-05:00Wi-Fi revisited with the ESP8266 chip<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;">The
new ESP8266 chip has created quite a buzz in the recent months, and I have
decided to give it a try for Wi-Fi communications between my instruments and a
Nexus tablet. The ESP8266 is a 3 $ chip that can be programmed as a Wi-Fi
access point (AP) as well as as client for a router (STA) at the same time if
required. It can even host a small Web server. An SDK (Software Development
Kit) is available to configure the microprocessor to specific needs.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;">In
my case, I use it as UDP server to send the serial output generated by my
system. The UDP packets are sent at the 10 Hz rate, and contain a payload of 76 bytes (mostly measured and calculated values in floating-point format). The
payload contents are described <a href="http://sailboatinstruments.blogspot.ca/2011/03/data-transfer-from-microcontroller-to.html">here</a>. And how the calculations are made is described <a href="http://sailboatinstruments.blogspot.ca/2011/05/true-wind-vmg-and-current-calculations.html">here</a>.</span></div>
<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH8kgVEsNmMMAOXDf13fEM9GtbuUqs3W94sbxkXyEtFNuTExWm_KC5ebTvfRyDkxfZL7LLVpPhsyE9lofc4neg15uL0vVoo3884D_me0ia7Vc4BCriBUKf41bMHvn2uwGkBYq39qtadtD7/s1600/esp0.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH8kgVEsNmMMAOXDf13fEM9GtbuUqs3W94sbxkXyEtFNuTExWm_KC5ebTvfRyDkxfZL7LLVpPhsyE9lofc4neg15uL0vVoo3884D_me0ia7Vc4BCriBUKf41bMHvn2uwGkBYq39qtadtD7/s1600/esp0.jpg" height="640" width="398" /></a></div>
<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;"><br /></span></div>
<div class="MsoNormal">
<br /></div>
<br />
<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;">The
Nexus tablet is programmed as a UDP client, connected to the ESP8266 AP network
visible to any Wi-Fi device. When the tablet software sends a ‘START’ message
to the ESP8266, it is bombarded back by the 10 Hz packets until it sends a ‘STOP’
message. These data are used to refresh the displays in real-time on the
tablet. Many different custom displays can be swapped around. Any resemblance
to recent professional first-class displays is not coincidental: the Android
graphics capabilities are impressive.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;">Here
is the prototype arrangement used. The ESP8266 is a 3.3V device, and a logic
level converter is used on the 5 V serial signal from the system.</span></div>
<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkDmylsME9NuvEDmTkoaxFL2pycFtR-vL6ujD63kmC9aqee_jO0Hqc8bokoJ7fGduAiQECylGGFDDayHqU2AqgNYc1fatELbOM66IHi9mjcuBz-CA2hOy1HO6uZbOMskiz1MwSMsadh-14/s1600/esp1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkDmylsME9NuvEDmTkoaxFL2pycFtR-vL6ujD63kmC9aqee_jO0Hqc8bokoJ7fGduAiQECylGGFDDayHqU2AqgNYc1fatELbOM66IHi9mjcuBz-CA2hOy1HO6uZbOMskiz1MwSMsadh-14/s1600/esp1.jpg" height="257" width="320" /></a></div>
<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9kidIfIVCm0FWuc2IBp9bB5NCrBVqPfV2Oo7YZqxJmlGiBTCWmSxGVVW6glAk6QYAyumJ0615RX6pRQiYqkgMBFPl70nnD6y6LI2l4fUguYxNTim2ZLPqvM1RWjMsk1jZys0RRk5nAfu4/s1600/esp3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9kidIfIVCm0FWuc2IBp9bB5NCrBVqPfV2Oo7YZqxJmlGiBTCWmSxGVVW6glAk6QYAyumJ0615RX6pRQiYqkgMBFPl70nnD6y6LI2l4fUguYxNTim2ZLPqvM1RWjMsk1jZys0RRk5nAfu4/s1600/esp3.jpg" height="240" width="320" /></a></div>
<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;"><br /></span></div>
<div class="MsoNormal">
<span style="font-size: 12.0pt; mso-bidi-font-size: 11.0pt;"><br /></span></div>
<div class="MsoNormal">
<span style="font-size: 12pt;">For
development with the SDK and programming, I used this Eclipse-based tool-chain,
on a Win7 64-bit machine: <a href="http://www.esp8266.com/viewtopic.php?f=9&t=820">Espressif DevKit for Windows</a>.</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-size: 12pt;"><br /></span></div>
<div class="MsoNormal">
<br /></div>
Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-4237678261594285909.post-66499599248287375002014-08-22T14:52:00.000-04:002014-08-23T20:49:13.180-04:00A low-cost marine compass (Part 3 – Calibration)<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">When
connected to a terminal program through the FTDI breakout at 115200 baud, the
compass displays the results formatted as NMEA sentences. This is the default
operating mode (Mode 4 in the software).<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">Two
calibration helper modes are available:<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";"> </span><span lang="FR-CA" style="font-family: "Arial","sans-serif";">Mode 1 : Accelerometer
calibration (type M1<ENTER>)<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="FR-CA" style="font-family: "Arial","sans-serif";"> Mode 2 :
Magnetometer calibration (type M2<ENTER>)<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">These
calibration modes are used to produce the raw data files required by the
calibration software <a href="https://sites.google.com/site/sailboatinstruments1/home">Magneto</a>. In these modes, the compass stops displaying
results until it receives an ‘x’ character (type x<ENTER> in the terminal
program). <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">In
Mode 1 (Accelerometer), it will then displays 64 consecutive (x,y,z) filtered raw
data (at the 200 Hz rate), then pauses until it receives another ‘x’ character.<o:p></o:p></span><br />
<span style="font-family: "Arial","sans-serif";"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsKuKAnSCTCw52y5EJ5X4YyanZDvWwuCG0WHA_oQMHeKhLorsoTwo3LyUjckvO2H5bqxeUM5CrYAg1pPaEIggLE5Z8lXpZlKo88wAM9P_7G4iMTW3p5cr1xQYfyYZjsU37llobjE3FxpJx/s1600/M1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsKuKAnSCTCw52y5EJ5X4YyanZDvWwuCG0WHA_oQMHeKhLorsoTwo3LyUjckvO2H5bqxeUM5CrYAg1pPaEIggLE5Z8lXpZlKo88wAM9P_7G4iMTW3p5cr1xQYfyYZjsU37llobjE3FxpJx/s1600/M1.jpg" height="320" width="297" /></a></div>
<span style="font-family: "Arial","sans-serif";"><br /></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">In
Mode 2 (Magnetometer), it will displays 16 consecutive (x,y,z) raw data (at the
6.5 Hz rate), then pauses until it receives another ‘x’ character.<o:p></o:p></span><br />
<span style="font-family: "Arial","sans-serif";"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyyc_gPe6NsCuHpLmVExVOlZ5UjXSpiRiy0K3vJHKPo-Z5feRkhlobfXj1RknQWsypvY0GZoUrqXnw9d-Whkdg06MPe7NkU4b43qm84OJJ4BYPej8qPKtihlp0246zEGm4azwqTEw-Zj14/s1600/M2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyyc_gPe6NsCuHpLmVExVOlZ5UjXSpiRiy0K3vJHKPo-Z5feRkhlobfXj1RknQWsypvY0GZoUrqXnw9d-Whkdg06MPe7NkU4b43qm84OJJ4BYPej8qPKtihlp0246zEGm4azwqTEw-Zj14/s1600/M2.jpg" height="320" width="277" /></a></div>
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">By
logging the results to a text file in the terminal program, it is then possible
to create the Magneto input files, by moving the compass around and pressing
the ‘x’ character at each new position.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">I
recommend moving the compass with roughly equal angle steps around three
perpendicular axis. For the accelerometer, you can use any support (metallic or
not) to help position the compass, but it is very important to wait until the
compass is completely at rest (no vibration) before hitting the ‘x’ character.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">For
the magnetometer, try to use the lightest non-magnetic support (wood or plastic),
and use the ribbon cable to keep away the FTDI brekout and especially the
laptop (all this in a magnetic clean environment!).<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">The
2 raw data files can then be processed by the Magneto software. The Pro Mini source
file can then be edited with the new values and recompiled.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">Unfortunately,
this is not the end of the game if we want to be rigorous. We will have to look
for misalignments between three independent reference frames: the compass base,
the accelerometer plan and the magnetometer plan, with a final offset correction
when compared to a known heading.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif";">But
the compass should already be quite usable, as these last corrections will be quite
small compared to what has been accomplished.<o:p></o:p></span><br />
<span style="font-family: "Arial","sans-serif";"><br /></span>
<span style="font-family: "Arial","sans-serif";"><br /></span>
<span style="font-family: "Arial","sans-serif";"><a href="http://sailboatinstruments.blogspot.ca/2014/08/a-low-cost-marine-compass-part-1.html">A low-cost marine compass (Part 1 - Hardware)</a></span><br />
<span style="font-family: Arial, sans-serif;"><a href="http://sailboatinstruments.blogspot.ca/2014/08/a-low-cost-marine-compass-part-2_20.html">A low-cost marine compass (Part 2 - Software)</a></span><br />
<span style="font-family: Arial, sans-serif; font-size: 22px;"><br /></span>
<span style="font-family: Arial, sans-serif; font-size: 22px;"><br /></span>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4237678261594285909.post-82964371101695907432014-08-20T21:58:00.002-04:002014-08-23T20:57:10.901-04:00A low-cost marine compass (Part 2 – Software)<span style="font-family: Arial, Helvetica, sans-serif;">The problem with low-cost sensors is that the accelerometer outputs are very noisy (much less so for the magnetometer).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The LSM303D sensor is one of 2 magnetic sensors supported by the <a href="https://pixhawk.org/">PX4</a> development team. The solution they have chosen to reduce the noise in the accelerometer outputs is to apply a low-pass software filter to the measurements, in addition to the hardware low-pass filter built into the chip. In this project, I have ported their<a href="https://github.com/diydrones/PX4Firmware/blob/master/src/drivers/lsm303d/lsm303d.cpp"> LSM303D SPI driver</a> and 2-pole <a href="https://github.com/diydrones/PX4Firmware/blob/master/src/lib/mathlib/math/filter/LowPassFilter2p.cpp">software filter</a> to the WinAVR environment.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I have also kept the strategy adopted for my Hi-Res compass, which is to use a higher sampling rate for the accelerometer, and take the average result in the calculation performed after each magnetometer measurement.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I have chosen a 6.25 Hz sampling rate for the LSM303D magnetometer, to insure that it will operate in its hi-resolution mode. The accelerometer sampling rate is set at 200 Hz, and the cut-off frequency of the software low-pass filter is set at 40 Hz.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here is a general explanation of the code behaviour during normal operation.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The Pro Mini continually reads triple raw values (x,y,z) from the accelerometer. For each axis, it feeds the raw value to the software low-pass filter, which spits out a new filtered value for each axis. The filtered values are accumulated and counted.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Each time the LSM303D magnetometer has a new set of 3 raw values available (x,y,z), it fires an interrupt on the Pro Mini. When this happens, the Pro Mini applies the calibration correction to the magnetometer values. It calculates the average of the accelerometer filtered values since the last interrupt, and applies the calibration correction. From this set of 6 values, it calculates the tilt-compensated heading, and the heel and pitch angles. It formats the results in 2 NMEA sentences that are sent to the serial port (115200 baud), 6.25 times per second. </span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglDT-yGPMwLnG_BgWF84YpQ3WluAipza-WNh5kHVOgFr0GMko6uTUa6bDpTdV-YTvG0ny8b4YvF9Of68terX3UUDOiB0STlc9rd-pcZ0XeMfVDAbVA35S1YG3nvuLA8M4u5XITHVjEnzKS/s1600/mode4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglDT-yGPMwLnG_BgWF84YpQ3WluAipza-WNh5kHVOgFr0GMko6uTUa6bDpTdV-YTvG0ny8b4YvF9Of68terX3UUDOiB0STlc9rd-pcZ0XeMfVDAbVA35S1YG3nvuLA8M4u5XITHVjEnzKS/s1600/mode4.png" height="341" width="400" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The source code for the WinAVR environment can be found <a href="https://github.com/bermerlin/Pololu">here</a>. I am using Programmer’s Notepad to compile the code and program the Pro Mini through the Arduino bootloader. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This implies that the calibration factors have already been found since they appear as constants in the code. The software has other modes of operation useful for developing these calibration factors, which will be presented in Part 3 of this series.</span><br />
<div>
<br /></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://sailboatinstruments.blogspot.ca/2014/08/a-low-cost-marine-compass-part-1.html">A low-cost marine compass (Part 1 – Hardware</a></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://sailboatinstruments.blogspot.ca/2014/08/a-low-cost-marine-compass-part-3.html">A low-cost marine compass (Part 3 - Calibratio</a>n</span><br />
<br />Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-4237678261594285909.post-60837001027900386172014-08-19T17:59:00.000-04:002014-08-22T15:03:38.612-04:00A low-cost marine compass (Part 1 – Hardware)<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif;">For an electronic compass, the accuracy depends more on the
quality of the calibration that on the price of the components. Here is the design
of a low-cost compass developed around this idea.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif;">The compass is based on the LSM303D chip which combines a
3-axis accelerometer and a 3-axis magnetometer. I used the Pololu carrier board
featuring this chip (9.95 US$).<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPnnUwxMacF-lsVSDrWyjA6ALwrXgh6D0WuBUo4OCStGC5IUcUqbOdloeDaC7aoRPgVz5IQyTNTkq9nYavr5gPZW6YA5V2G3RPvZ0RM6P-QjlmIZfUOw_oFL8A_ecJ6-SU4sYh-VZVdwsi/s1600/lsm303d.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPnnUwxMacF-lsVSDrWyjA6ALwrXgh6D0WuBUo4OCStGC5IUcUqbOdloeDaC7aoRPgVz5IQyTNTkq9nYavr5gPZW6YA5V2G3RPvZ0RM6P-QjlmIZfUOw_oFL8A_ecJ6-SU4sYh-VZVdwsi/s1600/lsm303d.png" height="240" width="400" /></a></span></div>
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif;">The other component of the compass is an Arduino Pro Mini
328 – 3.3V/8Mhz from Sparkfun (9.95 US$). The Pro Mini communicates with the
LSM303D through the SPI bus, using drivers adapted from the PX4 Development
Team. The 2 components are hardwired together to keep a compact form.</span></div>
<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIEXAcPjZz2GMIfzjMNHs0rpk9AHDkcnJATKJGw9iyvK2Rk83rIhhFcp5mYBlOCfgAW4n3DcaobK_VijY6mgsnoXbWo32385JpmHCrcLPHEvw04N-_xW6CDxD5wCqtKW2YeC5jlV4NgSYH/s1600/compass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIEXAcPjZz2GMIfzjMNHs0rpk9AHDkcnJATKJGw9iyvK2Rk83rIhhFcp5mYBlOCfgAW4n3DcaobK_VijY6mgsnoXbWo32385JpmHCrcLPHEvw04N-_xW6CDxD5wCqtKW2YeC5jlV4NgSYH/s1600/compass.png" height="300" width="400" /></a></div>
<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal">
<br /></div>
<br />
<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif;">The following picture illustrates the small compass besides
my Hi-Resolution custom compass previously described on this blog.</span><o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhU3AMYiupyoG1LZ12PCkUe8tDc87PeQjY8lcgjQF1sFrSCxpm8LRneVdhMxZypfPeNrWHLszP4CT2VooYECZhQp2hSApkMnVqknLnYH1eeChrNEj90HmNgdrL3OQGt2nx6DvoJPAz_ATTH/s1600/big_small2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhU3AMYiupyoG1LZ12PCkUe8tDc87PeQjY8lcgjQF1sFrSCxpm8LRneVdhMxZypfPeNrWHLszP4CT2VooYECZhQp2hSApkMnVqknLnYH1eeChrNEj90HmNgdrL3OQGt2nx6DvoJPAz_ATTH/s1600/big_small2.png" height="141" width="320" /></a></div>
<div class="MsoNormal">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Here is the wiring diagram for SPI communication. The FTDI breakout is used to program the Pro Mini and to read the LSM303D raw data during the calibration step.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2psCuhy2x-XAVjQhhe9eZ7VhMsXT6Ho6eLrNoU083ycdMi1v_J0tZPSt49Wzj0FS47XHrP-zMAFEmKw-ihOfunTXv_onQlhOHiDLMaZaDC_CG4v6GntVxPR8uRhoYYqKkctlzyiSrak17/s1600/compass_wir2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2psCuhy2x-XAVjQhhe9eZ7VhMsXT6Ho6eLrNoU083ycdMi1v_J0tZPSt49Wzj0FS47XHrP-zMAFEmKw-ihOfunTXv_onQlhOHiDLMaZaDC_CG4v6GntVxPR8uRhoYYqKkctlzyiSrak17/s1600/compass_wir2.png" height="320" width="188" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: Arial, Helvetica, sans-serif;">The long ribbon cable is required during calibration so that the compass can be moved around at a safe distance from the breakout and the laptop to avoid magnetic interference. After calibration, the ribbon cable is used to power the compass (3.3V) and to transmit the tilt-compensated heading and the heel angle through the serial link to whatever instrument that needs it.</span><br />
<br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://sailboatinstruments.blogspot.ca/2014/08/a-low-cost-marine-compass-part-2_20.html">A low-cost marine compass (Part 2 – Software)</a> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><a href="http://sailboatinstruments.blogspot.ca/2014/08/a-low-cost-marine-compass-part-3.html">A low-cost marine compass (Part 3 - Calibration)</a></span><br />
<br />
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4237678261594285909.post-75167625403472376442014-04-09T21:10:00.000-04:002014-05-09T17:36:23.710-04:00Catamaran’s Sailing Instruments<div class="MsoNormal">
A catamaran’s owner has decided to adapt my design to his
boat, which is sailed on a large freshwater lake. As the lake’s currents are
virtually negligible, the boat speed is measured from a GPS. Furthermore, for a
catamaran, there is no need to correct wind angle measurements for heel. No
electronic compass is planned for now. A Nexus tablet is used as display, with
a Bluetooth link to the system.<br />
<br />
For a catamaran, as there is no heel, there is no way to calculate the leeway as we do for a keelboat using boat speed and heel (as described <a href="http://sailboatinstruments.blogspot.ca/2011/02/leeway-calibration.html"><span style="color: magenta;">here</span></a>). So the owner will have to make test runs and physically measure the leeway in different conditions, while logging boat speed, wind speed and apparent wind angle. It is expected that the leeway angle can be correlated to these 3 variables, and that correction curves can be developed and programmed in the microcontroller. For now, the leeway corrections will be neglected until test data are available.<br />
<br />
<br />
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKpg9Dphnr44i2IPs8kp9Q5sSvFkt7g0hUV2PW5kjFJ0bZ182vbIFo49NvR8wlzsl6K1Mjh1SOlruFGEbv83-tJM2Lawr58A4icU-nTz0my9a72HKMMaHTPL_FOAQsm8prdptNJL4IEvFt/s1600/cat_diag.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKpg9Dphnr44i2IPs8kp9Q5sSvFkt7g0hUV2PW5kjFJ0bZ182vbIFo49NvR8wlzsl6K1Mjh1SOlruFGEbv83-tJM2Lawr58A4icU-nTz0my9a72HKMMaHTPL_FOAQsm8prdptNJL4IEvFt/s1600/cat_diag.jpg" height="357" width="400" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br />
<br />
The microprocessor acquires or calculates the following data
10 times per second (10 Hz):<o:p></o:p></div>
<div class="MsoListParagraphCxSpFirst" style="margin-left: 54pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->Apparent wind angle (AWA)<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 54pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->Apparent wind speed (AWS)<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 54pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->Boat speed through water (STW = GPS’s SOG)<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 54pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->True wind speed (TWS)<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 54pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->True wind angle (TWA)<o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: 54pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->Velocity Made Good (VMG)<br />
<span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->Leeway angle<br />
<span style="font-family: Symbol;">·</span><span style="font-family: 'Times New Roman'; font-size: 7pt;"> </span><!--[endif]-->Heading ( = GPS's COG, when not corrected for leeway)<br />
<span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;"> </span></span><!--[endif]-->Wind direction<span style="font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="MsoNormal">
<br /><br />
These data are available through a serial link, going both
to a Bluetooth modem and to serial-to-USB converter.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The Nexus tablet calculates running averages over an
adjustable range and refreshes a custom display 10 times per second.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
A laptop can be connected to the system to view or change
calibration values, or to download live data for further analysis.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The system is now under construction and will soon be
installed. Software (both for the microprocessor and the Android tablet) is
also under development. The microprocessor code under development (in the WinAVR environment) can be found <a href="https://github.com/bermerlin/bistro"><span style="color: magenta;">here</span></a>. More detailed documentation will be added at the same location.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4237678261594285909.post-3064393716332097762014-01-21T12:08:00.000-05:002014-01-21T12:08:40.985-05:00Going Bluetooth with an Android Tablet<div class="MsoNormal">
After experimenting with Wi-Fi, I have now added a Bluetooth
link between my system and an Android tablet. This has proved to be very
reliable, and simpler to implement when compared to Wi-Fi.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqh8ndrvVn5ZSuy08ImFnJB5tVVPop7l3aynOFX6NgjA2sm0w5U0Ud5AINA2xftmJWha1j5CTtVl-x15eLnoF6tK2NV3xLJP-KlUGorwfNVzsgLdfABByS33tz-9hMBnaxwViCicTsKPAx/s1600/blue_diag.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqh8ndrvVn5ZSuy08ImFnJB5tVVPop7l3aynOFX6NgjA2sm0w5U0Ud5AINA2xftmJWha1j5CTtVl-x15eLnoF6tK2NV3xLJP-KlUGorwfNVzsgLdfABByS33tz-9hMBnaxwViCicTsKPAx/s1600/blue_diag.jpg" height="318" width="320" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
As the Bluetooth modem operates from a 5 V supply, no level
shifting is required on the data line. <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
However, there is one constraint that has to be considered.
When the tablet tries to connect to the system, the connection will fail if there
is data already flowing on the serial output.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
There are 2 ways to deal with this:<o:p></o:p></div>
<div class="MsoNormal">
- add a
switch to manually cut the serial input during the connection step;<o:p></o:p></div>
<div class="MsoNormal">
-
connect during an initial delay at the system start-up (this is how I proceed,
as there is a 10 seconds delay without transmission when my system is switched
on).<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
In my Bluetooth app, the first screen shows a ‘Connect’
button and a disabled ‘Start’ button. The 'Connect' button is pressed when there
is no data coming in. Once the connection is established, the ‘Start’ button is
enabled and can be pressed to initiate a new thread that decodes the modem
output, and pass the information to the main instrument view that is now
switched on, refreshed 10 times per second.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
The Bluetooth thread also saves all data in a large memory
buffer (16 MB) that can store up to 4.5 hours of data per session. When the app
is closing, these data are written to a file on the tablet’s internal memory
card, that can later be transferred to a PC for analysis.<o:p></o:p></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4237678261594285909.post-57261030053488956902013-10-17T02:29:00.001-04:002013-10-17T11:40:10.003-04:007” Nexus Tablet as Instrument Display<span style="font-family: Calibri;">I have been experimenting in building custom displays on a 7”
Nexus tablet, from 10 Hz live data received through Wi-Fi from my master
microcontroller. This short video taken while sailing shows how this looks
like.<o:p></o:p></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dwPb03sa4_5siO6DZQ59buiKbnqXvQfZvoVg74xvi5jTOaC0MA8N0HkHixqqDhT4yMQHaJwBimHBF2i6PTtfg' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">The Nexus tablet is powerful enough for the job, refreshing
the screen 10 times per second with new data.<o:p></o:p></span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p><span style="font-family: Calibri;">This screenshot explains what is going on in close hauled mode:</span><br />
<span style="font-family: Calibri;"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGz4LRCgARf2Atmv0QJwgNsS5qPcAhpFqO-iapFqlHsk-jLYUqfmK9JCxUfLrHkNNuFQhrA6OvZuY6A7pvmmpHFaTuc3eagAtGnf_jPGhNYxvC6Dhhmho_xzGJPSzPhF3pVQHBeKreBF8M/s1600/pres_blanc.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGz4LRCgARf2Atmv0QJwgNsS5qPcAhpFqO-iapFqlHsk-jLYUqfmK9JCxUfLrHkNNuFQhrA6OvZuY6A7pvmmpHFaTuc3eagAtGnf_jPGhNYxvC6Dhhmho_xzGJPSzPhF3pVQHBeKreBF8M/s320/pres_blanc.png" width="320" /></a></div>
<br />
<span style="font-family: Calibri;">T</span><span style="font-family: Calibri;">here are 3 thick needles, each one accompanied with a smaller one and a corresponding number of the same color.</span><br />
<span style="font-family: Calibri;"></span><br />
<span style="font-family: Calibri;">The blue data is for STW (Speed Through Water), the green data is for VMG (Velocity Made Good), and the red data is for AWA (Apparent Wind Angle). The small needles are the instantaneous measured values, refreshed 10 times per second. The thick needles and the corresponding numbers are dampened data (moving averages over 1 to 5 seconds, recalculated 10 times per second by the tablet). The damping period (4 s in this screenshot) is adjustable on the fly by sweeping a finger on the tablet up and down.</span><br />
<span style="font-family: Calibri;"></span><br />
<span style="font-family: Calibri;">The small black circle is a moving target (depending on current True Wind Speed), which represents the optimal AWA for best VMG.</span><br />
<br />
<span style="font-family: Calibri;">The next screenshot is for downwind mode. Here, the red needle represents TWA (True Wind Angle), a more useful information when flying the asymmetrical spinnaker.</span><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTj8pse0R48cPTeGJKEK0a4it0uCHpPYW6d9OUM0lO8cHL4DYBt8AgZTZGpMhyphenhypheneLhWP4OFmyIUzSvRJO4TL8nE5BjieUGdACZ0Q_gShkvNufK92plOqS2E_BTgkbLlKQCcpC-qvLekMOhc/s1600/spi.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTj8pse0R48cPTeGJKEK0a4it0uCHpPYW6d9OUM0lO8cHL4DYBt8AgZTZGpMhyphenhypheneLhWP4OFmyIUzSvRJO4TL8nE5BjieUGdACZ0Q_gShkvNufK92plOqS2E_BTgkbLlKQCcpC-qvLekMOhc/s320/spi.png" width="320" /></a></div>
<br />
<span style="font-family: Calibri;"></span><br />
<span style="font-family: Calibri;"></span><br />
<span style="font-family: Calibri;">There is also a night mode available, created by inverting the black and white colors.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidoRpw3ss8v7p8AjB7Hnh0fJakJWjYOcZLdRSWcFtrGnxODF93Scmt3BQPlWao8cOrcclmNJksoapumHfAKlRqVyFRFOByyYQFMqXK34K8pI_j2aCkalNUpJdZJKIyBZfJNvAGBbGgC78X/s1600/pres_noir.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidoRpw3ss8v7p8AjB7Hnh0fJakJWjYOcZLdRSWcFtrGnxODF93Scmt3BQPlWao8cOrcclmNJksoapumHfAKlRqVyFRFOByyYQFMqXK34K8pI_j2aCkalNUpJdZJKIyBZfJNvAGBbGgC78X/s320/pres_noir.png" width="320" /></a></div>
<br />
<span style="font-family: Calibri;"></span><br />
<span style="font-family: Calibri;"></span><br />
<span style="font-family: Calibri;"></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">The tablet is not bright enough to be used as a fixed
display in the cockpit, but very usable as a personal display, like the tacticians in the last America Cup. </span></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;"></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;">
<span style="font-family: Calibri;">Ben Ainslie (Oracle Team)</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho-_35nQQ0NV2PNfI_AMwYCxW9eUHvzV3_cmAwmoglljtG7pLimcHMvu9R13BrDMEpNe4DhH3j1dLfGh_dvY5SnnU7Mt140oqKESZeI7WoVbLnnRFLrp5DiKppxjKBplQ9ASEBQM_7Xm_v/s1600/disp3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho-_35nQQ0NV2PNfI_AMwYCxW9eUHvzV3_cmAwmoglljtG7pLimcHMvu9R13BrDMEpNe4DhH3j1dLfGh_dvY5SnnU7Mt140oqKESZeI7WoVbLnnRFLrp5DiKppxjKBplQ9ASEBQM_7Xm_v/s320/disp3.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEw0sMbiMSx_sUc1fodRwwRpxcI-uWu7v7q9galmD9mlzwXnIYbtqraPBbS1WwJa1Y5BzQ17P-hTSMeMFl5eg8WitDlGFt-M7IPjY3tXSJx8aNuwd47nrmm7Tv8Ljoxx_CNfYIoymr2Jfk/s1600/disp4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEw0sMbiMSx_sUc1fodRwwRpxcI-uWu7v7q9galmD9mlzwXnIYbtqraPBbS1WwJa1Y5BzQ17P-hTSMeMFl5eg8WitDlGFt-M7IPjY3tXSJx8aNuwd47nrmm7Tv8Ljoxx_CNfYIoymr2Jfk/s320/disp4.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Calibri;">Ray Davies (Team New Zealand)</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5wueFr7IKc8TqzWahuSe1touVqXR8PNbCFsnK72EOi8OYXQFo0bk8ESzb1IkFca-IwvOhpnQjOGSEBX4SVOCvLJPmLKqCi78T-PDwQqxwUY5_dWx4H8HdqXwhQdj142H5GTEbj3AUut_G/s1600/disp5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5wueFr7IKc8TqzWahuSe1touVqXR8PNbCFsnK72EOi8OYXQFo0bk8ESzb1IkFca-IwvOhpnQjOGSEBX4SVOCvLJPmLKqCi78T-PDwQqxwUY5_dWx4H8HdqXwhQdj142H5GTEbj3AUut_G/s320/disp5.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWmK9aS6YP9LXQ6hyphenhyphen8tU8Hp3wFsFIcTyK6Wfb-YsMnJvWjsvedgTHIP6vHJHhdFDhibDVzdV6cToSJrAwwj8MU1k77bkR_4Ys8y9KOrxjEJDjMyNZ9im1wFqduZC3J9C4DK0ceJiJVKWim/s1600/disp6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWmK9aS6YP9LXQ6hyphenhyphen8tU8Hp3wFsFIcTyK6Wfb-YsMnJvWjsvedgTHIP6vHJHhdFDhibDVzdV6cToSJrAwwj8MU1k77bkR_4Ys8y9KOrxjEJDjMyNZ9im1wFqduZC3J9C4DK0ceJiJVKWim/s320/disp6.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
</div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;"></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;"></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
</div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;"></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;"><o:p></o:p></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-4237678261594285909.post-11476845853964723392012-11-28T13:33:00.000-05:002012-12-01T10:46:30.447-05:00GPS data from Wifly to Android phone (Part 2) <span style="font-family: Arial, Helvetica, sans-serif;">As a proof of concept, I have created a simple app that fetches the last UDP packet received, and displays its contents in a floating message box, each time the button is pressed.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHUwTCZY7KB_pvVzibj1w_m9zi_b4EzF1ttNsfZz4EO_TqUMZUpDWzn3AGJYM7Qf8XxsZgNvYKEcOiNVxTHNrwja9YgQRJUyNl-AGdH6LV832UirIgNEVk7qxMhnMZCGqf3kIrxwWoe1PC/s1600/gps_data.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHUwTCZY7KB_pvVzibj1w_m9zi_b4EzF1ttNsfZz4EO_TqUMZUpDWzn3AGJYM7Qf8XxsZgNvYKEcOiNVxTHNrwja9YgQRJUyNl-AGdH6LV832UirIgNEVk7qxMhnMZCGqf3kIrxwWoe1PC/s400/gps_data.jpg" width="225" /></a></div>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Here is an excerpt of the app's java code that is used for that.</span><br />
<span style="font-family: Arial;"></span><br />
<span style="font-family: Arial;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">...<br />public class MainActivity extends Activity {<br /> ...<br /> public void sendMessage(View view) {<br /> new ServerAsyncTask(MainActivity.this).execute();<br /> }<br /> ...<br /> public static class ServerAsyncTask<br /> extends AsyncTask<Void, String, Void> {<br /> private Activity act;<br /> public ServerAsyncTask(Activity _act) {<br /> this.act = _act;<br /> }<br /> @Override<br /> protected String doInBackground(Void... params) {<br /> byte[] receiveData = new byte[1024];<br /> DatagramSocket socket = null;<br /> try {<br /> socket = new DatagramSocket(50000);<br /> socket.setSoTimeout(30000);<br /> DatagramPacket packet = <br /> new DatagramPacket(receiveData, receiveData.length);<br /> socket.receive(packet);<br /> String contents = new String(packet.getData());<br /> publishProgress(contents);<br /> socket.close();<br /> } catch (SocketException e) {<br /> socket.close();<br /> } catch (SocketTimeoutException e) {<br /> socket.close();<br /> } catch (IOException e) {<br /> socket.close();<br /> }</span></span><br />
<span style="font-family: Arial;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> return (Void)null;<br /> }<br /> <br /> @Override<br /> protected void onProgressUpdate(String... str) {<br /> Toast.makeText(act, str[0], Toast.LENGTH_SHORT).show();<br /> }<br /> }<br />}</span> </span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4237678261594285909.post-86110630830767116342012-11-20T21:03:00.000-05:002012-11-28T12:48:57.088-05:00GPS data from Wifly to Android phone (Part 1)<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Times New Roman;">
</span></span><span style="font-family: Arial, Helvetica, sans-serif; mso-bidi-font-size: 11.0pt;">Once
an Access Point has been created on the phone with the app described in the last
post, we can use the app’s data to configure the RN-XV module. Let's keep the same example:</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="mso-bidi-font-size: 11.0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"><span style="mso-tab-count: 1;"> </span>- SSID :<span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 2;"> </span>DIRECT-6U-Android_37e5<o:p></o:p></span></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-family: Arial, Helvetica, sans-serif;">
<span style="mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span>- passphrase : <span style="mso-tab-count: 1;"> </span>sK2QIENk<span style="mso-tab-count: 1;"> </span><o:p></o:p></span><br />
<span style="mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span>- phone’s IP : <span style="mso-tab-count: 1;"> </span>192.168.49.1</span><br />
<span style="mso-bidi-font-size: 11.0pt;"></span><br />
<span style="mso-bidi-font-size: 11.0pt;">Here
is the arrangement used to configure the RN-XV module:<o:p></o:p></span></span></span>
<span style="font-family: Times New Roman;">
</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZIIhingCwX2Hgid5zvwBAcBUIoHL8_nXReSVoPqeagiCsH1vwRqmz06R3hhaW8C_PiwWQMq0bcGvx-bLfTWjd54qEi_M3_kGzPVoTLadMrRdDd8I7Jv8pttC8xgP4L07yeUe6OTj35oqj/s1600/rnxv_conf.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="254" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZIIhingCwX2Hgid5zvwBAcBUIoHL8_nXReSVoPqeagiCsH1vwRqmz06R3hhaW8C_PiwWQMq0bcGvx-bLfTWjd54qEi_M3_kGzPVoTLadMrRdDd8I7Jv8pttC8xgP4L07yeUe6OTj35oqj/s320/rnxv_conf.jpg" width="320" /></a></div>
<span style="font-family: Times New Roman;"></span><br />
<span style="font-family: Times New Roman;"></span><span style="font-family: Arial, Helvetica, sans-serif;">
<span style="mso-bidi-font-size: 11.0pt;">Only 4 pins will be used on the RN-XV module:</span></span><br />
<ul>
<li>pin 1 (red) : VDD_3V3</li>
<li>pin2 (yellow) : UART_TX</li>
<li>pin3 (green) : UART_RX, with an external 10k pull-up to 3.3 V</li>
<li>pin 10 (black) : GND</li>
</ul>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
The module is connected to a laptop running TeraTerm through a USB-to-Serial converter. Here, we use the Adafruit's USB to TTL Serial Cable. Note that the converter's red wire should NOT be used, as it is connected to the USB 5V power, which could damage or destroy the RN-XV. The TeraTerm monitor software is configured at 9600 baud, which is the default for the RN-XV UART.</div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
</div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
Once connected, the following commands are sent to the RN-XV module:</div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
</div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: "Courier New", Courier, monospace;">$$$<br />factory R<br />reboot</span></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: "Courier New", Courier, monospace;"></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: "Courier New", Courier, monospace;">$$$<br />set wlan ssid DIRECT-6U-Android_37e5<br />set wlan passphrase sK2QIEnk<br />save<br />reboot</span></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: "Courier New", Courier, monospace;"></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: "Courier New", Courier, monospace;">$$$<br />set ip host 192.168.49.1<br />set ip remote 50000<br />set ip proto 1<br />set comm time 10000<br />set comm size 75</span><br />
<span style="font-family: "Courier New", Courier, monospace;">set comm match 13<br />save</span></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: "Courier New", Courier, monospace;">reboot</span></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-size: 14pt; mso-bidi-font-size: 11.0pt;"></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-size: 14pt; mso-bidi-font-size: 11.0pt;"><span style="font-size: small;">With this configuration, the module will form and send a UDP packet from the already received data each time any one of the following conditions occurs:</span></span><br />
<ul>
<li><span style="font-size: 14pt; mso-bidi-font-size: 11.0pt;"><span style="font-size: small;">75 bytes of serial data has been received by the module through the UART_RX pin;</span></span></li>
<li>or the ASCII character 13 (carriage return) has just been received;</li>
<li>or 10 seconds have occured since the last packet has been sent.</li>
</ul>
<span style="font-size: 14pt; mso-bidi-font-size: 11.0pt;"><span style="font-size: small;">In the following arrangement, a GPS NMEA output at 9600 baud is connected to the UART_RX pin, and the RN-XV module continuously forms and sends UDP packets with the GPS data. Each packet will contain a complete NMEA sentence, as these sentences all end with the carriage return byte, and are less than 75 bytes.</span></span></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-size: 14pt; mso-bidi-font-size: 11.0pt;"><span style="font-size: small;"></span></span> </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi28b496SAB61ker6yMKvtrDMU6xG6AJTTeLpfaeLU9vNtEipgQtLafQh1Tq4ebGs45JZlyIZbAcz8GIHpqqV0vayhUz-zCJc3EdxYsyeyt7bC_rJt5r6IH34Utg8E7y1ZKH9Ij4i1Sai34/s1600/rnxv_gps.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="293" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi28b496SAB61ker6yMKvtrDMU6xG6AJTTeLpfaeLU9vNtEipgQtLafQh1Tq4ebGs45JZlyIZbAcz8GIHpqqV0vayhUz-zCJc3EdxYsyeyt7bC_rJt5r6IH34Utg8E7y1ZKH9Ij4i1Sai34/s320/rnxv_gps.jpg" width="320" /></a></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-size: 14pt; mso-bidi-font-size: 11.0pt;"><span style="font-size: small;"></span></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-size: 14pt; mso-bidi-font-size: 11.0pt;"><span style="font-size: small;"></span></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-size: 14pt; mso-bidi-font-size: 11.0pt;"><span style="font-size: small;">Our next step will be to create an Android app for the phone that will capture the packets, retrieve the GPS data and display the info on the screen. </span></span></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-size: 14pt; mso-bidi-font-size: 11.0pt;"><span style="font-size: small;"></span></span> </div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<br /></div>
</span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-4237678261594285909.post-15610425026512893182012-10-14T15:51:00.000-04:002013-03-26T20:49:29.624-04:00Talking to an Android phone through Wi-Fi<span style="font-family: Arial, Helvetica, sans-serif;">In this system, the master controller sends its serial data to a laptop through a USB-to-Serial converter. The laptop is responsible for creating a number of colorful animated displays from this data. Now I am interested to send this same data to an Android phone that can create its own custom displays. This can be done either through Wi-Fi or Bluetooth.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">I want to implement both, by double-splitting the UART Tx line to a RN-XV Wifly Module, and to a BlueSMiRF Bluetooth Modem.</span><br />
<span style="font-family: Arial;"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRxjnbW4R4Lp7PdKDx3jEk5YK-DQXH0rUAxlKctUrQBUHAK1Qz-WieKkSyGEQVK8tDlJzRgWKF2C0O6ZAzhwJ8syGuDZ17KSUZFezA2uV1brKcaiX46jS4dXOImZjE3F5hpvVUTnY-JpTK/s1600/diagram_new.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="395" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRxjnbW4R4Lp7PdKDx3jEk5YK-DQXH0rUAxlKctUrQBUHAK1Qz-WieKkSyGEQVK8tDlJzRgWKF2C0O6ZAzhwJ8syGuDZ17KSUZFezA2uV1brKcaiX46jS4dXOImZjE3F5hpvVUTnY-JpTK/s400/diagram_new.jpg" width="400" /></a></div>
<br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">In this post, I will discuss the Wi-Fi route. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">The goal is to establish a peer-to-peer adhoc connection between the Wifly module and the phone, and to use UDP packets to keep a low latency in the transmission of live 10 Hz data. Since Android 4.0, it is possible to programmatically configure the phone as an Access Point (AP) visible to nearby Wi-Fi modules (including those integrated in most modern laptops and computers).</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">There is currently a limitation to this approach <strong>(but see UPDATE below!).</strong> In creating the AP, the Android system assigns a random SSID and passphrase to it, and it is not possible to edit these values The Wifly module must have an advanced knowledge of these values in order to connect to the phone. So the AP must first be created by the phone, and its details made visible in order to configure the Wifly module.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">I have created a simple app tool to assist in this task. It is available on Google Play under the name ‘Wi-Fi P2P Access Point’. I have set up a small fee to refrain people to install it without having a real interest and knowledge of what it is designed for.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">With this application, you can create an access point that will live as long as Wi-Fi is enabled on the phone, or until you manually remove it in the app, or until the Android system arbitrarily decides to destroy it to reclaim resources.</span><br />
<span style="font-family: Arial;"></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8MBcnMBexEI6DyTp7txKxxqsHF7b29QYyTDmfHDdUYL9kI0ismVIxMkNwjML5ssXsim85V-nNDbsvMdGJYdgg-0IsY9EBodJsoeRKlixsigFzVXC9U2HPpjaDV1Xpe4Kdoe6GxlDtc0vM/s1600/app.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="266" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8MBcnMBexEI6DyTp7txKxxqsHF7b29QYyTDmfHDdUYL9kI0ismVIxMkNwjML5ssXsim85V-nNDbsvMdGJYdgg-0IsY9EBodJsoeRKlixsigFzVXC9U2HPpjaDV1Xpe4Kdoe6GxlDtc0vM/s320/app.jpg" width="320" /></a></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Here is a simple way to test if the AP actually exists. After you create an AP, your laptop will automatically list it as an available network, and if you want to connect, you will have to provide the passphrase. Once connected, nothing more happens because there is no data flow on the connection.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Avoid rapidly creating and removing APs without some pause between the commands. The app will become unresponsive and you may have to disable and re-enable Wi-Fi. </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">In coming posts, as an intermediate step, we will look at:</span><br />
<span style="font-family: Arial;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">- <a href="http://sailboatinstruments.blogspot.ca/2012/11/gps-data-from-wifly-to-android-phone.html">how to configure the Wifly module</a> to send GPS data to the phone;</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />- <a href="http://sailboatinstruments.blogspot.ca/2012/11/gps-data-from-wifly-to-android-phone_28.html">how to develop a custom app</a> than can display these data.<br />
<br />
<br />
<strong>UPDATE: With Android 4.2.1, the above limitation seems to have disappeared! The SSID and passphrase remain the same when the access point is removed and recreated.</strong><br />
</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />Unknownnoreply@blogger.com14tag:blogger.com,1999:blog-4237678261594285909.post-26439852638413095862012-06-23T20:11:00.003-04:002012-06-24T09:31:40.337-04:00Compass calibration on the water<span style="font-family: inherit;">Even if an electronic compass has been meticulously calibrated on land in a non-disturbed magnetic environment, it will need additional calibration adjustments once installed in a boat. </span><br />
<br />
<span style="font-family: inherit;">In a <a href="http://sailboatinstruments.blogspot.ca/2011/01/gyro-compass-calibration.html">previous post</a>, I described a procedure to recalibrate a compass with a GPS if you can find a patch of water where there is absolutely no current, a situation that practically does not exist in my maritime environment.</span><br />
<br />
<span style="font-family: inherit;">If your system can log the headings from a fast compass (5 Hz or more), here is an alternate method that can tolerate an existing current, but requires absolutely flat water (no waves) and no (or very negligible) wind. This is in fact the method that many commercial compass vendors choose to implement in their autocalibration routines, but presented here in a transparent manner.</span><br />
<br />
<span style="font-family: inherit;">These conditions must be met: a low and constant motoring speed (2 to 4 knots), and a tiller or wheel blocked in position so that a complete turn will take around 3 minutes.</span><br />
<br />
<span style="font-family: inherit;">Here is how I produced the results presented at the end of this post. </span><br />
<br />
<span style="font-family: inherit;">I made several turns while logging the headings (for both the Aimar H2183 and my own <a href="http://sailboatinstruments.blogspot.ca/2011/10/hi-resolution-custom-compass.html">Hi-Resolution compass</a>), as well as the boat speed. </span><span style="font-family: inherit;">From the speed log, I find a section where the boat speed has been very stable, and I extract the heading data from a full turn.</span><br />
<br />
<span style="font-family: inherit;">We can make the reasonable hypothesis (with no waves and no wind) that our angular velocity has been constant during this golden turn, so that all recorded headings have to be separated by equal angles. If this is not the case, we can calculate the local deviation.<br />
<br />
So several turns are recorded, but only the best one is used in the calibration. Here is simplified example using only a reduced set of measurements.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheBw1Vb2Sbop3LTTTx-PE18vijJD0ygN4C6TaPsPKe64LfH2R1NN0iarf0FRtcUc7e-mHGnxfkCXbhL67SV0mJKFQoOeMSnnOtFwuh5djsbRzwGH-JCrcVlPBchgr51lIwx2zQaSmXIpkU/s1600/deviations.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheBw1Vb2Sbop3LTTTx-PE18vijJD0ygN4C6TaPsPKe64LfH2R1NN0iarf0FRtcUc7e-mHGnxfkCXbhL67SV0mJKFQoOeMSnnOtFwuh5djsbRzwGH-JCrcVlPBchgr51lIwx2zQaSmXIpkU/s400/deviations.jpg" width="210" /></a></div><br />
<br />
<span style="font-family: inherit;">In Colum A, we have the measured headings on a complete turn, with 20 diffferent measurements. The expected angle difference between each measurement is 360/20 = 18 degrees. In Column B, we have calculated these expected headings if there was no deviation. In Column C, we calculate the deviation (A – B).</span><br />
<br />
<span style="font-family: inherit;">We can graph these deviations (C) vs. the measured heading (A). This is our deviation graph.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNDvBoQx2nga3mWrag-iGV9IaK3aM6lTQyTOyYtSASfAxNwsIicNFemkTYT-bdazGxsaVXshv_YhZm0cEPmm-GAcWfJUHrVUplHClkgSWTHChkl0A-VJt84YlxMJQRUEXkOu6yWd76l8RI/s1600/dev_curve.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNDvBoQx2nga3mWrag-iGV9IaK3aM6lTQyTOyYtSASfAxNwsIicNFemkTYT-bdazGxsaVXshv_YhZm0cEPmm-GAcWfJUHrVUplHClkgSWTHChkl0A-VJt84YlxMJQRUEXkOu6yWd76l8RI/s320/dev_curve.jpg" width="320" /></a></div><br />
<br />
<span style="font-family: inherit;">From these data points, we can calculate (using the NLREG software) the 5 deviation coefficients (A, B, C, D, E) such as that:</span><br />
<br />
<span style="font-family: inherit;">Deviation = A + B sin(H) + C cos(H) + D sin(2*H) + E cos(2*H).</span><br />
<br />
<span style="font-family: inherit;">By correcting the measured heading by the calculated deviation, we obtain a pre-calibrated heading that still needs a last offset correction. Our graph is based on the assumption that there is no deviation at our starting heading of 100 deg. But this is not necessarily the case; the zero-deviation point(s) may be at some other heading(s).</span><br />
<br />
<span style="font-family: inherit;">This last correction is easy to do, as we need only to compare any pre-calibrated heading value to a known heading. For example if, with the boat aligned along a dock at 78.0 deg, we obtain a pre-calculated heading of 76.5 deg, we will have to add a constant offset of 1.5 deg to all our pre-calibrated headings. (Don't trust your regular magnetic compass for this : it has its own uncorrected deviations).</span><br />
<br />
<span style="font-family: inherit;"><strong>Final corrected heading = Measured heading - Deviation + Offset</strong> </span><br />
<br />
<br />
<span style="font-family: inherit;">Here are the deviation curves obtained from my 2 compass, using data from the same turn.</span><br />
<br />
<span style="font-family: inherit;"></span><br />
<span style="font-family: inherit;">Airmar H2183 Compass (1721 meassurements, doubled 5 Hz samples ):</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjo2vv1fZyaL9cGJxsInmVVKsQuAHMAR10a2VnPFlwXh6yUwtca4nPXv7ubv5FE6rFDJPTzVaaZ-qYm3DlLBNXkfZZHEtApOpY69LvxvgVQJluJcb35XzXpoSawjDY7HERxHoh75Q9wlVtv/s1600/cal_h2183.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjo2vv1fZyaL9cGJxsInmVVKsQuAHMAR10a2VnPFlwXh6yUwtca4nPXv7ubv5FE6rFDJPTzVaaZ-qYm3DlLBNXkfZZHEtApOpY69LvxvgVQJluJcb35XzXpoSawjDY7HERxHoh75Q9wlVtv/s400/cal_h2183.jpg" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<span style="font-family: inherit;">Hi-Resolution Compass (1737 measurements, 10 Hz samples):</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr9x3dwfKrpIOL1HQ16gpoO2eP93rhNGLQyWwY0N158tkPc_wJ2M7_qy8pmrXCP2kFBNT9Q-y1JIzj9-F5_gpAjAc93Gau6BsHCJ6HARV7E7Gx-IJ80diDXLDi_i6-nia4cTOv0N_fp6xn/s1600/cal_hires.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr9x3dwfKrpIOL1HQ16gpoO2eP93rhNGLQyWwY0N158tkPc_wJ2M7_qy8pmrXCP2kFBNT9Q-y1JIzj9-F5_gpAjAc93Gau6BsHCJ6HARV7E7Gx-IJ80diDXLDi_i6-nia4cTOv0N_fp6xn/s400/cal_hires.jpg" width="400" /></a></div><br />
<br />
<span style="font-family: inherit;"> </span><br />
<span style="font-family: inherit;">So are we done?</span><br />
<br />
<span style="font-family: inherit;">Not really, because be still have to check if this calibration remains valid:<br />
- when the motor is not running<br />
- when the boat is heeling.</span><br />
<br />
<span style="font-family: inherit;">Getting an accurate magnetic heading is a never ending story.</span>Unknownnoreply@blogger.com8tag:blogger.com,1999:blog-4237678261594285909.post-65963631689990129092012-06-21T18:10:00.002-04:002012-06-21T18:16:45.188-04:00Interfacing the Raymarine ST1000+ Autopilot<span style="font-family: inherit;">I understand that the Raymarine ST1000+ autopilot (and the similar ST2000+) can receive exterior heading </span><span style="font-family: inherit;">data through the SeaTalk bus, specifically from a Raymarine ST40 fluxgate compass. So another project </span><span style="font-family: inherit;">would be to use the heading output from my <a href="http://sailboatinstruments.blogspot.ca/2011/10/hi-resolution-custom-compass.html">hi-resolution compass</a> to drive the autopilot.</span><br />
<br />
<span style="font-family: inherit;">First I was interested to see what kind of data the autopilot puts on the SeaTalk bus as a talker. </span><span style="font-family: inherit;">I used the following arrangement to monitor the SeaTalk bus.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ7zjJLpgi51W0ympxpAFsspxGlqcDbGU0DRrkdfPgiQ7NFJ63nvTGiJhqdJcK3JLkrVbVraKKZygJP0QzaYtl73RqJJ1ASFDjepIRhHH5G4eIBm3pL5xV1X8LX0INWhWBbzFO5g6MExoM/s1600/st1000.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ7zjJLpgi51W0ympxpAFsspxGlqcDbGU0DRrkdfPgiQ7NFJ63nvTGiJhqdJcK3JLkrVbVraKKZygJP0QzaYtl73RqJJ1ASFDjepIRhHH5G4eIBm3pL5xV1X8LX0INWhWBbzFO5g6MExoM/s400/st1000.jpg" width="343" /></a></div><br />
<br />
<span style="font-family: inherit;">The autopilot is connected to a serial port of a MAVRIC-IIB board through the SeaTalk interface circuit. </span><span style="font-family: inherit;">The MAVRIC-IIB has an onboard MAX222 chip to provide level conversion between the serial port and the </span><span style="font-family: inherit;">logic level pins of the ATMega128 microcontroller. The SeaTalk datagrams showing on the bus are resent in </span><span style="font-family: inherit;">hex format to a computer running Hyperterminal, through a serial-to-USB converter.</span><br />
<br />
<span style="font-family: inherit;">The microcontroller code is an almost direct port of the <a href="http://www.thomasknauf.de/rap/seatalk3.htm#Mon">“SeaTalk Monitor” code</a> available on Thomas </span><span style="font-family: inherit;">Knauf’s website. It can be found at the end of this post. </span><span style="font-family: inherit;">In normal operation (standby or auto), the ST-1000+ sends continuously these 2 datagrams, each one at 1 </span><span style="font-family: inherit;">Hz, with a half-second between them.</span><br />
<br />
<span style="font-family: inherit;">…<br />
9C C1 07 00 <br />
84 C6 07 00 00 00 00 00 0F <br />
9C C1 07 00 <br />
84 C6 07 00 00 00 00 00 0F <br />
9C C1 07 00 <br />
84 C6 07 00 00 00 00 00 0F <br />
9C C1 07 00 <br />
84 C6 07 00 00 00 00 00 0F<br />
…</span><br />
<br />
<span style="font-family: inherit;">Here, the 9C datagram encodes the compass heading (in degrees) and the turning direction (left or right). </span><br />
<br />
<span style="font-family: inherit;">The 84 datagram also encodes the compass heading and turning direction, plus the autopilot course when in </span><span style="font-family: inherit;">auto mode, and the currently active mode (standby, auto, vane or track mode). </span><br />
<br />
<span style="font-family: inherit;">We learn on Thomas Knauf’s site that the 89 datagram encodes the compass heading sent by the ST40 compass </span><span style="font-family: inherit;">instrument, and can be read by the ST1000+ or ST2000+ autopilot. T</span><span style="font-family: inherit;">o test this behaviour, I modified the microcontroller code (not shown here) so that it sends an 89 </span><span style="font-family: inherit;">datagram (89 02 04 00 20) after reading each of the 9C and 84 datagram, with a small delay to avoid </span><span style="font-family: inherit;">collisions. The datagram sent (89 02 04 00 20) encodes a heading of 8 degrees.</span><br />
<br />
<span style="font-family: inherit;">The monitor then produced this kind of ouput:</span><br />
<br />
<span style="font-family: inherit;">…<br />
9C 01 04 00 <br />
89 02 04 00 20 <br />
84 06 04 00 00 00 00 00 0F <br />
89 02 04 00 20 <br />
9C 01 04 00 <br />
89 02 04 00 20 <br />
84 06 04 00 00 00 00 00 0F <br />
89 02 04 00 20 <br />
…</span><br />
<br />
<span style="font-family: inherit;">From what I observed by playing with the autopilot in standby and auto mode, the 89 datagram is </span><span style="font-family: inherit;">interpreted by the ST-1000+ as a request to perform a heading alignment to the value encoded in the </span><span style="font-family: inherit;">datagram.</span><br />
<br />
<span style="font-family: inherit;">So if a custom heading is encoded in an 89 datagram sent on a regular basis, the autopilot will indeed </span><span style="font-family: inherit;">adjusts its heading alignment if required to reproduce this value. </span><br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">#include <avr/io.h><br />
#include <avr/interrupt.h><br />
#include <stdio.h> </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">unsigned char resh;</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">char buffer[256]; <br />
char hex[]="0123456789ABCDEF";</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">unsigned int collision_ctr;<br />
unsigned char in_ptr, out_ptr, limit_ptr;<br />
char receiver_buf, byte_ctr; </span><br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">unsigned char kbhit(void)<br />
{<br />
// return nonzero if char waiting<br />
unsigned char b;<br />
b = 0;<br />
if(UCSR1A & (1 << RXC1))<br />
b = 1;<br />
return b;<br />
}</span><br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">int uart_putchar0(char c)<br />
{<br />
loop_until_bit_is_set(UCSR0A, UDRE0);<br />
UDR0 = c;<br />
return 0;<br />
}</span><br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">int main(void)<br />
{<br />
in_ptr = 0;<br />
out_ptr = 0;<br />
limit_ptr = 0;<br />
<br />
/* enable serial port UART1 */ /* Set baud rate : 4800 @ 16 MHz */<br />
UBRR1L = (unsigned char)(207);<br />
/* Enable receiver with 9 data bits */<br />
UCSR1B = _BV(RXEN1) | _BV(UCSZ12);<br />
<br />
/* enable serial port UART0 */ /* Set baud rate : 9600 @ 16 MHz */<br />
UBRR0L = (unsigned char)(103);<br />
/* Enable transmitter */<br />
UCSR0B =_BV(TXEN0);</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> for(;;)<br />
{ <br />
if(kbhit())<br />
{<br />
// check 9th bit before reading UDR1<br />
resh = UCSR1B;<br />
resh = (resh >> 1) & 0x01;<br />
<br />
receiver_buf = UDR1;<br />
<br />
if(resh) // 9th bit set<br />
{<br />
if(byte_ctr) // More characters expected => Collision<br />
{<br />
in_ptr = limit_ptr; // Discard last datagram, restart from beginning <br />
collision_ctr++; // Count collision events <br />
}<br />
buffer[in_ptr++] = '\r'; // Put new command on new line <br />
buffer[in_ptr++] = '\n'; <br />
byte_ctr = 255; // Undefined datagram length, wait for next character <br />
}<br />
else<br />
{<br />
if(byte_ctr == 254) // Attribute byte ? <br />
byte_ctr = (receiver_buf & 0xF) + 2; // Read expected datagram length<br />
}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> if(byte_ctr) <br />
{ // Process valid data bytes, should always be true <br />
buffer[in_ptr++] = hex[receiver_buf >> 4]; // Convert Data to hex <br />
buffer[in_ptr++] = hex[receiver_buf & 0xF]; <br />
buffer[in_ptr++] = ' '; // Seperate by space <br />
if(!--byte_ctr) <br />
limit_ptr = in_ptr; // Complete datagram ready for output<br />
}<br />
}<br />
else<br />
{<br />
if(out_ptr != limit_ptr) // Characters waiting for Output ?<br />
{<br />
// Copy single character from buffer to screen<br />
uart_putchar0(buffer[out_ptr++]);<br />
}<br />
}<br />
}<br />
return 1;<br />
}</span>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4237678261594285909.post-16898075141218321492012-04-10T17:26:00.003-04:002012-04-12T10:39:55.284-04:00Building the 3 MHz ultrasonic transducer<span style="font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-CA; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">A first 3 MHz transducer prototype is ready for testing. A vintage Airmar ST200 speed transducer housing has been modified to receive the piezoelectric element.</span><br />
<br />
<span style="color: red; font-family: Calibri;"><strong>WARNING: this particular transducer design is not intended to be installed on a real boat for safety reasons. The threads between the compression ring and the housing may be stripped following an underwater impact, causing massive ingress of water. This design is intended to be used only for development purposes on special floating devices.</strong></span><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhreuWFn_rMqkzKosXYBx-7L3HpbgvAvxACpKbVj9-B2ZWtFwpwxZzOoELsmA76xOxle3TffYItNMK2jH00shGZH3mCbR11his0uwZGVv3yiUfShl0nYG8n4-xg12STc9ZrBrVvOy1y0oQT/s1600/transd00.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="262" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhreuWFn_rMqkzKosXYBx-7L3HpbgvAvxACpKbVj9-B2ZWtFwpwxZzOoELsmA76xOxle3TffYItNMK2jH00shGZH3mCbR11his0uwZGVv3yiUfShl0nYG8n4-xg12STc9ZrBrVvOy1y0oQT/s400/transd00.jpg" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"></div><br />
<span style="font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-CA; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">A future improvement will be to modify the form of the yellow urethane matching layer so as to get rid of the recess. This first prototype will be used mainly to test the electronics outside of a real boat, so that the safety epoxy plug will not be cast for the moment, in order to keep full access to the transducer.</span><br />
<br />
<span style="font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-CA; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">I was fortunate to get the help of a competent machine shop owner to achieve this. Here are some pictures.</span><br />
<br />
<div align="center"></div><span style="font-family: "Calibri","sans-serif"; font-size: 11pt; mso-ansi-language: EN-CA; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"></span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU6nemk1UxvF5z1HLWGTmnbJyxsGe8gltCciIq6vU5w2SPvnzbtAtcepFdCFD9q_v8Cfr0T1tJP_y54Rqlt_ieZmSoLJ7HtC2jIaui55GmExMRl2suFu5GyCrxtDoQzH0RPuCLXWwxSaH7/s1600/transd1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU6nemk1UxvF5z1HLWGTmnbJyxsGe8gltCciIq6vU5w2SPvnzbtAtcepFdCFD9q_v8Cfr0T1tJP_y54Rqlt_ieZmSoLJ7HtC2jIaui55GmExMRl2suFu5GyCrxtDoQzH0RPuCLXWwxSaH7/s400/transd1.jpg" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0344HVFw3kkfU2HWx2dV58oJERHMfkYAsqfb4CrDMnDhCTWuLetp-3eNwOzqY8GdiXuaOlIts7ySca07-c4DnLpwfQCVApJQUVmW4fiSVmCGnOgtcTeHxQBODeK6cU3o_GsmxS3LoRYdM/s1600/transd2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="304" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0344HVFw3kkfU2HWx2dV58oJERHMfkYAsqfb4CrDMnDhCTWuLetp-3eNwOzqY8GdiXuaOlIts7ySca07-c4DnLpwfQCVApJQUVmW4fiSVmCGnOgtcTeHxQBODeK6cU3o_GsmxS3LoRYdM/s320/transd2.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4237678261594285909.post-72380753370892211232012-04-04T20:30:00.013-04:002012-04-05T14:25:20.317-04:00Designing an ultrasonic transducer<span style="font-family: Arial, Helvetica, sans-serif;">Here is the conceptual design of the 3-MHz ultrasonic transducer. Apart from the piezoelectric element, the 2 important design parameters are the nature of the backing and matching layers.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGSPTs05uCeDbXZlBlgPmXEdcxWNPpjguma61SAokO9n4UuQz4sR3cEGeAi-stiK7Dnf8yn03w3BfWqMs6U2P4bl4AaeiZ3Pp0Nfa6QgRMjsvMvbjRHZ3NoKYT2BsfMcT-rr4uJe25YqBd/s1600/piezo1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGSPTs05uCeDbXZlBlgPmXEdcxWNPpjguma61SAokO9n4UuQz4sR3cEGeAi-stiK7Dnf8yn03w3BfWqMs6U2P4bl4AaeiZ3Pp0Nfa6QgRMjsvMvbjRHZ3NoKYT2BsfMcT-rr4uJe25YqBd/s200/piezo1.jpg" width="179" /></a></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">Air is a good absorber of high-frequency ultrasounds, and has been chosen as backing layer. The matching layer will be a sheet of urethane (40 A Durometer), available from </span><a href="http://www.polytechinnovations.com/SHEET.html"><span style="font-family: Arial, Helvetica, sans-serif;">this source</span></a><span style="font-family: Arial, Helvetica, sans-serif;">.<o:p></o:p></span></div><span style="font-family: Arial, Helvetica, sans-serif;"> <br />
</span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">The first step has been to characterize the piezoelectric element. Two wires have been soldered to the piezo’s silver platings.</span></div><span style="font-family: Calibri;"></span><br />
<br />
<span style="font-family: Calibri;"></span><br />
<span style="font-family: Calibri;"></span><br />
<span style="font-family: Calibri;"><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi46dbwZzGjl7HOI5XBTYyS9IQi4BBDR9AX6kQ-kfQCRkUiCLlA9D9oSWhdRGcgtjGhlxHX7_J1Ve9A7Wdlx0rZHcnu6VclQ44KXoJ3PQjuea5q6-xewPyxdE6XUVKmVtynVbkav0Hpde1z/s1600/piezo2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="169" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi46dbwZzGjl7HOI5XBTYyS9IQi4BBDR9AX6kQ-kfQCRkUiCLlA9D9oSWhdRGcgtjGhlxHX7_J1Ve9A7Wdlx0rZHcnu6VclQ44KXoJ3PQjuea5q6-xewPyxdE6XUVKmVtynVbkav0Hpde1z/s200/piezo2.jpg" width="200" /></a></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><span style="font-family: Times New Roman;"> </span><br />
<span style="font-family: Times New Roman;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> The following arrangement has been used to measure the resonance and antiresonance frequencies of the piezo disc. The frequency generator is first adjusted to give a maximum voltage across the resistor: this is the resonant frequency, where the piezo impedance is at its minimum. The frequency is then increased until a minimum voltage is measured: this is the antiresonance frequency, where the impedance is at its maximum.</span><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3s4wEvwL5UO3cQXvDgKBegO2ytyQIEmLMNY3Pfbcu_ASD_Tm6hxxEX2m-_psCyLIamz_QxNrFiBl961Z93rbv0Oz0CQjJqgDYzgvw__t4ix_JB_zF65iLEa8jGa6Mk4bWghiesWGyWlcW/s1600/piezo3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3s4wEvwL5UO3cQXvDgKBegO2ytyQIEmLMNY3Pfbcu_ASD_Tm6hxxEX2m-_psCyLIamz_QxNrFiBl961Z93rbv0Oz0CQjJqgDYzgvw__t4ix_JB_zF65iLEa8jGa6Mk4bWghiesWGyWlcW/s400/piezo3.jpg" width="400" /></a></div><span style="font-family: Times New Roman;"> </span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">The results of these measurements are as follows:<o:p></o:p></span></div><span style="font-family: Arial, Helvetica, sans-serif;"> <span style="mso-tab-count: 1;"> </span>Resonance frequency: <span style="mso-tab-count: 1;"> </span>2,932,000 Hz<o:p></o:p><br />
<span style="mso-tab-count: 1;"> </span>Antiresonance frequency: <span style="mso-tab-count: 1;"> </span>3,345,000 Hz<o:p></o:p><br />
<br />
</span><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">The resonance frequency is where the piezo element converts with the highest efficiency the electrical energy into mechanical energy. This will be the design frequency of the transducer. Note that these frequencies are for the unloaded piezo in free air. When the transducer will be completed, the resonance frequency will be measured again with the transducer in the water.</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">The powerful (and free) </span><a href="http://www.biosono.com/index.php"><span style="font-family: Arial, Helvetica, sans-serif;">BioSono KLM software</span></a><span style="font-family: Arial, Helvetica, sans-serif;"> has been used to model the transducer performance. From the physical description of the transducer components, this software will calculate a whole range of outputs, including the resonance and antiresonance frequencies and impedances.</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuF4sXQ856gApFwIBYvEUsAHRS5spzMIKp5uG7QkuJFtDoFtBluBBiU04qeF0AjiKlZIxKJ0PyWYkzP78i92cdrUO4uPtmV3sWTUS500xOAX8kOT9qR62Hfxk2_9ZPQTlK-__0nGe0ObeM/s1600/piezo4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="386" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuF4sXQ856gApFwIBYvEUsAHRS5spzMIKp5uG7QkuJFtDoFtBluBBiU04qeF0AjiKlZIxKJ0PyWYkzP78i92cdrUO4uPtmV3sWTUS500xOAX8kOT9qR62Hfxk2_9ZPQTlK-__0nGe0ObeM/s400/piezo4.jpg" width="400" /></a></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 12pt;"><o:p><span style="font-family: Times New Roman;"> </span></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">The model is in very good agreement with the measured frequencies, and calculates a resonance impedance of 0.37 ohm. This is in line with the piezo manufacturer figure of less than 1 ohm.<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><o:wrapblock><v:shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f"><span style="font-family: Arial, Helvetica, sans-serif;"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas> <v:path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f"> <o:lock aspectratio="t" v:ext="edit"> </o:lock></v:path></v:stroke></span></v:shapetype><v:shape id="Picture_x0020_1" o:spid="_x0000_s1026" style="height: 234.95pt; margin-left: 46pt; margin-top: 397.85pt; mso-height-percent: 0; mso-height-relative: margin; mso-position-horizontal-relative: margin; mso-position-horizontal: absolute; mso-position-vertical-relative: margin; mso-position-vertical: absolute; mso-width-percent: 0; mso-width-relative: margin; mso-wrap-distance-bottom: 0; mso-wrap-distance-left: 9pt; mso-wrap-distance-right: 9pt; mso-wrap-distance-top: 0; mso-wrap-style: square; position: absolute; visibility: visible; width: 321.7pt; z-index: 251641856;" type="#_x0000_t75"><span style="font-family: Arial, Helvetica, sans-serif;"> <v:imagedata o:title="" src="file:///C:\Users\Michel\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"> <w:wrap anchorx="margin" anchory="margin" type="topAndBottom"> </w:wrap></v:imagedata></span></v:shape></o:wrapblock><br />
<span style="font-family: Arial, Helvetica, sans-serif;">The design goal is to transmit a peak power of 12 W to the transducer. This means that during the pulses, a high-frequency AC current of 5.7 amperes will flow through the transducer. Usually, an impedance matching circuit would be placed inside the transducer housing so that the amplifier will see an impedance of 50 ohms with a reduced current ouput. The BioSono KLM software can be used to calculate the required impedance matching circuit.<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">However, for this project, the decision has been made to use a high-current Class-A amplifier with an output impedance matching the piezo’s impedance of 0.37 ohm.<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">There are 2 main advantages for this unusual design:<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">a) <span style="mso-spacerun: yes;"> </span>The ouput current to the piezo will be a pure sinewave instead of the typical square wave used in continuously transmitting ultrasonic applications;<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">b) The amplifier will use a standard marine power supply voltage of 12 V. <span style="mso-spacerun: yes;"> </span>With a higher impedance, a higher voltage power supply would be needed.<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Class-A amplifiers are well known for their high-fidelity but poor efficiency (as low as 15%). In this application, this efficiency penalty is not significant, because the length of the pulses will be very short. Even with an instantaneous transmitting power of 12 W, the average consumed power will much less than 1 watt.<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> <o:p></o:p></span></div><span style="font-family: Arial, Helvetica, sans-serif;"> <br />
</span><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><span style="font-family: Times New Roman;"> </span></span><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4237678261594285909.post-37072025091450635332011-11-19T21:48:00.001-05:002011-11-19T21:53:37.127-05:00Doppler profiler: design considerations<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">With a pulse-to-pulse coherent Doppler profiler, we can pick a specific remote region where we want the measurement to be made. Here we plan to measure the average speed of water in a sample volume of 1 cm long situated at 1 meter from the transducer.</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsnEpH5PZjhpNUaDUWWwXPXU4MgiZzCsmAHOVipGQ4m94QRdEZ_vUmwLoHdbHIypV4Q0mBmXMvYNjjQjQQGpHfhJOC7Wjt6yUt6maY-cpf02Noc5UlAe0I_L1F0pjqfHl3mXzYxwbOI6Bj/s1600/cone.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsnEpH5PZjhpNUaDUWWwXPXU4MgiZzCsmAHOVipGQ4m94QRdEZ_vUmwLoHdbHIypV4Q0mBmXMvYNjjQjQQGpHfhJOC7Wjt6yUt6maY-cpf02Noc5UlAe0I_L1F0pjqfHl3mXzYxwbOI6Bj/s320/cone.jpg" width="320" /></a></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"><o:p><span style="font-family: Times New Roman;"> </span></o:p></span></div><span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">With a speed of sound through water of 1500 m/s, the time to a first echo from the beginning of the sample volume is 1333.3 <span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">μ</span>s. The time to a first echo from the end of the sample is 1346.7 <span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">μs</span>. <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">To make a measurement, the 3 MHz transducer will send 2 pulses.<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">After sending the first pulse, the transducer will switch to receive mode and will sample the echo from exactly 1333.3 to 1346.7 <span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">μ</span>s after the beginning of the pulse. The microprocessor will digitize this echo with its internal 84 MHz ADC and store it in memory. Soon after, the transducer sends a 2<span style="font-size: small;"><sup>nd</sup> pulse and the process is repeated. <span style="mso-spacerun: yes;"> </span>The second echo is also digitized and stored. As the particles in the water have moved between the 2 samples, the echoes will be separated by a phase angle <span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">ϕ (the Doppler shift)</span>. <span style="mso-spacerun: yes;"> </span>From the stored data, the microprocessor will then calculate the Doppler shift (90 deg in the following figure). </span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXNNns0jVDR1EIzuJoWD6bMnC3376HdUaCWMA8mMvejqEX8wg43J7NVE9BO5_9jvYNsWDQsONNM9o56vrDs5YzH_bqXWqcJW-6Vx-UYuPv3aM2d9X7xiS_vswv8zNL5nKmNHWtk3qsWDds/s1600/shift.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="157" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXNNns0jVDR1EIzuJoWD6bMnC3376HdUaCWMA8mMvejqEX8wg43J7NVE9BO5_9jvYNsWDQsONNM9o56vrDs5YzH_bqXWqcJW-6Vx-UYuPv3aM2d9X7xiS_vswv8zNL5nKmNHWtk3qsWDds/s400/shift.jpg" width="400" /></a></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Times New Roman;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">The Doppler shift is related to the component of the speed of the water in the axis of the ultrasonic beam. But there is a problem: more than one velocity value will produce the same Doppler shift.</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Times New Roman;"> </span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeNhPru9HQxo_HbHrqvP8Ni4M7okf6JrUDvS-ZAssMLqVutP45-B5bAMorKaWbbFBRTZWHqO4_vg5dzLXNwozOKpU7zQL3bR3OcQdOBlPoxTXNyCxeob6gDCNhpUAoglDiqJBZEJjjvrNM/s1600/array.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeNhPru9HQxo_HbHrqvP8Ni4M7okf6JrUDvS-ZAssMLqVutP45-B5bAMorKaWbbFBRTZWHqO4_vg5dzLXNwozOKpU7zQL3bR3OcQdOBlPoxTXNyCxeob6gDCNhpUAoglDiqJBZEJjjvrNM/s320/array.jpg" width="320" /></a></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Times New Roman;"> </span></div><span style="font-family: Times New Roman;"><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">To pick the right one, we need an external information. In our case, we will calculate an estimate of the lateral speed from the </span><a href="http://sailboatinstruments.blogspot.com/2011/02/leeway-calibration.html"><span style="font-family: Arial, Helvetica, sans-serif;">boat's K constant</span></a><span style="font-family: Arial, Helvetica, sans-serif;"> and the current values of boat speed and heel angle. We will then pick the profiler's measurement that is the closest to this estimate.</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;"></span></div></span><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"></div></span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"></div>Unknownnoreply@blogger.com10tag:blogger.com,1999:blog-4237678261594285909.post-54898199941904440752011-11-12T13:58:00.000-05:002011-11-12T13:58:34.646-05:00A custom coherent Doppler profiler<span style="font-family: Arial, Helvetica, sans-serif;">Here is a preliminary diagram of the prototype profiler that I plan to build.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ6lQIKkzYcUnxfbFido_SWqEPr3gcCv4VJ0Hez1_qfHVasXOHXV-arP-WMVbUxrqHNUd4dXocDznVXKQEfQo0rBAC3Qy6JhzIkv_D68jwH7mBLVJ9XBUAJdCF5lbxYfKF6nMYU8-pWnAV/s1600/profiler.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ6lQIKkzYcUnxfbFido_SWqEPr3gcCv4VJ0Hez1_qfHVasXOHXV-arP-WMVbUxrqHNUd4dXocDznVXKQEfQo0rBAC3Qy6JhzIkv_D68jwH7mBLVJ9XBUAJdCF5lbxYfKF6nMYU8-pWnAV/s400/profiler.jpg" width="361" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><span style="font-family: Arial, Helvetica, sans-serif;">I intend to modify an existing depth transducer, replacing the piezo disc by a 3 MHz one. This may be the trickiest part.</span></div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><span style="font-family: Arial;">The frequency generator can be programmed to send either a constant frequency pulse or a variable frequency ('chirp') one. This may be useful later on.</span></div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><span style="font-family: Arial;">The STM32F4 board will control the frequency generator, and will receive and analyze the echo signals. The STM32F4 microprocessor has built-in DSP (digital signal processing) capabilities.</span></div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><span style="font-family: Arial;">The total hardware cost (with 2 transducers) should be less than 500 US$. Not too bad for near-America Cup performance, as this could develop in an open software project.</span></div><br />
<span style="font-family: inherit;"></span>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4237678261594285909.post-16404693660888097342011-11-11T11:04:00.005-05:002011-11-30T15:18:37.035-05:00Measuring lateral speed (leeway)<span style="font-family: Arial, Helvetica, sans-serif;">It is possible to measure directly the lateral speed through water of a sailboat making leeway, by using a pulse-to-pulse coherent Doppler profiler. This is the technique used by the <a href="http://www.nortek.no/en/news/new-navigation-capability-to-puma-ocean-racing-team">Volvo Ocean Race Puma</a> team. In their case, the transducers are installed under the bulb keel.<o:p></o:p></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">For a conventional sailboat, a different arrangement can be used.</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdTrwYuS8poQF_uAvmxrSjWU1CKnGanNkZZ9wwuth0L__hu1WRrRy9cQA2YLIXg9Q1WcTPFZNiR3RCxAmrp5rMEpqsf4Ej-llf_VuylC5klwcBKOMXPvplHS9zcXKbYaF-Lks-XTHDiQs8/s1600/rays.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdTrwYuS8poQF_uAvmxrSjWU1CKnGanNkZZ9wwuth0L__hu1WRrRy9cQA2YLIXg9Q1WcTPFZNiR3RCxAmrp5rMEpqsf4Ej-llf_VuylC5klwcBKOMXPvplHS9zcXKbYaF-Lks-XTHDiQs8/s320/rays.jpg" width="286" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="mso-fareast-language: EN-CA; mso-no-proof: yes;"><span style="font-family: Arial, Helvetica, sans-serif;">In the project that I am considering, 2 transducers will be able to measure the component of the speed of the water parallel to the axis of the ultrasonic beam at a distance of 30 cm from the hull.</span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="mso-fareast-language: EN-CA; mso-no-proof: yes;"><span style="font-family: Arial, Helvetica, sans-serif;">By knowing the installation and the heel angles, it is then possible to calculate the lateral speed of the boat.</span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhunOjVAx7rAJ-N1KZLN_Ftc27lz01ZLYqP41q31COBgwiUFY7OMZBxP6zFeZiHQ9wiPZG55y_fRjT3qCib_7ONJQsd54Xtr21GH7KJAopcQ13UrIqN0bDn7I-QrOBJXLXqZDrF4B_I_roO/s1600/diag_dop.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="201" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhunOjVAx7rAJ-N1KZLN_Ftc27lz01ZLYqP41q31COBgwiUFY7OMZBxP6zFeZiHQ9wiPZG55y_fRjT3qCib_7ONJQsd54Xtr21GH7KJAopcQ13UrIqN0bDn7I-QrOBJXLXqZDrF4B_I_roO/s400/diag_dop.jpg" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;"></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">A good introduction to the pulse-to-pulse coherent Doppler technique can be found in these documents:<o:p></o:p></span></div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">“Pure coherent Doppler systems – how far can we push it?”<span style="mso-spacerun: yes;"> </span>Lohrman and Nylund, 2008.<o:p></o:p></span></div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">“Performance of a Single-Beam Pulse-to-Pulse Coherent Doppler Profiler”<span style="mso-spacerun: yes;"> </span>Zedel, Hay, Cabrera and Lohrmann, 1996.<o:p></o:p></span></div><div class="separator" style="clear: both; text-align: left;"></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div>Unknownnoreply@blogger.com7tag:blogger.com,1999:blog-4237678261594285909.post-58834778199752980002011-11-09T16:44:00.001-05:002011-11-09T20:44:45.422-05:00A custom acoustic doppler velocimeter?<span style="font-family: Arial, Helvetica, sans-serif;">This recent</span><a href="http://www.sailinganarchy.com/article.php?get=8325"><span style="font-family: Arial, Helvetica, sans-serif;"> Sailing Anarchy entry</span></a><span style="font-family: Arial, Helvetica, sans-serif;"> about acoustic doppler velocimetry really got my attention, and I am thinking about developing a custom prototype.<o:p></o:p></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> My current understanding is that with this technology, you can measure the flow velocity at a certain distance of the transducer, beyond the near field described in this figure.<o:p></o:p></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAw5Bf2LvjfjI7W4h2S_Bi-y8vYQFxWRoMGHPYY7FVtM_S9RE-rzKk8gNdaa2vnvqLEGAisC4l3YZm7kgzSlajGrF037AK810iBOJUOZjuCDDLb_khyphenhyphenl50dMpwkYnanK6xN9aaXkOYZZP_/s1600/doppler.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="100" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAw5Bf2LvjfjI7W4h2S_Bi-y8vYQFxWRoMGHPYY7FVtM_S9RE-rzKk8gNdaa2vnvqLEGAisC4l3YZm7kgzSlajGrF037AK810iBOJUOZjuCDDLb_khyphenhyphenl50dMpwkYnanK6xN9aaXkOYZZP_/s400/doppler.jpg" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">Source : </span><a href="http://www.signal-processing.com/transducers/transducers_theory_frame.htm"><span style="font-family: Arial, Helvetica, sans-serif; font-size: x-small;">http://www.signal-processing.com/transducers/transducers_theory_frame.htm</span></a> </div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div align="left" class="separator" style="clear: both; text-align: center;"></div><span style="font-family: Arial, Helvetica, sans-serif;">The length Z of the near field depends on the diameter D of the emitter, and on the wavelength <span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">λ</span> of the signal. The wavelength <i style="mso-bidi-font-style: normal;"><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">λ</span></i> is related to the frequency <i style="mso-bidi-font-style: normal;">f</i> of the signal and on the speed of sound <i style="mso-bidi-font-style: normal;">c</i> in the water (around 1500 m/s).<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;"><o:p><span style="font-family: Calibri;"> </span></o:p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAbAY7vf_BovH4m6uFlAy0pdKmFmENwPtbJCSmtu7cVxLGIexIcRtMdysBhtPKUplWBtzy_4WTEEk0lGq6SXr7TbLkuydbOmzTbMPUFLovYiHwn87n172WWDoJ2EeFu3Sl__I1hduveORu/s1600/doppler1a.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAbAY7vf_BovH4m6uFlAy0pdKmFmENwPtbJCSmtu7cVxLGIexIcRtMdysBhtPKUplWBtzy_4WTEEk0lGq6SXr7TbLkuydbOmzTbMPUFLovYiHwn87n172WWDoJ2EeFu3Sl__I1hduveORu/s200/doppler1a.jpg" width="200" /></a></div><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">For example, a 25 mm emitter operating at 3 MHz would yield a near field of 0.31 m (12 in). This example is not totally arbitrary because, as an element of motivation, I have already ordered a pair of piezoelectric transducers with these exact characteristics from </span><a href="http://www.steminc.com/SAMPLES_USA.asp?PZ_TYPE=PIEZO%20DISC"><span style="font-family: Arial, Helvetica, sans-serif;">this source</span></a><span style="font-family: Arial, Helvetica, sans-serif;">.<o:p></o:p></span></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdRmFJyTgDMmZgpYnpAEmL5kS5YNO1qQv8WeLuP1dULfJe-AUDcsffY_66dySbzpWSKlC80bOZAVqufIBiV2GoIkl2BdOCU4_sV_QeGGLfUIU8peIVEejFzTbzpkI85pBmmRET4L5KvG77/s1600/doppler2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="253" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdRmFJyTgDMmZgpYnpAEmL5kS5YNO1qQv8WeLuP1dULfJe-AUDcsffY_66dySbzpWSKlC80bOZAVqufIBiV2GoIkl2BdOCU4_sV_QeGGLfUIU8peIVEejFzTbzpkI85pBmmRET4L5KvG77/s320/doppler2.jpg" width="320" /></a></div><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: Arial, Helvetica, sans-serif;">I will now try to identify what kind of electronics and software will be needed to eventually get a working unit.<o:p></o:p></span></div>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-4237678261594285909.post-23054168124946505762011-11-08T14:15:00.009-05:002012-01-22T12:23:05.640-05:00Damping AWA, TWA and heading values<span style="font-family: Arial, Helvetica, sans-serif;">Damping values is typically achieved by updating a running average of an appropriate number of past measurements. <span style="mso-spacerun: yes;"> </span>But calculating averages of AWA, TWA and heading values presents a problem. <o:p></o:p></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><span style="font-family: Arial, Helvetica, sans-serif;">AWA and TWA use values between -180 and +180 deg. The problem occurs when the values to average cross the +-180 line. <span style="mso-spacerun: yes;"> </span>For example the arithmetic average of -170 and + 160 deg is -5 deg instead of the correct average of +175 deg.<o:p></o:p></span></div><span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><span style="font-family: Arial, Helvetica, sans-serif;">Compass headings use values between 0 and 360 deg. Here the problem arises when the values to average cross the 0 deg line. For example, the arithmetic average of 350 and 20 deg gives 185 deg instead of the correct 5 deg.<o:p></o:p></span></div><span style="font-family: Arial, Helvetica, sans-serif;"> </span><br />
<div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><span style="font-family: Arial, Helvetica, sans-serif;">The solution developed here is to keep a double accounting of all the angles, one in the -180 to 180 range, the other in the 0 to 360 range. The average is calculated in both ranges, but only one is valid. The right value is identified and converted to original range if necessary.</span></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><o:p><span style="font-family: Arial, Helvetica, sans-serif;">Here is the algorithm used for averaging AWA (or TWA) values.</span></o:p></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><br />
</div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><o:p><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: #6aa84f;">// AWA values to average (-180 to 180)</span> </span></span></o:p><br />
<o:p><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">double awa[5] = {-170.0, -170.0, 175.0, 175.0, 175.0);</span></span></o:p></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><o:p><span style="font-family: "Courier New", Courier, monospace;"><span style="color: #38761d; font-size: x-small;">// alternate list (0 to 360)</span></span></o:p><br />
<o:p><span style="font-family: "Courier New", Courier, monospace;"><span style="color: black; font-size: x-small;">double awa_alt[5];</span></span></o:p></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><o:p><span style="font-family: "Courier New", Courier, monospace;"><span style="color: #6aa84f; font-size: x-small;">// build the alternate list (0 to 360)</span></span></o:p><br />
<o:p><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">for(i = 0; i < 5; i++)<br />
{<br />
if(awa[i] < 0.0)<br />
awa_alt[i] = awa[i] + 360.0;<br />
else awa_alt[i] = awa[i];<br />
}</span></o:p></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><o:p><span style="color: #6aa84f; font-family: "Courier New", Courier, monospace; font-size: x-small;">/*<br />
Alternate list: 190, 190, 175, 175, 175<br />
*/</span></o:p></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><o:p><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: #6aa84f;">// calculate the average of both lists</span> <br />
double awa_av = 0.0;<br />
double awa_alt_av = 0.0;<br />
for(i = 0; i < 5; i++)<br />
{<br />
awa_av += awa[i];<br />
awa_alt_av += awa_alt[i];<br />
}</span></span></o:p><br />
<o:p><span style="font-family: Courier New; font-size: x-small;">awa_av /= 5;</span></o:p><br />
<o:p><span style="font-family: Courier New; font-size: x-small;">awa_alt_av /= 5;</span></o:p></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><o:p><span style="color: #6aa84f; font-family: "Courier New", Courier, monospace; font-size: x-small;">/*<br />
awa_av = 37.0, awa_alt_av = 181.0<br />
*/</span></o:p></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><o:p><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: #6aa84f;">// find min and max of original list</span></span></span></o:p><br />
<o:p><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">double minang = 999.0;<br />
double maxang = -999.0;<br />
for(i = 0; i < 5; i++)<br />
{<br />
if(awa[i] < minang)<br />
minang = awa[i];<br />
if(awa[i] > maxang)<br />
maxang = awa[i];<br />
}</span></span></o:p></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><o:p><span style="color: #6aa84f; font-family: "Courier New", Courier, monospace; font-size: x-small;">/*<br />
minang = -170, maxang = 175<br />
*/</span></o:p></div><o:p><span style="font-size: x-small;"></span></o:p><br />
<div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">double minmax = minang * maxang;</span></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><span style="color: #6aa84f; font-family: "Courier New", Courier, monospace; font-size: x-small;">/*<br />
minmax = -29750<br />
*/</span></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: #6aa84f;">/*<br />
If minmax is positive, this means that the<br />
original values were either all positive or<br />
all negative, and the original average is<br />
valid. If minmax is negative, this means that<br />
the wind crossed the axis of the boat. If a front<br />
wind crossed the axis of the boat, the original<br />
average is valid. If a rear wind crossed the<br />
axis of the boat, then the alternate average<br />
(0 to 360) is valid, and must be converted back<br />
to -180 to 180.<br />
*/</span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">if(minmax < 0.0) <span style="color: #6aa84f;">// wind crossed axis of the boat</span><br />
{<br />
if(minang < -90.0) <span style="color: #6aa84f;">// rear wind, take 0-360 average</span><br />
{<br />
<span style="color: #6aa84f;">// convert to -180 to 180</span><br />
if(awa_alt_av > 180.0)<br />
awa_av = awa_alt_av - 360.0;<br />
else<br />
awa_av = awa_alt_av;<br />
}<br />
}</span></span></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><span style="color: #6aa84f; font-family: "Courier New", Courier, monospace; font-size: x-small;">/*<br />
At this point, the variable awa_av contains<br />
the correct average of -179.0 deg.<br />
*/</span></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><span style="font-size: x-small;"></span> </div><span style="font-size: x-small;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: small;">Some practical results using this algorithm can be seen <a href="http://sailboatinstruments.blogspot.com/2011/01/damping.html">here</a>.</span> <div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><br />
</div></span><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"></div><div class="MsoBodyText" style="margin: 0cm 0cm 6pt;"><br />
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-4237678261594285909.post-13352955256712694642011-11-01T13:34:00.002-04:002011-11-01T13:45:19.958-04:00Wind vane microcontroller code<span style="font-family: Arial, Helvetica, sans-serif;">Here is the code now used to calculate the measured apparent wind angle in this system.<o:p></o:p></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br />
</span><span style="font-family: Arial, Helvetica, sans-serif;">The analog-to-digital code makes use of the files ‘adc.h’ and ‘adc.c’ found in this </span><a href="http://www.bdmicro.com/code/gp2d12/"><span style="font-family: Arial, Helvetica, sans-serif;">BDMICRO sample code</span></a><span style="font-family: Arial, Helvetica, sans-serif;">. These 2 files shall be included in the project and be part of the compilation.</span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">//...</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">#include "adc.h"</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">//...</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">#define PI 3.14159265 <br />
#define DEG_TO_RAD ((double)(PI/180.0)) <br />
#define RAD_TO_DEG ((double) (180.0/PI)) </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">double awa_measured;</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">// Wind vane calibration data<br />
double wcx[2];<br />
double wcy[2];<br />
double xc;<br />
double yc;</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">uint16_t green, blue;</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">int main(void)<br />
{<br />
// ...<br />
<br />
xc = 741.2638;<br />
yc = 744.6921;<br />
wcx[0] = 1.002073;<br />
wcx[1] = -0.006924865;<br />
wcy[0] = -0.006924865;<br />
wcy[1] = 1.023132;<br />
<br />
/* initialize A/D Converter */<br />
adc_init();</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> for(;;)<br />
{<br />
// begin a new cycle</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> // ...<br />
<br />
green = adc_readn(0, 10); /* sample channel #0 10 times, take average */<br />
blue = adc_readn(1, 10); /* sample channel #1 10 times, take average */<br />
<br />
double dgreen = ((double)green) - xc;<br />
double dblue = ((double)blue) - yc;<br />
double xmap = wcx[0] * dgreen + wcx[1] * dblue;<br />
double ymap = wcy[0] * dgreen + wcy[1] * dblue;<br />
<br />
awa_measured = atan2(ymap, xmap) * RAD_TO_DEG; <br />
<br />
// ...</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> // Wait for timer signal to begin a new cycle</span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"> </span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"> // ...<br />
}<br />
}</span></span></div><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><o:p></o:p></span></span>Unknownnoreply@blogger.com4