TheLAMPA – remote controlled, adjustable workbench lamp - Page 1
Forum section: electronics / projects

author: ljwinkler
author_rank: Unknown
timestamp: August 21, 2014, 07:35:47 pm
content: The following post is the first part of a series about my most recent project I’m working on, TheLAMPA. I hope you will like it.As this is a live project I will be writing new posts along with the progress I make.I will share my considerations, failures, difficulties, etc. If you have any suggestions, advices (good or bad) or simply want to help - please leave a comment. Thank you!Ok, here we goI have bought a lamp in IKEA recently:Husvik Pendant LampThe lamp is sort of a billiard-lamp shape type. The central part (aluminium H-shaped profile, 80x6x2cm) holds a fluorescent bulb. Then, it has 10cm wide aluminium ‘strap’ running around as a shade.Ok, it may be quicker to draw it in a MS PaintPlease see attached image. This is a top view (the fluorescent tube sits in the middle rectangular part).This is what I would like to do:- leave the H-shaped profile untouched and hide there all the electronics, drivers, motors, pulleys, etc.- put 16 LED MR16 “bulbs” between the H profile and the shade- print mounting brackets for the MR16 sockets and bolt them to the H profile- use only 1 switching-mode power supply, 230V to 12V for the LEDs. For the electronics a simple 5V stabiliser may be enough- use ATmega328P microcontroller to drive the whole thing. The code will be written probably in Arduino IDE as there are plenty of libraries supporting all the hardware I may need for this project.The program however, will be responsible for:-Controlling each LED independently.I plan to use PWM (Pulse Width Modulation) – this will allow me to change the brightness of each LED (and of course turn it on and off). PWM works in a way that a high frequency square waveform is used (usually between 10kHz and 100kHz) so the eye will not see the flicker. The only variable is the pulse width/duration (how long in a single period the logical ‘1’ is on). If a factor is 50% it means, the HIGH state is for 50% of the time, same as the LOW state (all this happens thousands times a second). If the factor is 100% - it means the LED will be powered constantly. Same with factors like: 10%, 17%, 80%, etc... the LED will be in the ON state just for a proportional time, and then off for the rest. It will be blinking but the eye will not see it - it will be just an average light which will appear dim. Seems that TLC5940 is a perfect fit for this purpose. Also, by using different LED types I will get different colour temperatures which could be used for different purposes.-Receiving commands from a TV remote controller.A popular IR sensor TSOP31238 and a piece of code to understand what the remote controller is saying. Then just implementing actions based on commands received. Instead of using bunch of inputs in the microcontroller for a keyboard I will use only one – to read the data from the IR sensor. I will need to read all the codes first to know which code is assigned to which button. And then I can use the codes in a program. I’m thinking of using Volume Up/Down buttons to change the brightness and the Channel Up/Down buttons to change the height. Also, I’m thinking about making it more advanced, for example pressing a TXT button followed by “90” will make the light 90% or another button followed by “30” will lift the lamp by 30cm. POWER could turn the lamp off and pull it to the highest, park position. And so on, and so on-Controlling 2 motors to lift/lower the lamp.This will be a bit challenging as I would need to rethink few cases. At the minute I’m thinking about using 2 servos – these are incredibly strong (they have built-in gears already) and very small. The issue is that they only have 270 degrees freedom. I need to take the servo apart and remove the lock. Then it will rotate freely 360 degrees. But... the other issue is that it will not hold the position. A small servo can be turned by hand so the gravity may/will pull the lamp down once the power is disconnected :/ The solution may be to use a worm gear. The construction allows only one direction of driving it – the small, “threaded” gear turns the large one but not the other way around – this is exactly what I need. I’m going to print a cylinder with grooves to allow the lifting string to wind nicely (and not on top of each other, tangling) but this introduces another issue I need to solve: let’s say I want to have a working distance of 1m and the cylinder has 1cm in diameter (remember, we are working in a tight space within the lamp). It means that circumference will be just over 3cm (2*PI*r) so I would need 32 turns to get it done. If I’m going to lie the string every 1mm it will give me a barrel of 35mm in length... not good...OR... I could print a big, narrow gear with a string-thick groove in the middle – then the string will be rolled on top of the previous layer. This will eliminate the previous issue but will cause inconsistent lifting speed (as the diameter will change with every layer) and it will be a bit harder for the motor as well (higher = more string = greater diameter = more string to be pulled during one revolution). But if the worm gear will be used – this should not be a problem at all. In this case I may need a faster motor than a servo as one rotation of the worm gear will rotate the big one just by 1 tooth. I will need to test if first as it may be just rightAlso, I don’t want to wait 10 minutes for the lamp to arrive where I need it.-Reading data from acceleration sensorto make sure the lamp is level (it will be impossible to make identical movement with 2 separate motors). I would like to read the slope degree during lifting/lowering and if the lamp is off more than... 5 degrees? then I will stop/slow down one of the motors and speed up the other one to make the lamp level again. I have two candidates of accelerometers. Basically the same price but one is digital, the other on is analogue. In this project I don’t need super high precision or fast data rate.In digital accelerometer I would need to write a protocol to communicate with it, play with configuration registers, read a full set of data, understand it, and then extract only the part I need…The analogue one is much easier to implement as it returns a voltage depending on a position of the accelerometer. It returns 3 separate voltages (for X-Y-Z axis) but I’m interested only in one axis so I can use just one pin of the microcontroller to feed it to the built in Analogue-Digital Converter. The choice is: the analogue one, MMA7361.The datasheet says 1.65V is zero-g for an axis, so it is „level”. The program needs to consider if the voltage is lower, it need to lift one end, if higher – the other one, until the voltage gets back to 1.65V (with some hysteresis of course).-Showing current status on a display.A 7 segment, 4 digit display should be enough for the use. By pressing a button it may show the status, height, brightness, selected LED, etc. For example, pressing a MUTE button may show „LED” string, then pressing 5, may show „LED5” - changing settings for 5th LED. Changing height will show the distance, etc.I’m also thinking about using a standard, 2x16 LCD screen but from a distance of 1-2m (when the lamp is under a ceiling) it may be hard to read. I could use a library with custom characters, to write big characters using both lines of the LCD but then, I would get the same 3-4 characters display with much worse clarity and viewing angles than the bright and sharp LED display.-Recognising lamp’s position/height- another „problematic” point.- To measure the position of the lamp I could use ultrasonic distance sensor or an infrared one. If I mounted it on the lamp, pointed upwards I would know how far the ceiling is. But the problem is... dust. After a period of time I will be getting wrong measurements. I could mount it under the ceiling but this will introduce another set of visible wires going to the main board inside the lamp- The other option is to use a set of infrared emitter-receiver line and mount it somewhere beside the cylinder with the wire reel. The beam should be broken only when the reel is full/empty (meaning 2 sets of transmitters per motor). The downside of the solution is that this will be very hard to calibrate, align, get repetitive results.- 3rd option – multiturn potentiometer. I would need to pick the correct one – depends how many turns the motor/barrel will do for the full range of movement. Let’s say it is 80 revolutions – I could use 100-turn potentiometer. This will give me a safe margin for use the pot without breaking it, giving 80% of its range. Good enough for this project. ATmega328P microcontroller has a 10 bit ADC, it can recognise 1024 levels. In this case it will be „only” 800 positions (if I use a full range of the potentiometer) which gives me resolution of 1.25mm (for the distance of 1m). This is just to know the position of the lamp. The accelerometer will be used to make the lamp level. Also, it will be possible to know where the lamp is after booting up by simply reading the value of the potentiometer.-Saving/recalling ‘favourite’ height/brightness.The microcontroller has 1kB of EEPROM, so it can store 1024 8-bit values. It will not be erased when the power is off. To store 1 favourite height position and brightness I will need: 1 memory cell to store the height (0-100% or 0-100cm, both figures fit in 8-bit datatype), and then brightness: the PWM can be driven using 8-bit variable, it has 256 levels – same story, just 1 byte per value. Even having 16 LEDs + height position I will need only 17 cells of memory per one favourite setting - it means I could store 1024/17 = 60 settings. I will probably stick to 10 only (easily accessible using buttons 0-9 on a remote controller + a dedicated button to store or recall the settings).I have decided to go with LEDs as they use much less power and are more efficient comparing to halogen bulbs – I don’t want to have a 300W heater just beside my head. Also, they are not getting that hot so the printed plastic holders will not melt and also, I will not get my forehead skin peeled off when I touch the bulb accidentally(for high density boards I may need a lot of light so the lamp will be hanging very low).I’m hoping to write the next part soon, once I get my head around the above and prepare some materials.

