LVDT converter: a Mahr P2004M, some electronics, and sub-micron resolution

Recently, I got a Mahr P2004M linear variable differential transformer (in short: LVDT), which is a device that can measure distance of roughly 2 mm with basically unlimited resolution. As the name says, it is a transformer, and the primary is to be fed with 19.4 kHz (or there abouts) sine, at 5 Vrms, and if the plunger is half-way in, the secondary coils with balance out, and there will be zero voltage. For any displacement from that position, there will be an appreciable voltage at the output. With the right amplifiers and converters, we can use this to measure distances extremely precisely.

To do some test, I mounted the LVDT in a height gauge, because I didn’t know if it was actually working.

The plug was broken, mechanically, but the little board inside was OK. So I replaced the plug, it is rather common 5-pin DIN plug with screw shield, same as is used for precision 100 Ohm Pt100 temperature sensors.

The circuit appears to have some capacitor, resistor, and an overvoltage protection device. I drew the circuit, but nothing special found.

For a basic test, I used a HP 3325B generator and a dual-channel scope.

Clearly seen, the LVDT is working. There is a certain phase shift of the incoming and outgoing signal, which is normal.

The noise is very small, well below 1 mV with some averaging. Note that the signal will probably go through a filter with 1 Hz or slower time constant.

To check the frequency response, I connected the LVDT to a HP 3585A analyzer, and clearly there is a peak sensitivity around 20 kHz. Better to operate close to that frequency (Mahr may specify 19.4 kHz for most of their sensors).

The Mahr datasheet also specifies how the input is supposed to be connected. There is a similar R-C circuit in the plug, at the other end.

Following earlier circuit designs, and also some Application Notes (Analog Devices AN-301 in particular), a circuit has been put together, consisting of a phase-shift oscillator with buffer and stabilized amplitude (TL431 used as a reference).

The key part is the switched rectifier, which is in a fixed (adjustable) phase relationship to the exiting signal. For adjustment, first null the comparator, then adjust the phase shift for precise switching around the zero point and check that this also coincides with the maximum amplitude at reasonable deviation from the zero position (about 1 mm of travel may be good for a 2 mm probe). The adjustment of the phase is fairly non-critical, but will ensure linearity around zero.

For some basic measurement, connected a 16×2 LCD, but finally decided for a 128×64 dot matrix display with white backlight. With that I can use large lettering which is easy to read in the workshop from a distance.

The full schematic, it a bit crude, may need to be re-drawn eventually. There is a power supply, +-15 Volts firstly, for the amplifier circuit, +5 V for the LCD and microcontroller, an ATMEGA128A.

The A/D conversion is done by an ADS1211U (even if the schematic may show ADS1210), a very reliable and highly precise part. A 24-bit sigma-delta converter. These parts don’t come cheap recently, about EUR 30 a piece, but fortunately, I had one in stock.
It has two separate power supplies of 5 V, one for digital, one for analog (with additional filtering): both are derived from the +15 V rail.

The switched rectifier for phase demodulation is done by a DG202 analog switch (all switches paralleled up for low resistance) rather than a FET transistor – simply because this is a way I normally design the lock-in amplifiers and phase detectors.

With everything arranged and tested, I put the circuit in a sturdy aluminum case. The switches are toggle switches that are easy to operate in the workshop. Sure we could attached various touch screens and buttons, but these are not convenient in a workshop with oil and dust.

