Category Archives: Hardware

Low spec notebooks can’t handle large amounts of RAM

Cathy and I are seeing increasing contention for the grunty computer in the house not dedicated to playing computer games. It’s used for a combination of recreational programming, web surfing and media encoding tasks. We decided to acquire a second, and after comparing the costs decided that the premium for laptop portability wasn’t too great (about $100; in fact that seems to be about the price of the OS we were forced to buy with the hardware). In out usage profile, “grunty” isn’t defined by CPU, but responsiveness which really comes down to how often an arm has to venture out across a spinning sheet of rust. Unfortunately, bottom-end systems (i3 class CPUs) can’t handle our base-level RAM requirement of 16Gb, so yet again a portable computer is the most powerful thing in the house – the new system’s specs are:

Processor: AMD Quad-Core Processor A6-5200 (2.0GHz, 2MB L2 Cache)

25W of power consumption right there. Existing grunty computer pegs its CPU for about ten hours a year, in sustained encoding runs. We weren’t CPU bound, and yet the only way to get that RAM in an i3 lappy was to spend an extra $100 on a Toshiba with worse specs – so we got a quad core.

Memory: 4GB DDR3 1600MHz (max support 16GB)

That 4GB came straight out and was replaced by the most RAM that could be stuffed in there. Existing grunty machine had 8Gb and was paging a lot. Why are web browsers so memory hungry? This upgrade cost $160.

Storage: 500GB (5400RPM) Hard Drive

This came straight out before the machine was even powered up once. It was replaced by a Plextor M5-Pro 128GB SSD; this unit was selected for its fast random write speed, and the common-for-all-SSDs 0.1ms seek time. Back in the day (about ten years ago) I advocated that when building a machine, you should get drives with the fastest seek times and screw everything else, plus all the RAM you could afford – to use as disk cache. How little things change. This upgrade cost $129.

After Linux Mint 12.04 Maya (LTS) was installed (consuming 6Gb) there was 110Gb free on the replacement device. Paging has been disabled due to the SSD write limitations, and tmpfs is used for various directories to further minimise our impact on the longevity of the drive.

Graphics Card: Onboard (Integrated)

The contention for the memory bus is troubling, but at least there’s no extra juice being sucked down to power a fancy-pants GPU. This is not a gaming machine, 2D acceleration is useful, 3D not.

Operating System: Windows 8 64 Bit

That went with the rotating media. We’re going to see if we can boot a desktop machine off of it and still have the OS believe everything is okay. The laptop didn’t like the new OS, saying “Selected boot image did not Authenticate. Press Enter to Continue”, but the solution was to disable Secure Boot.

Screen: 15.6-inch diagonal HD BrightView LED-backlit Display (1366×768)

It took some fiddling for Cathy to figure out how to dim the damn thing under Mint. Turned out the answer was to install the proprietary AMD drivers.

Audio: Dual Speakers Stereo DTS Sound+

If you’re using a laptop for A/V reproduction, you’re doing it wrong.

Connectivity: Gigabit LAN (RJ-45 connector), 802.11b/g/n WLAN, Bluetooth

The Toshiba only had 100Mb, in this day and age! The Ralink wireless adapator wasn’t picked up automatically by the installer, so Cathy got down and followed the instructions off AskUbuntu

Built-In Devices: 1x USB 2.0, 2x USB 3.0, HDMI, RJ45 Ethernet, Headphone-out/microphone-in combo jack, SD/SDHC/SDxC Card reader

USB3 was important in picking the unit, as I’ve seem just how much faster it is. HDMI is necessary for twin-monitor development; MSY had a 21.5″ Full HD IPS on sale for $118.

Webcam: HP TrueVision HD Webcam with integrated dual array digital microphone

I’d just paint over it, but there’s a chance that we’ll have a use for videoconferencing. It stays, but it better mind it’s Ps and Qs or else it’s black electrical tape for it.

Optical Drive: DVD Burner

Yeah, like that’s ever getting used.

Weight: 2.33 Kg

I’m more used to computers that weigh 1Kg, not two and a half.

Dimensions: 56cm (L) x 13cm (W) x 34.5cm (D)

This thing has a widescreen display, it’s freaky big compared by my 10” netbook.

