Author: Brian J Hoskins

Brian Hoskins is a 35 year old Electronic Engineer from South Wales in the United Kingdom. He is passionate about Electronics Design, Computing, Programming and Science in general. He works as a Test Development Engineer at an automotive electronics company in South Wales and also carries out electronics design work on personal projects in his spare time. Brian has a BSc with honours in electronics engineering and is a member of the Institution of Engineering & Technology.

123-reg

For almost 15 years I have used 123-reg to host my website. I started off with a simple static html website which I hand-coded in 2004. Then I moved to a wordpress website with a 123-reg virtual server. After that I moved to a 123-reg dedicated server, and this is the solution that I settled on for about 5 years.

I have previously been satisfied with the support and service of 123-reg, and would have recommended them, but lately I have unfortunately had cause for complaint in multiple areas and despite my best efforts I was unable to come to a satisfactory resolution with their support team.

Server Move

For this reason I have taken the brave decision to run my own server at home, and host my simple website from there.

I have purchased a HP proliant server and over the past few weeks I’ve been learning a lot about how to set it up.
I have transferred brianhoskins.uk to this new server. It’s currently working, but there are significant teething troubles.

Outdated theme

I am using a custom child-theme which I wrote myself. The parent is the standard wordpress twentyten theme, so that should give you some idea about how old it is!
I have noticed that recent wordpress updates have started to break functionality in my old child-theme, so it’s time to reinvent it.

It will take me a while to write a new theme. In the meantime the site still has all my old posts but the rendering is somewhat unsatisfactory!
I could use a pre-written theme, and perhaps I’ll look into that, but based on previous experience I don’t feel confident that I’ll find something that does exactly what I’d like. So I think I’ll end up doing another custom child-theme.

On the upside, the effort should generate fodder for new posts. I have been meaning to sharpen my php, anyway.

Happy programming!

** Update 2018-06-24 **

My dated custom child-theme, based off wordpress twenty-ten, was performing so poorly that I felt I should simply switch to a default wordpress theme immediately and worry about putting my own modifications to it as a new child-theme later on. So now I am running on the twenty-seventeen theme.

Introduction

At home I am on LINUX pretty much full-time. I only run Windows inside a VM in some special circumstances. But at work I have to use Windows due to corporate policy, so I regularly face the challenge of finding cross-platform software which I can use both at home and at work.

One of the things I had to change when I switched from Windows at home was my text editor, because the previous editor I used was a Windows only application.

I decided that I would take the opportunity to go the whole-hog and learn a “proper” comprehensive text editor. But this would involve a significant and ongoing investment of my time, so I wanted an editor that I could learn once and then use it everywhere.

I chose emacs.

Since then I have discovered org-mode (a major-mode for emacs which supports task management) and I have developed a detailed configuration which enables me to plan my work, clock time spent on tasks, develop projects, take notes, produce reports, etc.

Of course, I needed a setup which would allow me to work cross-platform, so that my text editing and org-mode task management would be seamless no matter if I worked at the office on Windows or at home on LINUX. The need for a cross-platform installation and configuration was born.

In this blog I will explain my method for installing emacs on Windows. Some of the decisions I make are related to my desire for cross-platform use, and these will be discussed. But this blog works fine standalone, so even if all you’re interested in is using emacs on Windows, and you have no interest in sharing a configuration with LINUX, these instructions will still produce a working emacs installation on Windows for you.

I also discuss installation of org-mode and associated cross-platform use.

Pre-Requisites

EMACS ON LINUX

If you’re following this blog with the aim of cross-platform use, then you must already have a working installation on LINUX since I will not discuss the details of that here. Your config file on LINUX must be available at ~/.emacs because that is the setup I am going to replicate on Windows.

GIT

I will discuss an org-mode installation that makes use of git. If you don’t care to use org-mode and are only interested in emacs then this pre-requisite is not required and you can ignore it. Otherwise, if you want to replicate my cross-platform setup with org-mode, you’ll need git.
I don’t explain how to install git on Windows, so if you’re unsure about that you will need to find some tutorials elsewhere and come back here once you’ve got git installed. But here’s a hint: you need to visit the git web page, and install git for Windows. If you prefer a GUI client I recommend tortoise git, you will need to install this separately.

INSTALLING EMACS

Cygwin

The first task is to install Cygwin. Cygwin is a repository of GNU tools for Microsoft Windows. This will allow you to install emacs on Windows and maintain an environment and file structure that is similar to that on LINUX. This is essential to satisfy the cross-platform objective of the configuration.

Advance the installer, and when asked to choose a download source, select “Install from internet”.

Next you will be asked to choose an install directory. This will form the root of your Cygwin installation. Inside it a file structure will be created, and this will include your “Home” folder.
The Home folder is the crucial ingredient; this will allow us to maintain an emacs installation that is the same across Windows and LINUX.

You don’t need to do anything to set all this up. Just advance the installer script. You can choose a different install location if you want, but I tend to accept the default.

Choose the installation directory

Now it is time to choose the GNU packages you want to install. I’ll stick to what is required for emacs here. You can always go back and browse for further packages that interest you afterwards. I’ll be showing you how to install more packages later on.

In the search box type “emacs”. This will show all the emacs related packages. Now expand the “Editors” tree.

You must select the emacs package. This is the base emacs installation. You will see the package install message change from “Skip” to the version number that is going to be installed.

Now you have a choice. You can either select the emacs-X11 package, in which case you will get a console only version of emacs, or you can select the emacs-w32 package. In this case you will get the full emacs experience with GUI. Even though emacs usage is heavily weighted towards the keyboard, I still prefer this option.

The screen grab below shows the correct selections to make:

Selecting emacs packages

Advance the installer.

The next page asks you if it’s OK to install dependencies. You need to leave this box checked and advance to the next page.

Now cygwin will start installing everything, including emacs. Sit back and wait!

Installing cygwin & emacs

