Category Archives: Electronics

Electronics

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.

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.

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.

New Smart Home: at least, gas&electric meters are talking to the world wide web

With the recent move to my new home, some curiosity about the consumption of energy, gas and electricity, first and foremost. The heating system is completely new, so there were no historic data about the annual consumption, and with winter time currently, I thought it could be interesting to collect some data and analyze.

The meters are not the best starting point, the electric meter says, manufactured in Western Berlin, e.g., during the period of separation in Germany, pre 1989… The gas meter is a but more recent but the well known old design.

At least, the gas meter has some provisions for digital read-out, probably, a magnetic system, with relatively coarse resolution, and a mirror “6” which aids itself to optical pick-up with 10 Liter resolution.

Here you can see the mirror… the “o” of the “6”.

To pick up the reflection, I used some IR transmitter-receiver pairs, you may take similar from an used computer mouse, I purchased some sets as surplus parts years back.

Now, the next challenge is to get the readings of the meters from the basement and 2nd floor, to the ground floor office that has the web server – to collect the data in one place and to analyze.
This is achieved by NRL24L10 transmitters in the 2.4 GHz band. These transmit to a common receiver that is connected to the web server (running Apache/Ubuntu) via a wired 9.6 kbaud RS232 link.

The transmitters and receiver are controlled by Atmel m328p, from some ready-to-use Chinese controller boards similar to Arduino nano, but the software and use is all avr-gcc, nothing to do with Arduino.

There is no need to deal with the NRL24L10 chip itself, because there are ready-made small boards available cheaply, less than 1 EUR per piece…

For the gas meter mechanical part, a small piece of plastic scrap and a Nylon screw is all that was needed to get a stable signal.

Sure it needs to be positioned well, but it is not a particularly sensitive or critical adjustment.

First, I just transmitted the strength of the reflected light to the server (receiver), and did all the calculation in the receiver, but this has various issues if the transmission of the signal is interrupted for some reasons, like RF interference or some other outage at the receiver end.

So I decided to change to counting the “6” pulses at the transmitter end, and the transmitter will send data every few seconds (including the time stamp of last counter change, and a time stamp synchronization data package every 10s of seconds).

Now it is counting very reliably, and can recover from receiver outages no problem.

The data received are interpolated to 6-minute intervals, i.e. 240 intervals per day.

With the electric meter, the mechanical part is a bit more difficult, as there is no place to attach a screw or anything, so I decided to use a piece of plastic, precision made to fit the front cover recess, and a metal wire (spring bracket) to hold it in place.

At the right positions, openings have been milled so that the wheel can be “seen” by the IR detector (the wheel has a red mark, and 75 rounds per kWh consumed).

It needed some fine adjustment and tuning of the pick up threshold, and an algorithm to avoid false counting by introducing a dead-time after each pick-up event, because with the wheel turning fast, e.g., when 10 kW are drawn, there have been extra counts. This has now all been eliminated by proper adjustment, more margin of the IR detector.

Some examples, with high power consumption in the workshop, i.e., 5 and 10 kW machinery and heaters in operation.

Additionally, the same system is used to record the living room floor temperature, in a corner, which is a pretty good representation of the heating system’s effect on the house. At nighttime, the heating is essentially stopped (13.5 degC as minimum temperature, which requires no heating unless it is a very cold night). The sensor is a DS18B20, which can be directly connected to the microcontroller with no further converters and delivers good accuracy.

It is seen that the regulation has some on/off characteristics, but the temperature stability seem stable enough for the purpose.

If you want to do similar things or need the code, etc, just drop me a line.

ADF41020 PLL: mysterious failures, and a not so mysterious fix

For years I have been building PLL microwave frequency stabilizers using the marvelous Analog Devices ADF41020 circuit, however, while in all permanent installation there were never any issues, occasionally the inputs failed in my attenuator calibrator setup – essentially a set of two microwave receivers, a microwave source, and a ultra-precision directional coupler (Narda 5082) and a HP transfer switch.

A EIP counter is used to monitor the rough overall power level of the incident radiation, as well as to check the correctness of the frequency and providing the 10 MHz reference to the PLL system. Each PLL has a ADF41020 board as the key input element.

One day, I noticed some ground loop currents, and again, one of the boards failed. So I decided to dig into it and solve it once and for all. Strangely, the board of the generator had never failed.
Looking at the datasheet, there are input diodes that may be easily destroyed by DC current flowing into the ADF41020 RF input.

It can’t tolerate voltages below ground or above 3 V much, so it is quite clear that some ground loops or other potential shifts can destroy it.

Further investigation showed that the RF sample output of the Micro-Tel SG 811 generator actually is AC-coupled (there must be some decoupling within the directional coupler that is getting the signal out, or in the switch leading to the sample output – which is quite possible because there are PIN diode switches inside that normally need DC blocking caps to work). The Micro-Tel 1295 receiver however have the center pin of the RF sample output connected to ground via a 50 Ohms resistor at the other side of the directional coupler taking some power off the line. So it is at least clear that the DC current from the center pin caused the ADF41020 to fail. Easily solved, added some 2.2 pF microwave caps. These are tiny parts, 0402 size, and remarkably cheap for their performance.

