Software Paradim Shifts

The following is a list of concepts and technologies I consider to be the most important in computing in recent years. It is not meant to be a historic list. I will add items as they I become aware of them.

Note to self: This should not be a list of technologies like go and angular. Languages & frameworks come and go, what is important is the concepts they embody.

  1. Restful APIs – HATEOAS
  2. Service-oriented Architecture & Eating your own dog food
  3. Design as a real object – This if executed correctly

Raspbery Pi 8 Module Relay Build

This post shows my efforts to package up an 8 port relay module with a raspberry Pi. I did this for use with my home automation heating project. But it could be used to control any number of other things. I post it up here in the hope that someone else will find it useful.

Components List

The following is a list of things I get to build my system:

Raspberry Pi Model-B + Wifi Dongle

I attach the wifi dongle into the pi. Easy.

Raspbery to 8 Module Relay

5V 8 Module Relay

5V 8 Module Relay

The first thing to get wired up and working is the 8 module relay block using the Jumper Cables in the wiring configuration seen below. There is a nice post describing how to wire up these relays with a wiring diagram. I do not bother with the transistor board, instead deciding to do the default state in software. I go with the following pin mapping:

Relay Pi
GND GRD
1 GPIO 2
2 GPIO 3
3 GPIO 4
4 GPIO 7
5 GPIO 8
6 GPIO 9
7 GPIO 10
8/td> GPIO 11
VCC +5V

The relays on the board are Songle SDRs. They have the following behaviour: (See wiring diagram above for letter pin mapping.)

No power to relay control
Power to relay
Power to relay and pi

C ----o
     /
B----

A-----o

Power to relay WebIOPi started pin OUT LOW


C ----o
     
B----
     \
A-----o

Indicator LED on relay board lights up.

Power to relay WebIOPi started pin OUT HIGH

C ----o
     /
B----

A-----o

Below is a picture of the pi wired to the relay module.

pi-8ModuleRelay

Pi wired to 8 Module Relay

5V 1A Power Supply

To power the pi and control board I will use a standard pi power block. I want to use the mains voltage that powers the timer units in the same way to power the pi. To save space I saw open the plug to get the circuit board out.

powerBlockDisassembly

Power Adaptor Breakdown

Here are some images of the circuit board, I have wired it up ready to go in the project box.

Transformer Circuit

Transformer Close up

I have cut down the 5V wire as it was longer than I needed. I have chosen to use the micro USB connector rather than wire straight into the Pi as i means i get the fuse protection and makes future disassembly easier.

transformer CircuitWithWires

Transformer with wiring

Gift Wrapping

To package everything up I use a 114.5mm × 184.5mm × 62.5mm kit box. I start by drilling holes for the three wires (that I need it for in my current project) . I space the holes equidistant so that if later I want to re purpose the box for something else I can drill another 5 holes to maximise the 8 relay modules. I attach rubber grommets so the wires will sit snugly. To do this I have to chisel away part of the groves around the hole.

Plastic Box PX-4 Grey 114.5×184.5×62.5mm

Plastic Box PX-4 Grey 114.5×184.5×62.5mm

This Process can be repeated until there are 8 holes, one for each relay switch.

Box inside with plug holes - Note: chiseled groves.

Box inside with plug holes – Note: chiseled groves.


Box with plug holes

Box outside with plug holes

The box has groves down the side that fit the relay module block quite neatly. I now need to fit all the other components. To begin with i epoxy some lego bace blocks onto various areas of the box, when I do this I am careful to make sure that the various separate sections fit the lego block patten so that lego from one area can clip together with Lego from other sections. I lay a base for the area where the transformer circuit will go and another to raise the pi above the floor (where the wires will go).

Box with Lego base glued in

Box with Lego base glued in

Now that the base is in it’s time to build the transformer enclosure. I use blocks with holes in to allow access for the 230v and 5v wires.

Transformer enclosure.

Transformer enclosure.

