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.

A week to go for Google Reader – and… why is Feedly taking liberties with Chrome?

G Reader shuts down in a week.

I’ve been trying Feedly, but and have been trying to love it, but it’s annoying in a couple of significant ways.

Firstly, after clicking on a feed, I want to use the cursor down or Page Down key to move through the items in that feed. Unlike G Reader, Feedly doesn’t put the focus in the right place. Drives me up the wall.

Secondly, it’s embedding itself in multiple places in Chrome. First it put an icon of itself in the bottom-right of every browser tab (which even shows up in print outs, would you believe?)… and just in the last few days it’s started creating its own tab, which doesn’t even have a close icon on it. Is this conceited or what?

Feedly embeds itself into Chrome

Frankly this does not bode well for my future with Feedly, if they’re going to take liberties like this.

Perhaps it’s time to look at alternatives — even if they don’t have accompanying smartphone/iPad apps.

Anybody tried The Old Reader?

Any other good ones which are as close to Google Reader as possible?

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 <TimerOne.h>
//#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);
}

 

"Spaced" DVDs – volume problems

I've been re-watching the DVDs of Simon Pegg/Edgar Wright sitcom Spaced, and noticing that the volume levels go up and down all the time. I didn't remember that being the case from the first time I watched them… which was on a previous DVD player (a Pioneer).

Turns out I'm not the only one to have this problem — those reporting there noted it was an issue on some Toshiba players, but I'm currently using a Sony.

I also have a Panasonic Blu-Ray player I could use, but it's not multi-region, and these discs are Region 2. Damn. And I can't see any easy way of hacking the player to make it multi-region, alas.

That's okay though, because taking a cue from the forum led me to this post about DVD sound problems, and also to a Wikipedia description of Dynamic Range Compression — leading me to think this was causing the issue.

I found this in the DVD player's setup menu. Once I'd switched it from “TV mode” to “standard”, all seemed to be okay again, though in contrast, a newer DVD of Parks & Recreation now seems to have its volume fluctuate, so perhaps I need to switch it back for everything other than Spaced. Odd.

Chrome crashing in OSX – fixed by re-installing

I’m no OS X expert, so I was a bit befuddled to find Google Chrome began crashing on startup a few days ago. Was it some evil Apple plot to lock Google out of the Mac?

Chrome crashing on start up in OSX

All the grisly details from the automated report are below… it's not the most readable of reports.

The fix: What I did was to download Chrome again and re-install. That seems to have fixed it for now.

Continue reading

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

Flooding with water

So, looking at properties, and a number are down on the floodplain near the local moving body of water, a river/creek.  I wonder to myself if the area is at any risk from floodwater; should I even bother looking at the area?

The council, being the government body most connected to the area, ought to know.  It doesn’t; it can’t tell me except to tell me if a specific property has a flood-overlay, which says that modelling has determined that it is at risk of a 1 in 100 year flood.

What is the 1 in 100 year flood event?

The 1 in 100 year flood event is the storm that happens on
average once every one hundred years (or a 1% chance of
occurring in any given year).

Now, that means in any given year there’s a 99% chance you’re not going to get flooded.  In 100 years, that means a 0.99100 or a 36.6% chance of not getting flooded. A 2/3 chance of having water washing through your home at some point there.  Basically, that’s a guarantee that in the next century your home will be damper than normal – because the 1 in 100 year events are calculated off historic data, not forward climate models.  And the forward models say that things are only going to get more extreme; have you noticed how 1 in 100 year events seem to happen to the same place every decade or so?

In fact, pretty much anyone you talk to – water utilities for example – will only talk about 1 in 100 events. Vital government infrastructure (stuff that has to keep operating the event of a flood disaster, like hospitals and my home) has to be above the 1 in 500 line. From what I’m told, they calculate this on a site-by-site basis rather than having a map (they’re not building a bunch of new hospitals, so it’s easier that way).  Sites aren’t rated as being 1 in 110 year, you’re either in the 100 year box or not rated at all.

The gist of what I was able to read into the subtext of the hints being passed in my conversation with a town planner specializing in flooding was: Floodplains get flooded, even in cities, even if there’s a wetlands further upriver that could absorb a sudden influx of water, even if the sides of the creek are quite steep and the channel is surprisingly broad, and even if there are barricades; If you don’t like that, don’t live there.

So I won’t.  It makes searching for a home so much easier, even if the homes out of the floodplain are more expensive and built on those annoyingly sloped hill things.

Actually, this reminds me of the 1972 Elizabeth St Floods my Mum told me about getting caught in. I would never have guessed a major street in our CBD could turn into a river – and then it happened again in 2010.

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.

Subtitling now in the Suez

I imagine that Jacqui Mapoon from CSI (Captioning and Subtitling Australia… or International) is someone who helps them out very occasionally, judging by the quality of her work on The Doctor Blake Mysteries: Season 1, Episode 9 “All That Glitters” –  atrocious work.  The gaff that stood out most was the transcription of sewers, but there were so many problems.

Don’t these subtitling services get given the script?  There’s a job listed in the credits as “Post production scripts”, surely they’re able to hand the script over electronically, and it’s just a matter of timing, pagination and confirmation – no transcription, no transcription errors?  I doubt Tim Pye – the writer of the episode – would have got that wrong, nor made the other homophonic errors.