Axino Test Bench

Electronics snippets and schematics from Axino-Tech

These are circuits, ideas and sub-systems that I have developed. They are intended to be both educational and to stimulate ideas and interest. They are not fully evolved projects with complete constructional details. Where AC mains wiring is involved, proper safety precautions must be observed if one is reproducing the design. All Axino-Tech articles, including reviews and tests may be accessed from the Articles tab on the home page.

Latest projects first

Reducing the lamp flicker in the Jaycar QM3548 magnifier

Original schematic

A recent article about specifications for LED lamp flicker highlighted the poor result for this Jaycar LED desk magnifier. Read that article here. I decided to check out why the flicker from the lamp was so high. Below is the schematic of the power supply in the lamp housing. lamp PSU circuit The circuit is a simple full wave rectifier direct from the AC mains, using a 1.8uF/250V class X2 capacitor as a dropper. There is an R-C filter at the rectifier output. The 6.8uF capacitor has a rating of 250V. The dc voltage fed to the chains of LEDs measured 76V, however the superimposed AC was 26V peak to peak. This AC voltage accounts for the high level of 100Hz flicker from the lamp. This scope shot shows the levels fed to the LEDs. lamp scope view The scope is at 20V/division with zero ref at the bottom. Timebase is 2ms/division.

Improving the circuit

I added a 47uF/250V capacitor across the 6.8uF. While this did not fit on the small circuit board, it could be wired off the side with sufficient room in the housing. Also added was a 33k resistor across the capacitors to bleed off the voltage when the AC is switched off. This minor modification left the dc unchanged but reduced the ripple to 6Vpp. Following reassembly the flicker percentage was rechecked and it had been reduced from 84% to 30%. Still well above IEEE1789 recommendations, but now in the same ballpark as some other LED lamps that I had measured.

There is not much further scope for simple improvements to this circuit. A larger capacitor would not fit physically. If I was still concerned about the lamp flicker, the way forward would be either to try a get a small switching SMPS to fit in the housing, however 76Vdc models are not common. Failing that I would be inclined to remove the PSU, bring out the dc wiring from the lamp and use an external brick type PSU.


Only an experienced technician should contemplate a modification as presented. The dc output of the PSU is NOT isolated from mains and could be lethal. Safety relies on complete physical isolation from wiring and metal parts. It is very simple and other than an on-board fuse has no circuit protection. In fact, as it stands, if the LED's failed open circuit or the wiring to the LEDs was disconnected, the dc voltage on the filter capacitor would rise to around 340V and since the cap is rated at 250V, the smoke installed inside the capacitor will likely escape.

May 2017

Low pass filters for FM

Using the high order LTC1569 and MAX295 filters

For my recent attempt to make a simple low power FM transmitter, an Aareff stereo coder was used. Shortcomings of this coder included the fact that it included no audio low pass filters and in addition, the MPX baseband filter had considerable attenuation of the upper end of the baseband up to 53kHz. Audio low pass filters are required to pass audio to 15kHz without loss and then attenuate 19kHz in order to protect the pilot signal as well as have considerable loss at 23kHz and up in order to avoid aliasing with the sub-band from 23kHz to 53kHz. These demands typically require high order low pass and/or notch filters comprising a large number of op-amp active filter stages. Two such filters with matched characteristics are needed. Similarly, following the composition of the baseband signal, however that is done, a single low-pass filter is usually required to pass from 20Hz to 53kHz and attenuate harmonics of 38kHz (typically the odd-orders such as 114kHz and 190kHz). This filter needs good flatness and low group delay in order to avoid compromising stereo separation. The Aareff filter had 2.4dB loss and 23 degrees of phase shift at 53kHz while attenuating 114kHz by only 10dB. At that time I was keen to find a low parts count option to make suitable filters.

Switched-capacitor filters

The Maxim MAX295 chip is an 8th-order lowpass Butterworth switched-capacitor filter with corner frequency to 50kHz. This is a candidate for the audio low pass function. The Linear-Technology LTC1569-6 is a linear phase, 10th-order low pass switched-capacitor filter with up to 64kHz cut-off frequency, so is viable for the baseband filter.

For years, I had misgivings about the use of switched-capacitor filters for audio use, however this generation have low distortion along with clock to corner frequency ratios of at least 50:1 and with low clock breakthrough, the time has come to reassess. Both these manufacturers insist on manufacturing their products into such tiny packages that you can be mistaken into thinking that there is a small insect on the bench. However, after investing in a small scanning electron microscope I soldered the SO-8 chips to adaptor boards that bring pins out to 0.1" spacings, in the time honoured fashion.

MAX295 15kHz audio low pass filter

A pair of these filters were assembled in order to see how well matched they could be made. The schematic is below. For this trial I simply used the internal oscillator, although in a production version you might prefer a crystal derived external oscillator, despite the increased complexity of the sub-system.

Schematic stereo MAX295 15kHz low pass filter

MAX295 schematic

