USBasp – hints

The USBasp is a really useful and quit inexpensive ISP programmer that suits AVR 8 bit microcontrollers.

This article offers some hints on buying and using the USBasp.

There are lots of sellers of these on eBay, Aliexpress etc… but there are traps in buying them. I recall buying the USBasp with cable for less than $5, but they are more like double that now… or more

The adapters with the pogo pins are simply ordinary adapters with P75-xxx (eg P75-LM2) pogo pins inserted. Continue reading USBasp – hints

Fix for a certain TM1637 LED display

There are a miriad of low cost displays for hobbyists in online shops, particularly targeting Arduinos where libraries exist to drive the most common chips.

This article looks at a 4 digit LED module particularly suited to a digital clock display. The driver chip is a TM1637, and it requires Vcc and Gnd, a data IO wire and data clock wire.

Above is an example that just didn’t work. Continue reading Fix for a certain TM1637 LED display

Fox flasher MkII update 2/2021

Fox Flasher MkII and several follow on articles described an animal deterrent based on a Chinese 8051 architecture microcontroller, the STC15F104E.

This is an update after several years operation outside, and some in-service modifications to improve performance.

Above is the current version after 18 months in the weather. Continue reading Fox flasher MkII update 2/2021

Fox flasher MkII update 7/2019

Fox Flasher MkII and several follow on articles described an animal deterrent based on a Chinese 8051 architecture microcontroller, the STC15F104E.

This is an update after several years operation outside, and some in service modifications to improve performance.

ff201Above is the original basic schematic.

Above is the revised schematic. One only high current LED driver is shown, use as many as needed. The battery charger / protection module is based on TP4056 and DW01 chips and modules sell on eBay for $1 or so. Continue reading Fox flasher MkII update 7/2019

Fox flasher MkII – update 07/2019

Fox flasher MkII described a LED driver for an animal deterrent using a Chinese 8051 architecture microcontroller, the STC15F104E.

ff201a

Above, the schematic. A very simple circuit with just a handful of electronic components (one capacitor, two resistors, one LDR, one Polyswitch, 4 x LEDs and the MCU). Note the capacitor in shunt with the LDR, it is to reduce noise and to provide a level of RFI protection. Continue reading Fox flasher MkII – update 07/2019

Fox flasher MkII – high power 2 LED solar powered beacon – update 6/2019

Fox flasher MkII – high power 2 LED solar powered beacon described a LED driver for an animal deterrent using a Chinese 8051 architecture microcontroller, the STC15F104E.

FF100This article documents its failure  in June 2019 after five years service.  Continue reading Fox flasher MkII – high power 2 LED solar powered beacon – update 6/2019

Fox flasher MkII – high power 2 LED solar powered beacon – update 6/2018

Fox flasher MkII – high power 2 LED solar powered beacon described a LED driver for an animal deterrent using a Chinese 8051 architecture microcontroller, the STC15F104E.

FF100This article documents its failure  in June 2018 after three years service.

With the passage of time, the PV array surface has degraded until solar collection was insufficient to maintain the battery over several heavily overcast Winter days.

Above, a close up of the PV array surface. The pic is of about 8mm width, and one can barely see the silicon stripes which are about 2mm wide. Continue reading Fox flasher MkII – high power 2 LED solar powered beacon – update 6/2018

Inside the YHDC SCT013 current transformer

The YHDC SCT013 series is very popular for use in energy monitor projects.

Disassembly

Warning, the core is VERY hard, but VERY brittle, don’t hit it with anything hard, don’t grip in with pliers, don’t drop it on a hard surface.

The coil and half core are held in the lower housing by two obvious catches which click over the bobbin. Removal means pulling the assembly upwards gently whilst releasing the catches and feeding cable into the housing. One of the catches will probably catch on the slot in the bobbin, be prepared to release it.

 

An ideal tool for the purpose is an ordinary $2 DIP chip puller which can be used to get purchase on the two ears on the bobbin that can be seen in this pic. Push a little cable into the housing, pull upwards while releasing the catches, then feed more cable and the assembly is pulled upwards from the housing.

Above is the PCB detail. This one has a TVS (the black component) and no burden resistors. There is a place for two parallel 0806 burden resistors on the board.

The PCB floats on two plastic pin extensions of the bobbin. You may obtain benefit in securing it with two very small fillets of hot melt adhesive as above, small enough so as to not interfere with the guide rails in the enclosure.

Burden resistors

So if you wanted to add a burden resistor for 0.333V out at 50mA secondary current, R=0.3333/0.05=6.6667. You could do this with 1% resistors in the E12 value series, 12Ω and 15Ω will give the desired resistance. Likewise for 1V out, 22Ω and 220Ω in parallel will give the desired value of 20Ω.

If you wish to remove existing burden resistors, they can be removed with specialised tooling but small SMD resistors will usually melt the other side solder moments after melting the first side. Position a toothpick with one had to push the resistor sideways, with the other and use the soldering iron to eat one side to melt, move the soldering iron to the other side and push the resistor sideways with the toothpick as soon as both sides melt.

Protection

A CT that has no load could develop extreme and damaging voltage within the secondary winding in the presence of primary current. If the CT assembly does not have an integral burden resistor, it is wise to install a TVS or pair of inverse series 9V Zener diodes to prevent excessive voltage lest the external load be disconnected.

 

SCT-010-000 current transformer protection

The YHDC SCT-010-000 clip-on or non-invasive current transformer is widely used in DIY energy monitor applications, and is readily available on eBay for A$6 including post.

A key issue with current transformers is that current in the primary winding will cause excessive voltages in the secondary winding unless the secondary winding is suitably loaded. The broad rule of thumb is NEVER disconnect the output connections whilst current flows through the primary.

 

YHDC’s website is typical of Chinese web sites, and I could not find a datasheet for information on the internal circuit and possibly internal protection.
Continue reading SCT-010-000 current transformer protection

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