Other observations: the keyboard sucks balls, with the trackpad positioned such that you physically can’t touch-type on it because doing so places your palms on the trackpad, moving the mouse and screwing up your input (I think this is happening because gestures have been turned on; they might find themselves getting turned off again). For some messed up reason they’ve included a numeric keypad, so touch-typing is doubly hard – again with the palms. This thing’s going to find itself plugged into a USB hub with a real keyboard and mouse quite a lot I think.

Anyways, the HP Pavilion 15-E001AU was purchased from MLN for the low, low price of $500. Total system cost was $907, and at the end we had a 4GB lappy stick and a 500GB lappy drive laying around.

Replace a missing remote control with an Arduino and a laptop

I recently found myself without a remote for my WDTV Live media player, and limited resources to do anything about it – but I did have an Arduino, a breadboard and the local Jaycar had an IR LED.  Controlling IR devices is common practice with an Arduino. I would even be able to hack in functions that didn't exist on the manufacturer's remote – like creating a three minute skip by switching to 16x speed for 12 seconds.

The first port of call was to obtain Ken Shirriff's Arduino IR remote control protocol library – as opposed to communications protocols, of which there are quite a number; did you know the first cut of WiFi included an infrared version? Without the remote, I wasn't able to record and playback the IR signals sent to the WDTVLive, as you would with a learning remote. I had to find what to transmit from my custom remote. I little googling and I found the WD TV Live infrared remote control codes, which also helpfully reveals that the protocol is NEC.

I knocked up a quick proof of concept, installed it and watched it not work. Given I can't see in infrared, I didn't know if my circuit was working. I hooked a red LED up in parallel, and it didn't light up; I thought I had cathode and anode swapped around, so flipped the red LED – and it didn't light up. I pulled the IR LED, and then the red LED worked… I was shorting out the red LED. I couldn't – with the bits I had lying around – confirm the device was transmitting anything. Rather than put the LEDs in series, I got a cheap camera-phone with video function, and it could see IR just fine. And it turns out the IR LED was transmitting something, but the WD TV Live media player wasn't listening. Why?

The NEC infrared control protocol transmits 32 bits in one of two formats, one old (as in elderly) format encodes for 256 devices with 256 commands each, and the other encodes for ~64K devices with 256 commands each. The first 16 bits encode the device, and the second 16 bits encode the command. 16 bits for one of 256 commands, you ask? Well, one byte of the second 16 bits is the command, and the other is – for error checking purposes – the one's complement of that. Further details of the pulse timing and protocol contents are available in various places, but they neglect to mention the extended addressing format. There are many IR control protocols. To use Ken's IR library you need to know which protocol is used (which the google search revealed), and you can determine the protocol from the timing data found in the LIRC definition of a protocol, in this case the LIRC infrared control protocol for WDTV Live media player remote. The LIRC protocol defintion format is described by WinLIRC, so you can see what the timings are. In this case, the NEC protocol is revealed by the header, one and zero definitions, along with the fact that each code has 16 bits of 'pre-data' and 16 bits of data (a 32 bit package). Everything I could see was showing that the two, separately arrived at sets of command codes that were empirically sampled from the real world were compliant with the spec. One of the things the spec taught me was to transmit the NEC code twice, and to wait 70ms between re-transmissions.

I wasted time finding other codes for the remote, in other formats; I checked for byte ordering issues. Nothing worked.

