Monday, October 5th, 2015 at 7:18 pm - - Kayak Dive

Not much bloggable recently. Some well-formed untested ideas on matters of servo motor control, and lots of bad psychology. Two discoveries of note that’ll take up a lot of time are jscut for CAM and chilipeppr for CNC downloads, both of which run in the browser. I have an interest in this approach, but now that I’ve found some people who are doing it effectively, it will save me a lot of time.

Meantime, here’s a couple of bad pictures from a cheeky kayak dive in the docks during Becka’s Thursday night canoe polo session (aka murderball).

Getting ready to go down:

One of the scary eels that made me shriek when it appeared in the dark.

Eels look and move a lot like snakes. We’ve got an instinctive fear when we encounter them in their own environment. It was interesting how they could swim backwards just as easily as forwards.

Wednesday, September 16th, 2015 at 7:40 pm - - Flightlogger

Following on from last week’s episode and the Emil’s sterling work reverse engineering the HC-SR04 echo location board, JD tapped in to a couple of pins on the surface mounted microcontroller so we could get the echo signal directly.


I’ll try to report this as straightforwardly as possible without too many diversions about how we worked it all out.

With two HC-SR04s facing one another, and as per the datasheet, the scope tracing is as follows:
Cyan is the trigger to device A, Magenta is the 40kHz 8-cycle wave generated by device A (delayed to allow the MAX232A chip to charge up), Yellow is its corresponding echo pin which is programmed to go high once the 8 cycle signal goes out, and Blue is the received signal in device B. [The corresponding wave generated by device B is received at the same time by device A which is programmed to take its the echo pin (yellow) low.]

Zoomed in on the initial cycle to see there are 8 and that their wavelength is four to a vertical division, or about 25microseconds each, corresponding to 40kHz. The transducers probably resonate at this frequency (to give a better energy to sound conversion) which is why so many more waves are received than sent out.

This is the received signal, overlaying the half-second of samples (about 10 because I’m repeating the loop with a delay of 50milliseconds) proving that it’s pretty stable.

By zooming in on a single wavelength and averaging over the previous 64 we can make it dance with the application of the fan

Device B (the receiver) is the one by the oscilloscope. By directing the fan along the sound vector we’re able to blow back the sound signal by approximately half a wavelength or about 12microseconds.

I’ve spent hours playing with this setup, but it’s only going to be any good if we can read the values using a microcontroller, like an Arduino.

Tuesday, September 8th, 2015 at 4:08 pm - - Flightlogger

The amazingly cheap HC-SR04 ultrasonic sensor works pretty well for what it does, which is measuring distances by echo location, but I wanted to use it for measuring air velocity as my mechanical anemometer is unreliable and of no use for getting the direction.

The sonic anemometer uses the theory that you can measure the time it takes for sound to travel through the air (about 2938.6microseconds to travel one metre) and the delay it would experience if the air was also traveling against the direction of the sound waves (about 8.6 additional microseconds for each metre per second in velocity). These values should be no problem for an Arduino running at 16MHz frequency to detect.

The basic interface code to run the HC-SR04 is as follows:

float speedofsoundmps = 340.29; // metres-per-second
digitalWrite(triggerpin, LOW);  
digitalWrite(triggerpin, HIGH);
digitalWrite(triggerpin, LOW);
long timemicros = pulseIn(echopin, HIGH);
System.out.print("Distance (cm) = ");
                       // factor 2 because distance
                       // is there and back

The basic code for pulseIn() counts processor cycles for the duration of the voltage being HIGH.

Here’s my experimental setup using two such devices, one sending and the other receiving (though you do need to trigger both in order to arm the receiver). Note the desktop fan to generate the wind.

And these are the experimental results plotted over five minutes, making a reading 20 times a second for ten minutes.
The average time of 1545.7microseconds equates to 52cms, which is an under-reading as the actual distance is 60cm, but we’ll ignore that for now.

If we turn the fan on we get an average reading of 1551.7micoseconds with a higher standard deviation of 13.4 (not surprising as the fan air is chopped and turbulent) which is an average difference of 6microseconds amounting to a wind speed of about 2 metres per second, agreeing approximately with the figure from my mechanical anemometer.

I’m not interested in tracking down the source of the error or calibrating this setup while the readings themselves are so darn noisy and in excess of the signal I am attempting to detect.

What is the source of the noise?

Monday, September 7th, 2015 at 10:55 am - - Kayak Dive

Home at last. Lots of stuff to do, so here’s just the bare facts of the trip to the north part of Ireland with our kayaks, as well as a 4-day booking with aquaholics where the weather blew northerly gales the whole time, which denied access to the famous north face of Rathlin Island and the basking sharks were a no-show.

