Due to unreliability of my IKEA SmartDesk, which I built in 2015, I decided to make an upgrade, that greatly improved its usability!

I removed the original magnetic limit-switch and replaced it with ultrasonic PING-sensor that could measure the actual height from the floor.

Hardware

Ultrasonic PING-sensor

In this project I used a cheap ultrasonic PING-sensor that cost just couple of euros. This device acts as a range-finder, measuring distances between objects from 3 cm to 300 cm.

When measuring, the sensor emits an inaudible 40kHz chirp and starts listening for the echo. Distance can be calculated from the time it takes for the sound to travel back!

Range-finder mounted to the bottom of the desk

Range-finder mounted to the bottom of the desk

For ease of installation the sensor was mounted in a small project-box with mounting flanges. Just needed to drill couple of holes and solder in some 4-pin cable salvaged from old printer cable.

Ping-sensor itself has 4 wires: ground, 5V supply voltage, Trigger and Echo.

Controller

Controller-unit of the desk connects to the computer, receives instructions like “set the desk to 86 cm”, uses the ping-sensor to measure the height from floor and then control the motors accordingly.

At this point I had decided to make something more permanent so I relieved the Arduino Uno from it’s duties and modified the old Proto Shield that has the relays to take in something more appropriate, Arduino Nano.

Basically same functionality but in a smaller package.

Relay shield with Arduino Nano soldered in

Relay shield with Arduino Nano soldered in

You can read the distance to what’s in front of the sensor by sending it a standard length pulse via trigger-cable, then you get a response pulse from the Echo-wire. Distance between those pulses is proportional to the distance the sound has traveled in the air and you can use that delay to easily calculate the distance with Arduino. My setup is good for about 1 cm precision.

Controls under the desk

Control-switches under the desk

On the bottom edge of the desk is the away-switch which turns off displays and speakers by cutting the mains voltage going in (modified extension cord) and the original IKEA Bekant electrical desk controller which houses the control electronics and membrane-switches to control the mechanics. Arduino just virtually pushes these buttons via relays.

Software

This is a major upgrade to the system and requires quite a bit of new code to work. There had to be changes to the firmware and the controlling software.

I wont go into much detail here, you can get the source-code as usual from my Dropbox.

Arduino

For the sensor to work, software needs a way of asking it the distance so it can make decisions what to do.

Reading PING sensor with Arduino

Reading the PING sensor

Flowcode comes with it’s own libraries to deal with most generic PING-sensors but they for some reason did not work for me so had to make them from scratch.

To determine the distance, system makes 3 measurements with 60 milliseconds in between to allow the unwanted ultrasonic echos to dissipate. These measurements are then averaged together and calculated to centimeters which the software can then use.

After receiving a command to move, the software goes in a loop:

  1. Arduino: “Are we there yet?”
  2. Sensor: “Distance is X
  3. Arduino: “I keep pushing button”

After the desired height has been reached, loop breaks and the system returns to an empty loop, listening to input from the computer.

UpButt’n

New version of control software was needed for the new controller so it can handle the more analog height adjustment.

New version of UpButt'n

New version of UpButt’n has height display

It has height display, slider on the right to make finer adjustments to the desk height and few useful presets.

Microwork is excellent for soldering and what not while Storage raises the table enough for the chair to fit underneath.

I removed the timers, they turned out to be more annoyting than useful, easy access to the UP-button was way more effective than “being soft-forced to stand up”.

Keyboard shortcut

Two other exe-files were compiled, called up and down, with lazy hard-coded height values.

I set them behind function key as shortcuts so with a flick of a wrist I can set the table to proper standing or sitting height without looking up any programs and menus.

Keyboard shortcut to raise and lower the desk.

Keyboard in the picture is Corsair STRAFE RGB, mechanical gaming keyboard.

Video

Conclusion

I recently moved, so I had to take apart my workstation.
I was without this computer connected control-system for few months and I stood up once.
Just the system being there and being effortless to use makes a huge diffrence in one’s habits!

Verdict
  1. Don’t place garbage can accidentally under the sensor
  2. Learn to not hard-code all variables
  3. Do it properly the first time
Difficulty ★★★☆☆
Time ★★★☆☆
Price ★★★★☆

Documentation

Software and Source-files »

Creative Commons -lisenssi
UpButt’n & SmartDesk, writtend and designed by Henri Rantanen, are licensed under Creative Commons Attribution-ShareAlike 4.0 International.

Share this article
Share on FacebookShare on LinkedInTweet about this on TwitterShare on VKEmail this to someoneShare on Google+Share on StumbleUponShare on RedditPin on Pinterest