Saturday, July 16, 2022

The long-range magnetic latch: simulation oddities.

 While doing additional simulations I got really strange results if the magnet was more than about 1 inch long.  The initial force between the magnet and iron pole piece came out as a negative number!  It didn't make any sense.  Then I started thinking about the simulation "universe".  Part of the initialization needed for the simulation is to define the boundary of the problem, basically how large the space around the magnet and pole pice is.  I'd been specifying a relatively small distance that defined this, because increasing it also causes the simulation time to increase.  Well, it turns out that was a bad idea for some cases.  When I increased the size of my simulation universe, suddenly the force numbers all made sense again -- they all were positive, no mysterious repelling force was present.

Even simulations with shorter magnets that did not exhibit negative force came out slightly different when the boundary distance was increased.

Moral of the story:  even though it can cause simulations to take longer than you like, it's important to make the problem boundary large enough.  Start with a smaller size, then increase it to see what happens to the simulation results.  Look at the results you get with a critical eye to see if they make sense or not.

Tuesday, July 12, 2022

More About 2 to the millionth power: How Many Digits Does it Have?

Any old scientific calculator can tell you that log(2) is approximately equal to .301030.  The log of 2 taken to the power of one million (2^1000000) is log(2)*1,000,000, or 301030.  It's not trivial to use this number to determine 2^1,000,000 down to the last digit, but it IS trivial to say how _many_ digits the number has.  It is: 301,031 digits (because 10^0 is equal to 1, we need to add 1 to our result, then throw away the non-integer part).

For a simple verification of my assertion, let's take a look at 2^10, which is easy to compute:  it's 1024.  10 times .301030 is 3.01030.  Adding 1 to this is 4.01030.  Taking the integer value we get 4, and that's how many digits 1024 has.

In fact, we can use this scheme for any power of 2.  For example, we know that 2^16 = 65536.  16 times .301030 + 1 = 5.816, so we verify that the scheme works for any power of 2.  The limitation to the approach is the accuracy of the value we use for log(2), which is a transcendental number so it has an infinite number of digits.  But there are some online calculators we can use to get quite a few more digits.  One reports that log10(2) = 0.30102999566398114, which should suffice for determining how many digits 2^N has up to N = 10^17.  According to an earlier post of mine we already know that its least-significant digit is a 6 😀.

By the way, we know that log(2) MUST be a transcendental number because the relationship I described above has to hold for any arbitrarily-large power of N for 2^N.  It doesn't matter if N = 10 or 10^10^10.... 

Monday, July 11, 2022

Magnetic Latch Simulations, Part Two

 I changed my simulation scripts for two variations on a magnetic latch mechanism so I could plot force vs. distance for them.  One is the simple magnet and flat steel plate, and the other is one of my long-range latch designs.  The differences are pretty stark:



The long-range latch force vs. distance plot looks a little bumpy but the important thing to note is that it is exerting pretty significant pull as far away as 1.6 inches, while the simple latch just starts to do its thing at around one-half inch, and even at that distance is far less "strong".

Based on this result I think a combination of my long-range latch and a simple air pneumatic damper to get the soft-close effect should work pretty good.  And there's hardly anything that can wear out.  The most likely failure probably would be the one-way valve, and if that's the case I could easily make one using a bearing ball. Putting a tiny magnet in there to retain a steel ball would enable it to work in any position.  Of course, I'll have to use FEMM to simulate that 😃.






Tuesday, July 5, 2022

A deep dive: A broken soft-close drawer mechanism and finite-element analysis

 This post really highlights nurd-dom.

For some background, about 11 years ago we built our house.  We included soft-close cabinets for all the drawers -- the kitchen, all the bathrooms and the utility room.  At the time, the cabinet vendor we chose was including soft-close drawers at no additional cost, so of course we got them.

Ten years in, one of the two soft-close mechanisms in our most-often used kitchen drawer failed.  It was the silverware drawer.  The nifty latch mechanism that catches and releases the drawer at the right point broke.  It was just plastic and apparently not really up to the job.  That failure turned out to be pretty minor since the remaining soft-close device was still doing a good job.  However, about a week ago it also failed.  The latch thingie didn't break but it wasn't holding, probably due to wear.  It made a very annoying "sproing" sound every time the drawer was opened, when the latch let go.