A single supply of 9.6V is used, and a mid-rail bias point established as shown. There is nothing particular about this method; it uses parts that were available. Both chips share the same dc voltages. The oscillator frequency and hence cut-off for the filter is determined by a capacitor at pin 1. This is the only critical component. For a cutoff around 16kHz, the oscillator cap is a rather low value, such that parasitic capacitance is significant, meaning that the cap value needs to be corrected empirically. That is why you see 3 capacitors in parallel. Both pin 1's were connected together. In doing this, the capacitor needed is half the value determined from the data sheet, but means that cutoff frequency drift will be the same for both channels. Drift due to temperature changes will be largely dependent on the temperature coefficient of the capacitor. NPO or zero ppm capacitors should be used, but even these can be plus or minus zero. One can optimise the capacitor by using combinations of positive and negative coefficient capacitors so that drift is minimised. The MAX295 includes an free op-amp stage which may be used as an inverting buffer before the filter as shown, or post-filter to reduce clock breakthrough.

Filter plots

MAX295 response MAX295 THD

These are the response and distortion plots. THD is very low with 1 volt rms applied. Even at 1.8V rms, harmonics are better than 70dB down.
Response at 15kHz is -1.3dB

One has to compromise the cutoff frequency. A little higher will reduce loss at 15kHz , however then the loss at 19kHz and 23kHz is also reduced. This seems a fair compromise for such a low parts count filter. Is this enough loss at 19kHz? I have seen some publications quote 19kHz rejection required of 40dB , however is this much necessary? The pilot is transmitted at 10% modulation; thus 20dB down. With some margin for receiver implementation and allowing for pre-emphasis then perhaps 40dB is required to assure safety. There is, however, very little 19kHz content in the spectrum of music, such that one could sensibly expect such content to rarely exceed 30dB below peak audio level. It is still pre-emphasised, so rejection of 25dB might reasonably be required. Therefore, this MAX295 filter falls short of ideal; having only 10dB of rejection, however it is better than none at all. Best practice means that a supplemental 19kHz notch would need to be included.

Baseband low pass filter using LTC1569-6

This chip is quite versatile and with one resistor may be set to a variety of cut off frequencies, or used with an external clock at 64x cutoff. In addition there is an internal clock divider being either divide by 1, 4 or 16 making three cutoff frequencies available by setting of a single pin. For this application, the frequencies from 20Hz to 53kHz should be passed with minimal loss and 114kHz should have a lot of attenuation.

Schematic LTC1569-6 baseband low pass filter

LTC baseband filter schematic

The LTC1569-6 will operate from 3V to 5V single supply. It became clear that the dc rail is quite critical. For this filter, 3V gave better distortion but the maximum level was only 820mV peak. In the end, it was determined that 3.6Vdc was the best compromise, however that will depend on your exact design. The nominal value for R1 is 10Kohms for 64kHz cutoff, however I lowered this value just slightly to move the cutoff frequency a little higher. The filter response droops slightly from 10kHz up, so that 53kHz was 0.7dB down. This is the reason that a MCP602 buffer was added. The network around the buffer boosts the top end just slightly to improve the upper end response. This addition may not be essential since the error without the added network is relatively small, although it will compromise stereo separation a little.

Filter plots

LTC filter response

Above is the response at 1dB per division for the overall circuit, including correction network, up to 48kHz; the limit of my Praxis system.
Note also the very good phase response.
Below is a response out to 100kHz made with an spectrum analyser.

LTC1569 filter response to 100kHz

For this plot, the marker is at 53kHz and vertical scale is 5dB/division. Ignore the start of the sweep; the analyser RBW is not low enough to resolve the start of sweep from the dc point. 100kHz is 37dB down. Response at 114kHz (3*38kHz) was -47dB and at 190kHz (5*38kHz) the filter had 60dB rejection. More than enough to clean up residual 38kHz square waves from a stereo coder and a much better proposition than the filter on the Aareff board.

At 1Vrms signal input, harmonics were better than 60dB down when Vcc was 5V, however best distortion was obtained at 3.6Vdc and less than 820mV rms drive. There was no visible sign of the internal clock oscillator feeding through to the filter output. This filter is a very good option for an FM baseband filter.

Alternative 15kHz filter with the LTC1569-6

By leaving pin 5 of the chip open (actually with 100pF bypass capacitor), the divide by 4 option is enabled so that the cutoff frequency becomes one quarter of that previously set. So in this case, the filter cutoff became about 16.5kHz. This was tried simply to see if the LTC made a significantly better audio LPF than did the MAX295. As it turned out, the LTC1569, while leaving the resistor R1 at 9K4, had 1.33dB loss at 15kHz, 7dB loss at 19kHz and 25dB loss at 23kHz, so was similar but slightly inferior to the MAX295.

February 2017

Door intercom remote sounder

Hacking an Aiphone C-123L/A and using a small Class D amp

We have an Aiphone C-123L/A front door intercom. The master station is in the kitchen. It has served us well but the call chime sometimes cannot be heard down in the office or studio. This short article describes a remote chime repeater including interfacing to the Aiphone, the wiring and programming of an Arduino Uno to generate the melody and the use of a tiny 3 watt Class D amplifier to drive a 27mm mylar cone speaker.

