Wednesday, October 13, 2021

Driver for an electromagnetic pendulum

In a previous post, I described some experiments with circuits for driving an electromagnetic pendulum. The results were not very satisfactory, and for the Thriecan clock, I ended up using a commercial module. I have since revisited this, and now have something I am happier with. To recap: the pendulum contains a magnet. As it approaches the center of its swing, a sensor detects its presence, and then energizes a driver coil to impart some momentum to the pendulum. Ideally, you use one coil as both the sensor and driver. The circuit I present here uses an Arduino and a small number of discrete components.

Some initial experiments

In the first attempt, I was unable to get a strong signal from a coil: only a few millivolts. This is probably because of the geometry of the coil, which had a narrow diameter but was quite long (about 25mm), based on the one in the instructions for the Toucan clock. It is better to have a shorter, fatter coil, so that more of the winding is close to the magnet as it passes by. I rewound the coil on a bobbin with a 6mm inner diameter and a length of 10mm. I did not count the number of turns or measure the length of wire. Based on its resistance (35 ohms) and the resistance per unit length for 32 AWG magnet wire, it is around 60m. The winding is about 30mm in diameter.

I wanted to know how much difference the specific magnet made, so I constructed a pendulum with the magnet on the end of a 300mm brass rod and measured the voltage when the pendulum was dropped from a known position. The magnets I had lying around were:

  • 20mm x 4mm N38
  • 12mm x 3mm N35 (I think)
  • 12mm x 3mm N42
  • 10mm x 3mm N52
All but the first gave about 0.3V. If you add a second or third one, this goes up by 0.1V per additional magnet. The 20mm one gave 0.5V or around 0.65V with two. I was a bit surprised that the grade of magnet didn't make a difference, as each unit of N rating is supposed to correspond to an extra 1% in magnetic field strength (or something like this).

The distance between the magnet and the coil also makes a difference. My test setup didn't allow me to change it much, but an increase of distance between the coil and the magnet from about 3mm to about 6mm dropped the voltage by half.

The circuit

Here is the circuit. I'll explain the ideas behind it in a moment.

(Diode: 1N4001. Transistor: PN2907.)

The voltages I measured aren't enough to register as a digital signal when connected to an Arduino and are maybe too low to switch a transistor which could be attached to a digital input. An alternative is to use an analog input of the Arduino and then set a threshold in code based on the analog reading. With a resolution of about 5mv per step, we should be able to do this. A reading of even 0.1V would be detected as a value change of 20 on the analog input.

If you search the web for advice on connecting a coil as a sensor to an Arduino, there is a lot of unclear (and possibly misleading) information. The main concern is that transients from the coil could exceed the input voltage range of the Arduino and so damage it. Various solutions involving voltage dividers or Zener diodes can be found. I don't think this is necessary. The Arduino inputs have protection diodes which limit the voltage to just above 5V and just below 0V. The issue with the protection diodes is that they can only handle a limited amount of current. 1mA might be OK, 100uA definitely is. More than that would likely burn them out. In the circuit above, the flyback diode on the coil should eliminate most of the risks, but to be sure, I designed the circuit to allow for a 10V swing. In this case, with a 100k resistor on the analog input, the current would be 100uA and we are OK. Relying on the protection diodes is something that people argue about on various forums, leading to some of the other solutions. An application note from Atmel has an example in which an analog pin is connected safely to mains at 110-240V AC. Also take a look at this.

There is one further issue with using the analog input. The Arduino datasheet recommends that the input impedance to analog pins should be 10k or less, and we want to use 100k. Looking into this in more detail, the reason appears to be that the analog to digital converter works by charging a capacitor internally and them sampling its voltage. The internal capacitor is 14pF and it should be charged in 6us or less at standard sampling rates. With a 100k external resistor, we have a time constant of 1.4us, so we should be OK.

The remaining input element is the 10uF capacitor. It largely gets rid of noise and ringing on the input without slowing down the signal too much. Looking at the signal on an oscilloscope, there is still a small and short duration spike at an acceptable level. With no capacitor at all, there are spikes for about ten milliseconds before the circuit settles down.

On the output side, we simply drive a transistor from a digital pin. When the pin is low, the transistor turns on and the coil is energized. The sensor can't be read at the same time, and that's OK as we don't need to. The flyback diode helps to protect the transistor when it turns off and the field in the coil collapses.

In previous experiments, I found that I needed external power to get enough drive in the coil, mainly due to use a coil with less good geometry. For this version, the 5V output of the Arduino worked fine. Its Vin can also be used if a higher voltage or current is needed. I experimented with an Arduino Uno, but will move to using a Nano soon.

The code is similar to the version I gave before, namely:
  • read the sensor
  • when it exceeds a threshold (20), wait (10ms)
  • turn on the coil (200ms)
  • turn off the coil, and wait a little longer (10ms)
  • keep going
I still have to tune the exact timings and the threshold. These values give a very strong swing to the pendulum. Currently I am not using a weight bob or tuning to 1s per cycle, and this may affect the timing and possibly the voltage needed to drive the coil.

I've not fitted this to the Thriecan clock. My intention is to use it for a possible future design.

No comments: