Level sensor

A project log for Happy Vertical People Transporter

Douglas Adams envisioned a Happy Vertical People Transporter as opposed to the mundane every day elevators

digigramDigiGram 04/28/2014 at 02:400 Comments

What started out as a simple idea turned into some head scratching. I did not want to order any parts for this build, so IR and ultrasonic sensors were out of the question. I decided to use a resistor ladder to determine the current lift (elevator) level, as shortly described by [Lolla] in the build log: build.

Since the resistor contacts are at the low side of each level, I will have to determine three cases.

1) If no level is detected, assume the lift is between levels and report the previous value

2) If the lift is moving downwards, move until the correct level.

3) If the lift is moving upwards, move until the correct level, then move until the level changes, then move slightly down again.

This is not ideal, and if we had the time, I would have changed the layout, but I'm back in West Africa for work, so had to finalise everything sooner.

ADC values were calculated for the different floors, and then approximated experimentally:

Calculated | Experimental

0: 682.7 | 670

1: 819.2 | 803

2: 877.7 | 860

Ranges were defined around these values to catch slight off readings as well.

Code looks something like this:

    currentFloorRes = analogRead(levelPin);
    if (currentFloorRes > 640 && currentFloorRes < 735){
      currentFloor = 0;
    else if (currentFloorRes > 735 && currentFloorRes < 830){
      currentFloor = 1;
    else if (currentFloorRes > 830 && currentFloorRes < 900){
      currentFloor = 2;
    else { currentFloor = 0;}
    floorDisplay(currentFloor, destFloor);