The Aiphone

Master and door units are interconnected by a single cable pair. Power for the system is by four C-batteries within the master. Having few callers, these batteries have lasted for more than 5 years. The signals on the cable pair were monitored to work out how to trigger the remote sounder. When there is no activity, there is 6Vdc across the wires. If the door button is pressed, the voltage drops to around 0.7Vdc and may have superimposed audio if the caller also speaks. At this time the chime sounds in the master unit. While the button in the master unit is pressed, the homeowner may speak to the door caller. Voltage on the pair then also drops to around 0.7V with audio signal. Once the master button is released, voice from the door unit can be heard at the master station for about 15 seconds. All rather clever and elegant. There is no replaceable battery in the door unit.

A remote sounder could therefore be triggered when the voltage drops from 6V down to 0.7V. To avoid any loading, the trigger circuitry should be high impedance. A separate power source is also required, since any load on the master battery supply would decrease battery life.

Arduino circuit

schematicI picked up a Uno clone for under $10. A tiny 3W stereo class-D amp was $6.95 at Jaycar and a 27mm mylar cone speaker was $3.95. These were the significant material costs for the whole project. Some people treat the Uno boards as development boards only and then make their own board using just the peripherals required for their project. I don't. At under $10 for a board, it is not worth making anything; for a one-off anyway. The Arduino board becomes just one component of the whole.

When the trigger line goes low, the Uno first puts pin D12 high, enabling the power amp. The trigger pull-up resistor is deliberately high (220kohm) so that no loading of the intercom pair occurs. After a short delay, the programmed tune plays. It runs for about 3 seconds. The tone squarewaves at D8 are filtered by a 2 stage RC filter, which also attenuates the level to be suitable for the amp board. There is no variable gain control in the system. Thats it. My 12V supply is tapped off an existing system. You will see a low value resistor (6.8 ohms) in series with the Uno "Vin" pin. That is to relieve the dissipation of the Uno regulator while the chime is playing. The PA draws some current and although it is within the current rating of the Uno regulator to supply it, prudence dictates a simple mitigation strategy. In quiescent state the 12V drain is 47mA, and while sounding, the system draws 330mA. That resistor then drops 2.25V so dissipation of the Uno regulator is reduced.

The sketch is here. It is a slightly modified version of the "toneMelody" example by Tom Igoe supplied with the Arduino IDE and described in the referenced tutorial.

The Class D amplifier XC-4448 module uses a PAM8403 chip

XC-4448 module picThis tiny module was purchased at Jaycar. It is similar to several versions available on ebay and other sources. They all use the PAM8403 3W stereo Class D amplifier chip made by located in Texas. This Jaycar version is only 23mm x 16mm with a single row of 11 pinout holes down one long side. Unfortunately the holes are not at a standard 0.1" spacing. Some are, but most are at smaller spacings. The board operates with a single supply of between 2.5V and 5V, however you will only get the full 3 watts output per channel by using 5.5V and 4 ohm speakers. Outputs are balanced (internal bridge mode), so speakers may not be commoned, or connected to circuit ground. There is a paucity of data available in the so-called 'data sheet' and that issue seems par for the course regarding all these cheap modules coming out of China. Jaycar is not alone there. Accordingly, some notes and test results appear below. Although the PAM8403 chip data sheet is available, the figures given there are not all relevant to results achievable on any particular module.

Switching frequency and RF interference

The measured switching frequency of my board was 213kHz at 2.5Vdc running into a 6 ohm resistive load, but increased to 230kHz with the supply rail at 5.0Vdc. These vary also with load impedance. These amps are likely to cause RF interference; particularly to AM services. The fundamental switching frequency will cause the most interference, but so will odd multiples; so in my case, 690kHz and 1150kHz, both within the AM band would potentially be affected. I didn't do any further study on interference actually caused, but if you were to have problems, there are a couple of options. First, minimise the length of your speaker wires. Then make your wires a twisted pair, such as could be found within a Cat5 cable for example. Shield the wires, if necessary. XC-4448 switching If this proves insufficient, or is impracticable, add RF filters to the amp outputs. Four small RF chokes hardwired close to the board will be worth trying, but ensure the chokes have adequate current rating, or the cores will saturate when audio is passed through them. That will reduce your ouput power and cause distortion. Finally, since the interference frequency is supply-dependent, alter the dc supply a little to move the interference away from your favourite AM channel.

At left, the 230kHz 10Vpp squarewave output into 6 ohm resistive load.

Current drain

The theoretical maximum power output using a 5Vdc rail and 4 ohm load is 3.12W. That will be fully clipped and sensible power limits are somewhat lower. For 8 ohm loads the maximum is 1.56 watts. So, the maximum current drain, if you were to apply a continuous sine wave to both channels at 3 watts output into 4 ohms, would be around 1.33 amps. This assumes the efficiency is 90% as claimed. In practice, you don't get the full efficiency. It varies with power output and load anyway, but will be maximum at full power into 4 ohm loads. Normally for music, one does not encounter continuous sine waves so the average dc consumption will be considerably less, although it could momentarily reach the maximum. The point here is that your 5V supply needs to be able to supply up to 1.33 amps, if you have 4 ohm speakers, but does not need heatsinking based on that, because average current, with music, is a lot lower.

