This project exists because everyone deserves a good nights sleep!
For some handicapped people who are not able to move much whilst asleep, it can be frustrating and uncomfortable to be in a single position all night long. There are some air mattress solutions that vary the pressure points of an immobile person in bed, but not many "devices" that can actually move someone whilst in bed.
The needs of a handicapped person can be very individual. In this case, the need was to move someone between lying on their back to being around 35 degrees on one side automatically. Therefore, be ready to adapt to your situation !
Safety First : Moving someone automatically has the potential to cause injury to the person being moved, and also to someone operating the system. Therefore, it is necessary to consider safety, and "what if" scenarios at each stage of design. It is for this reason that this instructable will primarily deal with the principle of operation, and the control system, and be slightly vague about the detailed mechanical design. In this case, the system was designed for a lightweight teenager (<40 kg). The precise mechanical arrangement used might not be suitable for adults and may need redesigning depending on the weight of the rider !
Description of the Motorized Bed Function
The motorized bed is based on a medicalized bed made from a welded steel frame.
- The mattress support is hinged in the middle (long ways) and can be held in this position using chains.
- The mattress is held onto the mattress support with wire loops.
- The folded mattress support+mattress can be rotated around the centreline of the bed by approx. 35 deg.
- A 12v dc actuator is used to rotate the folded mattress support around the bed centreline.
- The 12v dc actuator is controlled using an Arduino UNO board, driving a generic dc motor drive board.
- An InfraRed (IR) proximity sensor is used to detect correct movement of the bed, and shutoff power to the actuator in the event of a fault being detected.
Step 1: Mechanical Alterations to the Bed
First of all, ensure that any existing bed motor lifting the head (pillow end) of the bed is removed or disconnected. That function is incompatible with this project !
You will need to decide how far you want to turn the mattress support. Around 35 Degrees was sufficient in this case, and seems reasonable. You need to consider that the person should not be rolled enough that there is a risk of being rolled out of the bed !
The mattress support has to be able to fold longways. We used 12mm thick pine board,hinged in the middle by a piano hinge for this. A foam mattress is wired onto the mattress support, it is not shown in the photographs for clarity, but note you may have to "adjust" the mattress with a sharp knife so it can be folded more easily.
The hinged mattress support has to be able to rotate around the longways centreline of the bed. We did this using 4 steel hinges welded onto to a square steel rod welded onto the bed.
Safety : Since the persons weight and the mattress support are held onto the bed by these 4 hinges, the fixation of hinges and the rod has to be able to comfortably take that combined load and more besides. You should test and design with the weight of a simulated person to ensure the strength is adequate.
The mattress support is held in the working "V" position (around 160 degrees) by a chain at each end of the bed connected to heavy steel brackets attached to the mattress support halves. In our case we added additional bracing on the mattress support to make the mattress support as rigid as possible.
The actuator is connected to the mattress support at one end, and the bed structure at the other.
We mounted the actuator under the bed on a steel rail welded onto the bed structure. Again, make sure metal rail can take the load of the person + a bit more.
Safety : The actuator installation position must ensure that at the fully closed position, the mattress support is horizontal, and at fully extended position, the folded mattress support is tilted to the maximum desired position. This ensures that the actuator cannot drive the mattress support past its range of movement.
Step 2: Actuator Control
Functions of the Control Box
Allows you to select via a momentary switch, actuator extend (up) or actuator retract (down). This allows the bed to be positioned as required. This is needed to return the mattress support to the actuator fully retracted position without waiting for the programme to do it in the morning when the person wakes up. It is also particularly useful during testing of the bed. You will want to test this bed before use !
The actuator movement follows a programme. This has been determined by trial and error and will vary for each individual. We do the following;
(1) Start with the actuator fully retracted. This is the datum position.
(2) Drive actuator UP to position bed to fully rotated position.
(3) Wait 45 Minutes
(4) Drive actuator fully back down to the starting position.
(5) Wait 15 Minutes
In addition, a switch labelled DWELL on the control box panel can select a variation to the above sequence. When DWELL is pressed (latching switch), the actuator waits at the actuator halfway extended position for 15 minutes between steps 2 ,3 and also 3 ,4 above.
In Automatic mode only, an infra red proximity sensor adjacent to the underside of the mattress support checks whether the mattress support is in the starting position or not. If the mattress support is not flat (actuator fully retracted) then a fault is registered. Once the actuator has been commanded to extend and after a few seconds, the sensor is checked to see that the mattress support is NOT adjacent to the sensor anymore. If it is, then a fault is registered. This fault detection is done on every loop of the programme.
When a fault is registered, a relay cuts (automatic mode) power to the actuator. A fault may indicate some kind of mechanical issue with the actuator or other issue.
Note: There are many possible variations to this fault detection. We originally envisaged to have 2 sensors detecting both the fully retracted and fully extended actuator positions. Finally, we decided it was better to keep such fault detection as simple as possible to reduce spurious fault detection.
Step 3: Control Box Hardware and Construction
An Arduino UNO board is used as the brain of this system. Everything is powered from a 3A 12vdc power supply (which is actually an old external hard drive power supply).
The UNO board is fully capable of running the necessary relays, completely for this project, but we decided against this. We use the UNO to do the 45 and 15 minute timing, and check the proximity sensor, then drive a shutoff relay if a fault is detected, but the actuator itself is driven by a dedicated DC motor delay reversing drive board.
Why would we do this crazy thing ?
By using the UNO to trigger a programmable delay motor drive board, the basic program timing, and length of time that the actuator is driven, are separated. The exact actuator driving time can be tweeked easily without having to re-programme the UNO.
This is important because the actuator position is only determined by the length of time that the actuator is driven. During testing you will see that the actuator drive time needs to be adjusted slightly depending on the load on the bed. The actuator drive time can be tweaked at 0.1 second accuracy easily via push buttons on the motor drive board. This is way easier than reprogramming the UNO for each minor adjustment.
Manual mode is achieved purely by switches and wiring. We found it necessary to disconnect the automatic motor drive output during manual operation because the motor drive board shorts out the motor supply when not powered :(
Safety : A 2A fuse is used to protect the actuator output from electrical overload.
Notes about components used
Actuator : This is a standard 12vdc 100mm extension actuator, rated for 750N force. It moves at 10mm/second which is about as fast as you want. You may need something stronger and slower. Usefully, such actuators have internal limit switches so you don't have to worry about driving the motor past the end of travel for a few seconds. By the way, try and buy an actuator that is described as being low noise !!!
Sensor : This is a cheap 3 to 5v, 3 wire, IR adjustable proximity sensor from EBAY. It can be connected to an Arduino UNO digital input to give a high/low signal when adjacent to a hard object. Power supply comes from the UNO board.
Motor Drive Board : The board has logic inputs (GND is the trigger) one for each motor direction. The UNO triggers these inputs. When an input is triggered, the board applies power to drive the actuator motor in either direction (depending on which input was triggered) for a pre-programmed time period (selectable 99 to 0.1 seconds). This time period is memorized by the board. It is powered directly from the 12vdc supply.
List of Main Components for the Control Box
Arduino (the brain) : Mounted in the box so that the USB connector is still accessible (for re-programming !)
12v relay board (Manual relay)
5v relay board (Fault/shutoff relay)
DC 12v Digital LED 3v-14v Motor Reversible Module Programmable Relay Control PLC (from EBAY).
Re-setting 2 A fuse (to protect against actuator overload faults)
DPDT toggle switch (OFF/Man/Auto selector)
DPDT momentary toggle switch (Manual mode control)
Latching pushbutton switch (to select extra dwell programme)
Handful of LED indicators (useful to have on the control panel for troubleshooting, but not essential)
Step 4: Software
Ok, so I am not really brilliant at Arduino programming. I have used the dreaded DELAY command instead of an interrupt based timing loop. Guilty, but it works.
There are a few ways that the attached code could be improved, and maybe I will sometime, but for now it works as is.
Fault Detection : In the software, we check for fault conditions at various times and if true, set a variable to TRUE. This variable is then used to energise the shutoff relay and the panel fault indicator (LED). In the software there is no way to recover from the fault except to reset the Arduino UNO board. This is deliberate. We don't need or want any way to recover actuator movement after a fault has been detected. If a fault has been detected, then you have to use manual mode to put the actuator/mattress support back into the "datum" position before re-engaging automatic mode. If you look at the schematic you will see that selecting manual mode removes power from the Arduino UNO and therefore it is reset automatically during this "recovery" operation. Obviously, you need to check the bed over for mechanical problems before restarting after a fault has been detected. You may get some spurious faults if the IR sensor is not well adjusted.
Self Test : During the set-up routine, the fault relay and indicator are energized and then the actuator is given an extend signal. Then the sensor is checked to see that the mattress support has not moved up. After a few seconds the fault relay and indicator are then turned off. This is a self test done everytime the Arduino board resets. If the fault relay fails, then the actuator will be driven during the test, and by reference to the sensor, a fault is detected.
We use a relay on the automatic supply to the actuator to shutoff the actuator, because this also protects against some wiring failures and also some failures on the motor drive board itself that could cause spurious actuator drive signals.
Step 5: Testing
You will need to test this bed for mechanical robustness. Is it strong enough ? You need to make sure that the mattress support can move unimpeded because the actuator is powerful and can bend and break anything that gets in it's way.
You will also have to check that you have mounted and adjusted the sensor correctly.
Testing should be done with load on the bed to simulate the intended rider. This will allow you to tweak the actuator run time as needed. Interestingly, while testing under load, I found that the actuator was a little faster to extend than to retract. This meant that I could not guarantee that it would come back exactly to the "datum" (fully retracted position). This could conceivably cause the "datum position" to drift upwards during the night which could cause problems with the fault detection logic, and also affect the intended range of movement. Fortunately the solution was easy!! After the actuator has been commanded to go to the fully retracted position, I added an additional retract command. This will then ensure the actuator is really in fully retracted position. As previously mentioned, it does not harm the actuator to try and drive it past its range because of the internal limit switches in the actuator :)
Sweet Dreams !