Mac with Windows

I have been experimenting with the best way of having both Windows and MAC.  Linux is great for servers – but you dont need it for apps.  I’ve got Lion on a 27 Inch iMac.  So I loads up Oracle VirtualBox.  Its like VMWare except its free and its amazing.  So within maybe 1/2 hour I got Windows 7 running in a seamless mode – which means I really do have the best of both.  I need Mac for development and xcode – but I can also run the Windows sessions on Visual Studio – works like a charm.

https://www.virtualbox.org/ – you can get the Mac version here.  It’s really very easy to set up.

I am going to get a 4Gb upgrade for starters – I put Windows 64 bit on as well – so it makes sense to have a bit more.  But you can’t do two things at once so VB seems to allow you to reallocate.  I really like the seamless mode – just works together very nicely.

 

 

Advertisements

Arduino – Pond Filler Upper

I have this little pond see.  Its not terribly big and it looks quite nice – but it has a small leak somewhere.  And its driving me nuts. So in a moment of geekery I thought the problem could be solved with a bit of software and an Arduino board.  So I concocted a small plan to keep the pond topped up.  Nothing too complex – just used a water level sensor and a solenoid driven water valve.  I also used the excellent Ciseco relay for Arduino. Simple and elegant.  Some pics here of the installation.  It’s really just a prototype – if it works I’ll put a more rugged version together.

Parts List

  • Arduino Duemilove
  • Hose Solenoid ( This is one from Ebay ) Its 12v
  • Tank Sensor ( Again from Ebay )
  • Ciseco Relay 
  • Wires of various kinds
  • Project Box
  • Switches
  • LED
  • Resistors – 10k, 1k – switch controls
  • 12-9V Regulator – I used this with a Capacitor so I can drive everything off a 12v DV PSU
  • 12V DC PSU

This is the Sketch to control the board

The sketch is rather simple and a bit clumsy.  I used the timerone library.  It works by trying to detect if the water has been running for more than WATERTIMEOUT.  If it does it waits for WAITIME. If it does that more than SYSTEMJAMED times – then the system switches off.  This should protect it if the sensor jams open.  I reckoned 1 minute at my water pressure was enough to fix the leak.

Still got to check if the sensor bounces for a few seconds but so far it works quite well.

#include <TimerOne.h>

/*
 *  Pond Relay
 *  August 2011 (c) Dave Robertson
 *	Arduino based pond relay with CISECO relay http://www.ciseco.co.uk/content/
 */

#define SYSTEMJAMMED 10      // Number of times the system starts a wait look
#define WATERTIMEOUT 60    // Number of seconds to run the sensor
#define WAITTIME 60    // Number of seconds to wait until running again
// constants won't change. They're used here to
// set pin numbers:
const int sensorPin = 2;     // the water sensor switch
const int switch1Pin = 3;     // control switch 1 - Manual Override
const int switch2Pin = 5;     // control switch 2
const int ledPin =  13;      // the number of the LED pin ( ardunio diag only )
const int relayPin =  7;      // the number of the relay pin that controls the valve

long timerRunning;        // Number of seconds since we started
long waterrunningTimer = 0;
long waitingTimer=0;
const int ledStatus =  4;      // the number of the LED pin

int systemJammed=0;        // The system is jammed so switch it off
int overrideSystem=0;      // Override the system and shut off the valve regardless

int s1State = 0;         // variable for reading the pushbutton status
int s2State = 0;         // variable for reading the pushbutton status
int sensorState = 0;         // variable for reading the pushbutton status
int oldsensorState = 0;         // variable for reading the pushbutton status
int ledFlash =0;
int beginwait=0;    // Controls waiting for next