Into a 4 ohm resistive load, with no audio output, module current was 190mA at 5V. One channel at full power, current was 700mA and both channels at full power, current was 1000mA. Now, I couldn't quite reach 3 watts with both channels driven (see next paragraph). In addition, I rated full power at the point where distortion just exceeded 1% and not 10% as per the chip data.

If you measure using resistive loads, you would not get the rated full power, nor would you get the rated efficiency. In the case above, the efficiency works out to be only about 63%. There is a reason for this and which will apply to all Class D amps that have no RF filter at the output. The amp is actually continuously putting out a 10Vpp square wave (assuming 5V supply) at 230kHz and this appears across the load. If the load is resistive then the amp is delivering power already into the load. You won't be able to hear it, but it will reduce power capacity and increase the current drain. In practice, even a 'resistive' load will have some reactance at that frequency as will the connecting wires. A speaker has a rising impedance due to its coil inductance, so will present a high impedance load at 230kHz, and not pull much current from the supply. DC supply currents, when operating into a speaker, are less than those into a resistor, for the same audio power output.

In my case, I used only one channel and the speaker was nominally 8 ohms with a further 4 ohms in series to lower the output. Into that load, the current drain of the amp without audio, reduced to 20mA and when operating near full output, was only 280mA. Including the 47mA of the Uno itself, total current is well within the ratings of the Uno regulator.

Frequency response, gain and distortion

It would be helpful if the suppliers of the modules would provide this information, however it looks like a vain hope. You could assume the chip datasheet would assist but overall performance depends on the peripherals around the chip.

XC-4448 response

For reference, the gain of this XC-4448 module is 18dB. Therefore, full power requires 440mV rms drive. The audio input resistance is 20Kohms. Although it wasn't an issue in this project, the frequency response of the module is poor at the low end. See plot. You can see both 4 ohm and 8 ohm plots here. The distortion (THD) up to and including the 9th harmonics, was 0.12% at 400Hz and 0.9% at 5kHz. This was taken at a power output just prior to the onset of clipping and was for only one channel driven.

Muting feature

Again, there is nothing on the module datasheet to indicate the working of the mute function. You have to pull the SW pin low (below 0.7V) to mute the amp. For normal operation, take the pin high. The amp draws negligible current while muted as it shuts off the HF switch generator. I noted that it takes around 220ms to enable, which is why there is a delay between enabling and start of tones in the melody generator sketch.

January 2017

dual MCP3201 12 bit ADC's

Using Arduino Uno

The MCP3201 is a 12 bit ADC in an 8 pin DIL package. It uses SPI to communicate and can operate at up to 100kHz sampling speed. I built a small breakout board including two MCP3201 chips along with low noise 5V regulator, precision 4.096V shunt reference, analog buffers and comparators; the latter might be useful to extract zero-crossing information.

The impetus behind this experiment was to trial the ADC's for sampling voltage and current for appliance power measurement. The Arduino is natively only 10 bit, and while this is perfectly adequate resolution for the voltage measurement, it is not really sufficient for the current range, since a mains appliance might draw as little as 1 watt and up to 2300 watts; which means rms current ranging from 4mA to 10A (on 230V/50Hz mains). That is a 2300:1 ratio, requiring a minimum of 12 bits quantizing. An alternative method might be to employ an PGA (programmable gain amplifier) for the current range.

ADC schematic

Referring to the breakout schematic, you will see that the two analog buffers are not quite identical. I designated channel 1 for voltage sampling, and this AC sample would be derived from a transformer scaled down to provide 1V peak approximately centred around 0V, so the buffer is AC coupled to the MCP602 R2R op-amp with a mid-rail offset (2.5V). The offset is necessary since the ADC analog inputs only function between 0V and the reference voltage, so may not go negative. I intended the current sample to be derived from an ACS712/20 current sensor chip, which has 100mV/A sensitivity centred on mid-rail. Since the ACS712 devices provide the bias, channel 2 input is direct-coupled. ADCschematic

An accurate and low noise reference for the ADC's is essential. I have used an LM4040A shunt reference which provides 4.096V within 0.1%. Using the configuration in the schematic, the total noise on the reference rail from 5Hz to 48kHz was measured at -72dBV, with no individual product above -90dBV. Once the system was running with the Arduino, and with zero input applied to the ADC, the noise jitter on the reading was only 1 count (1 part in 4096). Early tests using the Arduino 5V reference (from USB), gave a jitter of up to a count of 8, which effectively nullifies at least 2-3 bits of quantizing. The ADC count returned from a 12 bit converter ranges from 0 to 4096. With a reference of 4.096V, each ADC value represents exactly 1mV.