The actual problem was the unsigned long for the command was previously an int; failing to notice this simple error led me to spend a long time trying to figure out why nothing was happening when I transmitted a command. One of the problems with the C language is the guarantees about data sizes aren't worth much.  My entire life has been spent programming on architectures that have 32 bit data words; C compilers on these machines have all defined an int as 32 bits, but I've always been aware that the language spec says that an int is at least as wide as a short, which is at least as wide as a char with actual widths being up to the compiler implementation (although why you'd have different words for things of the same size is beyond me).  The AVR microcontroller in question has an 8 bit word; mathematical operands typically yield an 8 bit result (multiply is an exception) with compilers needing to implement more instructions to yield greater data widths. The defines express the codes as four byte values, which were then wrangled into a two byte int, and then again into unsigned four byte integer when passed to the IR library. Truncated bits in a protocol like this were the cause of inactivity.

Even with this fundamental problem solved, confusion was added by the fact that one of the memory cells in my Arduino is faulty. Once IR control code transmission was working, I noticed that sometimes it didn't work. I decided to echo the command to the serial port, and the command being transmitted didn't match that for the key pressed – the second byte was wrong. I added code to work around this memory corruption (not shown in the code below, because this is a pretty unusual). I've never come across this kind of problem before, recognising and then solving something like that is pretty old-school.

/*
Pin 3 is hard-wired into the IR library as the emitter
 */
#include 
//#define DEBUG

IRsend irsend;

#define btn_enter  0x219E10EF
#define btn_right  0x219E906F
#define btn_left   0x219EE01F
#define btn_down   0x219E00FF
#define btn_up     0x219EA05F
#define btn_option 0x219E58A7
#define btn_back   0x219ED827
#define btn_stop   0x219E20DF
#define btn_rew    0x219EF807
#define btn_ff     0x219E7887
#define btn_play   0x219E50AF
#define btn_prev   0x219E40BF
#define btn_next   0x219E807F
#define btn_eject  0x219E08F7
#define btn_search 0x219EF00F
#define btn_home   0x219E609F
#define btn_power  0x219E48B7

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
const int onboard_led = 13;
const int retransmit=2;
unsigned long play_after=0;

void setup()
{
  pinMode(3, OUTPUT);     
  pinMode(onboard_led, OUTPUT);     
  Serial.begin(9600);
  Serial.println("WDTV Live serial controlled IR remote");
  Serial.println("~ Power    Eject ^ & Search   Rew - + FF");
  Serial.println("  w         Back q e Enter   Play  P");
  Serial.println("a s d (Arrows)     x Stop    Last <> Next");
  Serial.println("3 - FastForward three minutes");
}

void loop() {
  unsigned long cmd=0;
  if (Serial.available()) {
    switch (Serial.read()) {
      case 'E':
      case 'e':
      case ')':
      case '0':
      case 'O':
      case 'o': cmd=btn_enter; break;
      case 'q':
      case 'Q': cmd=btn_back; break;
      case 'P':
      case 'p':
      case ' ': cmd=btn_play; break;
      case 'S':
      case 's': cmd=btn_down; break;
      case 'W':
      case 'w': cmd=btn_up; break;
      case 'A':
      case 'a': cmd=btn_left; break;
      case 'D':
      case 'd': cmd=btn_right; break;
      case '-':
      case '_': cmd=btn_rew; break;
      case '=':
      case '+': cmd=btn_ff; break;
      case ',':
      case '< ': cmd=btn_prev; break;
      case '.':       
      case '>': cmd=btn_next; break;
      case '/':
      case '?': cmd=btn_option; break;
      case '~': cmd=btn_power; break;
      case '!':
      case '1': cmd=btn_home; break;
      case '^':
      case '6': cmd=btn_eject; break;
      case '*':
      case '8': cmd=btn_search; break;
      case 'x':
      case 'X': cmd=btn_stop; break;
      case '3': 
        if (!play_after) play_after=4; break;
    }
  }
  if (play_after > 0) {
    if (cmd) {
      play_after=0;
    }
    else if (play_after > 5) {
      if (play_after < millis()) {
        cmd=btn_play;
        play_after=0;
      }
    }
    else {
      cmd=btn_ff;
      if (--play_after == 0) {
        play_after=millis()+12000;
      }
    }
  }
  if (cmd) {
    digitalWrite(onboard_led, HIGH);   // turn the LED on to indicate activity
    for (int i = 0; i < retransmit; i++) {
      irsend.sendNEC(cmd, 32);
      delay(70);
    }
#ifdef DEBUG
    Serial.println(cmd, HEX);
#endif
    digitalWrite(onboard_led, LOW);    // turn the LED off - we're done transmitting
  }
}
zp8497586rq

TV tuner for Mac Pro?

I’ve been delighted with the secondhand Mac Pro I got last year. It’s five years old, but probably the best Windows PC I’ve ever owned… we sometimes use OSX, and sometimes use Boot Camp to run Windows, and I did end up getting Parallels as well, which is able to boot the Boot Camp partition — this I think is nothing short of miraculous.

Anyway, our other Windows PC is due for replacement. I was thinking I’d wait and see what the next crop of Mac Minis were like, but it looks like I’ve again got the opportunity to pick up a used Mac Pro via the same workplace clearing more of them out. Same age, but (if my calculations are right) double the speed of the current Mac Mini. Given our usage patterns, this is a cheap easy upgrade… particularly if we put an SSD in it.

I’m now pondering: what’s the best TV tuner for it? That’s the main thing I miss about the HP desktop we had that died. (I did try and rip the tuner card out of that to try in the Mac under Windows. It didn’t work.)

So… Mac Pro TV tuners…

I’d prefer dual tuner. I’d want it to work with both OSX and Windows. In fact I’d go so far as to say that this second box will be mostly using Windows, and I’d want this to work with Windows Media Centre.

For a USB dual tuner, the Elgato EyeTV Diversity looks pretty good.

Asking around on Twitter, there was some good feedback:

(Why does Twitter’s embed tweet with “Include parent Tweet” not seem to work?)

It’d be used with a proper connection to a roof antenna, so not concerned about the mini antenna.

But I think I’d actually prefer an internal card, since I really don’t need it to be portable… and installed internally might be more out of the way/better for longevity.

Any good options?

PS. This ancient page talks about some options. Not sure how relevant it is anymore though.

Choosing a cheap DC motor controller

I have a desire to control some DC electric motors using a microcontroller.  Under the covers these are normally H-Bridges, so that the motor can run in both directions. I also require that the motors be able to undriven – to freewheel without electric braking.

The cheapest motor controllers will only deliver 800ma (per motor), which might be enough, but possibly isn't. I think the L9110 datasheet (also known as the HG7881) hints at a peak of 2amp, but my Chinese is insufficient. There is no information on the switching frequency. These controllers drive the motors in either direction, or brake – but they will not disable the motors.

The next cheapest drivers are based on the L298 motor controller chip. The parts number variants indicate the packaging type; L298N is the vertical version, and a L298P is surface mount – which I can't get my head around, how are you meant to dissipate the heat with a surface mount version? Anyways, the L298 can switch at up to 20KHz according to the L298 motor controller datasheet, and delivers a total of 4A, 2 amp to each channel, and a total of 25W maximum, presumably about 12.5 watts per channel. I'm looking at motors of around 6V, so the maximum wattage isn't a consideration, but I'd have to start thinking about the power limits if they were 12V motors.  I'll need to supply more than six volts because the L298 module sucks up 0.7V doing its business.  Even the cheapest modules using this chip expose the enable line for each motor, and they include a jumper to permanently enable (which I don't want, but that's just a matter of removing the jumper from the enable pin); more expensive modules expose the current sensing pins on the L298 (which I don't think I have a use for). This unusual one is a l298 with a connector for stepper motor. Solabotics has an informative (if poorly spelled) L298 instruction sheet with examples hanging off their product page.

