element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • 'Choose another store...'
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs Daily life tweak: Book Lamp
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jpnbino
  • Date Created: 30 Oct 2021 5:03 PM Date Created
  • Views 981 views
  • Likes 0 likes
  • Comments 4 comments
  • hack
  • hardware
  • build
Related
Recommended

Daily life tweak: Book Lamp

jpnbino
jpnbino
30 Oct 2021

image

My motivations to make this tweak in such an ordinary item were two: have fun and make it useful.

I normally enjoyed reading a book when commuting between work and home, a trip that takes around 40 minutes one way depending on traffic. It happened that during parts of autumn and winter the days are dark enough not to give conditions for reading. So, I came up with the idea of purchasing a book light to go on reading.

So, I bought a 10bucks well-rated reading lamp(4.6 out 5) on Amazon, and although it seemed to be good, I had an unpleasant surprise at first use: It was too strong to be used in the car ( later, I discovered that also at home ). Then, what to do now? Return?

Nooo...

I thought of returning the lamp and finding another one, but then I could run into the same situation again. Then, at first, I guessed that I could just easily increase the value of the resistors in series with the LEDs, and then the job was done. But it happens that after thinking a bit more, I realized I would miss changing the brightness because sometimes my eyes ask for different light intensities depending on the day.

Anyways, I needed first to break into the hardware and see how things are and then decide what to do. So, here we start and I hope you enjoy reading about this short trip.

 

What is about the original lamp?

As the video below shows, it has no luminosity control and the LEDs are then turned on at the maximum always. Even, less cool is that it has three light types: white, warm, and mixed ( which is the strongest with all 6 LEDs ON).

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

What did I expect then?

As these features didn't suffice my needs at all, I started thinking about how I would like this lamp to be and I basically had the answer promptly in my head, and here is what I wanted:

  • Control of light intensity;
  • and, more variations in the temperature of the light ( different combinations between white and warm).

The idea seems good, but at that point, I still needed to know the hardware and see if this modification would be possible or not.

 

Hardware teardown

The image below shows the lamp itself ( Those marks over the rubber were caused by me before opening). Also, In order to make it easier for the description, I called the parts: head and base.

image

 

 

image

Base PCB

The base PCB basically provides regulated 3V3 for the head PCB. The circuit will not be detailed but it is in short a regulator and a Li-Ion charger controller.

 

image

image

 

 

Head PCB

Finally, here is where the job really needs to be done. As you can see, the circuit is as simple as expected.

 

image

image

 

 

Drawing the SCH

Handed with a multimeter, it didn't take long until I could figure out how the connections were made. The figure below shows how these connections explicitly. note: although I wrote uC over the IC, it's was not necessarily an MCU.

image

Now, the circuit is completely known and something can be done about it. In a quick look, I realized that I  could find some MCU that has a pinout compatible ( power pins and GPIO functionality for the LED and the button ) with the uC and then add some firmware and have it working with everything I wanted. After a quick search, I found the PIC12F1840 (see below) which matched the pinout (also functionality) perfectly.

 

image

 

The Dev setup

As the MCU was delivered I just needed help from a hot air gun to remove the old controller and put my MCU in there. I also needed to solder a cable so that I can connect the programmer. The picture also shows an Analog Discovery 2 (AD2) which I used to simulate a button, this way I didn't need to press the physical button every time I wanted to test something, and actually, the real button was mapped to a pin used by the debugger which makes it useless in debugging mode. The AD2 was also used for checking the PWM generated to control the LEDs. Lastly, regarding the firmware development, I used the MPLABX IDE.

 

 

image

Firmware

Here you can find the repo

 

Since we already know the hardware, we can then think about the code structure, and in this regard, the manner I found to overcome the limitation of having only one button to control the whole system was to detect more than a single button click event. So I defined three events for the button: One-Click, Long Press, Double Click. Those are the events commonly captured by a smartphone as well.

 