Soldering needs a steady hand, and definitely you don’t want to put a lost of stress on the board, which is mounted by the SMA connector only. Probably it could be made more rigid with epoxy, but I rather like to treat such PLL equipment and microwave gear with great care, because these are solid structures, but don’t handle impact and bending well.

After put all back together, so far no failures at all.

Siemens Electric Master Clock: after some years, a little repair

My trusty Siemens master clock, after some years of service without any trouble, it needed repair. The electromagnet coil that charges the weight, it is triggered by contacts that got dirty over time. So I cleaned all well with contact cleaner and some ultrafine abrasive paper.

With these little repairs complete, the clock showed another issue. It just stopped after some random time, and that is no good for a Master Clock. Generally speaking, pendulum clocks that stop oscillation randomly are difficult to fix. It may be dirt in some gears or bearings, it may be incorrect adjustment of the escape wheel, it may be some local disturbance.
Fortunately, the full clockworks can be removed without touching the Invar pendulum.

There are connectors at the top, well large in size, and with some silk spun wire.

Upon closer inspection, one of the main gears, which also drives the minute hand, showed issues. It is not fixed in position, but moved in and out. How can it be? When it gets out too far, there won’t be any reliable force transmitted to the pendulum, so it will eventually stop.

There is a washer, brass, on the back side of the movement, and this is supposed to hold the axle in a fixed position, while allowing it to spin freely.

Somehow, this washer had worn out. So I just rotated it.

Giving the clockworks a good clean and oil (only special clock oil made for medium-heavy clocks supposed to be used!), but without a full disassembly.

Now it is ticking away again, and showing the time, day and night.

Force compensating precision balance: a few very interesting, very rare schematics

With the recent repair of a Mettler AE analytical balance, I never thought that the schematics would be available and obtainable anywhere. Maybe even the Mettler corporation only has some dusty copies in their Swiss secret archive. But, as luck would have it, a very kind reader provided some of the schematics to facilitate repair and understanding of the working principle.

At the time of the balance, like, 40 years back, it was still a challenge (maybe it is still challenging today), to build a mechanical system and ADC converters that are stable in resolution and drift to 1:10E7 counts and similar.

The basic working principle of force compensation and precision balances has long been known from the relevant patents, Sartorius, Mettler, Shimazu and similar. There is position sensor that can very precisely detect the position of the balance, to better than a micron. Then, there is a force coil, a magnetic system similar to a loudspeaker to compensate the force. Various levels and hinges may be involved. Then, there is a current regulation, a current reference, and a ADC to deal with the conversion to digital information. There are also normally temperature sensors to compensate temperature drift. Normally, the balance is continuously measuring the reference current and the coil current, and for best results, always leave it plugged in. Inside, there is some quite heavy aluminum case not only as an electrical shield but to avoid temperature imbalance. Accordingly, even when “switched off” by the front panel switch, these balances are actually internally on, doing their thing.

Key part is the position sensor. It works by a differential pair of photodiodes, and the total photocurrent is kept constant by active regulation (the left opamp), both diodes work vs. ground in essentially short-circuit current mode. Note that at the red point, the currents of both diodes add up (as total flux reaching the diodes) and need to cancel out the current from the 680 k resistor to 15 V rail. One diode, of course, has a resistor in the feedback loop of the right opamp (transimpedance amplifier) that will drive current through the 680 k resistor in its feedback loop to cancel out any differential current of the two diodes (to keep the negative terminal at virtual ground). More precisely, both diodes are keep at constant bias (short circuit) even if the photo current various or is unbalanced. Such setup has very linear response over several tens of micrometers. Rather than the BPX48 diode, you can use better Hamamatsu parts. Normally a small slit is used to illuminate the diodes, say, 30 um. You don’t want to make it too small, otherwise, there will a lot of light needed with associated heat and drift, and you don’t want to make the slit to wide otherwise sensitivity will be less. Certainly good to use a high efficiency light source like the SFH401-2 (15 degree emission angle, IR emitter).

The ADC, it works by an integrator, a reference current source (based on a LM399 high precision reference in some balances!), and a few current switches.

The magnetic coil current is simply regulated by a control loop that has some lead-lag elements similar to a PID regulator (otherwise such loop won’t be stable because of the nature of the electromagnet and phase angle).

Such system is integrated in a custom ASIC. Probably the best solution at the time.

Fake DAC8512, AD8512, Mixup, or both?

The semiconductor industry is quite a bit plagued with counterfit parts, and there are all kinds of variations – plain fakes, parts that work similarly, parts that are actually true and real silicon dies but packaged by someone else, relabeled parts…

Troubled with these parts – clearly marked as DAC8512…

So I took a file and some patience to cut open the thing, until the bare die came to light.

Not easy to read on the picture – but my eyes are still good enough, clearly, there is the Analog Devices logo, and a marking, 17012, AD8512A.

Is this real? Did someone package AD8512 dies (probably sitting around in a box for some time, rejects or aged stock) and then put a DAC8512 label on then?

Found this picture on the web, of a genuine AD8512, decapped by a professional company – clearly, the same die.

No wonder I couldn’t get it to work as a DAC…. It is an opamp.