If I could switch at 30KHz, that's beyond human hearing and thus “silent”, but beyond these two controllers there's not a lot of commonly available choice, so I'm going with the ever-so-slightly more expensive and actually lets-me-do-what-I-want choice.

Higher frequencies seem to require MOSFET technology, which means dollars – and it seems higher voltages for the motors, which means more expensive motors, and more unusual power supplies (more cost).  I recall that higher switching frequencies lead higher efficiency. Oh well.

zp8497586rq

Traffic light and pedestrian crossing implemented with an Arduino

This video shows the Traffic light and pedestrian crossing I've implemented with an Arduino. It's a reproduction of the crossing near my home, timings taken from a video of it.

Pedestrian light_bb

Incidentally, I produced the diagrams for this using a product called Fritzing.  It's a nifty piece of software that allows you to draw a breadboarded version of your circuit, lay out the circuit schematic and then automatically design the artwork for a etched circuitboard. I haven't experienced the latter, because of an autoroute bug in version 0.8 of Fritzing.

I exported the images as SVGs from Fritzing and discovered that WordPress won't allow them to be uploaded because of security issues; presumably the ability to include JavaScript inside a SVG for animation (etc).  So then I exported as PNG, the lossless format.  One of the two images wouldn't upload, but was acceptable to WordPress after scaling down. I started out publishing on the web using notepad and FTP, and look where I am now.

Hardware