author: eneuro
author_rank: Super Contributor
timestamp: August 21, 2014, 08:37:35 pm
content: Quote from: ljwinkler on August 21, 2014, 07:35:47 pmJust working on lighting project too but much simpler requirements-lamp have to light on when I'm in a room and it adjusts its illuminance to keep it constant regardless of external day light conditionsIdea is also that those dedicated light drivers detects via radio that I need them lighting (they detect me in a room) and when I move between rooms they switch on off without any thinking about itAnother one IR pilot for light? How to find it after dark when needed?I will use myTesla Clockto control wireless radio devices around me and it will be charged without wires of course while sleeping

author: Yago
author_rank: Frequent Contributor
timestamp: August 22, 2014, 07:26:54 am
content: Quote from: eneuro on August 21, 2014, 08:37:35 pmHelp finding remotes or flashlights in the dark, bond a Tritium vial to the device:http://www.survivaldepot.co.uk/product/tritium_vial

author: eneuro
author_rank: Super Contributor
timestamp: August 22, 2014, 08:25:13 am
content: Quote from: Yago on August 22, 2014, 07:26:54 amSound controll can be another option, so no IR remotes needed, but using radio one can switch on/off light in a large area

author: ljwinkler
author_rank: Unknown
timestamp: August 22, 2014, 08:29:09 am
content: Thanks for the tips!However, the lamp will be used just as a workbench lamp. It will not be the main source of light in a room so I'm not worried about looking for a rc in darkness