When the installer finishes you will have an option to create a desktop icon. This shortcut is not for emacs! It’s a shortcut for the cygwin terminal. The terminal is quite useful, so I recommend you allow the installer to create the shortcuts, but it’s up to you.

Setting up emacs.

Emacs is installed and will run as it is. First, let’s check it works. Launch the Cygwin terminal using the shortcut icon.

Now you will see a terminal appear. If this is the first time you have launched a cygwin terminal you will see some initial setup take place; cygwin will create some startup files in your cygwin home directory. Then you will get a terminal prompt.

In the terminal prompt, type:

emacs &

If everything has worked, you should find that a bare-bones default emacs setup will launch.

emacs first launch

Now it is time to set things up. If you’re a seasoned emacs user you will surely have your own config file that you want to use. If you’re new to emacs then you should still create the file we’re going to talk about (because you will undoubtedly want to edit it in the future).

Now, a disclaimer: I can’t possibly know what you’ve got inside your own .emacs file. If you’ve created a rats-nest in there, and some things don’t work, it’s up to you to fix them. I’m happy to answer questions if I can though! Ask them in the comments. Note that I consider myself very much an amateur emacs user. I am still learning the ropes myself! I don’t know everything.

I have quite an extensive .emacs file which I have developed while using emacs on LINUX. I control it with git, so I checked out the file and copied it to my cygwin home directory. Assuming you accepted the default cygwin installation path then the home directory will be located at:

C:\cygwin\home\user

Where ‘user’ is your Windows user name.

This is what we refer to as your “home” directory. On LINUX the home directory for a user is typically abbreviated as ~/. This abbreviation works in Cygwin as well, and that’s why we can develop a common configuration that works across LINUX and Windows. We only need to make sure that critical files (e.g. files which are referred to explicitly in .emacs, or used in org-mode) are kept in the home directory with a file structure that is replicated across the two systems. The location of the home directory itself is not important, nor is the user name, since we will use the ~/ abbreviation when we refer to the home directory in code.

Creating an emacs shortcut icon

You might find it tedious to have to launch a cygwin terminal and type ’emacs’ every time you want to launch the application.

To fix that you can find the emacs executable in the cygwin bin directory and send a shortcut for it to your desktop. Or you can pin it to your start menu, whatever you want. See the screen grab below:

Creating an emacs shortcut

That’s it for emacs! We’re done!

You just need some way to keep the .emacs file current on both your Windows and LINUX systems. I use git for that, so whenever I make changes I commit them to a git repository and then simply pull the changes on each local system. This means I have one configuration which works at home on LINUX and at work on Windows. The user experience and functionality is identical between these systems.

If you want to set up org-mode, read on:

org-mode setup

There are a few ways to set up org-mode. I don’t debate the pros and cons here, I only offer a method that works for me.

I run org-mode by pulling the latest code from a repository and then running uncompiled source files on my systems. This works on both LINUX and Windows. Here’s how to do it:

First, you need git installed. Otherwise you’ll have to find a manual method by which you can obtain the org-mode source.

Clone the org-mode repository:

clone the org-mode repository

make

Now you need to install the make utility. You can get it from the Cygwin repository. It could have been selected and installed at the same time as emacs, but if you’re not familiar with Cygwin this is a good opportunity to find out how to install extra packages.

You need to launch the Cygwin installer again. Advance the installer in the same way as you did before until you get to the package selections. Change the ‘View’ combobox to “Full”. Then search for “make”.

Install make

You need to install the GNU version. Select it so that the status changes from skip to the version number that will be installed. Then advance the installer in the same way as before.

Make will be installed.

make uncompiled org-mode

Now open a Cygwin terminal. Change directory to the location of the org-mode repo (in my case it’s ~/git/org-mode). Enter “make uncompiled”. See screen grab below:

Synchronising org files

Now you need a way to synchronise your org files in a way that will be common on both LINUX and Windows with the file paths being identical.

Some people use git to sync their org files, and that’s something I’d like to explore. But right now I am using ownCloud, which is a cloud storage tool. I use ownCloud because I run my own server and prefer to be in control of my own files, but you can use any cloud storage tool: Dropbox, Google Drive, One Drive, they all should work the same. If you’re looking to run cross-platform, like me, then your choice will be limited by the clients that are available on both platforms.

The important bit is setting a target path for the cloud storage client that can be repeated on both platforms. That means setting it up in your home folder.

I have my org files set up in the following path on both systems:

~/ownCloud/Documents/emacs/org

This way I am safe to refer to this path in my .emacs file. For example, I have some lines in my .emacs that tells org-mode to include all org files inside certain folders into the agenda view:

This works on both platforms because ~/ refers to my home folder on LINUX and to the Cygwin home on Windows. As long as the rest of the path is common on both systems, it’ll work.

When I am at work my org files are changed as I clock into and out of tasks, complete tasks, set new tasks, take notes, and so on. These changes are synchronised with my server using ownCloud, and then the ownCloud client on my LINUX side at home pulls down the changed files.

The Final Result

Here is a screen grab of my emacs installation. The theme and all configuration is common across LINUX and Windows using a single .emacs file.

Introduction

Recently I have had cause for complaint with our Samsung LE40M86BD LCD Television. It had been working just fine, and then all of a sudden it developed a power-cycling problem. The symptom is as follows:

From power-on, the TV works perfectly for around 10 minutes.

After a while the TV switches itself to standby, waits a few seconds, and then switches itself back on.

Once this starts happening the cycle repeats itself every 30 seconds.

I decided to take a look, and that’s what this blog post is about!

Troubleshooting

A Peak Inside

I took the back off, and it never ceases to amaze me how little there is inside modern TVs. They are for more complicated than older TVs of course, but all the technology is packed into densely populated embedded systems.

Inside the Samsung TV

In this photo you can see the two main parts of the Television. Near the centre is an off-white coloured circuit board; that’s the main Power Supply. To the right of the Power Supply is a similarly sized green circuit board. This board is the heart of the Television. It’s basically a custom computer!

