EmonTx3 v3.4 ‘wired’ implementation

Introduction

EmonTx3 is a measurement node for an energy measurement system. It has measurement inputs for 4 current transformers, AC voltage, 6 DS1820B temperature sensors and a meter pulse counting sensor.

The standard configuration uses a HopeRF RFM69CW radio transceiver to emonhub running on some host.

This article describes modifications to the system to use a wired serial connection to the emonhub host.

Above is the emonTx3 board.

The approach taken is a minimal change to existing firmware and software, no change to existing hardware, and inexpensive components to extend the connection.

Outline of the solution

The existing firmware writes a debug stream to the connector used for firmware upgrade. It is a different format to that used for the radio link, and there are good reasons for that, but it means writing an interface handler for emonhub to parse the debug stream.

emonTx V3.4 Discrete Sampling V2.80
OpenEnergyMonitor.org

No EEPROM config
RFM69CW Node: 8 Freq: 433Mhz Group: 210

ct1:-51,ct2:0,ct3:0,ct4:0,vrms:23910,pulse:0,t0:223
ct1:-71,ct2:0,ct3:0,ct4:0,vrms:23924,pulse:0,t0:223
ct1:-6,ct2:0,ct3:0,ct4:0,vrms:23921,pulse:0,t0:223

The solution involves some hardware to interface the emonTx3 to the wire line, and a similar interface at the other end to the host running emonhub.

Hardware

Above is the debug stream from the modified firmware.
Above is an adapter (~$3) from the TTL levels of the UART port to RS485. The port is currently run at 115200bps, and that can be carried 800m with good noise immunity on good copper using RS485.

USB-485-10

Above is the host end adapter.

Firmware changes

The firmware was changed to repurpose the output that may be used for switching power to the DS19B20 sensors, it is now used primarily as an RTS signal to the RS485 adapter to reduce current consumption when there is no traffic. In fact, the RTS signal has been asserted also at times when the DS18B20 sensors are read and it could also be used for its original purpose without conflict.

Host changes

Assigning a consistent name to the RS485 adapter

A problem with USB serial adapters is that they may acquire different device names depending on the order in which they are started.

This is solved in this solution by use of FTDI adapters which have a serial number that uniquely identifies the adapter, and setting udev rules to assign a consistent symbolic link to the device. It is this symbolic link that is used in emonhub.conf

The link is achieved by adding the file /etc/udev/rules.d/75-RS485.rules with the contents below (the contents must match the actual adapter).

#Assign fixed symlink to RS485 adapter for emonttx

SUBSYSTEM=="tty", ENV{ID_SERIAL}=="FTDI_FT232R_USB_UART_A9WRVDPD",SYMLINK+="ttyRS485-0"

The udevadm command will provide the information needed.

root@emonpi(rw):log# udevadm info -n /dev/ttyUSB0
P: /devices/platform/soc/20980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/ttyUSB0/tty/ttyUSB0
N: ttyUSB0
S: serial/by-id/usb-FTDI_FT232R_USB_UART_A9WRVDPD-if00-port0
S: serial/by-path/platform-20980000.usb-usb-0:1.2:1.0-port0
S: ttyRS485-0
E: DEVLINKS=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9WRVDPD-if00-port0 /dev/serial/by-path/platform-20980000.usb-usb-0:1.2:1.0-port0 /dev/ttyRS485-0
E: DEVNAME=/dev/ttyUSB0
E: DEVPATH=/devices/platform/soc/20980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/ttyUSB0/tty/ttyUSB0
E: ID_BUS=usb
E: ID_MODEL=FT232R_USB_UART
E: ID_MODEL_ENC=FT232R\x20USB\x20UART
E: ID_MODEL_FROM_DATABASE=FT232 USB-Serial (UART) IC
E: ID_MODEL_ID=6001
E: ID_PATH=platform-20980000.usb-usb-0:1.2:1.0
E: ID_PATH_TAG=platform-20980000_usb-usb-0_1_2_1_0
E: ID_REVISION=0600
E: ID_SERIAL=FTDI_FT232R_USB_UART_A9WRVDPD
E: ID_SERIAL_SHORT=A9WRVDPD
E: ID_TYPE=generic
E: ID_USB_DRIVER=ftdi_sio
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=FTDI
E: ID_VENDOR_ENC=FTDI
E: ID_VENDOR_FROM_DATABASE=Future Technology Devices International, Ltd
E: ID_VENDOR_ID=0403
E: MAJOR=188
E: MINOR=0
E: SUBSYSTEM=tty
E: TAGS=:systemd:
E: USEC_INITIALIZED=8089809829

