Machine

13 March, 2015

I have a moment to work on the machine, as the steam pipes that supply my place of employment with power have temporarily been interrupted.

I have succeeded in ordering the brain to move the arm back and forth. My machine moves more smoothly in one direction than in the other – it seems that it is destined to be an awkward, misshapen thing. But it shall serve my purpose, or be destroyed.

Now I must consider the details of what thoughts this brain is to think. I wish to be able to move the arm back and forth on command, and to have the brain move the arm itself when the event occurs.

Of particular importance is that the arm must not move too far, lest it damage the device it is attached to. I believe I need to equip it with the following:

  • An arming switch. When the device is armed, then at the event it will move the arm to its extremity.
  • A pair of buttons, for moving the arm forth and back. Perhaps I may be able to have the brain recognise a press-and-hold to differ from a swift double press.
  • A way to inform the device that the current position of the arm is an extremity that it must not move beyond. Perhaps the pair of buttons may serve this purpose: a switch shall indicate that the pair of buttons is to be treated as an order to move the arm; or that they are to be treated as a setting of the arm’s limits.
  • If the buttons can distinguish between a press-and-hold and a double-press, then a press of both buttons will suffice to indicate where the arm is to be moved to at the occurrence of the event.

In order to make any of this occur, I must first equip the machine with a kinesthetic sense – some way to know where the arm is. I shall resort to a lodestone and magnetic switch located on the middle shaft. The brain shall be prodded as the switch activates in the presence of the lodestone. (Will it interpret this prodding as “pain”? Perhaps. Its suffering is unimportant to me, or to science.)

But how will it know whether the count is to be increased or decreased? There are two ways. Two magnetic switches may be used, slightly offset. But a simpler method is for the counter neurons to be aware of the motor neurons.

So. Two switches, two buttons, and the magnetic switch. And perhaps a temporary switch whose task it is to simulate the occurence of the event to which the creat- the machine shall respond.

volatile byte increment = 0;
volatile int position = 0;

int positionA = 0;
int positionB = 0;
int sunrisePosition = 0;

void reed_switch_interrupt() {
  position += increment;
}

void start_up() {
  increment = 1;
  // start the motor
}

void start_down() {
  increment = -1;
  // start the motor
}

void stop() {
  // stop the motor
  increment = 0;
}

void motorTo(int moveTo) {
  long stop_time = now() + 10000; // 10 sec

  if(moveTo > position) {
     start_up();
     while(now()<stop_time && position<moveTo) {
       sleep(100);
     }
  }
  else if(moveTo < position) {
     start_down();
     while(now()moveTo) {
       sleep(100);
     }
  }

  stop();
}

loop() {
  if(need_to_handle_sunrise()) {
    handle_sunrise();
  }
  if(either_button_pressed()) {
    handle_button_press();
  }
  sleep(250);
}

handle_sunrise() {
  moveTo(sunrisePosition);
}

handle_button_press() {
  // ok. watch A||B. if it goes low during the .5 seconds, note the fact
  // after the .5 seconds is done, look at the state of the buttons.
  // this means that a double click is a click then a click-hold

  sleep(25); // debounce

  boolean doubleClick = false;

  long tt = now() + 500;

  while(now() < tt) {
    doubleClick = doubleClick || !either_button_pressed();
  }

  if(!either_button_pressed()) return; // meh.

  if(set_switch_setting()) {
    if(both_buttons_pressed()) {
      sunrise_position = position;
    }
    else if(button_a_pressed()) {
      positionA = position
    }
    else if(button_b_pressed()) {
      positionB = position
    }
  }
  else {
    if(both_buttons_pressed()) {
      motorTo(sunrisePosition);
    }
    else if(button_a_pressed()) {
      if(double_click) {
        motorTo(positionA);
      }
      else {
        start_up();
        while(button_a_pressed()) sleep(10); // maybe put a timer in here, too
        stop();
        positionA = position;
      }
    }
    else if(button_b_pressed()) {
      if(double_click) {
        motorTo(positionB);
      }
      else {
        start_down();
        while(button_b_pressed()) sleep(10); // maybe put a timer in here, too
        stop();
        positionB = position;
      }
    }
  }
}


Machine

11 March, 2015

I have purchased parts for the Device (Curse it! Why must I part with good money for this! Is it not the 19th century? When, oh when will they install turnstiles on the cemeteries?)

Nevertheless, it has been worth the expense. Now, the heart drives the limbs without difficulty, even with as little as one and one-half voltaic units of electrical Fluid. The final arm turns with enough force that I must give some thought to the possibility that the Device may injure the fitment it is destined to drive. My landlord has been a reasonable soul, and I do not wish to annoy him.

Next, I shall attempt to connect the brain to the body. A difficult matter, as the currents of the mind cannot directly excite the gross matter of the body. I have, again, been to some expense to purchase an H-Bridge. Its principles are simple enough, and although I desired to build such an assembly from more basic components (the better to understand them), the cemetery had been picked clean of the necessary.

If I can succeed in commanding the brain to move the limb forward and back, then I shall have made good progress.

The headaches continue unabated, but I grow accustomed to them. The spots in my vision are no more than a nuisance.


Machine

10 March, 2015

Work on The Device proceeds slowly, in fits and starts. I begin to connect together its limbs and sinews out of scraps of brass and other materials. Its heart I also have, but fear that it may not be sufficient for the task.

I must give it nerves, or rather: one nerve, and one eye. Then, God forgive me, I shall give it a brain.

My lodgings have acquired an odd odour – not entirely unpleasant, and I see movement in the corner of my eye.