Eddie_Young

Mindstorms EV3 Lamp (Now with program explanation)

Recommended Posts

You know when you build a huge MOC and your lamplight doesn't illuminate the whole thing and you have to constantly aim and re-aim the lamp? You might not know it but this adds no less than 42 minutes to your overall build time! Outrageous! Luckily, I've found the solution:

The video may be left to speak for itself:

Now the build is pretty simple. The base was the toughest part. Getting two independant spinning axles througha turntable while keeping the area nice and clean! The whole structure rests on four tyres to eliminate vibration and the resulting sound. the bulb is clamped by a worm and 8-tooth gear. I did not alter any bricks to fit the bulb and the bulb can be taken out at any time if anyone requires a purely LEGO lamp. And who would dare! The lampshade is how it is because the lighbulb was very mean and melted through the system bricks that formed the first prototype. It brought a respectable amount of tears to my eye. :cry_sad: This new framy lampshade has endured over two hours of maths homework with no sign of wear!

Now, the programming did require some little thought. The aim in the vertical plane is done through a load of trigonometry, while the horizontal aim works directly with the IR sensor's "beacon heading" output. One thought I'm particularly proud of is my use of squared and cubed values to slow the motor down as they approach their desired positions, thereby eliminating any shaking from hesitation or even indicision!

That's all I have to say but I'll be more than happy to answer any question from a fellow moving-LEGO-lamp enthusiast, if there ever was such a thing! 

Please check out my Wind-up Robot on LEGO IDEAS!

Thank you, for reading my words! :wub:

Edited by Eddie_Young

Share this post


Link to post
Share on other sites

That creation blew my mind, very impressive! Reminds me a lot of the Pixar lamp (you only need to make it jump now :wink: ) Congratulations!

Share this post


Link to post
Share on other sites
Just now, Davidz90 said:

Aren't there any issues with lightbulb heat?

I wrote about that in the description... It melted through a couple system bricks on my first prototype with a full lampshade but as it is, there are no problems whatsoever!

Edited by Eddie_Young

Share this post


Link to post
Share on other sites

Great work, it performs very well! 

Real servo motor drivers have a whole bunch of programmable variables, including acceleration and deceleration. You can probably make a custom block for this on the EV3. 

Share this post


Link to post
Share on other sites

Very clever... I never though of using the beacon tracking for something like this!

13 hours ago, Eddie_Young said:

I wrote about that in the description... It melted through a couple system bricks on my first prototype with a full lampshade but as it is, there are no problems whatsoever!

You should have used a LED globe - it produces almost no heat at all!

Edited by mocbuild101

Share this post


Link to post
Share on other sites
1 hour ago, mocbuild101 said:

You should have used a LED globe - it doesn't produce any heat!

It produces also heat, but not so high, but it would be better, of course.

Almost fantastic implementation.

Share this post


Link to post
Share on other sites
8 hours ago, BusterHaus said:

Real servo motor drivers have a whole bunch of programmable variables, including acceleration and deceleration. You can probably make a custom block for this on the EV3. 

I'm not quite sure how I would use it... Can you elaborate? 

4 hours ago, mocbuild101 said:

You should have used a LED globe - it produces almost no heat at all!

Originally, I didn't think it would be a problem and then I was too lazy to change the design, so... :grin:

 

Share this post


Link to post
Share on other sites

Very nice lamp. It looks cool and works smoothly. Impressive. I'm very intrigued to see how you handled the deceleration as a function of distance.  I know it is your IP but I have to ask: Is there any chance you could share the program?
Anyways, congratulations.

 

On 10/22/2017 at 10:50 AM, kbalage said:

Reminds me a lot of the Pixar lamp

I thought the exact same thing.

Share this post


Link to post
Share on other sites
11 hours ago, dagupa said:

Very nice lamp. It looks cool and works smoothly. Impressive. I'm very intrigued to see how you handled the deceleration as a function of distance. I know it is your IP but I have to ask: Is there any chance you could share the program?

Ok...But only if you support my WInd-up Robot!!! Nah, just kidding...here we go:

In the video, I demonstrated the single joint option. The explanation will be much simpler for that program, as the amount of nerd-talk increases exponentionally with the amount of joints (I'll be using screenshots, because I have no idea how I'd share the actual program)

37869532702_5643444abd.jpg

This is the program in all it's beauty! Let's break it down:

37180580613_3df7280dee_b.jpg

The file that "file access" refers to as "abc" is the value of the A motors degree count from the program's last run. The original files are created in a calibration software which I'd be happy to share if anyone's interested. The first block says to jump to the beginning of the file, then to copy the value into a variable (reading a variable is easier for the EV3 than reading a file) and then to delete the file so that they don't get mixed up later on. The next loop simply takes the motor's rotation sensor output, adds the motor's last known position from the file access variable and writes a new variable which tells the program the motor's actual position. This is repeated until you end the program with the enter button, at which point the motor's actual position is copied into a file for later use.