Interfacer module to parse the debug stream

An additional interfacer module was written to parse the debug stream, and it was hooked to the main module.

The interfacer is configured in emonhub and port layout copied in from source.

(the contents must match the actual adapter).

#Assign fixed symlink to RS485 adapter for emonttx

SUBSYSTEM=="tty", ENV{DEVLINKS}=="*usb-FTDI_FT232R_USB_UART_A9WRVDPD*",SYMLINK+="ttyRS485-0"

Code source

Code source is available the original git emonhub repo, and in the following git repository forked from the official repo:

Test

The wired configuration is under test with emonhub installed on a Ubuntu server, and about 40m of cat5e cabling from emonTx3 to host. No issues have arisen.

References / links

EmonTx_V3.4

DS18B20 input for the generic heating / cooling controller

The generic heating / cooling controller (hcctl) is a flexible bang-bang thermostat controller based on an ATTiny25.

The project has been expanded to accept a Dallas / Maxim DS18B20 1-Wire temperature sensor. The DS18B20 produces a digital output (signed sixteenths of a degree) has a range of -85° to 125°, accuracy of about 0.5°, and costs a dollar for bare chips, a few dollars for an encapsulated probe.

Above is a development prototype with the DS18B20 being heated by a small incandescent dial lamp to test function.

Continue reading DS18B20 input for the generic heating / cooling controller

ic9350 updated to support 3040

Announcement: ic9350 is updated to v1.03 to add support for the Codan 3040 automatic antenna.

The ic9350 is protocol converter to permit use a Codan 9350 or 3040 automatic antenna with an Icom radio. Most Icom radios support the Icom AH-4 ATU, so the approach is to design a protocol converter that converts the protocol used by the 9350 and 3040 to the AH4 protocol to allow full integration with the Icom radios that support the AH-4.

The ic9350 Protocol Converter uses the interface uses the radio’s ATU interface in the way that Icom intended, and will not disrupt radio operation . Continue reading ic9350 updated to support 3040

Thoughts on binocular ferrite core inductors at radio frequencies

Binocular ferrite cores are widely used, but not so widely understood.

Understanding inductors is an important first step to understanding transformers are they are coupled inductors.

The usual use of them is to make a winding of several turns around the central limb. One turn is a pass through both sides of the core around the central limb. Figures given in datasheets for Al or impedance rely upon that meaning of one turn.

A common assumption is that L=Al*n^2.

Note that published Al values are obtained by measurement typically at 10kHz and are not directly applicable at radio frequencies for core materials where the permeability µ is significantly different to µi (most ferrites). Notwithstanding this fact, most inductance calculators assume µ is not frequency dependent.

Let us measure a one turn winding on a practical binocular core for reference

Above is a measurement of R,X of a BN43-202 core with a one turn winding at 10MHz. X is  59.57Ω implying inductance of 0.95µH (assuming a simple two component model which does not capture self resonance effects). Datasheets for this core specify Al as 2200nH for one turn, yet we measure 950nH at 10MHz… proof of problems in simple application of Al.

Of course it is possible to make an inductor by passing a conductor once though one side of the binocular, a half turn if you like, but don’t let that label imply the impedance relative to a one turn winding.