Date Site Place type depth (m) time (mins)
2015-08-28 Mulroy Bay Downings Kayak 15 19
2015-08-28 Mulroy Bay Downings Kayak 17 35
2015-08-29 Melmore Head Downings Kayak 20 45
2015-08-30 Gloster Rock Malin Beg Kayak 20 12
2015-08-30 Shark Rock Malin Beg Kayak 20 30
2015-08-31 2nd Pinnacle Slieve League Kayak 18 12
2015-08-31 Big Cave Slieve League Kayak 9 15
2015-08-31 Carrigan Head Slieve League Kayak 20 23
2015-09-01 Portnagh Rock St Johns Point Shore 26 52
2015-09-01 Skuddagh Rock St Johns Point Shore 17 48
2015-09-02 Black rocks Rahlin Island Boat 31 36
2015-09-02 HMS Drake Rahlin Island Boat 18 46
2015-09-03 Black rocks Rahlin Island Boat 31 38
2015-09-03 Scallop bed Rahlin Island Boat 21 48
2015-09-04 SS Lough Garry Rahlin Island Boat 30 29
2015-09-04 Harbour wreck Ballycastle Boat 19 37
2015-09-05 SS Lough Garry Rahlin Island Boat 29 29
2015-09-05 Black rocks Rahlin Island Boat 29 36
2015-09-06 Lees Inner Wreck Strangford Lough Kayak 11 24
2015-09-06 Lees Outer Wreck Strangford Lough Kayak 12 29

Kayak diving wins again!

The most notable sighting of wildlife was this unexplained swimming snail above the kelp at the start of yet another black rocks dive (where we failed to find the right bit as usual).

Wednesday, September 2nd, 2015 at 9:17 pm - - Kayak Dive

The past five days have been kayak diving and camping in Donegal. Now we’re in Ballycastle for four more days of expensive boat diving where the weather has turned bad and probably won’t be so good underwater, but at least we’ve got a roof over our heads.

Camping in Ireland seems pretty easy. The two places we’ve stayed at had “day rooms” for people with tents where you can do your cooking, make toast, sit down and drink tea.

First two days were at Downings, diving in the almost totally enclosed Broadwater Bay at Massmount, and then at the totally exposed Melmore Head once we’d got our confidence back.

Then it was south to pitch tent at Derrylahan hostel before spending the day out at Malin Beg having to seal launch the kayaks off the slip at very low tide and poking our noses along the Slieve League cliffs for a couple of kilometres to check if paddling its full length was going to be a silly plan. The local fishermen thought it was an okay idea and said there weren’t any currents. With a northerly wind blowing we had perfect shelter.

Here’s a short video of a dive into a shoal of mackerel at the mouth of a huge cave. I noticed them only because they broke the surface as the streamed past my canoe and it looked like rain was falling onto the water even though the cavern ceiling was dry.

The next dive onwards was on the east side at exactly the tip of Carrigan Head, completely sheltered from the wind, waves and current by a 2 metre high headland of rock, but where the sounder registered a sudden dropoff to 20metres. The place was scoured of kelp revealing a low animal turf and dozens of large wrasse fish parked in the slot doing nothing in particular. As usual, Becka did the cycle back along the road to fetch the car while I packed the gear and walked up the road to the hostel to have a cup of tea.

On our fifth day in Ireland we got air fills at Dive Donegal before using it all up on two long short dives from St Johns Point. If anyone is counting, the one on the left out from Portnagh Rock should be in the top ten shore dives of the world for its perfectly designed architecture of satisfaction. You use up your air at the perfect rate at the perfect depth and everything is easy to find. The karst rock of the main reef has eroded into shelves that are like a condominium hotel for critters (one alcove contained a fat lobster chewing on the hide of a dead dogfish). It’s worth the drive, even if we couldn’t find a decent breakfast anywhere nearby to fill us up in the morning.

All this kayaking is exhausting and makes me not interested in spending many hours at the computer. I’ve got all winter to do this when I get home and settled down.

Wednesday, August 26th, 2015 at 1:24 pm - - Whipping 1 Comment »

If voting changed anything, they’d make it illegal — Emma Goldman.

So, if you want people to vote, they have to believe that it can change something.

The Labour Party is undergoing a sudden and spectacular revolution with hundreds of thousands of people signing up on the belief their vote will make a difference when they elect Jeremy Corbyn. No one saw this coming.

Just one month ago the former leader Tony Blair said that anyone who supported Corbyn should get a heart transplant.