The Power Supply Board

Here’s a photo of the power supply, on the bench. Now, any time you see electrolytic capacitors mounted right next to a heatsink as they are here, you simply have to be suspicious of them, especially in older equipment. That big old heatsink pumps heat into those capacitors day in, day out. And if there’s one thing electrolytic capacitors don’t respond very well to, it’s long term heating.

Two of these capacitors, highlighted in the image above, are showing the classic signs of dielectric degradation. The top of the cans are bulging at the seams.
Sometimes this type of capacitor will also leak electrolyte, which can be very bad news indeed. In this case, it’s just the classic bulging.

At this point I decided to replace all the capacitors in the local area, as sometimes an electrolytic capacitor can be bad without displaying any obvious physical signs and they all will have been subjected to the heat pumped out by the nearby components.

More Trouble

After this I was quite hopeful of a quick and easy repair. But my hopes were dashed when I discovered that the TV was still power-cycling after a few minutes of use.

So, what to do? Well, I decided to be a bit more scientific about it from now on. I got my ‘scope out and checked each of the power supply rails generated by the PSU board. I discovered two things:

The Power Supply rails were now rock-solid. They probably weren’t before I changed those nasty capacitors, but they definitely were now.

I could run the Power Supply into a load, away from the rest of the TV, and it never power-cycles.

So… the original fault was not on the Power Supply board then.

As a point of interest, I discovered an input control pin on the Power Supply called “ON/OFF”, which is driven from the main system. I decided to take a capture of it and I discovered that my estimate of ~30 seconds power-cycling was almost spot on:

You can see here that the TV stays on for 28.7 seconds, then switches OFF, and immediately back ON. The cycle repeats with exactly the same period over and over again.

So, this got me thinking. The fault is surely on the main circuit board, as this appears to be deliberately instructing the Power Supply to turn OFF at regular intervals. Let’s take a look!

The Embedded System

Embedded System Main Board

So, at first glance, there isn’t really much for me to get my teeth into here. There was next to no information about this board on the internet. I found a schematic, but it was more block-diagram level than anything else.

The photo above shows the board with the screening can removed, revealing the microprocessor underneath. I took the screening can off because I noticed a bunch of SMD electrolytic capacitors and I wondered if they had been getting a little hot under the collar over the years.

An inspection of all the SMD electrolytic capacitors didn’t reveal anything suspicious; no bulging or evidence of leakage at all.
However… that isn’t particularly definitive. Let’s see what happens if I try to measure the ESR (Equivalent Series Resistance) on some of these capacitors!

C1104 ESR

So, the ‘scope capture above shows the voltage drop across C1104 when stimulated with a 100kHz square wave at 1V peak-peak (50Ω output impedance). C1104 is a 100uF capacitor, so the voltage drop at this frequency on a healthy capacitor should be close to zero. What do we see instead? 286mV!

If you do the math, you’ll find that this comes out as approximately 5.5Ω ESR. A horrendously bad capacitor!

At this point I went all around the board measuring ESR on the SMD capacitors. I was able to measure the majority of them in-circuit, and I found a whole bunch of bad caps. I replaced them all.

Success!

After this, the TV is finally working properly. The fault has not re-appeared in over a week.

Last Christmas I bought a Velleman MK170 Christmas Star project for my Wife to build. She often shows interest in my various electronics projects and I thought it would be a good way for her to build something that she could show off to friends and family, whilst at the same time teaching her a thing or two about electronics, components, and soldering.

First Try

After the build was completed we connected it to a 9V D.C. supply, as instructed by the documentation, and…

Star Before Mods

I was quite disappointed! The project was definitely functional, but the display was extremely dim and underwhelming. At first I was convinced we’d done something wrong during the assembly, but nope; everything was as it should be!

The camera flatters the result. To the naked eye the brightness of the LEDs is completely unsatisfactory.

I decided to revisit the project for this year. I downloaded the schematic from the Velleman website, and took a look to see what was going on.

MK170 Schematic

Looking at the schematic (click the image for a larger version) you can see that we basically have three sets of LEDs, each of which is split into sub-groups of series and parallel LEDs.

Now, one thing that jumps out straight away is the value of the series resistors; they’re HUGE!

Take, for example, the series chain consisting of LED1, LED2, LED3, LED4. I measured one of these individual LEDs and they don’t even begin to conduct until ~1.7V. So to work out the current through these resistors we have:

(9V – (1.7V * 4)) / 2200R = 1mA!

I looked up the datasheet for the LEDs and I found that the typical forward current should be around 10mA. Practical tests showed that these LEDs conduct 10mA at around 2V forward voltage.

So, to work out more appropriate resistor values:

Four Series LEDs

For the chains with four series LEDs, the forward voltage drop will be 2 * 4 = 8V.

This means the drop across the current limiting resistor will be 9 – 8 = 1V. In order for 10mA to flow, we’ll need a 100R resistor.

100R!! The 2k2 resistors that Velleman fitted are not even in the ball-park!

Two Series LEDs

The same process can be used to determine the appropriate value for the chains with two series LEDs. The drop across the resistor ends up being 5V, so you need around 500R for the current limiting resistance.

Conclusions

Star After Mods

I really don’t know what Velleman were thinking with this project. Their choice of current limiting resistor values are way off. I can only imagine that their intension was to reduce the current down to the absolute minimum, so that the project could be powered by a standard PP3 battery for relatively long periods of time.

That’s all very well, but the result is a project with totally unsatisfactory LED brightness.

I changed all the resistor values on ours, and now we are able to show off the project along with all our other Christmas decorations.

The current consumption on my unit, after my modifications, is 120mA when all LEDs are lit. Not all the LEDs are lit all of the time, but I guess it would be reasonable to assume >90mA average current consumption.

A standard 9V PP3 battery is going to be wasted very quickly at this current consumption. I would estimate 1-2 hours use before the battery drains flat!

That’s probably why Velleman used such high resistor values. But my take on this is that it was a poor design decision to build the project around a PP3 battery in the first place. These batteries have very low capacity, so they were on to a loser from the beginning.

We are powering ours from a 9V DC adaptor, which is the only realistic way forwards for a project like this.

Install Heimdall

Note that the “Frontend” packages are not required. Everything can be done easily from the command line.

Install Heimdall using dpkg:

sudo dpkg -i ubuntu13.04-heimdall_1.4.0-0_amd64.deb

Install adb

Install adb from the Ubuntu repositories:

sudo apt-get install android-tools-adb

sudo apt-get install android-tools-fastboot

Download ClockworkMod Recovery

Download ClockWordMod Recovery for the Galaxy SII (i9100). I got it from here.

Download CyanogenMod

Download a compatible version of CyanogenMod for your handset. You can get it here.

My personal preference is to stick with CM11 (Android 4.x) on the Galaxy SII. CM12 (Android 5.x) is available too but it’s an old handset now so you need to consider if it’s ideally suited to the newer versions of Android. CM11 runs really fast on it, so I prefer that.

Download GAPPS

Normally the best place to get GAPPS (Google Applications; Play Store etc) is via OpenGAPPS. But in my experience the packages provided by OpenGapps are too large for the Galaxy SII. If you took my advice to install CM11, then you need GAPPS version gapps-kk-20140105-signed.zip, provided here. This one is small enough to install successfully.

Flash Custom Recovery onto the Galaxy SII

With the handset turned OFF, place it into “Download Mode” by holding VOLUME-DOWN, HOME & POWER.
You should see a screen which looks like this:

Press ‘VOLUME-UP’ to confirm and then you should see the Download Mode screen:

Connect the handset to your computer via USB.

Now, on your computer, browse to the location where you downloaded the CWM package (see Pr-Requisites section). Extract it. It should come out as a filename called “zImage”. If what you get is named something a bit different don’t worry, just take account for that in the terminal command you’re going to enter next…

Open a terminal and ‘cd’ to the directory where the CWM package was extracted. Then enter the following command:

sudo heimdall flash --KERNEL zImage --no-reboot

You should see a blue transfer bar appear on the handset download screen. The transfer is complete when the blue bar has filled, as shown in the photo below.

IMPORTANT – Boot into Recovery Next

This next bit is a little important; you need to boot into the custom recovery you just installed next, before you do anything else. If you don’t, the stock recovery might overwrite CWM. The consequences of this are minimal; you’ll just have to start again! But to avoid this, boot into recovery as follows:

Disconnect your USB cable from the handset.

Turn the handset OFF by holding the POWER button.

Boot into CWM by holding VOLUME-UP, HOME & POWER.

You should see a screen like this:

Now, using the VOLUME buttons select “wipe data/factory reset”

Press POWER to enter.

Select “Yes – Wipe all factory user data”

Press POWER to enter.

If factory wipe is successful you will be returned to the main menu.

Flash CyanogenMod

Now for the cool bits. Connect your handset back to the computer via USB.
Open a terminal and ‘cd’ to the location where you downloaded the CyanogenMod zip file. Don’t extract the zip! We’re going to transfer it as-is to the handset and then the handset will extract it and install.

At the handset, use the VOLUME buttons to select “install zip” and then press POWER to enter.
Select “install zip from sideload” and select.

At the handset you should see a message confirming that sideload has started. Using adb, you need to transfer the CyanogenMod zip file using a terminal command as follows:

adb sideload cm-11-20141115-SNAPSHOT-M12-i9100.zip

Adjust the command to suit the filename of the ClockworkMod you downloaded.

You should see some information in the terminal to confirm that the file is being transferred. When it’s done, the handset will attempt to install the update, and you’ll see a screen similar to below.

Unfortunately you don’t get any obvious confirmation that it completed at the handset. But one way to tell is to try the menu selection; if you have control of the menu using the VOLUME keys, it has finished.

Install GAPPS

This next bit is optional (maybe you don’t want any standard Google Apps on the handset) but without it you won’t be able to use the Play Store.

Using the same method as you used to transfer and flash CyanogenMod, ‘cd’ to the location where you downloaded the GAPPS package (see Pr-Requisites) and then enter the zip sideload function on the handset. When ready, use adb to transfer and install GAPPS:

adb sideload gapps-kk-20140105-signed.zip

If the process fails you’ll be informed about it. Otherwise, if you haven’t been shown any errors on the handset and you have control of the menu, it’s finished.

DONE! Reboot

That’s it! You’re done. Use the menu to select “Reboot” and enjoy CyanogenMod on the Galaxy SII.
Note that boot-up will take longer the first time as the handset will install and set itself up.

I came across this blog post, which claims to discuss sexism in the work place. The post centres around a bar owner (Jordan Gleason) who, fed-up with the “sexist” attitudes of some of his male customers towards his female employees, decides to take a stand and ban them.

I read the post and I find myself in total agreement with Jordan’s disgust at the behaviour of these particular male customers. And “good on him”, I say, for taking a stand against these people and barring them from his establishment. Such abhorrent behaviour should be fought wherever it is found, and I celebrate it all the more in this case because Jordan stood up to his own customers even though it meant turning down present and future business. That’s not a trivial decision for a small business to make. I applaud someone who stands up for important principals first, and matters of business second.

I do have a problem with Jordan’s post, though: I don’t agree that the behaviour of the men can be attributed to “sexism”.

The Behaviour.

First of all, I wanted to talk about the behaviour. Here is a summarised version of what the male customers did:

Made lewd comments directly to female members of staff about their breasts.

Made similar lewd comments directly to the female staff about them bending over.

Attempted to defend his own comments based on what the female staff were wearing.