author: PointyOintment
author_rank: Frequent Contributor
timestamp: September 01, 2014, 12:23:05 am
content: Quote from: ljwinkler on August 21, 2014, 07:35:47 pmWhy is that a bad thing?QuoteTheinconsistent lifting speedcould be compensated for with a little math, as long as the string doesn't compress when more string is layered on top of it. Alternatively, you could loop the string around a smaller wheel right below the winch, and measure the speed off of that wheel.QuoteI see no reason to allow the lamp to go off-level and then correct it. Simply put an axle between the two winches so that they cannot get out of sync. You could then use only one motor, or keep two motors—they will share the load.QuoteA 100-turn pot? Are you crazy? Simply put anencoderon the winches and use alimit switchto detect the park position. Solved. (The only issue is that if you go with the spiral winches instead of the helical winches, you'll get an inconsistent speed, but again, you can compensate for that with a little math or using a small speed measurement wheel like I mentioned above.)QuoteI look forward to what happens next.

author: ljwinkler
author_rank: Unknown
timestamp: September 01, 2014, 04:33:10 pm
content: Thanks PointyOintment for your input.Quote from: PointyOintment on September 01, 2014, 12:23:05 amMaybe it is not a bad thing - the problem is the working space in the frame is roughly 2x3cm. (yeah, I know I have said 2x6cm in my previous post - it was including the bottom part where the tube and diffuser sit). No way I am going to fit there all the gears, barrels, etc. However, after some thoughts I came to the following solution/idea: DC motor with set of gears (something like this one:http://i00.i.aliimg.com/img/pb/594/453/023/1023453594_347.jpg) and a worm gear mounted on the shaft. Then I will print much bigger gear with a groove (I planned it previously) and mount it on top of the frame so the rotating parts will be visible - similar to the pulleys on top of an elevator cabin (http://opacity.us/images/db/12/18/0000000671.jpg) but instead of being just a pulley - it will wind the string.QuoteI like the idea of the second wheel - it is easy to implement to adjust the speed of the motor to keep the 2nd wheel spinning with constant speed - but again, I may not have enough space to do it. Unless I would use the '2nd' wheel to turn the string 90 degrees.I mean: the string goes from the ceiling to the frame, then bends 90 degrees on the '2nd' wheel and goes along within the frame to the winch. In this case I don't really care how the string is winded - all I need is measure the speed of the string. Thanks for the idea!QuoteYes, you are right - I could put an axle between but:- it needs to be about 60cm (that's the distance between the 2 strings)- it will take most of the space in the lamp (the position of the components is: 10cm - string - 60cm - string - 10cm). I need to put there the uC, LED controller, 16 MOSFETs, optocouplers, 16 pair of wires, etc. To prevent catching the wires I could put the axle in a pipe but this will reduce the space even more- also, I'm considering lifting just 1 side of a lamp to change the angle of the light - if I use my idea with the big gears outside of the lamp, I could position the lamp almost verticallyQuoteGood point but I didn't explain the full story in my first post:- The stop point is about 10cm under the ceiling (this is limited by construction of the ceiling part of the lamp (ok, I could stick a magnet on a string and then detect it. Or as I mentioned previosly, use an ultrasonic/ir detector).- I wanted to know all the time where the lamp is, even after booting it up. In your solution the lamp would need to go up to the stop point and then count the encoder impulses while moving.I fully agree with you with the encoder, it is a great idea but it will complicate the project a little:- more uC pins used for 2 encoders (I need only 2 pins for 2 pots). Unless I would use some fancy encoders that return the data over I2C bus - then I could hook them up together and use same 2 pins.- more complicated program (to detect the rotation or communicate over I2C). In the pot version I can read the status when I need it, without worrying about loosing impulses, etc. I would probably use interrupts to avoid it but it will not be as simple as reading a value 0-1023- stop point/points to have it level (assuming I will not use the common axle) - additional pinsI know, using the potentiometers is old fashion but it simplifies the project.This is just a hobbiest, once-off project, to brighten my work bench. That's itThanks and regards,LJ