Funnily enough, Blair only became party leader (and, by default, Prime Minister) because John Smith had a heart attack and died. Blair was then stupid enough to believe that he was there because of his awesomely crappy policies that caused so many people to quit the Labour Party he had to fund his 2005 election by selling seats in the House of Lords.

Voting in Scotland in a referendum was going to make a difference, and the turn-out there was massive.

But in the wider country there continues to be a problem with General Election where necessary change is not coming about and people are getting screwed.

Young people don’t vote because they know it doesn’t make a difference. The system is too skewed. The old people in the rural constituencies reliably root for the Tories and provide their base. The Tories return the favour by redistributing the wealth from the youth to their elders on a massive scale through rising house prices, tuition fees (after this older generation got educated for free), historically low wages, a rising retirement age, a declining pension (which doesn’t effect the current generation of pensioners), expensive public transport while car driving becomes cheaper, cuts in inheritance tax (how old are the “kids” when they actually get the money?), and huge bank bailouts to protect the savings of those with hundreds of thousands of pounds on deposit.

Wednesday, August 19th, 2015 at 6:44 pm - - Machining

The limitations of the scipy.optimize.minimize() function has now become apparent. They should have called it localminimize() starting from an “initial guess”.

This follows on from the mess I made out of using this same function to calculate the circumcircle of a triangle.

Here I begin with a STL file of a widget which was then probed from 20 random directions to a distance (ball radius) of 5mm.


This was done using a my barmesh library that I ought to start getting back into as I haven’t touched it since I got distracted by all this arduino electronics.

The barmesh code itself is impenetrable when I looked at it recently, but use of its features is still possible.

Thursday, August 13th, 2015 at 5:27 pm - - Flightlogger

I’ve got a Global Top Inc FGPMMOPA6H GPS module (datasheet) in my hang-glider data logging device. Using the command packet:


I’ve programmed it to give me a GPRMC every 50 cycles, a GPVTG every cycle, GPGGA every cycle and a GPGSA every 10 cycles.

The command $PMTK220, 200 is used to set the length of the cycle at 200ms, so I’m getting a positional and velocity reading 5 times a second.

The code for controlling all this is here. Note that my code does not contain hundreds of lines of #defines of the form:


that you tend to get in other people’s programs for the purpose of referencing the this-will-never-change-hardware-encoded 3-digit string ‘314’ by the arguably more readable (ie I will argue with you) string ‘PMTK_API_SET_NMEA_OUTPUT’ that serves no purpose, isn’t interpreted by anything except the preprocessor, and you have to look it up to get back to the number that is actually documented in the manual. Why is this controversial? </rant>

Monday, August 10th, 2015 at 5:24 pm - - Machining

I failed to take a photo of the experimental set-up which the guy on the Newcastle stand at Manchester Makefest let me shove my airspeed probe into. The airspeed probe is described here and some interrupt timing misery to do with it (which I don’t know was properly solved) is reported here.

This is the track of the windspeed when it’s in the device, and then when we put a card across the air intake that roughly halved the flow.
The time interval is 5 seconds for every green vertical line.

The readings where it is flat and high (off the left of the diagram) have an average of 7.11m/s, standard deviation 0.11 over 60 seconds. The middle low section has average 3.26, sd=0.05 over 35 seconds. The final high value when I took the card off the intake was 6.99m/s, sd=0.077 over 45 seconds.

The tailing off of the wind speed measurements is probably an important factor.
Squashing the graph down the Y-axis and plotting the green lines at one second intervals, we can compare the two incidences where I put a card over the intake and halved the wind flow.

It takes about one second to settle, and the two curves don’t match up.

I can’t tell if this is due to the inertia in the propeller sensor, or inertia in the wind tunnel device when I cover it up making it sound like a blocked vacuum cleaner.

At least half is due to the latter, or the curves would be a better match because they’re smooth enough and the propeller inertia doesn’t change.

We’d need another way to more quickly vary the intake into the wind sensor. For example, we could rotate it slightly so that it picks up less wind. The engineer suggested introducing some controlled friction into the system to dampen the spinning so it responded faster. Alternatively there’s a pitot tube.

Of more immediate concern is the unexplained wandering around of the wind speed sensor by as much as 6% across multiple seconds of time. This can’t be turbulence in the device as it wouldn’t have such lasting effects.

Also, there are short bursts of zig-zagging every half second indicated by the red marks.

I’ve seen these zigzag effects before with the temperature measurements, probably caused by the interference with other devices on the same microcontroller, going into and out of phase with their interrupt cycles.

I don’t know of a mechanism for voltage changes to affect the rotating fan blades (like they did the thermistors), although something could be introducing small delays into the detection of the interrupt signals.