The little device runs from 230 VAC mains, and doesn’t need much power at all (to most is consumed by the LCD backlight, which is LED based and supplied from the unregulated negative voltage via a resistor current limiter.

Finally, placed the LVDT setup on the granite surface plate.

So far working very well. There is no visible drift, at a 0.1 micron resolution. I have no intention to go below 0.1 micron in my workshop, as this is a metal working facility, no intention to fabricate telescope mirrors or optical parts.

Etalon 77.19000 Height Gauge: a broken pinion

Recently, I found a nice offer on Ebay, an Etalon 77.19000 height gauge, along with a ultra high resolution Mahr LVDT length sensor. About the sensor, we will hear later, but the height gauge, although sold as “working”, didn’t work.

Still in good mechanical shape, and all Swiss Made. Mitutoyo has a very similar model, 192-130, which sells for well over 600 EUR.

The mechanism uses a rack and pinion design, with two pinions, one tensioned by a spiral spring, to avoid backlash. Practically, even without the spring – which was bent – there is no noticeable backlash.

There is also a second rack, and this drivers a fully independent counter mechanism.

After some examination it became clear that one of the pinions had a broken shaft, and this also let to the other pinion spring being damaged. The spring was easily fixed, but the broken shaft of such a tiny and hardened pinion, hard to fixed. I managed to drill a hole with a carbide drill, but when pressing in a new shaft, the whole thing broke apart…. a disaster.

Looking around in my drawers, I would this cheap Chinese dial, 0.01 reading. What if it uses the same rack pitch? Indeed, it does. The dimensions seems to correspond to a module 0.2 gear, and examination under the microscope showed identical tooth count on the pinion. Only the drive gear is a bit different but this could be pushed off.

The gutted dial, well, it is less than 10 USD.

To assembly it, I cut off and ground the lower part of the old pinion to a diameter a little bit less than needed, made a sleeve from stainless steel, and ground a suitable cylindrical length of the spare pinion so that all can be pushed together and fixed in the sleeve to form a new gear assembly of the correct dimensions.

All quickly done with a tool grinder and a lathe. And with the new gear, the Etalon is good as new!

Automated Basement Ventilation: keeping it dry

Basements in older German houses are usually pretty humid and cold, and there are various rules about the proper ventilation. You are supposed to open the window in the early morning, let some dry air in, but during the day, especially in summer, it must be closed. Summer air contains a lot of moisture, because the quantity of water that air can absorb strongly depends on the temperature, the so-called saturation vapor pressure of water. When such moist warm air enters the basement, it will cool down and water will precipitate on the walls. Not good. For me, this is all a bit inconvenient because rather than potatoes I store a lot of electronic parts in the basement, and I want to keep all as dry as possible. So I decided some month ago to set up a little system: (1) a window fan, (2) two humidity/temperature sensors, (3) an ESP32 to control the fan. As sensors, I use the ubiquitous AM2302, because it is easy to read and accurate enough.

For the fan, a KVVR K011301 Model, about 200 m3/h, it also has a feature to close the opening when the fan is off, so that no air can enter the basement when the fan is not running. In principle, you can also use two fans, one to supply air to the basement, and one to extract it, but for me, it works just fine with one fan to extract the air.

A little contraption made to fit the fan to the window. It is all reversible, so if I don’t like to use the fan any more, I can just fit the old window again.

A little control box was quickly made, with an ESP32 module, and a small transformer, a 5 V voltage regulator (be aware that the ESP32 needs pretty high peak current, several hundred mA in WiFi mode! So I needed to add some rather beefy capacitors. Next time I should use a larger transformer…

The key part is the calculation of the absolute moisture level. This is done by regularly (like, every minute) measuring the temperature and relative moisture level inside the basement, and outside, at a protected spot. Then calculate the saturation vapor pressure (which is a formula you can find in textbooks), and multiply with the relative moisture (in percent). This will give you a value that corresponds to the absolute water content (scaling to grams per m3, or similar, but I just use the hPa value, water partial pressure in air). If the water content outside is lower than inside, in absolute terms, I have the controller switch on the fan. There is some hysteresis to avoid all too frequent switching.

A nice box contains all the circuitry, and it can be accessed via a web interface, pretty handy. I also have a server poll the values every few minutes, to prepare some nice diagrams and to check if the system works as designed.

Indeed, it works brilliantly for several months, but then the AM2302 suddenly failed. It would read back the correct temperature, but the moisture value was stuck at 99%. Not good. I tried to clean the sensor, but to no avail. Also, this is the inner sensor, not exposed to the elements or anything. A is outside, B is inside.

So for the time being, I replaced it with a new AM2302, and hope it is just a freak defect and not a general limitation of these sensors — if it is, I will replace the AMS2302 by Bosch BME180 sensor.

This diagram shows the absolute humidity delta, outside minus inside, so if the outside is dryer than inside (for example, outside 10 hPa water, inside 12 hPa, the value will be negative, and the fan will switch on accordingly.

For now, in June, it is all working well, and the basement is indeed much drier than last year, and I don’t need to worry at all about closing and opening windows.

In this region, it seems that at least every few days there is reasonably dry weather for several hours, and the system uses these hours well to ventilate the basement thoroughly. Sure if you have rainy season in your country, this control won’t help, but it all the more moderate climates it seems to be a nice gadget to have.

Workshop Upgrade: Laser cutter and engraver SCULPFUN S9

There are various laser engravers or cutters available in the market, so it is hard to make a choice. Finally I got a Sculpfun S9, which appears to be well-regarded in the community as a cost-effective and capable machine. I was also looking for something that is easily serviceable, not using custom controls or special motors – the Sculpfun S9 is built from all relatively standard components so it can have a very long service life even if I eventually need to fix the electronics or replace the controls altogether.

The machine ships as a kit, but there are good instructions for assembly, step-by-step, even the screws packaged for each step in a separate bag.

The machine is fairly portable, so you can also set it on the surface of large panels to do local engraving or similar.

Some first tests, works very well indeed! Just the smell of burned wood and plastic – it is really not a machine for an apartment, and the laser also seems no toy for kids. It is fairly strong and can be dangerous. This laser has a very sharp (maybe 0.1~0.2 mm beam) that cuts through several mm material in a single cut. No good idea to get your fingers in the way.

You can also cut foil. Maybe better to use a knife cutter (because of the smell and vapors), but for some once-off jobs, it is easy to use and also cuts uneven old foil very well in my test. Better use some magnets to push the foil down on a piece of sheet metal.

The main application that I am looking for is to cut custom seals from plain seal stock. The machine cuts well through 1 mm Elring Abil plate, and similar materials. Even thin rings can be cut, no problem (very hard to cut with a cutter knife or punch).

Next step will be to get the machine properly installed. This means, adding an air nozzle to assist with cutting (made from brass), a machine table, and an enclosure with exhaust fan to get rid of the toxic vapors.

The nozzle is made from a piece of brass (several of these pieces purchased at a scrap yard 25 years ago when I was still a kid).

The nozzle has a side inlet, and is designed for about 20 L/min with 1.5 mm diameter, so we are looking at 150~250 m/s linear velocity at the nozzle outlet.

The gas is fed through a 4 mm PU pneumatic tube.

To measure the air flow, we are using a very cheap Chinese gas flow meter. This has a needle valve, but it is not working well – the needle valve puts a spin on the gas, and the indication is incorrect (the sphere starts oscillating and spinning), so I use a separate needle valve (FESTO GR-QS-8) in the supply pipe.

The flow meters comes with flimsy plastic connectors, and these have 5/16″ UNF (24 TPI) tread… not a very common part in Germany to get a transition from 8 mm pneumatic tubing to 5/16″ UNF…

Fortunately, found a suitable thread cutter in my tool selection, so an adapter was made quite easily (from 5/15″ UNF to 1/4″ NPT, then us a 1/4″ NPT to 8 mm push-in tube connector).

The next step has been to make a suitable table, sure you can put the laser machine on some ordinary table, but it has quite some speed and movement and even relatively stable tables will be moving and there is some impairment of precision. So I wanted to give this machine a stable basis that doesn’t shape. It is all welded construction from about 1.5″ square steel pipe. The top is 18 mm waterproof plywood. There will be a piece of zinc-plated sheet metal on top, also to use magnets, and a open cutter support plate on top in case of heavy cuts.

To fabricate such a table, after the welding is done, grind off the scale (this is just plain steel), clean with acetone, and then roll-on some primer paint.

Finally, painted in a blue-gray color, and with the top plate mounted.

Next step, fabrication of an enclosure with a movable cover. All made from 15×15 mm (about 3/4″) square tube, all TIG welded…. looks easier as it is with all the parts and angles.

There will be two large windows, 40×60 cm, to observe the process. I selected GS-1C33-GT Plexiglas (acrylic glas) which is nicely transparent for visible light, but blue light of the laser can’t pass at all.

This is also confirmed by the spectrum, the laser is emitting at about 452 nm.

After some hours of work, the enclosure is ready for painting. It opens nicely and smoothly, also because of a gas spring (200 N, 535 mm total length, 220 mm travel).

It is one of the few occasions that I have use gas loaded springs in my design but it is working well. Just the design calculation is complicated and probably it is always a bit of experimentation to find the right gas spring size and force. But this time, successful at the first attempt. My recommendation, to rather use a slightly stronger spring (say, 200 N if 150 N is calculated) to allow for aging of the spring or other design uncertainties.

Workshop Upgrade: 3D Printer

Finally, I had to opportunity to acquire a long desired tool, a 3D printer. In recent years these have become fairly affordable, and also easy to use. So it is on longer needed to spend days with optimizing various settings. I am planning to print mostly in durable parts, so I am targeting PETG and ABS rather than PLA plastic materials. Mostly planning to use it for spare parts, or mold patters for aluminum casting.

The machine, it is an Artillery Sidewinder X2, a great product, all nicely arranged in a box.

It didn’t take long to set it up, maybe one hour, and then you can use the well known software packages to run the machine. I am using Freecad for modeling and Cura for processing.

All worked fine already for the first part… great!

A cylinder, and a space shuttle. All fairly robust.

So far, I can only praise the machine, it is working fast and precisely. Just printing low cost PETG material. Key point is to keep the bed rather hot to keep the parts sticking, and then just remove them after cool-down with no effort.

Cheap personal scales: turned into parcel scales with USB interface

With many parcels being shipped, and for some other projects including measuring the contents and consumption of LPG gas cyliners, other gas cylinders, chemical tanks etc, I always wanted a slim and stable balance, at low cost. Sure we can fabricate one from steel plates and load cells, at considerable cost. But why not try with a personal scales, and convert it to some usable tool. This scales from local LIDL supermarket comes for EUR 8.99 in the shop, 10 dollars.

It is very slim and stable, basically a piece of hardened glass, with 4 load cells. There are 2 thin-walled stainless tubes to carry the wires to the main processor.

That’s the type, just for reference:

The load cells are the typical 3-wire elements (two load elements inside, red is the center).

The main disadvantage of these balances is (in addition to the absence of an interface) the absence of a continuous reading, in contrast to a good old analog balance it only shows one weight once, when you step on it. For various uses, I rather need a balance that continuously shows the weight, and can transfer it to a host for data analysis.

The load cells rest on certain plastic parts that are glued to the glass plate.

We need to cut a little modification on the milling machine, to make space for a small AVR controller board, and the USB (micro-USB) plug. There is no need to batteries any more, it will all be powered by USB.

For the load cell interface, the 4 load cells need to be wired up in a bridge (not important in which order of the load cells, but always white-while black-black, and alternating red wired for drive and signal inputs.

So we use a very common HX711 driver, it seems to work well with these load cells. I still had a board with higher data output rate (can be changed by floating a pin on the HX711), but you may select the data rate as you like. The HX711 is continuously active, and sending data to the host though a USB serial chip, CH340.

The internals, a arduino nano fake board (not running arduino code, but just some plain avr-gcc code), and the HX711 all wired up, we just need some hot glue to keep it together.

All ready to be put back together. Watch the wires, these are very thin.

The USB port, it all looks as if it had never been without.

The receiver side, the balance digital converted value is directly transmitted to the host, so all the conversion to kg and zero correction is done by the host, including smoothing.

It is just a simple software, I programmed it using wxWidgets, but you can use any software that can handle USB/RS-232 communication and read serial ports, including Python, etc.

One bug with Windows – because of the continuous data stream over serial, Windows 7 seems to believe the balance is a serial mouse, and starts randomly moving the mouse pointer. With the little code below, this can be disabled and avoided. Probably need to add some waiting time before transmission starts in the AVR code.

If you need any of the code or further instructions, just let me know!

For calibration, a good hint, you can use milk packages (UHT milk), one pack is about 1060 g with very little variance, and it can easily be stacked up.
The Zero-Point seems to be very stable, I tested it after 90 kg load changes and so on, and it is not moving by 10 g.

CNC Lathe Signal Conditioning: fighting the noise

For the control of my CNC lathe, I need to read the spindle encoder (index and rotation signal), and two glass scales. These encoders all provide TTL level signals, and so far it worked well, but there are cases were electric noise of the switching motor or other equipment in the workshop. So finally I decided to put a bit more effort and upgrade the interface.

So far, it is just a cable that connects the three sources (spindle-index, x, z) to a parallel port input (a PCI card).

For signal conditioning, the input signals are filtered with a 4n7 capacitor+330 R, followed by a 74LS14 inverter schmitt trigger.

Everything on a little PCB, and put in dust-proof case so that it will work in the dusty workshop.

Finally, put it to a test and it worked “out-of-the-box”.

A simple schematic:

Electronic Master Clock: a huge train station clock is ticking again

Recently, I have been asked how an old slave clock could be controlled, it was saved from being scrapped, when a local train station closed down. It is really big and heavy. Eventually, I checked it out and it can be operated from 12 V, 24 V, or higher voltages by adding a resistor. We decided to operate it on 12 V, simply because one of the slides (this is two-sided slave clock) had already been set to this value.

In order to control the slave clock, we have to send a 1~2 second long voltage pulse, every minute, in alternating polarity. Then the minute hand will advance minute by minute. There is no second hand on this slave clock.

The control board is fairly simple, to test it all out, I soldered it on a piece of prototype board. Main control is by an ATMEGA8 microcontroller. This is using its own clock, from a Kyocera HC1 crystal oscillator to derive a 1 minute time interval, and and auxiliary 1 second output, for calibration purposes.

The actual adjustment of the clock is done in software, because the oscillator is pretty stable, and this is just a test circuit. If the slave clock will be a minute off, or two, nobody will mind.

The clock drive is completely separate from the controller, isolated by optocouplers. I used a small transformer, with dual 12 V output (because it is small current only, the output voltage is high enough, but you may use a 15 V transformer if it is handy).

Seems we are about 25 ppm out. After correction, the clock was running well within 1 ppm, fractions of a second per day.

To make the contraption a safe and useful thing, I put it in a little box, with some cables and feed-throughs.
Now it is up for some long term test, let’s see if it needs any modification.

SMEG CS19ID-6 Range: another defect

It seems my SMEG kitchen range is getting older… at least it is again showing some issues. The right hand side front induction field is sometimes coming on, intermittently, only to shut off quickly again. Normal operation is no problem, but when it is switched off, it doesn’t remain fully switched off all the time. Could be dangerous if some pot is left on the induction field, and the range decides to switch it on by itself… a praise to all the old-fashioned switches that completely took power off the appliance.

First we need to find out the source of the issue, is the it controls electronics, or the switch? To test, I opened up the front panel (easy enough, it is just 8 screws…), and switched the cables going to two of the front panel switches. And, as it turns out, the issue also switched. So it is probably a defective switch rather than any issue with the electronics. That’s good news.

For about 35 EUR, I got a new switch, as it turns out, it is no switch put a potentiometer…

… and a quick exchange fixed the issue. Now let’s do some study of the old part.

Made by printing some conductive composite on a circuit board. Looking good. I can’t see any issue with it even under the microscope. Maybe just some contact issue, the contacts also don’t look clean.

So I will clean it all up thoroughly, bent the contacts a bit to give it slightly more force, and keep it as a spare.

These potentiometers aren’t cheap, at least the use good engineering plastics for it, like, glass fiber reinforced materials.

Siemens Master Clock: Revision 2

This clock has now been in my possession for close to 10 years, it is a Siemens master clock with 3/4 invar pendulum. It is a nice clock, but also needs some repairs at times, especially, the contact wear out or get dirty over time so every two or three year it needs adjustment, cleaning and so on. Another issue is the noise every minute, which is caused by an electromagnet driving the winding mechanism.

There are many contacts and all these need to work, also the main gear of the second hand is triggering a contact, which is known to have an adverse effect on the clock stability, by putting extra load (losses) on the pendulum.

So, we have to re-configure the winding mechanism, and I decided to use a maintenance-free stepper driver. Like those used in old floppy disk drivers.

Only needed to fabricate a metal bracket to mount it to the clockworks. Needless to say, no modification of the clock has been made, I just made use of the existing holes and screws.

To indicate the fully-wound position of the clock, there is normally another set of two contacts that stop the magnet from further winding up the clock. However, also these need some cleaning and adjustment at times, so I replaced them with a inductive proximity sensor.

The sensor has a M8x1 thread, so a mounting bracket can be easily fabricated from some brass.

To control the stepper motor, the winding mechanism, and the second’s pick up (a simple light gate with some comparator circuit), a electronics board is in place, using an ESP32 microcontroller that include a WLAN interface.

The circuit is fairly straightforward. The stepper is driven by a 4-phase uni-polar driver, which has some resistors and diodes, and current switched by darlington transistors. The current per phase is roughly 120 mA, and only one phase active per step, operating in full-step mode with 200 steps/rev. Timing is roughly 10 ms per step.

Power is obtained from 9 VAC power, but the circuit will accept DC or AC, any polarity. A DS18B20 is used for temperature sensing. I am thinking about adding a BMP180 barometric sensor to the circuit, but now that everything is running nicely, I don’t want to disturb the clock. In any case, the circuit is connected to the clock by a 15-pin SUB-D plug, so it can be removed from the clock without removing the dials or anything else.

So I can run a small web interface which is polled every 10 minutes by my main server, to get the current time deviation of the clock, and its temperature.

The adjustments were very easy, and it only took a day to get the clock working to within 1 sec/day deviation. Let’s see if there is some drift developing over time.

The software gave me quite a hard time initially, because the motor control is interacting with the pick up of the pendulum (the light gate signal wire and the motor wires with inductive currents all installed parallel and powered from the same supply, so there were some false counts. Now the timing is such that the winding happens in the dead time, i.e., after a “tick” of the pendulum, and well within the time to the next “tick” (tick-tock-tick-tock spaced 0.75 seconds, so it is 40 ticks per minute for the 3/4 pendulum). That solved the false-count issues altogether, and still I am using a filter algorithm to reconstruct the action pendulum motions perfectly fine, even if one tick would be missed, etc.

SimonsDialogs – A wild collection of random thoughts, observations and learnings. Presented by Simon.