error: can’t find a register in class ‘SIMPLE_LD_REGS’ while reloading ‘asm’ error: ‘asm’ operand has impossible constraints

Nothing fancy with my program (it’s not an Arduino/Wiring sketch, just plain AVR C), my avr-libc is version 1.6.8-2 and compiling with avr-gcc version 4.3.5-1 for an ATmega644. Can you think of the cause for this issue? Thanks for the great post!

]]>Nice work. Having built two different successful magnetic levitator projects in the past, I can tell you are close to finish line. While many complex approaches are available to analyze stability and avoid oscillations, the simple idea of adding electronic damping is easy and good.

How? You already mention the possibility of differentiating the signal. Yes, I would go with that. The differentiated signal will be noisy. You will probably want to start by differentiating the unfiltered data (filtered data is not the most up-to-date information). You might be motivated to learn about band-limiting the signal. But save band limiting refinements as a polishing step. You just want a reasonable velocity estimate, even if it is a little noisy to start. You need it so you can electronically fight any unwanted velocity up or down.

As soon as you have a reasonable velocity estimate (noisy or not), multiply this “Derivative” term by some gain and add it to your existing control signal. Be sure to flip the sign of this term such that you will attenuate (rather than amplify) existing motion. This is to be added to your existing control term. You will then have Proportional+Derivative (PD) control, instead of only Proportional (P) control.

Numerically estimating the derivative can be simple: velocity_estimate = (current_position – previous_position) / sampling_time.

You can add a simple filter that can help the derivative not be so noisy later. You probably have one or two in mind already. But be careful. Filters introduce delays, and delays can be de-stabilizing.

Good luck. There are lots of ways to add a little electronic damping. Hope you find great satisfaction in finding your own method. I would be happy to offer other suggestions if you are interested.

Tim

]]>“Feedback Control of Dynamic Systems” talks about lead and lag compensation. “Lead compensation” is like differential control – subtracting a multiple of the measured speed of the magnet to stop it overshooting – but adds an extra term (an extra pole in the transfer function – eek! maths!). It tries to get round problems with differential controllers, notably being prone to high frequency noise and differentiation error. You’re introducing high frequency noise in your digital process.

There is also information about systems where the sensor and actuator are co-located. I don’t know from what I’ve read whether the problems discussed are a general case (and don’t see why they should be) but it sounds like your system. The system discussed is a disk drive head mechanism.

I think this is the area to start exploring, but it is quite mathematical. Techniques have improved since the 90s so you may find an easier way of working it out. You’re on the right start with the differential equation of your system. You then transform this into a transfer function and work on it. I don’t remember studying the technique I’ve been reading about this evening (“root locus”), but instead some of the other techniques in later chapters of the book (“Bode” and “Nyquist” plots). Given a Bode plot of your system you can work out the transfer function of the control system that’s needed to control it. Then it’s a case of realising that system.

]]>I thought it you might be interested.

In all of professional technical devices that I’ve seen use two magnets are located opposite each other. Always.

Once one learns how to recognize kanji, then learning their readings “in context”, and just doing a bunch of stuff in japanese everyday, will take care of “frequency” by itself.

]]>Thanks for the suggestions. Using an optical or a sonic sensor is quite standard. But I wanted something more compact, without anything else than the coil above the magnet. The second hall-effect sensor would help a lot, and in fact I linked to a project that uses that kind of setup. It appears to be much more stable than mine. But my goal was using as simple hardware as possible, and use software to do the processing. I wanted to learn how to do advanced signal processing on a microcontroller. That’s much closer to my field of expertise. Of course, if someone just wants to make a magnet levitate, she should use one of the setups you suggested.

Norbert

]]>