Of course, any reasonable person – men included – would agree that this behaviour is inappropriate, despicable, rude, lewd, and maybe even abhorrent as well. For me personally, the behaviour became “abhorrent” (which I reserve for particularly disgraceful behaviour), at the point that the men – when challenged – chose to put the blame on to the very women they targeted and insulted.
A person who does something extremely distasteful, but is able when challenged to appreciate what they did; that’s one thing. But a person who somehow manages to believe that the victim is to blame for the behaviour they themselves perpetrated… that’s something far more serious.

So yes, “abhorrent”. I stand by it.

Sexist?

So I agree with rude, lewd, disgraceful, abhorrent, and many other negative names people would use to describe it.
I don’t agree with “sexist”, which is what Jordan primarily uses to describe the men’s behaviour.

Sexism or gender discrimination is prejudice or discrimination based on a person’s sex or gender. Sexism can affect any gender, but it is particularly documented as affecting women and girls.

OK, so sexism is about discrimination based on gender. And to be totally clear, it is necessary to describe ‘discrimination’:

Discrimination is everywhere. We all undoubtedly experience it multiples times every single day. Discrimination is just a fact of life.
Many instances of discrimination are unwelcome in our lives, but just because discrimination is unwelcome – or even hurtful – doesn’t necessarily mean it is considered “unfair”. Not all discrimination is considered equal in our society, and for good reason. Here are some examples of fair discrimination:

“Fair” discrimination, welcome & unwelcome:

A boss interviews candidates for a job, and selects the person she feels is the best suited for the position. You didn’t make it.

You ask a woman to go out on a date, but she doesn’t want to because she would rather go on a date with someone else.

You are picked first for your community football team. Someone in the line gets picked last. Others don’t get picked at all.

Your boss needs someone to negotiate with a customer. He values you as an employee, but he thinks your colleague is better suited for this particular task.

These are all examples of fair scenarios in which you are discriminated against. Notice that “fair” doesn’t mean “nice”. We’ve all been on the wrong end of fair discrimination. At the end of the day, it’s life.

There are some types of discrimination that we, as a society, have deemed to be “unfair”. Most of these (particularly those regulated by law) relate to matters of the workplace, but there are examples to be found outside of the workplace as well.
Examples:

It’s unfair to select a candidate for promotion based on gender.

It’s unfair to sack someone because you find out they are homosexual.

It’s considered unfair, and increasingly frowned upon, to deny children certain interests based on gender.

So we – as a society – have ring-fenced certain types of discrimination and decided it’s not fair, and that people who are found to be engaging in unfair discrimination shall be held to account. Sexism is an example of this. Most people would agree that this is a positive thing in our society.

How does this apply to the lewd comments?

And here is my problem. A man makes some lewd comments towards a woman. I recognise this behaviour as despicable and wrong, of course. I would also agree that his comments were sexually motivated. But sexually motivated behaviour is not the same thing as sexism. Sexism is unfair discrimination directly applied to gender. Where is the gender discrimination here? Can I say he discriminated based on gender because he made lewd comments to the female staff but not the male staff?
So the guy is a pig if he does it to both genders but he’s a sexist pig if he does it to one gender? I would say no. I don’t think that’s in the spirit of what gender discrimination stands for.

My Conclusion

I think these men are examples of pigs. And it’s great that someone took a stand against it. There isn’t anything “sexist” about it. The behaviour was sexually motivated, sure. But that’s something different to sexism, in my view.

Recently I was asked to produce a circuit to create a variable ‘dim’ control for an existing LED based exhibition.

I decided to go with a simple 555-timer based design which provides control of the pulse width of an output, whilst keeping the oscillation frequency fixed.

The circuit is shown below. It’s an unusual design, because the output is taken from pin 7. This ‘output’ is not capable of driving current (at least not without affecting the circuit behaviour) so you have to be careful with the connections you make to it.

555 PWM Circuit

The circuit works because of some very simple rules:

When pin 7 is high, the output pin (3) is low.

When pin 7 is low, the output pin (3) is high.

Pin 7 will be high when the trigger/threshold pin is > 2/3 of VCC.

Pin 7 will be low when the trigger/threshold pin is < 1/3 of VCC.

When the circuit is first powered on, pin 7 is low because C2 is discharged. This causes pin 3 to go high, and C2 begins to charge via D1. When C2 reaches about 2/3 of VCC pin 7 goes high, causing pin 3 to go low. Now C2 discharges through D2 until its voltage falls below 1/3 of VCC and then the cycle repeats as an oscillation.

The resistance in the charge and discharge cycles is controlled by RV1. When the resistance is increased for the D1 side of RV1 the resistance falls by the same amount on the D2 side of RV1. This changes the relative ‘speed’ of the charge/discharge cycle, which has the practical effect of pulse width adjustment.
Since the total resistance of RV1 (for the total charge/discharge cycle) is constant, the frequency of the output is stable and is determined by the values for RV1 and C2.

The frequency of the output is governed by a simple formula:

FREQUENCY = 1.44 * RV1 * C2

The power switch is a PMOS FET. It controls the switching of a 12V feed onto the existing LED array at the exhibition. RV1 is adjusted to provide the desired brightness for the display, and LED D3 provides an indication of the level of ‘dimming’ that the circuit is currently providing.
The circuit oscillates at 100Hz, so there is no perceived flicker.

Introduction

If you’re away from home it’s very important to have a pin or password lock on your phone, just in case you misplace it or it is stolen. Typically the modern mobile phone is a gateway to a multitude of private services and data, such as personal photos and videos, cloud based data, social media, shopping accounts and even bank account access. A password lock will not necessarily prevent the determined person from gaining access to your phone, but it will at least prevent instantaneous, unchallenged, access to compromising services. The idea is that you would shutdown access to these services at the earliest possible time after your phone has been discovered missing, and hopefully before access to the mobile phone is gained.

When you think about it, the modern mobile phone (which is really a mobile computer first, with a mobile phone as a secondary or even tertiary feature) is a very compromising device to carry around with you – and most of us take it for granted.