When building the enclosure I include bracket bits to hold the right side of the relay board.

Transformer enclosure. Note: The mounts for the relay board.

Transformer enclosure. Note: The mounts for the relay board.

The relay board now fits snugly into a grove on the left side of the box and the bracket mounts on the transformer enclosure.

Transformer enclosure sealed and relay board mounted,

Transformer enclosure sealed and relay board mounted,

Close up on the bottom of the relay block. The heating control wires will connect here. You can also see the Lego arch mounts for the platform where the pi will be mounted. This gives good space to run the wires under.

Base of Relay board where control wires will connect.

Base of Relay board where control wires will connect.

The Pi mount. This will sit on top of the arches and the pi will fit inside this.

Lego Mount for Pi.

Lego Mount for Pi.

The Pi mount installed in the box.

Pi mount assembled in the box leaving space for wires underneath.

Pi mount assembled in the box leaving space for wires underneath.

All the components are now installed in the box and it all fits nicely. No the only thing left to do is to take it apart again and fit the wires.

Fully assembled box minus control wiring.

Fully assembled box minus control wiring.


The lid fits onto the box to finally seal everything away. I notice that it doesn’t sit totally flush and have to make a last min modification of cutting a little divot on the right hand side to fit the rip over the top edge of the relay control board.

Box lid. Note the small divot I take out of the flange at one edge to allow the relay board to fit flush.

Box lid. Note the small divot I take out of the flange at one edge to allow the relay board to fit flush.

And there you have it, a fairly simple boxed up raspberry pi with relay module and power source. As the wiring I use (Flex Round 3 Core) has three cables in each and I only need two for each relay on the current project I can re-puposed two of the spare wires to provide Live and Neutral for the power block. If this doesn’t float your board you could cut one further hole for these wire.

Example Use


The box in situ. Three wires come in from each of the devices the box is controlling. As these cables carry three wires; Live, Neutral and Earth and I only need two from each to complete the circuit I decide to use one of them to bring the neutral line to power the pi (the live comes of one of the control circuits). I terminate the other redundant two in a bit of spare cabling sheath. To stop the wires from being ripped out I attach some zip ties to the wires at the point just before they leave the box, I tighten them with pliers to make sure they dig in. Safety first.

Box wired Up with Earth wire carrying neutral to the power circuit and other Earth wires terminated. Wires secured from tugging with zip ties.

Box wired Up with Earth wire carrying neutral to the power circuit and other Earth wires terminated. Wires secured from tugging with zip ties.

Everything is resembled again in situ.

Fully assembled box in place.

Fully assembled box in place.

Software

Now we have all the hardware done it’s time to get the software up and running to control this thing. I choseWebIOPi as it gives you a pretty complete stack right up to a web server with pin layout. Instructions are all there on setting it up and getting it running. Enjoy.

Worthwhile

Here is a collection of content i hold in high regard:

TED

Great videos on all sorts of topics from Architecture to Religion.

Hacker News

Good tech news and general programming related topics.

Adam Curtis

Pretty much any Documentary he has made as well as his blog for interesting insights into geopolitics and general socio political behaviour.

Hans Rosling

An insightfull view of the world using statistics through the Gap Minder software. Often reporting on good things going on in the world with the odd amusing quip thrown in.

Doubling time and the rule of 70

Lecture on what exponential growth really means to you. The answer to this question is incredible important in a way you will not comprehend until you watch this video. It also teaches you what compound growth is, this is important for anyone who has a bank account.

Multivax and the The Last Question

A short story by Isaac Asimov on the future. Shows that entropy is kind of scary.

Typeography

Practial Typography

Helvetica

A documentary about typography and graphic design in the last century. It stars some very interesting and enjoyable characters, talking passionately about a subject you engage in everyday but probably think little about.

Photography – Cambridge in Colour

If you read all the tutorials and articles on this site you have pretty much undertaken a basic to mid level digital photography course without paying anything.