37180581053_62e24032f5_b.jpg

The file "abcd" is the last known value of the C motor which represents the bottom joint. The string of file access blocks reads the last known value and sets the bottom joint into an upright position automatically, it then sets the file to 0 because upright is the starting position. This is where it gets interesting! The maths block is in the advanced setting and the equation is "-10*(atan(a/b)+c/24)" 

"a" is the beacon's proximity (the proximity variable is written in the third and last loop) "b" is the lamp's height which is, in this case constant. If we add a line representing the direction of the lamplight, we get a right-angled triangle with the legs a and b. This means that the angle between the lamplight's direction and the lamps height is equal to arctan(a/b) (or atan(a/b) in the EV3 software) and that angle is exactly the angle which the top joint controls! c is basically the rotation sensor output, it is devided by 24 because of the gear ratio between the joint and the the motor. Therefore c/24 is the actual angle of the top joint.

Now that we have the desired angle and the actual angle, all we have to do is to find and correct the variance between them! c/24 is actually negative because of the way the motors work, which is why there's a plus instead of a minus. What I did now, is I fed this difference (that is: atan(a/b)+c/24 ) directly into the motor's power input. On finding that it was a bit too slow and did the opposite of what I wanted, I added -10* infront of the mess and voila!

24048509388_5b218eddf3_b.jpg

This one should be much simpler! The "wait for beacon" loop holds the whole program (including the other loops) until you turn the beacon on. This is done through the green data wire. Once the beacon is detected, the proximity variable is written from the sensor's output and the "heading" output is fed through this equation: a*abs(a) or a * |a|. All that does is give the square value while preserving the positive/negative factor. An a^2 would give you a positive number from any value (except 0) and we can't have that because the +/- represents the direction of the turntable.

The IR sensor is mounted on above the turntable which means it doesn't matter where the turntable starts or finishes. That's why I don't use the same file access trick for this motor.

I'm not the best with explanations, as you no doubt have noticed, so please ask away!

Edited by Eddie_Young
proofreading

Share this post


Link to post
Share on other sites
On 10/22/2017 at 8:02 PM, BusterHaus said:

Real servo motor drivers have a whole bunch of programmable variables, including acceleration and deceleration. You can probably make a custom block for this on the EV3. 

 

On 10/23/2017 at 5:09 AM, Eddie_Young said:

I'm not quite sure how I would use it... Can you elaborate?

You talked about programming an acceleration and deceleration for the motors to prevent jerky movements - this is a very smart thing to do, as it protects the motors (and mechanism) from excessive wear and damage.  The acceleration and deceleration will vary on the momentum of the mechanism being controlled by the motor.  The higher the momentum, the longer these two cycles.  I don't know why Lego didn't include a block or a variable to control this, beyond the position lock/free spin motor mode.  Perhaps it's because they don't expect the motors to be subjected to heavy duty action, or maybe it's because it's fairly trivial (although not always obvious) to implement when required.

By the way, thanks for sharing the program and doing the explanation, it was a very good read.

Share this post


Link to post
Share on other sites
42 minutes ago, BusterHaus said:

Perhaps it's because they don't expect the motors to be subjected to heavy duty action, or maybe it's because it's fairly trivial (although not always obvious) to implement when required.

Ah I see...I just think that a beginner wouldn't understand what purpose such functions serve and anyone more advanced than that can make farely easy work of improvising it himself.

42 minutes ago, BusterHaus said:

By the way, thanks for sharing the program and doing the explanation, it was a very good read.

No problem! Explaining it made me feel smart (for once... :cry_sad:) and I'm glad you liked it.

Thank you. :classic:

Share this post


Link to post
Share on other sites
On 10/24/2017 at 8:30 AM, Eddie_Young said:

What I did now, is I fed this difference (that is: atan(a/b)+c/24 ) directly into the motor's power input. On finding that it was a bit too slow and did the opposite of what I wanted, I added -10* infront of the mess and voila!

 

Hello. Thank you very much for the explanation. I think I got what you did. It's actually "simple" and clever. (Please note the quote marks). Now, I'm going to try to reproduce the same behavior with a similar setup. That means I may have to come back and ask you more questions.
Thank you, again.

Took me a while to find your robot, until I realized It was in your signature. You got my (two) votes, anyway.

 

Share this post


Link to post
Share on other sites
On 24/10/2017 at 8:36 PM, Josephiah said:

Now, if you could just rig up another servo connected to a dimmer switch...

I was afraid someone might say that... :look: 

22 hours ago, dagupa said:

That means I may have to come back and ask you more questions.

Took me a while to find your robot, until I realized It was in your signature. You got my (two) votes, anyway.

 

No problem! Although I believe you won't be needing my help anyway. :wink: Thanks for the support!

Edited by Eddie_Young

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.