Since my ADC reference is 4.096V and the midpoint bias is 2.5V, the maximum peak input that may be applied is 1.596V. So, the volt sample peak must be below this, and this is also the highest value that can come from the ACS712 current sensor chip. At 100mV/A, this means I can measure appliances of up to 15.96A peak current. This is fine on 230V systems but may be inadequate for 110V appliances. The ACS712 series comes in higher current versions.

The comparator sections are entirely optional. These produce a square wave with transitions at the AC zero-crossings. It had occurred that it might be useful to sync the ADC samples or try and measure phase difference, however my initial Arduino sketch does neither.

Arduino Sketch

This is for a basic Uno. The sketch is below: It gets the raw ADC values from ADC1, followed immediately by ADC2. With no serial port running, there is a delay of abt 4us between completion of ADC1 read and start of ADC2 read. Conversion time depends on the ADC clock divider. If DIV=4, conversion time is 18us. Time between successive reads depends on all the stuff in loop, but without serial printing,and DIV=4, time is 48us with 6us timing jitter. Samples from each ADC are not strictly synchronous, however for the purposes of calculating AC power of an appliance, the error will be small. I measured 22us in total with the settings in the sketch, meaning a phase error difference of 0.4 degrees. Serial printing is enabled in the sketch, mainly for diagnostic reasons, but these may be commented out to keep the time between successive reads as low as possible. Ultimately, the results would be displayed on an LCD or TFT display, once the system was refined.

The sketch returns the sample instantaneous values with the offset removed, so the numbers returned are equal to millivolts. This, it does for both channels. Then there is a routine for the max and min value within a rolling 15 cycle window on the ADC2 channel (for current) only. Most analog implementations of this would then have the values exponentially decay to the next cycle, but here, the decay is linear, just to keep the calculation simpler and faster on the Arduino. Then, there is a smoothing routine on ADC2 only. I have averaged 40 samples for this value. It may be of use for low values of current, or to establish the zero point, although with this breakout, the zero point is stable and can legitimately be hard-coded. Since this is experimental so far, there is no scaling applied to the returned values. I have had this sketch running with test signals and the returned values are accurate. The "Serial Plot" app is very useful to visualize the serial port outputs in cases like this.

Next step is for me to work out a way to calculate rms values from the external ADC instantaneous values. My attempts to date have not been succeeding which is not a surprise, since my hardware skills far exceed my programming skills. I have noted that many methods seen on the web to calculate rms in software rely on the AC waveform being sinusoidal. Yes, it is relatively easy to scale for a known signal like a sine and that might just be sufficient for the (usually slightly distorted) voltage waveform, however the current waveform from mains appliances (apart from heaters) is far from sinusoidal and so a sampling, squaring, averaging of aggregates method is required. That will be in the future.

Project files

House AC power remote monitor

Using Arduino and Nextion display

Many years back, before the 'OpenEnergyProject', I built a monitor unit to measure house power consumption. It used purely analog techniques, with hardware rms detectors and included local readouts for voltage and power consumption. Data was obtained using a clamp current transformer situated around the incoming neutral of the switchboard. A small 1.5VA transformer was used to produce a sample of the mains voltage. This unit was situated out in the garage, adjacent to the switchboard. The unit was accurate and stable but wandering into the garage to see the power consumption became a bit tedious after a while.

On reading of the HopeRF RFM69HCW integrated packet tranceivers and having discovered their ready availability, this project to send the data via wireless to my office was born.

The sending end

The HopeRF modules run from 3.3V, so I used an Arduino Pro Mini 3.3V to drive it. I made up a small sub-board to go inside my original monitor unit. This board has the Arduino, the RFM69HCW-433 board, a 3.3V PSU and a dual op-amp rail2rail buffer section. The only external change to my monitor unit was the 6" antenna wire and a blinkin' LED which flashes every 15 seconds when a data packet is sent, or gives long flash if my 3.3V PSU becomes out of limits. The Arduino sketch includes both the LowPowerLabs RFM69 Library and the emonLib library. Thanks to both Felix Rusu of and the OpenEnergyProject.

TXend block

I implemented the NetworkID, NodeID and encryption features, but not 'acknowledge' since the transmit and receive ends are in fixed locations and if a rare packet was missed, there is no consequence. This is the 433MHz flavour of radio, they also come in a 915MHz variant. The -HCW models produce up to +20dBm. This is a bit high to be legal here, with +14dBm maximum EIRP allowed, so a line in the sketch reduces the radio power to under 0dBm. This proved to be more than enough for the system- the RSSI result on the receiver varies between -60dBm and -70dBm.

The emonLib does the calculations for the electrical parameters. One sets a scaling factor for voltage and current. The library produces values for realPower, apparentPower, powerFactor, supplyVoltage, Irms from the voltage and current AC samples fed into the Arduino. These five parameters were assembled into 'csv' format and sent as a single packet. Scaling factors were set by comparison with a Yokogawa WT210 precision power meter.

The receiver end

An identical RFM69HCW board is used as the receiver. I wired this up to a Arduino 'Metro' because I had one lying around. These are a Uno style board from Adafruit Industries. In addition, to time stamp the data, there is a DS3231 RTC module. For the remote local readout I purchased a Nextion color TFT display of 320x240 pixels. These are really cheap and they have onboard memory so once the display module is programmed, the Arduino need only supply the textual data values. Of course there is a learning curve for the Nextion Editor, but for this simple application it isn't too long. The Nextion is touch screen and can have multiple pages; neither feature is used here. RXend block

Power supply requirements slightly complicate the receiver end. The Metro is 5V, as is the DS3231 and the Nextion. The RFM69HCW is 3.3V, and when transmitting, it draws 130mA; a bit more than is desirable to try and get from the Arduino. Although this board is strictly a receiver I didn't want to take the chance it might transmit (such as when acknowledging a packet). As it happens, the Nextion module has a 3.3V regulator on board. I tested it's capacity and it would supply 130mA without trouble. So I hard wired out the 3.3V from the Nextion to run the RFM69HCW board. As another complication, logic-level conversion is necessary. There are five data lines to and from the radio. One can buy cheap logic level converters which are bi-directional; four to a board. Sigh, so two of these became necessary. Cost isn't the problem, but mounting and wiring out is, especially for elderly eyesight.

The DS3231 RTC module (aka ZS-042) may need a modification. If you either don't run a backup button battery, or use the rechargeable lithium such as the LIR2032 type, then no modification is necessary. However, if you use the common non-rechargeable lithium CR2032 type and this is what it may even come with, then you need to cut a track to avoid the system trying to recharge the battery. There have been instances of the lithium non-rechargeables bulging and getting hot, so this process is advised. Instead, you could either remove the 200 ohm resistor or diode connected in series from the 5V bus to the battery, but cutting the track allows for simple restoration if you decide to go rechargeable later. The CR2032 only powers the essential timekeeping part of the chip while 5V is removed and will last a very long time. I did build in a battery monitor to the sketch, which will show 'Batt Low' if the button battery goes below 2.4V. The DS3231 will keep time on battery down to 2V. I have seen ads for these lithium batteries from many web suppliers where they either don't state that the CR2032 is non-rechargeable, or have them in the rechargeable battery section.

Always thinking to the future, I brought out the 32768Hz from the RTC to a panel connector for no particular reason other than it might be useful. It is reasonably accurate; of the order of 2ppm. I also wired out the SQW pin of the module to a LED so I can see time passing in 1 second increments. This pin will supply only 3mA but is sufficient for a LED.

The Nextion communication with an Arduino is via a Serial UART. The Uno has only one serial port and that is used for programming and to Serial.print the electrical data to the outside world for logging and analysis. So it is necessary to use the SoftwareSerial library, which adds a virtual serial port. This enables the Uno to send data to the Nextion independently of the hardware serial port. I could not, however, establish a way of linking serial data from the hardware port to the virtual port in order to upload firmware to the Nextion. So, as you will see from the schematic, there is an 6 pin header on the back of my unit with a 2 way switch so that the Nextion can be programmed by use of an FTDI cable when required. display pic

This Nextion display has a visible display area of 60mm x 45mm. Every 15 seconds, the data fields update as a packet is received. In addition, the signal strength from the receiver is displayed, plus the RTC battery status. Finally, along the bottom is the RTC time.

Data logging

The USB output of the Arduino can be connected to a pc and with the use of a serial monitor (Arduino IDE, or PuTTY, or Eltima Software RS232 Data Logger) can be visualised directly or logged to a file. I simply configured the serial output as a single line: "Date,Time,realPower, apparentPower, powerFactor, Vrms, Irms, RXlevel, BattFlag". Such a CSV file may be easily opened with Excel or similar for analysis. In future, I may want to develop a simple web page displaying the essential data, but have not yet connected all the process and programming dots from the point of saving a csv file to my Winampserver to a working web page.

Links and project files

Line voltage monitoring

with small transformers

For domestic AC line monitoring purposes, there is a requirement to measure the voltage. Most of those commercial power monitors simply assume a line voltage in order to calculate power, but if the line voltage varies then their power calculations will be wrong. Where I live, the voltage can vary from 215V to 255V; a range of -6.5% to +11% from the nominal 230V. I advocate using low power step-down transformers. While I have seen designs for isolated high side monitors, these are inevitably more complex, needing an isolated dc rail and complex electronics. The power grid is an electrically hostile place and too many things can go wrong.

What is wrong with using the humble transformer? Again, on browsing web articles on the matter, most objections seem to be related to distortion. I have to question this, since if the only requirement is to obtain a voltage sample, then some distortion will not matter. In any case the voltage and phase relationship is a constant and the scaling factor can be established easily enough. transformerpicIf one wants to measure the AC voltage distortion, this is another matter. Power consumption can be of concern, but with careful design, this can be reduced to less than a couple of watts. Size is immaterial since encapsulated transformers under say 2VA, with the proper isolation specifications are neither large, nor expensive. Persevere with transformers because this is the safest and most reliable method for the hobbyist/TestBench.