void setup()
{
  pinMode(10, OUTPUT);
  Timer1.initialize(1000000);         // initialize timer1, and set a 1/2 second period

  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt

  pinMode(ledPin, OUTPUT);
    pinMode(ledStatus, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(switch1Pin, INPUT);
  pinMode(switch2Pin, INPUT);
  pinMode(sensorPin, INPUT);

  pinMode(relayPin, OUTPUT);

  digitalWrite(relayPin, HIGH);
  delay(2);
    digitalWrite(relayPin, LOW);
  Serial.begin(9600);
  Serial.println("Starting Now 5 Second Delay");

  // Flash to indicate we starting up

  for (int i=0;i<100;i++)  {
        delay(50);
        digitalWrite(ledStatus, digitalRead(ledStatus) ^ 1);
  }
    Serial.println("Entering loop");
}


//
//  Timer call back here - update timers and LED for status
//
void callback()
{

  // Flash the led to show valve is on

    Serial.println(s1State);
    Serial.println(s2State);


  if (systemJammed>SYSTEMJAMMED) {

    Serial.println("System Jammed - all off");

    for(int i=0;i<10;i++) {
      digitalWrite(ledStatus, digitalRead(ledStatus) ^ 1);
      delay(1000);

    }
    return;
  }

//   if (ledFlash)
//      digitalWrite(ledStatus, LOW);
//   else
//      digitalWrite(ledStatus, HIGH);

    if (sensorState && !beginwait) {
       waterrunningTimer+=1;
       Serial.print("Water is running now for secs: ");
       Serial.println(waterrunningTimer);

    }

    timerRunning += 1;
    // We rest after 24 hours as this a fine time window for what we want
    if (timerRunning == 5184000) {
      timerRunning = 0;
      waterrunningTimer = 0;
      Serial.println("Time now");
    }

    // Increment the waiting timer
    if (beginwait) {
      digitalWrite(ledStatus, digitalRead(ledStatus) ^ 1);

      Serial.println("Water ran too long - switched off waiting");
      waitingTimer++;
    }
}

void loop()
{


  // Get the state of water sensor  and switches
  sensorState = digitalRead(sensorPin)^1;
  s1State = digitalRead(switch1Pin)^1;
  s2State = digitalRead(switch2Pin)^1;

  if (s2State == HIGH) {
   // System off - no action
    digitalWrite(ledPin, LOW);
    digitalWrite(relayPin, LOW);
    waterrunningTimer=0;
    digitalWrite(ledStatus, LOW);
    oldsensorState = LOW;
    waitingTimer=0;
    beginwait=0;
    systemJammed=0;  // Reset jammed sensor counter

    //Timer1.stop();
    return;
  }
    else {
    //  Timer1.start();

    }

  if (s1State == HIGH) {
    // Override sensors and reset everything
    if ( oldsensorState == LOW)
    {
       waterrunningTimer = 0;
       oldsensorState = HIGH;
    }
    //digitalWrite(ledStatus, LOW);
    digitalWrite(ledPin, HIGH);
    digitalWrite(relayPin, HIGH);
    digitalWrite(ledStatus, HIGH);
    systemJammed=0;
    return;
   }

  if (systemJammed >  SYSTEMJAMMED)
     return;


  if (sensorState == LOW ) {  // Clear everything as water has filled
    // Sensor has read water filled
    digitalWrite(ledPin, LOW);
    digitalWrite(relayPin, LOW);
    waterrunningTimer=0;
    digitalWrite(ledStatus, LOW);
    oldsensorState = LOW;
    waitingTimer=0;
    beginwait=0;
    systemJammed=0;  // Reset jammed sensor counter
  }


  if (waterrunningTimer > WATERTIMEOUT ) {
      // Water has been running for over  a minute and the sensor is still high

    sensorState=LOW;    // Switch it off
    digitalWrite(ledPin, LOW);
    digitalWrite(relayPin, LOW);
    digitalWrite(ledStatus, LOW);

    oldsensorState = LOW;
    if (!beginwait) {
          Serial.println("Water running too long");
          waitingTimer=0;
          beginwait=1;
          systemJammed++;
      }


  }

  if (beginwait && waitingTimer>WAITTIME){

    Serial.println("Timeout - switching off");
    beginwait=0;
    waitingTimer=0;
    waterrunningTimer=0;

  }


    // The sensor state read

  if (sensorState == HIGH ) {

    if ( oldsensorState == LOW)
    {
       waterrunningTimer = 0;
       oldsensorState = HIGH;

    }
    //digitalWrite(ledStatus, LOW);

    digitalWrite(ledPin, HIGH);
    digitalWrite(relayPin, HIGH);
    digitalWrite(ledStatus, HIGH);

  }

}

CMIS

Content Management Interoperability System.

Had a quick look at this for a client last week.  Managed to get it working with Documentum from .NET clients – a bit slow but it does work.

I used the DotNET client from openCMIS – Apache Chemistry. http://incubator.apache.org/projects/chemistry.html

DotCMIS is the best thing I found – although I really struggled to get web services working with Documemtum – so I used the AtomPub binding and the session factory.- that seemed to work reasonably well.

 

 

 

 

 

openVMS

I must be mad – going back in a timewarp to my first job – programming on a DEC PDP 11/34

So anyway I needed to do a DCL script for openVMS – which is still alive apparently.  So using FreeAXP and openVMS – I managed to get a VMS session up again.

Why people think VMS is good in the world of Unix and Windows is beyond me.  Navigating around the filesystem is just plain confusing.  But I was able to boot it up and get it working – so all credit to those folks at FreeAXP – works fine for me.

SO I’m writing DCL again…

Maybe I’m in dreamland…

 

 

 

 

 

 

 

 

Arduino and LadyAda Wave Shield

I’ve been messing around with my fantastic Arduino board.  The whole Arduino thing is without question an Italian masterpiece of our generation.  I could spend 24 hours a day just messing with it.  The software side is as elegant as the hardware side – the idea you can add C++ and Java libs is stunningly brilliant.

Anyways – I wanted to do something with it – and I decided I wanted to build a simple SFX box for my little rock band.  We use sequencers and MIDI – but I wanted to do AC/DC’s For those about to rock.  The song has some nice cannon fire effects and this really has to be in the mix for a live performance.  So I thought that if the Arduino can be used.  I’ll be doing a more complex project later using Arduino to drive MIDI for live performance.

So I bought a kit for a the Wave Shield from AdaFruit – very very good business that – and sampled some effects.  I then put together a new app based on  the supplied player code on the AdaFruit site – hooked up a couple of footswitches on the Arduino and thats it – super fast special effects in WAV format – for the AC/DC song – some nice real cannon fires.  Hook it all up to the PA and boom.. nice.

This is the Arduino with a Wave Shield all hooked up in test

Footswitch found in dump… RS good quality – works well on stage

Buy the Arduino at RS Components and get the Wave Shield and info at www.adafruit.com/waveshield.  Get the footswitch at your local tip/dump/junkyard/scrapyard

Afternoon Tea – A Review

I’m not a theatre critic as you can probably tell but I do like the theatre. An so it was that I went to see a play in Manchester City centre on Saturday evening.

Afternoon Tea, a short play written by Lindsay Kernighan was performed at the Taurus Bar in Canal Street in Manchester. The basement of the bar had been transformed into a small 50 seater theatre – an intimate setting for  a uniquely intimate play.

On descending to the basement theatre – we were met with a tea room setting. Walking past the actors – you immediately had a sense of attention to detail that would make this short play interesting. As the actors nibbled on their cakes – my appetite for a good performance was whetted.

I was not disappointed. This was the last of 4 performances and it was clear that the actors and the director had established themselves and were comfortable in the setting and their roles. The writing was sharp and observational and at the same time had a touch of surrealism – like Father Ted without the priests – Mrs Doyle would not have been out of place serving her tea sandwiches and goading with a few go-ons

For me – the main thrust of the story was the young girl /old guy couple – struggling to find common ground and although the plot thread was clichéd to an extent – it was well performed and believable. The other couple – a two well heeled ladies of lunches who have a good old gossip – was nicely interwoven. I particularly liked the character of the “old guy” – William – whom having managed to catch himself a 25-years-younger female was aptly demonstrating that he was not satisfied by admiring himself having caught the eye of a presumably even younger checkout assistant in Tesco… You knew this would end with a soaking!

The performance of the ladies was engaging as it was funny. Clearly the actors were comfortable and the banter and the gestures led to a sharp and comical interpretation of the roles. “Making a dozen sweaters out of her mop” – nicely delivered.

The story was lightweigth – I didnt lose any sleep  – but it wasnt meant to change hearts – only make sure you’d enjoyed your visit.  I did.

The 35 minutes went by far too quickly and for me and the rest of the audience enjoyable. I’d go back again and I ended up staying in the bar for some food and some nicely poured Leffe Blond. As an evening – well it was memorable, enjoyable and I’d recommend them went they go back to the Buxton Fringe..