Introduction: Electro Mechanical Control of Hidden Bookcase Doors
Here I will describe my first Arduino project that I designed and built to automatically open and close two hidden bookcase doors that I build two years ago. To understand the choices used in this design you should first visit the instructable that documents that project.
Step 1: Design Criteria
Reliable, fully automatic open and close mechanism for both door hinges/sliders
Outside open switch should be hidden.
Inside manual switches to open/close doors
- Automatically close doors if no motion in room for 2 hours
- Low electric power use when in standby
- Emergency ingress/egress in case if power/arduino failure
- Pinch free if person or object is between closing doors
Step 2: Electrical and Mechanical Choices
After my first attempt to move the doors using stepper motors (too embarrassing to describe here), I choose to use 4 Progressive Automations PA-14 linear actuators. I found that 8 inch travel could be used for both the hinged movement and slide movement. I choose 50lb force versions that would allow the doors to fully open or close within an acceptable 10 seconds, but wouldn't go too fast and shake the contents in the bookcases.
These linear actuators (I'll refer to them as motors) contain built-in end stops so I didn't need to use any feedback circuits to the Arduino.
These motors were driven by a MultiMoto Arduino Shield. This can independently drive 4 12V high current DC motors forward or backward at variable speeds. This was important since I found out that under load some of the motors would open or close at slightly different speeds. I needed to compensate by slowing down the faster motors empirically until the 2 doors operated at the same speed.
The Arduino chosen was a genuine Uno (instead of a Mega) since I already had one. This proved to be a challenge since the MultiMoto shield used most of the pins for its own interface and I had to be clever to get my own input/outputs into the Arduino. I used the 5v standby voltage from the ATX power supply to power the Arduino, but had to wire this directly into the USB interface since the Arduino Vin needed to be above 7v.
Finally, the Arduino would receive the 3 switch inputs and upon activation, would ground the ATX power on pin which would power up and provide the full 12V high current needed for the MultiMoto board to send to the 4 motors.
All the hardware is mounted on a convenient shelf 5 ft off the ground.
Step 3: Secret DVD Switch for Opening Doors
The door is built from 3/4" maple plywood and didn't really want to drill a hole through it. I tested and decided to use a magnetic reed switch attached to the inside of the door and used a high power 1" neodymium magnet taped to the inside of a DVD case. The reed switch I already had was normally closed (NC) and placing the DVD fully on the shelf would make the switch go open. Either NO or NC switch could have been used here.
The Arduino code would require the DVD to be tilted away then reinserted before it would start the open sequence.
Step 4: Arduino Interfaces
In additon to the Multimoto shield (which only requires 12v, ground and the 8 motor pins), I needed these inputs
2 manual inside switch inputs
1 outside switch input
1 PIR sensor (would go low if motion detected so needed this on an interrupt)
I also needed these as ouputs:
5v to power the PIR sensor
gnd for switches, PIR sensor
ATX pwr_on (gnd turns on)
However only pins 0,1, A4,A5 were unused by the Multimoto.
I initially wanted the PIR sensor on one of the native interrupt pins, but couldn't as the Multimoto used these. After talking with the very helpful techs at Progressive Automation and RobotPower, I wired the PIR sensor to the A5 input and used what is known as "Pin change interrupts" to trigger on a low pulse. A global counter is incremented every second if no PIR motion is detected . After 2 hours the door would start a door close sequence. If motion was detected, the count is reset to 0.
Pin A4 was wired as an output to the ATX pwr_on pin using an ATX power extension cable. This cable allows me to easily change the power supply without cutting/re-soldering if it fails in the future.
The reed door open switch was wired to Arduino pin 0. However this pin is also responsible to communicating on the USB port, so I needed to unplug this cable anytime I uploaded new code.
This still left the 2 manual open/close switches. The Arduino would communicate to the Multimoto shield at setup using the SPI bus. After setup, these pins were not used, so I piggybacked the open/close on pin 11 (MOSI) and 12 (MISO). These pins are duplicated conveniently on the Arduino 6 pin ICSP header at the bottom of the board (as well as 5v and gnd). This requires neither of the two pins to be pressed in the first few seconds of powering up the system.
Step 5: Linear Actuator Mounts
After trial and error, I found the mounting spots where the 4 motors could fully close and fully open at their end stops. See these 2 videos for the open and close sequences. The sequences start the motors around half speed and quickly ramp to full speed to reduce mechanical stresses. The door motor mounts on the right side door are a mirror image of the left door.
Step 6: Hinge Motor Mounts
I had to drill holes (at 90 degress) in the 2 motors responsible for pulling/pushing the doors on the hinge. This would allow the heavy motor to hang below the linear actuator to reduce stress and allow a smaller profile. This was necessary since there is only about 3" clearance for the right door when opened.
Step 7: Emergency Features
I originally mounted the door slider motors directly to the wood with a bolt. I one of my more clever moments, I changed this mount to use 2 very strong hard drive head magnets. This allows me to force the two slides apart to allow emergency egress (ie: power failure, fire, etc) and ingress if any part of the Arduino control failed. The magnets hold firmly during the open or close sequence but manually slide apart easily if necessary.
.A side benefit is you don't have 50 lbs of force squeezing together if you get a finger/arm stuck during the close sequence.
One other safety feature is the Arduino code will power up assuming the doors are in a closed state. That way it will always allow the door to be opened from the outside DVD switch even after a power failure.
My code is shown here. The interesting stuff is in subroutines door_close_seq() and door_open_seq()
I hope you enjoyed this project!