Wednesday 23 October 2013

Beware of Dark Patterns!

Dark patterns are increasingly-common user interface elements designed to trick unsuspecting users into selecting an undesirable option, such as installing an unwanted app or signing up to an unwanted service.

Although designers go out of their way to provide a sleek user interface for hooking you in, you may not always find an equivalent feature that lets you undo your mistake afterwards.

A typical example

The following screenshot comes from an installer stub program which the user must run in order to install video editor software downloaded from a popular website:

Most software will require you to accept a license agreement before you are allowed to install. In the above screenshot, the user will probably assume that the green 'accept' button is the only way to go forward with installation.

Reading the screen more carefully reveals that it is actually referring to a different, completely unrelated program; one that alters the user's web browser settings in order to display advertisements. In this case, the correct way to proceed with installing the video editor, without the unwanted extra software, is actually to click the greyed-out 'decline' button.

By accepted user-interface convention (as specified by Microsoft and Apple, among others), a greyed-out button denotes an invalid option that is not able to be selected by the user. Here however, the 'decline' button is a perfectly valid option even though it has been given the cosmetic appearance of a greyed-out button. It has been greyed out purely to deter the user from clicking on it, even though it is probably the preferred option for the majority of savvy users.

Why do dark patterns exist?

Organisations typically have a financial incentive to persuade users to install a particular program or buy a particular service. In the above case, an organisation would receive a commission for each user who clicks the 'accept' button. There are always incentives for a company to improve sales, and deceptive sales tactics are hardly anything new.

Why does it matter?

If you own a computer, you have the right to be in informed control over what runs on it.

Unwanted applications are a security risk. If you have sensitive data on your computer, you probably don't want to allow strange applications to install themselves and assume free-reign over your files.

Unwanted applications deprive you of full use of the computer you paid for. If you perform computationally-intensive tasks, you probably don't want to have your system's performance and reliability compromised by a poorly-coded application you didn't realise you'd installed.

Finally, in an age of email-viruses spread through a combination of shady social-engineering tactics and uninformed users, it really isn't a good look when otherwise-reputable organisations engage in the same tactics.

What to do about dark patterns

Ideally, you should never trust someone with your business, or your web traffic, if they do not treat you – or your computer – with respect.

If you stumble across a dark pattern on a website you're using (for example, a website that tries to trick you into adding unwanted items to your order, or one that doesn't tell you what the 'catch' is until you've already invested time in filling out your details), stop using that website and find an alternative.

If you find a dark pattern in an app you've downloaded, immediately delete the app from your computer. If the app is distributed by a reputable organisation, consider sending an email to the distributor to let them know what is going on.

More information

There's an excellent guide to dark patterns, along with a collection of examples, over at darkpatterns.org.

Tuesday 8 October 2013

Getting a CNC mill

We've just got hold of a cheap CNC milling machine, which ought to come in handy when building hardware prototypes.

What's a CNC mill?

Everyone's heard of 3D printers. A CNC mill is a bit like a 3D printer in reverse. Instead of building up an object by adding material in layers, a CNC mill starts out with a solid piece of material (a block of wood, aluminium, etc.), and carves away unwanted material until you're left with the finished part. The quality is higher than 3D printing. When Apple sells a high-end product that was 'carved from a single piece of aluminium', they're talking about CNC milling.

Unlike 3D printers, CNC milling machines haven't started to become 'consumerised' yet. You pretty much have to know the machine inside out in order to use it. Fortunately, they aren't particularly complicated machines, and we do appreciate the fundamental simplicity. There are two main bits to understand:

  • A spindle holds an engraving bit. It spins the engraving bit at high speed (like a drill) to carve out material.
  • The spindle can be moved around in three dimensions (X, Y, Z axes) to different co-ordinates by a program script (called G-code) running on a connected PC. When you move the move the spinning engraving bit through a path where a piece of wood happens to be, wood is carved out by the spindle (unless you go too deep too quickly, or forget to spin up the spindle first, in which case you're likely to stall the machine or break something).
    The machine has a set of three motors, one for each axis of motion. Each motor turns a long screw that moves the spindle along its respective axis.

What did we go with?

We went with a YOOCNC 3020 machine. This machine is sold on eBay under a variety of brand names (just search for CNC 3020), and is just about as cheap as you can get a new machine without building your own from scratch. By all accounts, it's a machine loved by amateurs, hated by professionals, and requires the odd few modifications to overcome the inevitable design flaws. We're new to all this, so we haven't been spoiled enough to demand anything better.

Setting up the machine

The CNC machine is controlled by a PC through the parallel port interface that many motherboards no longer include (although there are cheap PCI cards available on eBay that will add a parallel port to any motherboard). The PC must provide the correct impulses in real-time, or else the CNC machine stutters or the PC application that controls it gets out of sync with the machine's actual position. That usually means that you set aside a PC that's dedicated exclusively to CNC work and nothing else.

There's a special Ubuntu-based operating system called LinuxCNC (formerly known as EMC2), which provides software for controlling a CNC machine and uses a customised Linux kernel optimised for the real-time demands of CNC machines.

For controlling the machine, I put together a PC with a 1.5GHz Via C7-D processor, 1GB of RAM, and an old 4.3GB Quantum Bigfoot hard drive that cost around $900 in 1996. I used an older version of LinuxCNC/EMC2 because the new version is based on a more bloated version of Ubuntu). The Via C7 line of CPUs came out a few years ago as a competitor to the Intel Atom. Despite mediocre performance in many desktop and gaming applications, they provide great real-time characteristics which made them well-suited to industrial applications.

Limitations of the machine

On this particular machine, the spindle control is all-manual. You have to flick a switch to turn it on, and slowly rotate a variable control to take it up to full speed. (More expensive machines allow the spindle rotation to be controlled by the computer.) The machine comes with a sticker attached warning you that you'll blow one of the internal fuses if you spin it up too fast:

The emergency stop button on the front panel is purely a software input to the PC through one of the parallel port pins, so if you have it set up correctly, it'll instruct the PC to stop moving the machine along the X, Y, Z axes, but it won't cut the power to the rotating spindle. (Looking inside the controller box though, there is an unused pin header on the power supply board for an emergency stop input for the spindle. Perhaps with a bit of work, the controller box could be modified to incorporate the spindle into the emergency stop.)

A problem we noticed fairly early on is that some engraving dust tends to get sucked into the controller box by the inbuilt cooling fan. We'll discuss this later in another blog post.

Another issue is that there are no limit switches or inputs on the controller box. What does this mean? Well, a CNC machine always knows how to move, say, 52.4mm along the X axis from its current position, but it has no way of knowing its absolute position, or how close it is to slamming into the end of its range of motion and stalling one of the motors (or, in the case of this machine, pinching the Z axis motor cable). Without limit switches, you have to zero (or 'touch-off') the spindle position relative to your work-piece each time you use it. With limit switches, the PC software can automatically home the machine to a default position each time you use it, and automatically ensure that the spindle doesn't go outside an allowed safe range of motion.

The good news is, it is possible to add limit switches to this particular machine: the PCB inside the controller box provides the capability, although there's a bit of soldering required. We'll cover this in another blog post later.

Finally, the documentation leaves a bit to be desired. Parameters are provided for a Windows program called Mach3, but EMC2 requires a few extra parameters. We found we had to start with what was given and work backwards to determine the rest.