Still, having to enter a pin or password on your device can get pretty tedious after a while, especially when you’re at home. If you’re in the comfort of your own home, you know your device is safe, and maybe you’re willing to relax the security on it under these circumstances.

This post will explain how to do exactly that – automatically – using Tasker. If you decide to use this option, please be very aware that you are significantly compromising the security of your device. You are basically trading away some security for a bit of convenience. I’ll explain some of the security vulnerabilities at the end of the post. The choice, then, about whether to make the trade, will be up to you.

Pre-Requisites

The pre-requisites for this tutorial are:

An Android based mobile phone, with Tasker installed on it. You can get Tasker from the Play store.
If you’re running iOS you’re out of luck; Apple think you’re too stupid to know what you’re doing, so they would never let you have access to a great application like Tasker in the first place. You should take this opportunity to throw your Apple device in the bin immediately – liberate yourself from the oppression!

Your phone should be rooted. Root access is not required for Tasker itself, but it is required in order to enable a third party tool (which Tasker will use) to change the phone lock settings.

The third party tool you need is called “Secure Settings”. This is available on the Play store as well. You may need to purchase the pro version to get access to the features we’re going to need (I can’t remember what comes with the free version). If you do, it’s cheap anyway and well worth spending a few bob on.

The Tutorial

Enable Admin Access for Secure Settings

The first thing to do is give Secure Settings the admin access it’s going to need in order to change the lock settings. Open the Secure Settings application and select the little ‘spanner’ icon to enter the preferences. At the time of writing this post, the spanner icon is available at the top of the Secure Settings main screen. Once you’ve entered the preferences, check the box labelled “Device Administrator”.

Set up the Tasks

Now you need to set up the Tasks, from within Tasker, which will enable/disable the pin lock.

First, to enable the pin (or password) lock, open Tasker and select the ‘Tasks’ tab at the top of the screen. Then select the ‘Add Task’ button (a large plus sign) at the bottom right-hand-side of the screen. Call your task something descriptive; I called mine “EnablePin”.

Now you need to add an action to the Task. Select the ‘Add’ icon in the bottom middle of the screen. Then, from the Action Category list that appears, select ‘Plugin’. If Secure Settings is installed, it should display as an available plugin. Select ‘Secure Settings’ from the list.
Now edit the configuration by selecting the edit icon (a pencil) from the right hand side. In the Secure Settings Actions menu that appears, select “Dev Admin Actions”. A secondary list will appear, from which you need to select “Password/Pin”.

Inside the Password/Pin settings, Select the ‘Disabled’ button so that it changes state to ‘Enabled’. Now you need to choose a Password or a Pin Code and enter it twice. Once you have entered it, select the ‘Save’ icon (a floppy disk) to complete the action.

You will be returned to the Action Edit area and there should now be some text inside the Configuration area. The text will be the name of the action that will be performed – in this case, either “Set Pin” or “Set Password”.
Return to the Tasker task edit screen by selecting the back button at the top left of the screen. You should see a Secure Settings action as the only action in the list. Select ‘back’ again to return to the Tasks list.

Now you need to repeat the same process to add a “DisablePin” task. The process only differs in the Secure Settings Actions setting. Instead of selecting the ‘Disabled’ button to change its state to ‘Enabled’, you need to leave it in its ‘Disabled’ status. Then select ‘Save’ as before. This should create a Secure Settings “Clear Password” action. At the end of the process you should have created two Tasks; one that sets a pin or a password of your choice and enables it, and one that clears the pin or password. You can test the tasks by selecting them from the list and then selecting the ‘run’ icon. After you run the Enable Pin task, you will need to enter the correct pin or password to unlock your device. After you run the DisablePin Task, you will only need to swipe the screen to unlock your device.

Set up the Profile

Finally, you need to set up a Profile, to automatically trigger the tasks when you’re at home. There are quite a few options here; you could set a profile to trigger the clear password task when you’re within range of a certain cell tower, or when you’re connected to a specific Wifi access point, or when you’re within range of a particular Bluetooth device (e.g. your car’s bluetooth). Or you could add a button to your screen to manually (but conveniently) enable/disable the pin lock at will.

I will show you how to set up a profile which will clear the password when you’re connected to a particular wifi access point, and set the password lock if you’re not connected to the wifi access point. In practice the wifi access point would be your home network hub, or something like that. You can also set a profile which activates if you’re merely in range of the wifi hub, so that you don’t even need to be connected to it. There are many variations upon the theme which you can explore for yourself; the process for all the various profile options is very similar.

First you need to create a new profile. Enter Tasker, and select the ‘Profiles’ tab at the top of the screen. Then select the ‘Add Profile’ button at the bottom-right of the screen. You will be shown a small Profile Category list. We want to activate the profile given a particular state, so select the ‘State’ category.

Next you will be shown a list of states. Select the “Net State”. Now you will be shown a list of Net States. You will see various Bluetooth states, Wifi states, Network states etc. Choose ‘Wifi Connected’.

Now you will be shown the ‘wifi connected’ state setup. You have three optional settings which can be configured. If you don’t configure any of these, then the profile will become active when you are connected to any wifi access point.
If you only want to activate the profile when you’re at home, then you need to enter options which are specific to your home wifi access point. e.g. you can enter the SSID of your home wifi (the wifi name which shows up when you scan for an access point). If you’re unsure what the exact name of your wifi access point is, you can select the search button (magnifying glass) and choose from a list of scanned access points.
You can do the same with MAC, to set the profile to trigger when you’re connected to a wifi access point which has your home wifi hub’s MAC address. Again you can search for this to help you set it up.
You can also set the IP, so that the profile only triggers when your device is connected to a wifi access point and you are assigned a specific IP address. This would be useful if your home hub is configured to assign your device a particular static IP address.
If you combine all the options, the profile will activate only when you’re connected to a wifi access point which has the correct SSID, the correct MAC address, AND assigns you the correct IP address.