About the environment

I made use of the MCC ( Microchip Code Configurator ) to configure the hardware as I needed for this project, the timers, clock, GPIOs, and so on.

 

 

The Button behavior

  • One-click: Changes the light temperature. If the light is off it simply turns it on.
  • Long Press: keeps changing the Brightness until the button is released
  • Double click: Turns off the light

 

The light temperature

     The head PCB has 6 LEDs: 3 white and 3 yellow. As two independents PWM control the LEDs, I defined 5 different sets of white and yellow intensity to perform the role of the temperature of the light. The combination is shown in the table below:

 

SETYELLOW (%)WHITE(%)
11000

2

7525
35050
42575
50100

 

The percentage corresponds to the amount of influence of that light in the total brightness.

 

The Brightness

For the brightness, there are five 5 levels available which I chose according to some experimental tests varying the Duty Cycle of the PWMs that controls the light. the formulas below show the relationship between the brightness and the light temperature. light_ratio refers to the values in the previous table.

 

(I)       Brightness.white =  (Brighteness) * light_ratio.white/ ( light_ratio.white + light_ratio.yellow)

(II)      Brightness.yellow = (Brighteness) * light_ratio.yellow/ ( light_ratio.white + light_ratio.yellow)

 

The Implementation

Now that we know how everything from the perspective of usability, we can now think in terms of code. In order to make it easy to implement the code, let's make some representation for parts of the system. First,  as the button is going to generate particular events, we can think of a state machine like the one drawn below:

 

image

 

Then, we need another state machine from each we can have the events generated by the button clicks. The drawing below represents the button subsystem

 

image

 

The real thing

After the implementation, I recorded separately in the following video the result of the whole implementation.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Conclusion

I had the fun I wanted from this project for sure and although I was not working on it consistently, let's say it was going often to the drawer of "things I wanna do", I managed to finish it and have my book lamp working properly. Also, what made me happy was that I applied effort to have this project written down. I'm aware that I have some difficulties in bringing what is in my head into words, but I am sure that I can improve with practice. Lastly, if anyone wants more information about it or would like to share suggestions, I would be glad to know.

 

 

  • Sign in to reply
  • jpnbino
    jpnbino over 1 year ago in reply to beacon_dave
    with smaller books you tend to end up with more curved pages ...

    I took some books to make some checks.

    • Book 1 ( in the picture): Old book with pages softened by the time
      • Keeping the book light close to the middle and adjusting somehow, gave quite a uniform result.
    • Book 2: new, hardcover book.
      • Here, the effect you described about the curved pages was totally visible and the readability was compromised.
    • Book 3: new, softcover but bigger ( width x height)
      • In this case, the turned pages were not a problem but the illumination until the end of the page was not good anymore. Maybe I didn't adjust that well.

     

    image

     

    Alternatively you clip it at the next chapter

     

    That's how I have been doing... and putting the light in the middle between pages on the left and right. I really like the idea about the double independent lights, I should give it a try, thank you.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jpnbino
    jpnbino over 1 year ago in reply to genebren

    Thank you, Gene

     

    I just wrote an email to them about it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave over 1 year ago

    That looks like a very useful modification. There are two other problems I find with such lamps though:

     

    1. with smaller books you tend to end up with more curved pages on one side and more flatter pages on the other so with a single lamp you tend to end up with more specular reflections on one side and  more diffuse reflections on the other. It perhaps needs two light heads which can be adjusted independently.
    2. I can never get the clamp to sit well on the page, especially for the first half of a paperback book when it tends to be located on the flimsy more curved left side of the book ( in order to allow you to still turn the right hand pages over ). Alternatively you clip it at the next chapter on the right side allowing you to turn a chapter's worth of pages before readjusting, but then you tend to get the hot spots where it has now distorted the page...
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 1 year ago

    Very cool hack to an existing product.  Perhaps you should approach the company with your updates to their product?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube