Some leftover boards are stocked at Tindie. More can be manufactured if there is demand:
If you like my work please consider supporting my caffeine addiction!
This is a logic level impulse to S0 converter/interface board. It is used to convert 5v logic level impulses to an S0 compatible format to use sensors like the TCRT5000 reflective optical sensor in existing smart home systems, that usually use 12v or 24v levels for digital inputs. This can be used to read out old school electrical meters as well as modern smart meters that only offer optical IR impulses or a spinning disc to "display" the current power usage.
There are 'two versions' of the board included. LasS0_FET uses a FET input stage. The included gerbers are NOT tested and probably won't be. The initial NPN input stage version however was ordered and tested working. The other, more recent version uses an AVR microcontroller as the input stage, specifically providing pulse extension and pulse division between the input and the S0 output. This was neccessary for me since my electricity meter outputs 10,000 imp/kWh with only a pulselength of about 7ms, which my smart home controller could not read. It required pulses of at least 15ms to reliably detect every pulse. The AVR counts a set number of input pulses and outputs a fixed output pulse once enough inputs have been counted. In my case I divide 10:1 and output a 30ms pulse after every 10 input pulses, changing the total resolution of my specific meter to 1,000 imp/kwh.
The AVR board additionaly breaks out all unused portpins to pinheaders as well as the AO screw terminal so you could theoretically read out the analog value of a TCRT5000 as well.
The device needs to be powered through J1
with 12-24v.
One of the upper jumpers needs to be set to choose between Direct
and Inverted
which would invert the output fully. If no jumper is set you won't get any output. If both jumpers are set you are going to have a bad time.
A 5v logic level impulse input such as the output of a TCRT5000 can be connected to J3/J4
at D0
, which is then output to J2
as an S0
compatible open collector signal through the optocoupler.
The following jumpers need to be configured to your usecase. Without setting anything, you will get an open S0 output without any pullup/downs on the inputs or outputs.
S0+ - VCC
- connectsS0+
toVCC
, allowing VCC pulses to be output onS0-
S0+ - PU_VCC
- connectsS0+
toVCC
via a 10K pullup.S0- - GND
- connectsS0-
toGND
, can be used withS0+ - PU_VCC
to have 24 V logic pulses onS0+
, which is how I use it for Loxone inputsD0-PD_GND
- connects a 10K pulldown to the D0 input. The AVR only has included pullups on the input port so if your application needs a pulldown it can be enabled on the board. Pullups can be enabled in firmware.
Additionally PA1
, PA3
, PA7
as well as 5V
and GND
are broken out to pin headers, the ICSP
port is fully exposed to pin headers, and PA0
is exposed to the A0
screw terminal, enabling analog inputs as well.
To translate any type of input pulse to any type of output pulse an Attiny24a is used. The firmware is done in C but built in PlatformIO. The project can be found in the firmware/Platformio
folder. To compile and upload, you will need to choose one of the build environments as default
will compile and upload all build configurations one after the other.
If you don't wanna compile yourself, there are several prebuild binaries for different configurations of input and output pulses. Find them in the firmware/builds
directory.
This directory contains .elf and .hex files for every environment.
The naming structure for the environments is as follows:
tinyWW_XXX_Y_Z
W
= Divider ratioX
= Output pulse lengthY
=r
for rising edge input,f
for falling edge inputZ
=i
for inverted output,n
for non-inverted output
So:
tiny10_30_n_r
generates a30 ms
positive
output pulse for every10
rising edges
on the inputtiny5_250_i_f
generates a250ms
negative
output pulse for every5
falling edges
on the input
The firmware is uploaded via ICSP
.
The device was tested, on a 23 V supply with 5 V test pulses from a function gen as well as the TCRT5000.
This version uses the high input impedance of the ATTINY inputs, reducing required input current significantly, not loading your input sensor at all. The following measurements / demonstrations were done with the AVR
board, PCB version 788734e, with the S0+ - PU_VCC
and S0- - GND
jumpers set, setting a pullup to SO+
and connecting S0-
to ground. Channel 1
is the function gen output, Channel 2
is measuring the pulled up S0+
.
The firmware version used is 1_10_n_r, outputting a 10ms non-inverted output pulse for every rising edge on the input.
10ms input pulses being translated to 10ms output pulses, just shifting levels.
The shortest input pulse that is stable to detect is about 150ns long at 5V. The device still outputs a 10ms output pulse.
Looking only at the switch on time the device needs about 100µs to fully switch on the output after detecting a rising edge on the input.
The following screenshot is a demonstration of the 5_10_i_r firmware, outputting a 10ms inverted output pulse for every 5 edges on the input.
The version that was tested needs around 6mA of current on the DO input to drive the input stage. My TCRT5000 module is only able to deliver about 1mA somehow so the channel 1 voltage with the TCRT5000 drops significantly but the output is still fully driven. Currently ordering some new TCRT5000 to see why the comparator can only drive such low currents.
The same measurements have been done with the FET version using AO34000A MOSFETs, removing the high input current but otherwise providing almost identical outputs (mostly limited by the output optocoupler, which explains the similar results).
The following measurements / demonstrations were done with the S8050 input stage, PCB revision 38b7723, with the S0 pullup jumpers set:
Considering this is meant to go inside your electrical cabinet it is best printed in PC or ABS and not PLA.
There is a 3D printable DIN rail case for the LasS0 PCB itself, as well as a readhead to attach a TCRT5000 module to EMH eHZ readers (which is what I am using this whole project for).
The case incorporates DIN rail clamps, remixed from a cable clamp by mdkendall, check it out here!.