Once you’re happy with the setup, return to the Tasker profile setup screen. You will be asked to select a Task to run: select the DisablePin task you created earlier. Now you will see a profile entry with the trigger set to your particular preferences. There will only be an entry task though, shown with a green arrow. You really want an exit task as well, so that the password is set again when you’re no longer connected to the Wifi access point. If you select and hold the entry task, another menu will appear from which you can select “Add Exit Task”. Choose the “EnablePin” task which you created earlier.

Now you should have a profile set up which triggers the “DisablePin” task when you’re connected to your home wifi, and triggers the “EnablePin” task when you’re not connected to your home wifi. In this way, you can disable the pin or password lock screen when you’re at home.

Conclusion

That’s it, you’re done! There are many variations upon this theme which you can play with. Explore them and have fun!

Be very aware that this particular Tasker profile significantly compromises the security of your device. For example; if I happened to know that you had such a Tasker profile set up, and I was able to gain physical access to your device, then I could simply set up a spoof Wifi access point with the same SSID, IP and even MAC address. Then, when your phone connected to it, it would think it was your home wifi and disable the password access.

Of course, this assumes I have detailed knowledge of your Tasker profile and your home wifi details up-front. Probably an unlikely scenario for the person who comes along and steals your phone, or finds it by chance. So it’s a risk you can choose to take, or not!

Introduction

Freerouting was a web application created and maintained by Alfons Wirtz at his website, here. It allowed us to import a design file from kicad and then auto-route the project based on some design preferences. It was basically a free auto-router for kicad. Hence the name!

For “various reasons” the author has decided to drop the project, and it is no longer available as a web application at his site. However, he has been kind enough to open-source the project and he encourages users to run it as a local application.

There are some wikibooks instructions for installation of the Freerouting application here. I have recently attempted to follow these instructions, but there are some stumbling-blocks which prevented me from being able to run a working application. I believe these same stumbling blocks will face lots of people; at least those who decide to install it on a recent Ubuntu variant.

This blog will detail all of the instruction steps necessary to run a working local copy of Freerouting. My instructions are based on those at Wikibooks, but with some extra steps to get around the stumbling blocks.

The Pre-Requisites

You can skip this part if you already have installed a recent version of:

Git

Java JDK

Netbeans

Otherwise, read on!

Installation of Git

Use your package manager, as follows:

sudo apt-get install git

Installation of Java JDK & Netbeans

This post used to direct you to install the JDK and Netbeans packages separately, but all of a sudden this method stopped working. When I queried it with the Netbeans team they refused to admit any problem, but suggested the “combined package” instead. Well, I don’t agree there isn’t a problem but the combined package does work so let’s do that instead!

First you need to locate the JDK & Netbeans combined package. At the time of writing this post, you can get it here.

Once you’ve downloaded it, you need to make sure that you have permissions to execute it. To do that, ‘cd’ to the directory where you downloaded the installer, and then type the following command, substituting for your version of netbeans if it’s different from mine:

chmod u+x jdk-8u111-nb-8_2-linux-x64.sh

Then execute the installer:

./jdk-8u111-nb-8_2-linux-x64.sh

You should see a screen something like this:

JDK & Netbeans Combined Installer

Walk through the installer dialogue to completion.

Installation of Freerouting Dependancies

The freerouting application depends on a couple of things to work. It requires jh.jar and netx.jar. To get those, install the following:

sudo apt-get install javahelp2 icedtea-netx-common

Installing FreeRouting & Running in NetBeans

Downloading FreeRouting

Now you need to download freerouting. It’s available on github, so you just need to ‘cd’ to a directory where you want to download the project, and then enter the following command:

git clone https://github.com/nikropht/FreeRouting

Loading FreeRouting into NetBeans, Compiling and Running

Now you need to start netbeans (should be under ‘Development’ in the application launcher) and import the FreeRouting project.

With netbeans open, select File -> New Project or use the keyboard shortcut CTRL-SHIFT-N.

In the Source Package Folders area, select Add Folder and browse to the place where you downloaded the FreeRouting sourcecode from git.
Select Finish. Netbeans will create the project.

Select File->Project Properties.
In the categories area, select Libraries. Then, with the compile tab displayed in the area on the right, select ‘Add JAR/Folder’. Browse to and choose /usr/share/java/jh.jar.

This next part is not explained in the wikibooks instructions I linked to at the beginning of the post. But it is absolutely necessary in order for FreeRouting to work. While still in the Libraries area, Select ‘Add JAR/Folder’ again. Now browse to /usr/share/icedtea-web/netx.jar.

Now, contrary to the instructions in the wikibooks link, we are NOT going to use Web Start:
While still in project properties (File->Project Properties), select from the categories area, underneath Application, ‘Web Start’. Make sure this check box is NOT enabled. Then Select ‘Run’ from the categories area and make sure the Configuration pull down menu is set to <default config>
Select OK to exit Project Properties.

Now from the netbeans main menu, choose Run and select “clean and build project”. If all has gone well, it will conclude with “BUILD SUCCESSFUL”. Now you can run the application: select the green triangle or press F6 to run the project. You should see the following:

Success!

Now you just need to learn how to use Freerouter! I got it routing a PCB pretty quickly without instructions so I think it is pretty intuitive to run. However, it may not be so intuitive to choose all the correct options for your PCB. That’s for another post, maybe.

Introduction

Sometimes you’ll end up having to deal with a DVD which has video recorded on it but the author neglected to finalize the disc. This can be a bit troublesome, because until the disc is finalized it doesn’t contain the necessary data to make it compatible with the DVD standard. Most consumer DVD players and PC based DVD drives rely upon this information to make sense of the data content on the DVD, so if it isn’t finalized most systems won’t open the disc. Either it will open a blank explorer window, or it won’t mount this disc at all. What to do?