This would take a lot more building of separate interrupt-driven dedicated microcontroller circuits to test the theory. And then that doesn’t answer the 6% wandering.

I got to get back to other parts of the project, and look at this later when I have use for these measurements as well as a test rig.

Maybe there’s other technology, such as a thermal anemometer or a beautiful sonic anemometer that measures windspeed and direction instantaneously for a mere $2700. I haven’t got that kind of money to squander at the moment, but it does show what’s available.

OMG, what’s this publication I’ve just uncovered:

Sonic anemometer and atmospheric flows over complex terrain: measurements of complex flows

Three measurement campaigns and the use of sonic anemometry under specific conditions are described in this work. EBEX2000 was an international energy balance field experiment in San Joaquin Valley USA, were different sonic anemometer types, and heat and momentum flux measurements, were analyzed and compared. The second case was a complex coastal flow at Madeira Island, Portugal. The complexity of the flow compromised the performance of an existing wind farm. The use of post-processing techniques, such as Fourier and wavelet spectral analysis allowed the detection, and unveiled, the existence of coherent structures and other specific features of that wind turbine site. The flow over the mountainous terrain of Madeira Island is also presented for the latter case, where sonic anemometer measurements were executed at wind energy resource assessment phase.

I found some excerpts of the book where they are discussing the instruments. Taking some liberties with the text, there is:

As discussed in chapter 3 the sonic anemometer measurements have to be corrected due to transducer shadow effect and overestimation of measurement due to flow acceleration through the transducer array…

The cup anemometer systematically overestimates the mean wind velocity compared against the sonic… Wyngaard (1981) showed that cup anemometers respond faster to wind speed increases (u > 0) than wind speed decreases causing the anemometer to overspeed.

My anemometer is a propeller, which requires it to be pointed in exactly the right direction. This is not going to help when there is yawing of the glider of up to 80 degrees.

The interesting thing about atmospheric flows over complex terrain is that good glider pilots have the experience to guess the locations of up-currents by visual inspection and from what they know of the wind direction.

In the future the swarms of cooperating autonomous cargo gliders which connect the world together using zero energy (unlike the plans for drones) will be able to not only rely on thermal updrafts, but could also use dynamic lift by reference to weather stations dotted at critical places around the landscape to inform the flow model accurately enough to fly downwind with exactly the right height to clear the next tree line.

I’ve got to climb out of this rabbit hole now before it sucks me in for the rest of the week.

Monday, August 10th, 2015 at 3:14 pm - - Kayak Dive

What do you do with someone who broke their elbow six weeks ago?

Take them on a long 7 hour canoing trip up the Conwy river from the coast at Deganwy to the new inland surf station at the historic village of Dolgarrog, of course.


Due to the lack of a waterproof camera, I don’t have any photos of our journey and of the many hours upwind paddling through miles of waving reed meadows and into the small dry creek leading to the hydro power station.

We parked on a bank full of thistles and waded through stagnant pools and along rocky river beds before we reached a road bridge where we could climb up and over the fence.

Down that road was the surf pond, already packed out on its 6th day of operation. We had our picnic on a bench watching the surfers, noted that it was already half past six, and then rushed back to the boats before we got benighted.

In the meantime the hydro power gates had opened, causing a slightly worrying river crossing. The tide had also risen another metre (more than an hour after Conwy high tide at 5pm) nearly washing our boats away.

More engineering

Last Thursday I made a trip to the Advanced Manufacturing Research Centre in Sheffield. It’s a bit of a massive establishment with a lot of machine tools, so they ought to have people making special CNC toolpaths for them. On the other hand, I don’t think the development of yet more passenger aircraft technology is necessarily a good investment of engineering resources, given that the industry needs to shrink by 10% per year from now on as part of any strategy for us to survive on this planet with our species and civilization intact.

I decided I need some mechanical engineers to put to work on the triangular machine tool, and formed a theory that there were not enough of them around because they’d all got a proper formal education which put them on the conveyor belt into corporate employment where they were no longer an accessible resource. On the other hand, software engineers are often self-taught and therefore don’t begin their careers with much faith in the system, and so tended to be easier to entice into random start-ups that don’t have any rich person’s backing.

Then I spent most of my Sunday in Manchester at the MakeFest in MOSI not helping on the DoESLiverpool stand at all. But I did find plenty of mechanical engineers who immediately contradicted my theories.

One of them had made a tiny wind tunnel model into which he let me insert my hang-glider wind meter for testing, which I’ll talk about in the next post rather than confuse everyone by putting at the bottom of this page here.