Circuit diagram for pedestrian lights controlled by an AVR microcontroller

I've been using an Arduino Mega2560 as the development environment but I'm targeting something smaller for implementation. The code compiles (on the bulky Mega instruction set) to 3.5Kb, so I'm satisfied that as things stand I'm not going to blow any memory budget.

The LED lights all share a single 220 ohm current-limiting resistor, and the call button is pulled low with a 47K ohm resistor to prevent the input pin from floating all over the shop when the button isn't pressed.

You may notice that the video doesn't exactly match the diagram. That's because it's built out of bits and bobs I had lying around. The ~200-ish Ohm resister had leads that wouldn't insert into the breadboard. Thus, alligator clips all over the place.

Software

The light cycle is handled with a state machine; the flashing of lights is effected via state changes. The state machine is triggered by interrupts; the ISRs (Interrupt Service Routines) are lightweight, with the “heavyweight” processing for the state machine occurring in response to changes made in the ISRs. To minimise the processing load in the buttonpress ISR a test has been cached in a variable.  The timer ticks over every half second, giving the state machine a half-second resolution – which seems to match what happens in the real world.

The state machine is initialized into a safe state of having the traffic face a red light, and the pedestrians facing the flashing red man.  That means if the system restarts in the middle of a crossing cycle, no one gets killed.

Although the timer is fired via an interrupt, it won't fire during a delay() so the delay in the main loop is very short.

Although the environment gives an opportunity to develop an OOP solution, their wasn't any clear need for that level of abstraction, and microcontrollers tend to feel the additional cost of indirection. For example, accesses to members of the state were costly in terms of instructions and lead me to consider using multiple single dimension arrays, accessed by pointer.

#include 
//#define DEBUG
/*
Simulate a pedestrian crossing

An Australian pedestrian crossing has three traffic control lights, 
two pedestrian control lights and a light to acknowledge "call requests" 
(i.e. pressing the crossing button).
The traffic control lights cycle red -> green -> amber, solid in all.
The pedestrian control lights cycle red -> green -> flashing red.
The crossing button lights up the call request light, which stays lit
until the pedestrian control light turns green.
Once the traffic control light turns green, it stays that way for some time
before it will yield to a call request.  This is to ensure the road is not
continuously blocked servicing pedestrian crossing needs.

This code responds to two events: the passage of time and the pressing of
the call request button.  Outside of responding to these events the program
has no secondary task.  To optimize the performance of the CPU in its
secondary task, the primary tasks occur in response to interrupts.
*/
// Pin allocation:
const int CallbuttonPin = 2;        // the "I want to cross" button
const int lightCallAcknowledge = 3; // the light that says "you pressed the button"
const int lightGreenMan = 4;        // Pedestrian "walk now"
const int lightRedMan = 5;          // Pedestrian "Do not start walking"
const int lightGreen = 6;          // Traffic go
const int lightAmber = 7;          // Traffic stop if safe
const int lightRed = 8;            // Traffic stop
const int timerPin1 = 9; // lost to timing, can't be used for IO
const int timerPin2 =10; // lost to timing, can't be used for IO
const int onBoardLED = 13;      // on board, can be over-ridden or even cut

typedef struct {
public:
  byte timer_length; // How long to stay in this state (1 tick = 500ms)
  byte action;  // state to set the lights to
  char next_state_on_timer;
  char next_state_on_call_button;
} StateTransition;

const int bitClearCallButton = B00000100; // Clear call acknowledge
const int bitGreenMan =        B10001000; // "walk now"
const int bitRedMan =          B00010000; // "Do not start walking"
const int bitGreen =           B00110000; // Traffic go
const int bitAmber =           B01000000; // Traffic stop if safe
const int bitRed =             B10000000; // Traffic stop
const int maskControlLights = 
            bitGreenMan | bitRedMan | bitGreen | bitAmber | bitRed;