Being a DIY kind of person I removed the drawer and examined the mechanism and figured out that it couldn't be repaired, so I just took the broken soft-close mechanism off the drawer slider.  Because the drawer no longer stayed closed I made a simple magnetic-latch using a counter-sunk ring magnet screwed to the back of the drawer and a wood block topped by a piece of steel, screwed to the back of the base unit.  It works to keep the drawer closed but it's really easy to close the drawer too hard so it bangs into the base unit, and in some cases has bounced back out.  I looked at some off-the-shelf soft-close replacements but the only ones compatible with the rest of our drawer hardware were exactly the same design as the one that had failed. I didn't have good feeling about that so decided to look elsewhere.

I started thinking about some kind of damper to slow that final approach so the drawer behaves more nicely when it's closed.  One my goals was to make something that is much more reliable than the original version, so I looked at a type of pneumatic damper to complement the (presumably pretty reliable) magnetic latch.

The basic idea I came up with was to make a piston and cylinder with a one-way valve so the piston could be easily withdrawn but the valve would close when the piston was being pushed back into the cylinder.  Air leakage around the piston would be slow enough to produce some back-pressure and slow the cabinet's entry at the end of its travel.  A rod attached to the piston would extend out so the back of the drawer would push against it and the piston.  To pull the piston out, the end of the rod would have a small magnet.  The magnet would be attracted to another steel plate, this time mounted on the back of the drawer.  Sounds a little complicated, but the idea was to use simple physical phenomena rather than a complicated and fragile mechanical latch mechanism to do the job.

I was pretty sure the damper would work, but the problem then came back around to the magnetic latch.  When the drawer pushes against the piston mechanism the force will initially be fairly high, so the latch needed to be able to exert enough force over about an inch's worth of distance to slowly pull the drawer in against the damper's resistance.  The force between a magnet and a flat plate, my basic magnetic latch design, has an extremely nonlinear relationship with regard to the distance between them.  It starts out very low and stays that way until the magnet is very close to the plate.  I wanted to extend the attractive force, to make my system work better -- or, perhaps, to enable it to work at all.

The thought I had was to make a different kind of steel piece to attract the magnet.  The idea was to make an iron cylinder with a Vee-shaped interior, where the magnet would travel inside to the bottom.  The iron would start out being fairly close to the magnet so the initial pull-in force would be sigificant, but to ensure that the magnet would continue to travel inside the cylinder its interior would be machined to have a V-shaped profile, becoming smaller as the magnet went inside it.  This way the magnetic force would act to continue to pull the magnet into the cylinder.

That geometry looked to be pretty difficult to get right -- it could take a lot of experiments to figure out what would and wouldn't work very well.  So I turned to software, in the form of a magnetic-field simulator called FEMM.  It solves magnetic field problems using a technique called finite element analysis, and one of its features is that it can calculate the force between a magnet and an arbitrarily-shaped iron pole piece.  Perfect....except that I wanted to easily change things like the angle of the V profile, the dimensions of the magnet and other features that I thought might make it all work better.  For simple problems you can create shapes by using your mouse, but that isn't very easy to use when creating precisely-shaped features.  Fortunately, FEMM also can be operated using a basic-like scripting language (called LUA), enabling me to create all the geometry with a program, then run the simulation and display the results, so I could easily change the physical design using a text editor and quickly evaluate the result.  For an example of the program's output, I offer this screen shot:


The intensity of the magnetic field is depicted by colors, where teal is very low and red is high.  In this model, the latch is basically shown from a top view, where the back of the latch is at the top of the screen.  The back of the iron pole structure has a hole in it to reduce the final holding force of the latch.  My simulations showed this worked to get the pull-in force to be comparable to the hold force, which in this case is the force needed to separate the magnet from the back of the pole piece.  It is NOT the same as the "lift capacity" of the magnet as specified by vendors like K & J Magnetics, due to the presence of the hole.

This is a theoretical study -- clearly, a structure with just the magnet and pole piece would be unstable because it would only take a minute offset one direction or another to cause the magnet to snap over to one side or the other of the pole piece, messing up my nice simulation work.  To prevent that, the inside of the pole piece actually will have a plastic insert (cast or machined) to fit closely between the pole piece and magnet.  That will keep the magnet centered so my simulations should be reasonable approximations to what actually happens.  I hope.....

I'm thinking that it may be possible to integrate the damper and long-range latch into one unit, but initial testing will be done using two separate parts to evaluate their separate functions.  One real concern is how to install the pieces correctly, to ensure proper operation.  When the drawer is installed it's almost impossible to see how everything lines up so that problem will need to be addressed.

More later :).