To try and quantify transformer distortion, I performed a couple of simple experiments. THDnoloadA small encapsulated transformer (Block VB 1,0/2/24) which is 230V to (24+24V) at 1VA , is connected through a variac and the distortion measured at various voltages and load factors. Because power consumption should be minimised, the first test is with no secondary load (actually about 68Kohm). The two 24V windings were wired in series and a potential divider used to feed the THD analyser. Result is plotted at right. Distortion starts to increase above about 175Vac input. (75% of nominal voltage). Distortion is significant by 250Vac. I know from previous measurements at these premises that the AC line voltage here has between 3.5% and 4% distortion, so it is a reasonable conclusion to say the transformer is not distorting below 75% of nominal primary voltage.

So, if the waveshape were of importance, then this would be of concern. This test was repeated with an 8VA transformer from the same manufacturer. The same basic trend was apparent but to a much reduced extent. In that case, THD reached just over 4.5% at 260Vac. The power rating of the transformer is relevant to the result, however an 8VA model is becoming impractically large for the application. I should add that a transformer used as a voltage monitor should not also be used as a power supply for other parts of the circuit, unless one is very careful to keep the loading constant.

Back to the 1VA version, the test was repeated with a 1500 ohm resistive load on the secondary. Remembering that in this case, the secondary is rated 48V at 1VA, making this load slightly exceed the rating of the transformer for primary voltages over 200V. But now the distortion vs voltage curve is completely different. THDwithloadSo this suggests that with heavy loading, a given transformer has relatively insignificant THD, while at no load, the THD increases rapidly above a certain primary voltage, meaning that core saturation due to exceeding a threshold flux density is the culprit. Different makes of transformer are likely to produce different results; they are made for differing purposes, with variations of core materials, but the general principle and trend will remain.

The answer seems apparent; that to maintain the waveshape, which is to say minimise the harmonic distortion, then the transformer should be operated with a heavy (relative to the rating) load on the secondary and to be a stable voltage monitor, that load should be constant. However, we also want to minimise the power drawn by the monitoring circuit. A heavy load is then contra-indicated. Therefore, use the smallest transformer possible; Block have a 0.35VA rating variant with all the safety and isolation standards necessary. The other way is to use a transformer designed for a higher primary voltage, if possible. You 110V people have the option to buy a 230V transformer, or possibly series up two primary windings to get the same result. A transformer running at around half rated voltage will have minimal distortion, even with a light secondary load. Here in 230V-land, there are no such transformers suitable off the shelf. Looking for 460V transformers produced no useable result; these start at about 500VA.

The next best option for a AC voltage monitor which minimises distortion, while keeping power consumption low, is to reduce the voltage applied to the primary. A resistor seems the obvious answer. Keep the voltage applied to the primary under half the rated input voltage and there should be no problem with distortion. What value of resistor? For my 1VA transformer, primary resistance was 3850 ohms. For the inductance, I measured 35H, by using the resonance method in conjunction with a known capacitor across a signal generator. The reactance of a 35H inductor at 50Hz is 10996 ohms. Therefore the primary impedance at 50Hz is 11650 ohms (square-root of sum of squares). 60Hz people need to recalculate. So, a 12Kohm resistor would be about right. That needs to be rated for at least 2 watts in this case, and it is always best to put two equal resistors in series anyway, for voltage handling reasons.

This was wired up on the bench and the voltage across the primary was indeed about half, however the distortion was worse! The reason for this was immediately clear and that is that we now have a RL high-pass filter. Inductive reactance increases with frequency and so the transformer was now more receptive to coupling harmonics of 50Hz, making THD worse. Increasing the value of series resistor worsened this effect further still. The next step was to try and flatten the rising impedance with an RC network across the primary of the transformer. If the values are chosen correctly, the RC network will be a 'mirror-image' impedance, making the whole look resistive. Choose a resistor more or less equal to the resistance of the primary winding, so in this case about 3.9kohm. The capacitor value is best empirically determined and this is what i have done, ending up with 2.2uF in series with the 3k9 resistor. That network further increases the gross voltage transformation ratio, so the output voltage is lower, but the distortion is now minimal. In fact, you could choose any suitable value of dropping resistor (the 12kohm calculated above) so that your secondary voltage is in the range of your analog to digital converter, which might be only 1.65V peak. I ended up with the network below:


The 1.4V peak ac output is about right for an ADC running 3.3V reference and with a half-rail offset. In fact the half rail voltage divider could be applied to the centre-tap of the transformer and each end fed to the differential inputs of a suitable ADC. The two 27k resistors now dissipate only 0.87 watts between them and the primary transformer voltage is around 12Vrms. Distortion is minimal. Transformers are complex beasts and there is no such thing as a perfect version, outside of a textbook. Inter-winding capacitance and leakage reactance make even modelling them a time-consuming process. There is one further advantage of a network like this used as an AC voltage monitor and that is to correct the phase shift. The unobtainable perfect transformer will have zero phase shift with a resistive load. My tests of various models reveal they typically have between 7 degrees and 10 degrees of phase shift between input and output. The 2.2uF capacitor partly corrects this, and by varying the value a little, it could be corrected to zero, for a given transformer. Alternatively, leave the 2.2uF cap alone and add a small value cap across the secondary. Of course, you will need some means of checking the phase shift while benching all this up, in a safe manner of course. There is some danger of 'improving' the distortion of the mains by doing this. By adding capacitors one is adding low pass filters that can reduce the higher harmonics. To preserve the original AC waveshape one must maintain the original ratio of harmonics, so reducing harmonics is as bad as increasing them. Fortunately you only need to have a flat frequency response to the 7th harmonic, or 350Hz. (420Hz for 60Hz countries). Above that, the harmonics of the grid AC line voltage drop away quickly. This is not true for harmonics of current waveforms, for which I have seen some nasty loads that produce harmonics out to the 49th at least.