const char NoTransition = -1;
const StateTransition state[] = {
  {8,  bitAmber|bitRedMan,  1, NoTransition},  // Amber and Red Man (4 seconds)
  {4,  bitRed|bitRedMan,    2, NoTransition},  // Red and Red Man (2 seconds)
// Red light lasts for 28 seconds total - 56 ticks
  {21,  bitRed|bitGreenMan|bitClearCallButton,  
                            3, NoTransition},  // Red and Cross
// 7.5 Seconds of flashing red man                            
  {1,  bitRed|bitRedMan,    4, NoTransition},  // Red and Flashing Red Man
  {1,  bitRed,              5, NoTransition},  // Red and Flashing Red Man
  {1,  bitRed|bitRedMan,    6, NoTransition},
  {1,  bitRed,              7, NoTransition},  // 2s
  {1,  bitRed|bitRedMan,    8, NoTransition},
  {1,  bitRed,              9, NoTransition},  // 3s
  {1,  bitRed|bitRedMan,   10, NoTransition},
  {1,  bitRed,             11, NoTransition},  // 4s
  {1,  bitRed|bitRedMan,   12, NoTransition},
  {1,  bitRed,             13, NoTransition},  // 5s
  {1,  bitRed|bitRedMan,   14, NoTransition},
  {1,  bitRed,             15, NoTransition},  // 6s
  {1,  bitRed|bitRedMan,   16, NoTransition},
  {1,  bitRed,             17, NoTransition},  // 7s
  {1,  bitRed|bitRedMan,   18, NoTransition},
  {1,  bitRed,             19, NoTransition},  // 8s
  {9,  bitRed|bitRedMan,   20, NoTransition},  // Red and Red Man
// Allow at least 25.5 seconds of traffic through
  {51, bitGreen|bitRedMan, 21, NoTransition},  // Green and Red Man
  {99, bitGreen|bitRedMan, NoTransition,  0},  // Green and Red Man  // Loop if button pressed
  {1,  bitRed|bitRedMan,    3, 3},  // initial state
};
volatile char current_state = 16;
volatile char next_state = 3;  // Start in a safe state:
volatile byte ticks_remaining = 1;
boolean call_button_disabled = true;

void transition_to_next_state()
{
#ifdef DEBUG
  Serial.print((int)current_state);
  Serial.print(" transitions_to ");
  Serial.println((int)next_state);
#endif
  if (next_state == NoTransition) return;
  current_state = next_state;  
  next_state = NoTransition;

  // turn on the lights as per this state
  byte mask = B00001000;
  byte light=lightGreenMan;
  while (light < = lightRed)
  {
#ifdef DEBUG
    Serial.print("light pin ");
    Serial.print(light);
#endif    
    if (state[current_state].action & mask)
    {
      digitalWrite(light, HIGH);  // turn on the signal
#ifdef DEBUG
      Serial.println(" HIGH");
#endif    
    }
    else
    {
      digitalWrite(light, LOW);  // turn off the signal
#ifdef DEBUG
      Serial.println(" LOW");
#endif    
    }
    light++;
    mask = mask << 1;
  }

  // Turn off the call acknowledge light if that's something we do
  call_button_disabled = state[current_state].action & bitClearCallButton;
  if (call_button_disabled)
  {
#ifdef DEBUG
    Serial.println("CallButtonDisabled()");
#endif    
    digitalWrite(lightCallAcknowledge, LOW);  // turn off the signal
  }

  // start the timer until the next state
  ticks_remaining = state[current_state].timer_length;
}

void timer_tick()
{
  if (--ticks_remaining == 0)
  {
    next_state = state[current_state].next_state_on_timer;
  }
  // See if we can service any existing call
  else if (digitalRead(lightCallAcknowledge))
  {
    next_state = state[current_state].next_state_on_call_button;
  }
}

void call_button_pressed()
{
  // Don't acknowledge if it would be cleared
  if (!call_button_disabled)
  {
    digitalWrite(lightCallAcknowledge, HIGH);  // Acknowledge the request
  }
}

// the setup routine runs once when you press reset:
void setup() {
#ifdef DEBUG
  Serial.begin(9600);
  Serial.println("Traffic light simulation");
#endif    
  pinMode(CallbuttonPin, INPUT);     
  pinMode(lightCallAcknowledge, OUTPUT);     
  pinMode(lightGreenMan, OUTPUT);     
  pinMode(lightRedMan, OUTPUT);     
  pinMode(lightGreen, OUTPUT);     
  pinMode(lightAmber, OUTPUT);     
  pinMode(lightRed, OUTPUT);     
  Timer1.initialize(500000);         // initialize timer1, and set a 1/2 second period
  Timer1.attachInterrupt(timer_tick);  // attaches callback() as a timer overflow interrupt
  attachInterrupt(0, call_button_pressed, CHANGE);
}