Well, thankfully, it is possible to recover from this situation. There are some commercial applications out there which will do it (get your wallet out) or you can make use of open source software instead. I am going to describe the process for some free open source software on Linux.

DVD+RW-Tools

First of all, you need some free open source software called DVD+RW-Tools. This is a collection of programs for working with optical video disc media. Most modern linux distributions come with the tools installed as standard.

Reading the disc

Once you have the tools installed, you can use them to extract useful information about the data content on your unfinished disc. To do this, open a terminal and type:

dvd+rw-mediainfo /dev/dvd

You will get some output from the command. Here is a sample of output from an unfinalised DVD+RW which has one track on it:

Note that it is possible to have many video clips contained within a single track or you can have video clips spread across multiple tracks; it depends on how the video information was written by the original equipment. You may also see multiple disc ‘sessions’. In the sample case above, we have a single track within a single session and I happen to know that there are multiple video clips contained in it.

I will show you how to extract the video for the above single track, but the method is exactly repeatable for any number of tracks and any number of sessions.

The dd Command

‘dd’ is a command for copying data from some media. To use it, you give it a block size, a start address, an end address, an input file and an output file. To see how this applies to the above information, consider the following command:

dd bs=2048 skip=0 count=716192 if=/dev/dvd of=/$HOME/track1.vob

This will extract the single track from the disc and place it in your home. To explain, let’s go through the parameters one at a time:

bs

This is block size. To get the correct block size, take a look at the information from DVD+RW-mediainfo. You will see that the data information (e.g. Start Address) is terminated with an asterisk and a number:

Track Start Address: 0*2KB

In this case we are given 2KB. Since there are 1024 bytes in a kilobyte, the number to give for bs is 2048.

skip

This is the number of bytes to skip in order to reach the start address of the track. In the above example the start address is 0, so there are 0 bytes to skip. But in examples with multiple tracks and/or sessions, you will have non-zero start addresses. Just enter the start address for the track you are interested in as the parameter for skip.

count

This is the number of bytes to extract, from the start address. To obtain this information, simply use the track size data:

Track Size: 716192*2KB

if

This is the input file. You need to supply the path to your DVD device. In most cases it will be /dev/dvd

of

This is the location where the output file will be written. $HOME works fine.

Finished – Play It!

Once you have extracted your track, you can play it in any standard media player. You could also write it to a new disc, remembering to finalise it this time!!!

rarcrack

I stumbled across a little program called rarcrack yesterday, which provides brute-force cracking of password protected archives. I decided to give it a try and make some general observations about it.

An example

To set up an example, I created a .rar with a 5 character password. The password consists of upper-case letters, lower-case letters, and numerals. rarcrack does not know ahead of time how many characters the password is, so it has to try all possible combinations. I set the cracker going, and left it for a while. The next day, over 24-hours later, it was still going and had not cracked the password. Here’s a sample of the program output this Morning:

So it seems that it has started on 5 character passwords, having completed 4 character combinations. But it is still working through the 5 character combinations and I can see that it hasn’t got to mine yet because it does numerals first and my password started with a letter.

Some Calculations

Okay, so given the above information, how long can we expect rarcrack to take to crack a 5 character password? The speed is ~1300 attempts per second. That seems really low to me, but I assume it has something to do with the overhead associated with accessing the .rar file. Otherwise I would expect a PC as powerful as mine to make a lot more attempts per second than that.

Happy Valentines Day!

A few years ago I created a little valentines day project, shown in the video at the end of this post. It’s basically just a multi-vibrator circuit with two groups of LEDs, arranged as an inner and outer heart:

The full schematic is shown here, click on it for a full enlarged display:

Finally, if you want to download all the project information, you can get it here. This project is considered to be in the public domain.

I’ve thought about doing a new version actually, with micro-control of the LEDs for brightness fade in/out etc.

Adding USB Devices in a Windows Virtual Machine with VirtualBox

One of the most confusing things for me when I first experimented with VirtualBox was the question of how to add USB devices. I run Linux (Ubuntu) as my main OS now, but sometimes I need to dig around in Windows (e.g. work related stuff) so for those cases I run it in a virtual machine. I recently needed to add a data acquisition device for use in the virtual machine on Windows, so I thought I’d document the procedure here.

Pre-Requisites

You need to have VirtualBox installed on your machine, and a Windows virtual machine set up. I am going to run Windows XP in a virtual machine on Ubuntu in this tutorial.
You also need Virtual Guest Additions installed in the virtual machine to enable the USB support, amongst other things. If you’re confused about this aspect, there is plenty of information available if you ‘google’ it.

Sorting out the Group Permissions

The only reason that USB support is confusing at all is that you need to add your user to the VirtualBox group before any USB devices will show up for use. VirtualBox doesn’t offer any other useful information; it just complains that there are no available devices. The problem is that VirtualBox is not allowed to share your USB devices, so the next steps will fix this.

First you need gnome-system-tools. Run the following command in a terminal to install it:

sudo apt-get install gnome-system-tools

Now go to the dashboard and type ‘user’. You should see an icon for Users & Groups appear. Select it, and the following window will appear:

Select ‘Manage Groups’. The following window will appear:

Scroll down to ‘vboxusers’ and then select ‘Properties’. The following window will appear:

Make sure your user is ‘ticked’. It probably won’t be by default. Then select ‘OK’.

Now USB should work. But you have to log out and back in again first. You should do that now. When you log back in, open Virtual Box and select the settings for your virtual machine. Select the USB settings, and make sure USB is enabled. Now you just need to add the USB device you want to use in your machine. Make sure it’s connected to your computer, and then select the ‘add’ button. I’m going to add my National Instruments DAQ device:

Now, when you start your virtual machine, Windows should detect new hardware and install it for you:

Finally, when it’s done, you can test out your hardware. I am using a DAQ device so I started the software for it and captured an analog signal 🙂

DONE

That’s it, you’re done. Any time you need to add more USB devices, you can add them to your virtual machine in the same way.