Photo Editing – dpBestflow

If you are into photography you should know all your tools, this extends to more than just your camera. You should know the content of these links and how they apply to making your pictures pretty.

Books

Interesting books. No particular order.

Stalingrad
ISBN: 0141032405
War is not fun.
Zen and The Art of Motor Cycle Maintenance
ISBN: 0061673730
The Curious Incident of the Dog in the Night-Time
ISBN: 0099450259
The Hitch Hiker’s Guide to the Galaxy
ISBN: 0434003484
Brave New World
ISBN: 0099518473
Eats, Shoots and Leaves
ISBN: 0007329067

Erowid

If someone supposedly tells you what a drug is like and this website doesn’t have a similar story they are probably lying. This place has more interesting stories about drugs than the 60s rolled into one.

Music

  • cmd.fm Command Line tool for internet radio

Open Catalogue Protocol (OCP / OCF)

I Have recently been trying to find a way of standardising the on-line catalogue we use at work. Something to do with the same data being entered into multiple databases, lots of manual data entry you get the picture.

I have been a bit disappointed to discover that there is very little in the way of a standard format for exchanging catalogue information. I can understand why Online Shopping Cart projects have been slow to implement this “we don’t want them running away from our system” but i would have thought there might have least been a push from some of the more confident open source movements.
Please correct me if I’m wrong here i haven’t looked at them all

After digging around a bit i did find that someone has created a format called the Open Catalogue Protocol or Format but unfortunately whoever implemented doesn’t seem to be around any more. (http://www.martsoft.com/ocp/)

If anyone knows where i could find a DTD for this please let me know.

This is the only example i could find of its implementation:


From:  http://www.martsoft.com/docs/hierarchy.txt
Date:  1999-05-05

<?xml version="1.0" standalone="yes"?>

<!--
  Catalog hierarchy file:
    this file only contains a hierarchy of categories, no products;
    the catalog engine caches it in memory
-->

<catalog>

  <category name="Computer Product">

    <param name="NumberOfProduct" value="23"/>

    <attr name="Part ID" value=""/>
    <attr name="Vendor" value=""/>
    <attr name="Description" value=""/>
    <attr name="Cost" valuetype="float" value="" unit="dollar"/>

    <category name="Computer Hardware">
      <link name="" valuetype="Alternative"
         value="OCP://www.martsoft.com/UPYP/Computer Related/Computer/HW/"/>
    </category>

    <category name="Computer Software">
      <attr name="title" value="Software xxx"/>
      <attr name="Platform" value=""/>
      <attr name="Version" value=""/>

      <link name="" valuetype="CrossSell" value="OCP://www.xyz.com/sw/"/>

      <product name="11000078">
        <link name="" valuetype="PartOf" value="Computer Product/Computer Software/11000079"> 
        <attr name="Part ID" value="33444IET">
        <attr name="Vendor" value="Microsoft">
        <attr name="title" value="Microsoft Word"/>
        <attr name="Cost" valuetype="float" value="29.99" unit="dollar"/>
        <attr name="Platform" value="Microsoft Windows 98"/>
        <attr name="Version" value="7.0"/>
        <attr name="Description" value="Word Editor"/>
          <value>
            <val>Inline pictures</val>
            <val>HTML ready</val>
          </value>
        </attr>
      </product> 

      <product name="11000079">
        <link name="" valuetype="HasPart" value="Computer Product/Computer Software/11000078">
        <attr name="Part ID" value="33444FFY">
        <attr name="Vendor" value="Microsoft">
        <attr name="title" value="Microsoft Office 98"/>
        <attr name="Cost" valuetype="float" value="399.99" unit="dollar"/>
        <attr name="Platform" value="Microsoft Windows 98"/>
        <attr name="Version" value="7.0"/>
        <attr name="Description" value="Office product suite"/>
      </product>

    </category>

  </category>

  <category name="Real Estate">
  </category>

</catalog>

Just Another