Above is a measurement of a BN43-202 core with a ‘half turn’ winding.

If inductance followed the formula L=Al*n^2 and this was truly a half turn winding, we would expect the inductive reactance X ( 37.16Ω) to be one quarter or 25% of that of the single turn inductor (59.57Ω). Clearly it is not, it is 62%, the notion of a half turn or the formula or both have failed badly in this case.

Well on the back of that failure, lets try 1.5t.

Would we be brave or foolish to predict inductance will be 1.5^2 times that for one turn?

Above is a measurement of a BN43-202 core with a ‘one and a half turn’ winding.

If inductance followed the formula L=Al*n^2 and this was truly a half turn winding, we would expect the inductive reactance X ( 155.2Ω) to be 1.5^2 or 2.25 times that of the single turn inductor (59.57Ω). Clearly it is not, it is 2.60 times, the notion of a half turn or the formula or both have failed badly in this case.

Now let us look at Q, the ratio of X/R. The Q of the half turn inductor is 1.051, the one turn inductor is 1.022, and the one and a half turn inductor is 1.016. The quite small decrease in Q may be entirely due to the lower self resonant frequency as more turns are added and may not indicate a significant increase in core loss because of ‘half turn effects’ as sometimes claimed.

The error in conventional n^2 estimates of odd half turns becomes less significant with higher turns.

Conclusions

The traditional formula L=Al*n^2 does not apply to ferrite binocular cores at radio frequencies for odd half turns, and does not account for variation of permeability with frequency or influence of self resonance.

Understanding inductors is the first step to understanding transformers are they are coupled inductors.

VY Commodore key repair

There is lots of advice from online experts on dealing with a flat battery in a Commodore VY key. The battery is not “user replaceable”, it is embedded inside a key shell that is glued together.

In my case, the battery had leaked.

The following procedure was for the exact key, there may be other key types used in VY production, and it is also possible that other models used a key with the same internals and could be repaired in the same way.

NO WARRANTY: if you break it, you get to keep both parts!

I am an experienced technician, it is inadvisable to attempt this unless you have the necessary competencies.

Enough of the fear, let’s get on with it.

The key uses an ordinary CR2032 lithium cell, though with tabs. Above are two batteries which I prepared with 4mm tabs, but as it turned out, while the +ve one is 4mm the -ve tab is 3mm, I should have used 3mm.

Holden’s answer to the problem of the $2 battery being flat / leaking is to buy a new key head and get it programmed for a total cost of around $150.

Above, the underside of the board. The small chip is a 93S46 EEPROM, which hints that this thing has non-volatile memory and unless the controller chip does something clever like erase the EEPROM on power up, it should be possible to replace the battery carefully without sustaining power to the board. Continue reading VY Commodore key repair

BLHeli 14.8 damped light and active freewheeling

Aficionados of BLHeli call out the benefits of “damped light” and “active freewheeling”, terms coined by BLHeli’s author.

Since these are terms invented by BLHeli, so you might wonder whether they are truly innovative or just marketing hype for existing techniques.

Lets go to the BLHeli manual for an explanation.

Pwm damped light mode adds loss to the motor for faster retardation. Damped light mode always uses high pwm frequency. In damped light mode, two motor terminals are shorted when pwm is off

Taking the last statement first, in fact, what happens that as that during the OFF phase of the PWM drive, the high side FETs at both ends of the winding are turned ON. One FET is on for the whole phase, and the other one switches on a short time after its corresponding low side FET turns off. The short time is to allow the low side FET to cease conducting, otherwise both high and low side FETs would conduct at the same time, a current from battery +ve to -ve via the two FETs. There is a corresponding pause at the end of the PWM phase. The time delays allowed depend on the driver circuitry and FET performance, they are specified in the firmware  for a specific and don’t necessarily apply to a pin compatible ESC.

This technique is known in the wider community as COMPLEMENTARY PWM, a very standard technique. Continue reading BLHeli 14.8 damped light and active freewheeling