// the loop routine runs over and over again forever:
void loop() {
  if (next_state!=NoTransition)
  {
    transition_to_next_state();
  }
  delay(50);
}
zp8497586rq

5V relay module

The module Keyes_SR1y is the KY-019 5V relay module for Arduino (or most anything else really, it’s not as if it plugs straight into the board – you’ve got to connect the pins off to disparate parts of the Arduino board). Relays mostly are used to switch larger loads than opto-isolated switches; they’re generally used in cars or for switching household devices on and off. Large currents are dangerous; you have been warned. This module can switch 250V at 10 amp – at least, that’s what the printing on the box says. The 5 volt part is about the voltage needed to switch the relay. I haven’t measured the current used to switch, but it runs happily off the current supplied by a laptop USB port.

The circuit board marks the 5 volt (+) and ground (-) lines (because of the current draw, these are fed from the power circuitry of the Arduino, rather than the GPIO pins); the remaining line is a digital input; the program code or “sketch” to control it looks something like

const int relayPin=5;
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH);

assuming you’ve hooked the relay up to pin 5. Split the code into the body, setup(), loop() and elsewhere as appropriate.

HIGH energizes the relay (switches it from its normal state), LOW does the opposite (and switches it into its normal state). When it changes state it makes an audible click. On board the module is a red LED that lights up when the relay is energized. The relay has Normally Open (NO) and Normally Closed (NC) circuits, so save some power and use the appropriate one for the normal state, or design for a useful fail-safe state.

This module is one that you’ll find in the various Arduino Module Packs around the place.  One guy has made an attempt to identify and document the lot: http://space.makehackvoid.com/wiki/DxArduinoModulePack

Sony Vegas 10: Out of memory when rendering

We were having issues rendering a reasonably complex but fairly short video using Sony Vegas 10 (32-bit) on a 64-bit machine (Win7 x64) with plenty of RAM and disk space free. After a few seconds each time, the rendering would stop dead with an Out Of Memory error.

I looked around on Google, where various discussion forums came to different conclusions about a fix (including changing the rendering thread and RAM options within Vegas) — and a 4-minute YouTube video claiming also to fix it — honestly, who has the time to watch something like that? — just give me the solution in words I can quickly scan and replicate.

I eventually found this:

I finally found the solution to Vegas giving me memory errors using CFF Explorer… This is what I did.

1) Using “CFF Explorer” I open the original “VegasMovieStudioPE100.exe” file.

2) Now go to “NT Header/File Header” and click “File Header”. There you will find a button labeled “click here”. Click it. And select the checkbox “App can handle> 2GB address space”

3) Now press the “ok”'s and when back on the main menu, click on the disk button and save the modified “.exe” file, overwrite the orginal one. (Note in Vista and 7 you must be running CFF Explorer in Administrator Mode).

Suddenly all my low memory errors were history and have been able to render all my movies with no issues.

Happily, this worked for us too. Hopefully repeating the fix here will help others find it more quickly. Thank you, “Lowlypawn” for posting your solution rather than just posting your problems like many do.

At some stage we'll upgrade to a newer (64-bit) video editing package. But it's nice to know this one can be cranked up to keep going for a bit longer.

It makes me wonder why (a) Sony hasn't issued their own information about this, and (b) something as incredibly useful as CFF Explorer isn't built into Windows.

Click through to read the full post, which includes feedback from Sony from when he contacted them about it.

zp8497586rq

How much memory should you have in your PC? How about 8Mb? #BackToThe90s

Charles Wright, the IT whiz who writes regularly in The Age Green Guide, and has a persistent habit of referring to himself in the plural, reckons in his latest column that you should have eight megabytes in your PC, but soon it'll be practical to have up to sixteen megabytes.

This quarter the price of RAM has jumped about 60 per cent as manufacturers shift the emphasis to production of mobile memory, squeezing supply of PC memory. The 8MB of Kingston RAM that we recommend is now $60, compared with $38 in December.

It's possible to see the future of desktop computing contained in a diminutive box into which the customer can stuff as much as 16MB of RAM and a fast mSATA SSD drive, at prices ranging from $500 to $700.