The Axino mini-FM transmitter

Up to 1 watt RF output

meter displayThis small project arose from my earlier (2014) attempt at making an FM transmitter and which, for the reasons of expediency, was based around a MAXPRO3000+ transmitter board from pcs-electronics. You may read the full technical description of that exercise via this link.

The MAXPRO3000 had some issues; namely RF harmonic levels too high, deviation sensitivity varied considerably with RF frequency and the modulator became unstable with low audio frequencies. The current project is an exercise to see if a simple transmitter could be built without having similar problems.

The synthesizer and modulator techniques are hardly ground-breaking and are entirely conventional. A modern approach would most likely comprise a DDS and a lot of programming, but I considered that too steep a learning curve at this stage, so stayed with the simple VCO and single loop synthesizer approach.

mini-FM transmitter article

RF controller experiments using ASK/OOK 433MHz modules

no microcontroller needed

tx and rx  picSimple RF controllers may easily be built using readily available and inexpensive RF modules which operate within the 433MHz band allocated to such devices. In New Zealand, this band extends from 433.05MHz to 434.79MHz having a nominal centre of 433.92MHz. Maximum permitted power level is -16dBW (25 milliwatts) EIRP. An example pair of these was bought on ebay for testing.

RF controllers article

An improved mini-oven temperature controller

Better temperature control

I recently bought an inexpensive mini-oven (benchtop oven). I will always be amazed at just how little one has to pay for simple appliances.

Part of the answer is of course, that these are unsophisticated in design and construction. panel controls picYou will have seen similar in appliance stores. Controls on this one include a temperature dial, an element selector for top, bottom, both or none and a clockwork timer (-it is the 21st century) that goes ding when time has expired. It also turns off the heating elements when it hits zero.

You know, it does work. One cannot argue about the functionality for the price paid. However, the temperature control was not good. When set to say around 150 degrees (celsius) or above, the elements would never turn off and there was a suspicion of the smell of overheating plastic. It would cycle on and off if the set temperature was below around 120 degrees, but the whole temperature control was unsatisfactory.

The temperature dial was actually a simmerstat and the temperature of the oven is effectively only guessed, since there is no actual temperature measurement or feedback. Simmerstats are appropriate for hot plates, but ovens? I tried to readjust the simmerstat but this was difficult, and I only succeeded in making it switch on and off at too low a temperature even with the control at maximum. It did seem impossible to get just right. So, it was time for improved temperature control.

Temperature Controller article

The Axino-tech appliance power meter

Checking appliance power consumption

This article presents the design of an 230V appliance power meter. The meter not only reads out the real time rms voltage and current values, but has isolated sample outputs of both voltage and current for viewing on an oscilloscope or measurement via any sound card based system.

meter pic Appliance meter article

An AC auto-boost unit

Steps up low AC line voltage

Our Hoover washing machine stopped operating if our AC line fell below 234V. This unit provides for just 12V boost, which kicks in if the input side goes below 234V. Once the AC input reaches 241V, the unit switches back to bypass. I used a toroidal 12V+12V transformer, rated at 160VA; wired the secondaries in parallel and connected one side of the secondary winding(s) to the incoming mains in the sense that provided boost. The parallel connection means this transformer can deliver 13A, so is larger than is needed, but the next size down (80VA) I regarded as marginal for this application. Usually I prefer not to wire secondaries in parallel because a slight difference in voltage between secondaries causes additional transformer heating, however a well made toroidal type can be relied on to minimise this problem.

Auto-boost unit article

Build a microphone preamplifier

Using a THAT1512

Data sheet for the THAT1512 can be found here. This IC is designed from the ground up to improve on existing integrated microphone preamps by offering lower noise at low gains, wider bandwidth, higher slew rate, lower distortion, and lower supply current. The IC includes ESD overload protection on all critical pins.

mic amplifier

My design evolved a little (some call it scope creep) to include some high-pass filtering, low pass filtering and a simple bar-graph level indicator. I decided to run the unit from +12V and so the design includes a 48V converter for the phantom power and balanced 15V rails for the audio stages. Most of the sub-sections are based on manufacturer data sheets or are off the shelf boards. This is however, not a step-by-step constructional project although experienced constructors should have no problem replicating the final design.

Mic preamp article

Axino-Tech Consulting & Services 2009-2017