LED lighting woes

Pressed to replace working lighting with so-called ‘energy efficient’ lighting by well-meaning but narrow sighted conservationists, I recently replace about 25 CFL lamps with 12W LED MR16 lamps.

They have started failing now after a couple of years of service, perhaps a few thousand hours of service. So much for the claims of 100,000 hours… clearly preposterous.

In an effort to identify which of the switched mode power supply or LED assembly was the problem, I tried to substitute LEDs to different power supplied.

That was not a good idea, lets look at the anatomy of your typical Chinese junk MR16 LED.

Above is the complete 12W MR16 lamp with GU5.3 bipin connector on the back. Continue reading LED lighting woes

TV upgrade – MER optimisation

At TV upgrade I reported a change in TV antenna pointing to a different and distant transmitter, and gave a Spectrum Analyser plot at the main TV receiver.

At that time, I adjusted the antenna accurately (within 1°) based on compass heading, but antennas are not perfect and two significant path obstructions may have bearing on best signal.

I could have run up and down the ladder making small adjustments and observing amplitude or better, RF S/N on the Spectrum Analyser but that is tedious and suboptimal so I purchased a DVB signal analyser.

Importantly, a good DVB analyser gives measurement of not just signal strength, but carrier to noise (C/N) ratio (which is actually RF S/N), Bit Error Rate (BER) and Modulation Error Ratio (MER), the last two very important statistics in optimisation and validation and not available on an ordinary Spectrum Analyser.

MER is calculated as the sum of the squares of the magnitudes of the ideal symbol vectors is divided by the sum of the squares of the magnitudes of the symbol error vectors. The result, expressed as a power ratio in dB, is defined as the Modulation Error Ratio (MER).

MER is a good overall single statistic for quality, but BER is more sensitive to occasional errors, so they are both important.

satlink01

Above, the DVB analyser (the red device) enables a view of measurements whilst adjusting the antenna. The analyser here is connected to the masthead amp output and of course powers the masthead amp. Continue reading TV upgrade – MER optimisation

Coil32 inductance calculator

A recent online posting gave unequivocal recommendation for the Coil32 Inductance Calculator for application to a ferrite toroidal HF current balun.

Always interested in these things, I tried to download it to evaluate it but there was rigmorol to create an account and aware that I have never downloaded a calculator that handled that specific problem at all well, I was reluctant.

They do however have some online calculators that are supposed to use the same algorithms and methods as the downloadable software, so lets review the one for a toroidal ferrite inductor.

screenshot-07_11_16-16_21_15

Above is the data entry form, and warning bells sound. The “relative magnetic permeability” field is a simple scalar quantity, but the permeability of most ferrites at HF needs to be considered as a complex value (ie having real and imaginary components). Continue reading Coil32 inductance calculator

TV upgrade

The restack of TV channels, and then the allocation of spectrum immediately adjacent to a 4G mobile site that is 1km away and directly in line with Knights Hill (30km) caused me to rethink our TV source and switched to Mt Gibraltar (5km) to escape the 4G interference.

For whatever reason, the signal from Mt Gibraltar has dropped in level and is intermittently very inconsistent.

So, it is back to Knight’s Hill with a LTE filter to try to alleviate the interference from the in-line 4G site.

tv

Above is the received channels at the TV set with a 6dB 75/50 pad inline. After the last restack, the five desired are now at least 90MHz lower than the edge of the 700MHz LTE (4G) allocation, and with an LTE filter in the masthead amplifier, it seems interference is not noticeable. Signal quality reported by the TVs is consistently 100%.

The spectrum analyser plot underestimates RF S/N due to the system noise floor.

The channels used are 35 (ABC),36 (WIN),37 (CTC),38 (CBN),39 (SBS), all 250kW. Ch 35 and 39 are on the BA tower, the others on the WIN tower.

If only there was something worth watching!