The Age, 28/3/2013

Wow, don't go overboard on the RAM there Charles.

Charles Wright's column in The Age, 28/3/2013

zp8497586rq

New monitor

Mostly for my own records:

Since one of my two Samsung 940N 19″ monitors (bought in 2006) developed a horizontal line through it, I’ve replaced it with a 23.6″ Philips 247E3LSU2, which was $168 from Officeworks.

Bigger monitors wouldn’t really fit into the space.

It’s plugged into “Calculus”, the Mac Pro. I should get a DVI-D cable to get the best picture quality out of it… amazed at how damn expensive they can be retail. I’ve ordered one from DealExtreme instead (no particular rush – the VGA cable I have may not be optimum, but it works).

Error code L6

If you have an ACS-15 digital scale beeping and flashing error code L6 on the LED display, I think it means “battery undercharged, and I refuse to work until it's better charged. I don't care if you plug me into the mains.”

And now Google knows. I wonder where I put the instructions?

zp8497586rq

Upgrading Netgear Stora without data loss

Despite my expectations, I’ve managed to upgrade our NAS’s storage quickly, easily, and without losing a byte of data.

We have a Netgear Stora as our home NAS. We’ve been butting heads against the storage limit of the box, but I’ve always been careful not to populate the second drive bay; the last upgrade replaced the single 1Tb drive with a single 2TB drive – 2TB was the cost/storage sweetspot. However, a couple of years on and it’s still the sweetspot, the largest drive capacity is only 3TB (I suspect due to the Thailand floods of 2011 - we’ve been stalled at this capacity for a while… which is a little misleading, but I’m not paying $550 for a 4TB drive when I can have 3TB for $150) and it seemed like it was time to exploit the second drive bay.

Researching online shows that the default configuration for a Stora is RAID 1, which is… not the default I’d have chosen. What we want is a JBOD array. I didn’t recall changing the configuration the last time we did an upgrade, so it’s a safe bet that we were still a RAID 1 setup. The documentation is clear that converting from RAID 1 to JBOD or vice versa requires a format of the media, so step 1 was to ensure our backup of the backup was up-to-date; that took overnight to complete, even with the 2TB USB3 drive that we picked up for only $99 from Officeworks (how are they able to sell a drive and enclosure for the same price as a cut-price parts supplier sells the naked drive?)

If anyone can explain why I was getting over 70MB/s to my external USB3 hard drive when I started, and a few hours later when I went to bed I was getting under 30MB/s, I’d love to hear it. It was a steady decline in I/O rate and I’m at a loss to explain it.

Anyway, with the backup completed, and verified, it was time to bite the bullet. For step 2 I powered down the NAS, extracted the existing drive from the NAS and put it aside, took our lying-around-spare 2TB drive and shoved that in its place and then restored power. I fired up the (Windows-based) Stora management software and connected to the Stora and it announced that there was some weird drive mounted, and what storage configuration did I want? Having picked JBOD, it then proceeded to format the drive.

Once the formatting was done, I proceeded to step 3. I powered the Stora down, inserted the original drive in to the previously unused bay (the vertical orientation flipped relative to the other bay, which was surprising) and restored power. I fired up the (Windows-based) Stora management software and connected to the Stora and it announced that there was (again) some weird drive mounted, and what storage configuration did I want? Annoyed that it didn’t remember that I’d already picked JBOD, it then proceeded to format the drive, both as expected (per advice on the Internet) and as it had last time. There was a slow moving progress bar and everything.

Once that was all done, I got ready for step 4: restore the backup. I browsed to the mount, and discovered all the data was already there. Every last byte. The lying bastard of a thing had formatted nothing. The carefully prepared backup was not needed; I spent several long moments stunned, absolutely stunned.  I even ran a few checks to make sure I wasn’t being lied to, that the OS had cunningly cached the directory structure. But it was true; I could play media, read configuration files, the works. Free space was now reported as 2.2TB. I’d suspected there was a chance that this would work (JBOD shouldn’t require any special formatting, unlike RAID 0 and perhaps RAID 1), but still couldn’t believe it.

A technology upgrade worked, and contrary to advertised capabilities. Has this ever happened before?