Monday 23 January 2017

Define Success

A question posed by Katja Leyendecker (@KatsDekker) this morning:

Serious question.



...to which I replied "8-80".

This may seem like a slightly flippant response to the serious question, but it certainly wasn't intended as such. Follow up replies from Katja quickly clarified this was as much about measuring on-going success as much as outcomes. Hard to grasp and define...

And therein lies the problem. Each cycling advocacy group will have a different measure of success. For example, some of my local group are very proud of the number of children trained. This is a valid measure, but I haven't seen an increase in the number of bicycles chained up at school (anecdote klaxon).

Other than perhaps, cycle counts, we have no national standard that can be used by local advocacy groups to measure their success (or effectiveness of their campaigning) against an objective target.

The measure of the success of any campaign can only really be measured by its outcomes. Objectively measuring ongoing progress towards an outcome is a little more challenging. We have had decades of political 'encouraging' rather than 'enabling', so perhaps it's time to start measuring success by who has been enabled.

8-80 (#8to80) is not a new concept (e.g. this, from David Hembrow (@DavidHembrow) in 2011). It is clearly the standard to aspire to for all urban transport infrastructure but may also be a useful way of consistently measuring effectiveness of campaigning and the implemented schemes.

Towns and cities are ever evolving, but schools, shopping centres, stations and industrial areas tend to remain fairly static. Routes to and from these destinations are like the most trafficked. They are frequently surveyed by LAs for start/destination of motor traffic use, but rarely (I have never been questioned) when walking or cycling. We have some counts of existing cyclists, but have little data on those who are not using these routes.

How onerous would it be to annually count those who are not cycling these routes?

Getting data at the lower end of the 8-80 could be done via (PTAs at) schools - to parents: "Would you (do you) allow your eight-year-old child to cycle from [home|school|town]  to [school|town|home] unaccompanied by an adult".

Data for the upper end could be also gathered in this way ("Would you allow/encourage/discourage your childs grandparent to cycle from home to town?"), as well as for intermediate ages.

The collated data would give a consistent picture across the country. It will allow advocacy groups to compare apples with apples and provide on-going success markers.

TL;DR:
A year on year decrease in those not cycling at the two extremes of the 8-80 range is the surest measure of how successful the advocacy has been.

Of course all this may be already happening... but then why would Katja be asking the question?





Monday 16 January 2017

Nearmiss-o-meter Build Guide, Part 2

Build Guide, Part 2

This part of the build guide uses the switch PCB design available here on GitHub. As with the main board, it is possible to replicate the circuit design using a pegboard.

The Switch PCB
Clean Up the PCB

When the boards are manufactured, they often have small 'nibs' left on the edges (circled red). Carefully break these off with a small pair of pliers and use a file to remove the remnants. If you're using the 3D printed switch case, make sure all edges are cleaned up.

Click on the picture for an enlarged view.


Molex Connectors and Ribbon Cable
Solder Molex Connectors to Ribbon Cable 

If you've soldering the cable directly to the main board PCB, you can skip this step.

The Molex connectors are designed to be crimped, but the crimping tools are absurdly expensive, so a small dab of solder and manual crimping will have to suffice.

I've temporarily mounted the four individual connectors onto a spare PCB header which helps solder the ribbon cable a little more accurately. Make sure the 'barbs' (arrowed) are all facing up.

The red marking on the ribbon cable I've used denotes the switch wire. The opposite side ins the ground and the centre two are for the LEDs

UPDATE: Thanks to Paul for this crimping tool recommendation - much, much easier (and more secure) than soldering all for less than a tenth of the price (£23) of the official Molex ones.

Molex Plug

Insert Connectors into Molex Plug

Once soldered, crimp the connectors over the cable insulation and then push into the Molex plug casing, ensuring the barbs locate in the square holes (arrowed).


Switch on PCB

Solder the Momentary Switch to PCB

Straighten the switch legs and splay them out slightly. This will allow the switch body to sit directly onto the PCB.

Solder the legs from the back, ensuring the switch doesn't 'pop-up', then cut off any excess.




LEDs on PCB

Solder the LEDs to PCB

Mount the LEDs tight to the PCB. Note the positive tails (arrowed, slightly longer) and both to the inside.

Solder from the back and then cut off the tails.





Ribbon Cable, Switch End

Cut the Ribbon Cable


Cut the ribbon cable to the required length (this will depend where you mount the switch relative to the nearmiss-o-meter on the bike - I've cut to approximately 280mm long).

Leave the switch wire (red stripe on my build) about 10mm longer than the other three.

Solder the Ribbon Cable to Switch PCB

Tin the ends of the wires an push through the PCB from the top. Double check the routing from plug to PCB is as per the photograph, solder from the back and snip off any excess.

That's it!

Next up, the Arduino code and case fitting.

Friday 13 January 2017

Nearmiss-o-meter, Build Guide, Part 1

Build Guide, Part 1

This part of the build guide uses the PCB design available here on GitHub. It is possible to replicate the circuit design using a pegboard, but I wouldn't recommend it.

The list of parts I have used is available here.


Nib Removal

Clean Up the PCB

When the boards are manufactured, they often have small 'nibs' left on the edges (circled red). Carefully break these off with a small pair of pliers and use a file to remove the remnants.

Click on the picture for an enlarged view.


Sonar Bridging

Solder the Sonar Bridges

There are two bridging pads on the PCB to allow the use of the US-100 or the MaxSonar (not yet tested).

The photograph shows where I have bridged with a short length of wire for the US-100 sonar.





Cut the Header Pins
Female Header Pins Cut Into Groups

We are using round low profile header pins to install the Feather M0, partially because this is an expensive (and reusable) component, but also because we need to remove the Feather to solder other components onto the PCB.

Using a sharp knife, cut both male and female header pins into five pairs and three singles.



Male Header Pins Before Cutting
- Note Orientation

Solder Header Pins into the Feather M0

Note the male header pins have a top and a bottom. The flat face (shown in the top pair in the photograph) seats against the Feather.






Solder Headers Using
A Breadboard
Use a breadboard to hold the sockets and pins vertically as you solder the pins into the Feather.  Note: the photograph shows extra pins (9 and A0) on my board - these are just remnants of previous incarnations.

Solder pins to: BAT, EN, 11, 10, 6 , 5, 3V, GND, A2, A3, A5, RX and TX.





Solder from bottom of PCB

Solder the Header Sockets onto PCB

With the header sockets still attached to the Feather M0, solder them from the bottom of the PCB.

Once soldered, cut the pins back as tightly as possible, particularly the three nearest to the Sonar, the ones in front of the Molex and the one connected to the BAT pin. It may be better to cut these pins flush with the PCB before soldering -they must protrude no more than 0.5mm.

Header Pins for Feather
Note the Feather will be off centre - this is to allow the SD card to project into the case side wall.

Again, ignore the extra pins on my board!

The top of the PCB should now look like this.





Resistors R1 and R2

Solder LED and LDR Resistors/Jumpers

The LDR (R1) and the blue LED (R2) resistors are soldered onto the bottom of the PCB and the red (R3) and green (R4) resistors are soldered to the top.

I am using a 100KOhm resistor for the LDR and insulated jumpers wires for the LEDs as they are rated for 3.3volts.



Resistors R3 and R4
Make sure the tails of R3 and R4 are cut as flush as possible to the PCB so the Molex socket can sit flat. Once cut off, you can push them back with the soldering iron as there is plenty of space above - or as above, cut them flush before soldering.






Molex Socket and Switch

Solder Molex Socket and Toggle Switch

These are soldered onto the bottom of the PCB. Try to ensure they both sit as flat and square as possible.

Note: Both of these need to be tight to the PCB, but make sure there is plenty of clearance between the toggle switch and the 3V header pin before soldering.




Blue LED

Solder the Blue LED to PCB

This is the (optional) indicator of a near miss - also used to sanity check.

Bend the lens to 90°, ensuring the correct orientation of the positive and negative legs. The positive leg (on the right with the lens facing you) need to be covered with a short length of insulation.

Solder to the PCB and cut any excess short as usual.


GPS Module Headers

Solder GPS Headers

Use the breadboard to solder the headers to the GPS PCB with the uBlox module face down. These are standard square headers that are normally supplied with the GPS module.

Try to keep the PCB as square as possible.







GPS Antennae

Attach the GPS Antennae

A small piece of double sided sticky tape, or a very thin blob of bluetac will hold well enough.

Note the routing of the antennae wire.






GPS Soldered to PCB

Solder the GPS to PCB

Solder the PCB module onto the top of the PCB, again ensuring it is as straight as possible.

Cut the header pins as short as possible, either before or after soldering.




US-100 Sonar Position

Solder the US-100 Sonar to the PCB


The sonar mounts on the underside of the PCB. It should align evenly on each side of the PCB (it is slightly narrower).


Make sure the sonar PCB (green) is no more than ~0.5mm from the main PCB (purple).



Sonar Soldered from Top
Solder the pins shown in the top view here (only four of the five pins need to be soldered).

While soldering, make sure the sonar PCB remains perpendicular and parallel (~0.5mm) to the main PCB. Solder a pin at one end, check alignment, then solder the pin at the opposite end and re-check. Do not solder the remaining two pins until you are sure the alignment is spot on.



Battery Fly lead and LDR Position

Solder the LDR and Battery Fly Lead to PCB

If you have already printed a 'snorkel', use this to position the LDR facing the side of the snorkel, otherwise just leave a small gap between the LDR and the sonar. It is a little difficult to see, but the LDR is no the right hand corner of the PCB in the photo.

The battery fly leads only need to be ~25mm long. Once soldered in, use a hot glue gun (on the PCB/wire junction) to provide some support (not shown in photo).


The next post will detail the switch build.

Tuesday 10 January 2017

Nearmiss-o-meter, Bill of Materials

Bill of Materials (BoM)

Apologies for the delay since the last nearmiss-o-meter post. Sometimes life throws you higher priorities than the side project you happen to be working on...

These are the items I have used to build a near-miss-o-meter (version 04). Prices are approximate and primarily from UK suppliers. You may be able to buy cheaper directly from China/US.

I have not provided direct links for some suppliers (e.g. eBay) because the items seem to change so rapidly. If you search for the title or quoted description it should return the correct items. Where I've used 'standard' components, I've linked to the the appropriate manufacturer or supplier.

I've tried to brush up on my old photographic knowledge, so a click on the images should provide a higher resolution version.


Adafruit Feather M0

Adafruit Feather M0 Adalogger

This Arduino has an on-board Micro SD card plus Lipo battery charging. See Adafruit website for details. Make sure you are buying the M0, not the 32u4.

The Micro SD card is only used to store the configuration file and the near miss log files. The logs are in CSV format, generating less than 1kB of data per hour, so any standard capacity/speed card you happen to have lying around will likely be enough.

Cost: ~£21.00


uBlox Neo 6M Module

GPS Module uBlox Neo M6

The uBlox Neo 6M GPS module seems to give the right compromise of price, accuracy and reliability. Often listed as an 'Aircraft Flight Controller' for Arduino, there are a couple of different form factors - both work, but only the one with the loose antenna will fit the case properly.

Cost: ~£12.00

The Neo 7M has slightly better 'accuracy' (uses GLONASS) but is more expensive and will need a modified case because the antennae is thicker.





US-100 Serial Sonar

US-100 Ultrasonic Sonar

The US-100 does all the range timing 'on-board' and has temperature compensation too. More reliable, consistent & robust than the ultra-cheap (HC-SR04) sensors.

Cost: ~£7.00

An alternative is the MaxSonar (I have tested the MB1010 EZ1 at ~£20.00, but using outdoors voids the warranty. Weatherproof versions are ~£100). The PCB is designed (but not yet tested) to use either US-100 or MaxSonar via solder jumpers.



Round Pin PCB Headers

Low Profile Round Pin PCB Headers

These are fairly unusual (I could only find them in small quantities from Hong Kong), but allow the Feather board to be mounted 'upside down', making it a similar height to the GPS+antennae.

Usually described as 'Male Female Black 40 PCB Single Row Round Pin 2.54mm Pitch Spacing Header'...

You need both male and female.

Cost: ~£1.00.


Molex Connector

Molex Connectors and Terminals

This is a 4 way/pin right angled socket attached to the PCB and a plug attached to the ribbon cable.

Socket: 70553-0003

Plug: 50-57-9204

Crimp Terminals: 16-02-0086 

I chose these because they are the smallest form factor that still has a 2.54mm pin spacing. The specified plug is a friction type which will help protect the unit if the cable is snagged, but the socket will also take a latching type for extra security if desired.

These are sort of optional as you could solder the ribbon cable directly to the PCB.

Cost: ~£2.00 per set, but may need to order multiples.


Toggle Switch

PCB Toggle Switch SPDT

Used to disable the Adafruit Feather by grounding the ENable pin. This does not isolate the battery (so it can be charged).

This is from RS Components: 734-7220

Manufacturers Part Number: 2MS1T2B4M6QNS

If using the PCB, the pin arrangement needs to match (2.54mm spacing).

Cost: £1.00.


Momentary Switch

PCB Momentary Switch

Used to start/stop recording and for tagging. This is a cheap and dirty switch but we do some 'debouncing' in software to overcome its limitations.

If using the switch case, this will need to be the 1.5mm button version (the lowest available).

Cost: ~20p, but may need to order multiples.


Red, Green and Blue LEDs

3mm LEDs

Three 3mm LEDs are used: Red for GPS status, green for record status and (optionally) blue for near miss indication and sanity check.

I have used cheap 3.3 volt versions from eBay but the light output is not consistent across the colours. The PCB design includes provision for resistors, so a lower forward voltage can be used with the appropriate resistor in place.

If you're using 3.3v LEDs, then you'll need some short lengths of insulated wire to use as jumpers in place of the resistors.

The LEDs for the switch PCB need to have 2.54mm spacing on the legs, and if using the switch case sit no higher than 5.5mm when mounted on a PCB.

If using the blue LED, you'll also need a short piece of insulation (shrink wrap or pulled from a piece of wire) as the legs are quite close to metal parts of the sonar.

Cost: ~20p each, but may need to order multiples.


Light Dependent Resistor

LDR [optional]

An optional Light Dependent Resistor is used to dim the GPS and record LEDs according to ambient light level. You'll also need a resistor.

I implemented this because 'superbright' LEDs are needed for daylight but at night (or when testing) you'll end up with spots before your eyes...

I'm using a 100KΩ (Ohm) resistor with a 70-200KΩ LDR from Maplin.

Cost: ~£1.00


Resistors

You will need three resistors (or jumper wires) to match the red, green and blue LEDs and one for the LDR.

There are several online resources to calculate the resistors required for the LEDs. eg: LED Center or LED Calculator.


Evil Mad Scientist has a bit more in-depth information.

Cost: ~£1.00


Ribbon Cable

This is used to connect the remote switch. I have used ribbon cable but any four core cable will do. If you're planning to use the near-miss-o-meter case with the optional cover, then you'll need to use thin flat cable.

Cost: Free if stripped out of an old PC...


Oshpark PCBs (front and back)

PCBs (or Pegboard and Patience)

All of the components have been chosen for 2.54mm (0.10") spacing on the pins. This is, first and foremost, to allow easier soldering, but it also allows the same circuit to be implemented on both a PCB and a pegboard.

I really cannot recommend a pegboard. It's perfectly doable, but tedious and time consuming if your soldering skills are not ninja level.

Cost: The two PCBs (main board and switch board) are approximately £4.00 per pair (ordered in sets of 3 from Oshpark).

The Eagle .brd files are here on GitHub - just upload them to Oshpark or your favourite PCB manufacturer.


500mAh LiPo Battery

LiPo Battery 500mAh

If using the near-miss-o-meter case, this needs to be a 500 mAh measuring approximately 44mm x 25mm x 9mm.

Cost: ~£3.00 each (ordered as a set of 5 with a charging fly lead)

The Adafruit Feather M0 can also be powered from the USB port, but it would be a shame to not use the onboard charging...


Walkerman and JST Fly Leads

Battery Fly Lead

The battery connector on the Adafruit Feather is a 'standard' JST. Most easily available LiPo batteries have a different (Walkerman) connector. You have a number of options:

  1. Use a male Walkerman fly lead (on left in picture above). There are various vendors who sell 5 LiPo batteries with a charging fly lead... This is the route I took.
  2. Swap the female Walkerman connector for a JST connector and connect directly to the Faeather board. This was the first route I took, but BE WARNED! There is no standard for the positive and negative terminals. The leads I obtained (on the right) were opposite the the implementation by Adafruit (centre in photo), so I managed to fry my charging circuit. I notice Adafruit now have a warning notice on their site...
  3. Solder the battery leads directly to the PCB. Not my favourite option as I like the idea of being able to quickly isolate the battery should the need arise.


Case

I've created a case suitable for 3D printing. The parts are on github here. If you don't have a 3D printer (why not?), they can be printed via 3DHubs - just upload the files choose 'PLA' material and search for a suitable printer (often quite local).

You'll also need two 40mm M3 screws and nuts to hold the base and lid together.

The 'case04-cover.stl' is optional - intended to keep the SD card and USB slots clean and a little dryer if it rains (Although I have used this case in the rain, it is not waterproof in any way shape or form. Use at your own risk!)

Cost: ~£12.00


Handlebar Mount

The case has a GoPro mount on the top, so any mount should fit. Search for 'Camera Handlebar Seatpost Clamp Roll Bar Mount for GoPro Hero' and you should find one like this. Be warned: They are useless for cameras (too much wobble).

If you don't already own a GoPro, you'll also have to buy a 'GoPro long thumbscrew' separately to attach it to the mount.

Cost: ~£4.00

Next up: The Build

I have photographed the build and am currently writing it up...