Monday, May 30, 2022

Experimenting with RF modulators part 2: Sky IO Link and control via a Raspberry Pi

Following on from Experimenting with a programmable RF Modulator (making a controller for it and testing harmonics), I have continued my work on this topic with these goals in mind:

  • Make a neater VBIT-Pi assembly by integrating the modulator, VBIT-Pi hat and Raspberry Pi into a single unit
  • Control a Sky IO Link

Raspberry Pi control

The Raspberry Pi already has I2C support, and it is fairly straightforward to use it from the command line and in a Python script. In my application, the Raspberry Pi is already being used with a VBIT-Pi hat, an open-source hardware teletext generator which adds teletext data to an external video signal, which has two ICs on it connected to the I2C bus. Fortunately, the modulator IC's I2C address is different to the two ICs, so it's simply a case of wiring up the I2C pins to the same pins used on the VBIT-Pi.

The i2cdetect command can be used to test that all the I2C devices are connected:

pi@raspberrypi:~ $ i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n]
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- 25 -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- 65 -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

The modulator can then be tested from the command line with a command like this: i2cset -y 1 0x65 0x80 0x10 0x25 0xF4 i (this will set the output to C21)

I modified the VBIT-Pi to remove the composite video output, since that was now wired into the modulator, and add an audio input for the modulator instead. I also added a micro USB port (wired to a GPIO pin via a resistive divider) with the intention of connecting that to the USB port on the set top box that will supply the video signal, so that the modulator is only active when the set top box is on.

RF modulator mounted on the Pi

I wrote the script to control it in Python. To keep things simple, I only implemented the maths for UHF channels, even though the modulator supports VHF channels.

When pressed into service, the Pi can be set up to run the script at startup. During testing, it can be started from the command line with python3 ./rf-mod.py and terminated with Ctrl+C. If you have no need for the external enable, then all the code concerning the GPIO interrupt can be removed.

# RF modulator example code
# This example controls an MC44BS373CA RF modulator
# from a Raspberry Pi. The GPIO set as an input
# can be used to enable and disable the RF modulator
# on demand, and if connected to the USB port on a
# set top box, will automatically turn the modulator
# on when the set top box is on.

import time

import smbus
# Set I2C bus number (may vary according to the Pi used)
bus = smbus.SMBus(0)

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)

# GPIO 23 set up as input.
GPIO.setup(23, GPIO.IN)

device_address = 0x65
# Set desired channel here (UHF only)
desired_channel = 38
# Set to 1 to enable test pattern or 0 for normal behaviour
test_screen_enable = 0
desired_frequency = (desired_channel - 21) * 4 * 8 + 1885
desired_n = (desired_frequency << 2) & 0x3ffc
desired_n_h = (desired_n >> 8) | (test_screen_enable << 6)
desired_n_l = desired_n & 0xff
config_values = [0x80, 0x10, desired_n_h, desired_n_l]

def configureModulator(gpioChannel):
        #gpioChannel only needed for setting up event handler; it doesn't do anything
        try:
                time.sleep(1)
                bus.write_i2c_block_data(device_address, config_values[0], config_values[1:4])
                print("RF Modulator configured: C", desired_channel, " System I")
        except:
                print("I2C Bus Error (Modulator probably not powered)")

#Configure now just in case modulator is already powered
configureModulator(0)

try:
        GPIO.add_event_detect(23, GPIO.RISING, callback=configureModulator, bouncetime=2000)
except KeyboardInterrupt:
        GPIO.cleanup()       # clean up GPIO on CTRL+C exit

#Loop forever - should not be resource intensive
while True:
        time.sleep(1000)

GPIO.cleanup()           # clean up GPIO on normal exit

This works very well and reliably. The output of the modulator is fed into the house AV distribution system, making it available at every TV point in the house. In retrospect, it may be more useful to use the set top box signal to control a multiplexer which switches the video input between the set top box and Raspberry Pi's composite video out, instead of turning the modulator off. The Pi could then be used to display an "in vision" service or other video content when the set top box is turned off.

Sky IO Link

The Sky IO Link is an RF modulator in a small box which was introduced alongside later Sky+HD boxes where the built-in modulator was removed to reduce costs. This modulator is still made today (2022) by various manufacturers and sold at a low price (~£10), which makes it a great choice for any project requiring a modulator.

Photo of IO Link

The modulator is similar to the ones that were previously built into the Sky boxes, but with an Abilis modulator IC rather than the Freescale one used previously, but the IC claims to be a drop-in replacement, so it should work with the code I've already developed.

The short cable is terminated with a 10-way mini DIN connector, and probing around suggests the following pinout: (wire colours on my unit shown)

IO Link Pinout

The VBIT-Pi's open-source PCB layout could be modified to include the mating connector, which would allow neat and tidy integration with the Pi.

10-way mini DIN PCB connector wiring

For testing, I wired the connector up to the Pi's GPIO header and connected the video input to the Pi's video output:

  • 4 (Power supply) - 2 (5V)
  • 5 (GND) - 9 (GND)
  • 6 (SCL) - 5 (GPIO 1 / SCL 0)
  • 7 (SDA) - 3 (GPIO 0 / SDA 0)

The SCL and SDA pins require pull-up resistors, and should be pulled up to 3.3V (not 5V as shown in my photo, but I got away with that bodge).

I ran my Python script from earlier (changing the SMBUS port to 0 for the original Pi in use here) and it worked perfectly.

IO Link connected to Pi and TV

Monday, May 2, 2022

Outdoor LED lighting controller

Introduction

This is a simple project which is a lighting controller for the inexpensive LED tape which is widely available from marketplace sites and is designed to be powered from 12V.

LED tape lights

The requirements for this project were:

  • Automatically turn the LEDs on at dusk and turn them off at dawn
  • Run the LEDs at a dim brightness during normal operation, or at high brightness when high brightness mode is enabled
  • Have a button for selecting high brightness mode. High brightness mode shall automatically be turned off after a time period
  • Have good efficiency

Preliminary testing

Prior to building the controller, the waterproof LED tape was installed as desired around the outside of my house. Around 8 metres of LED tape was installed in three separate lengths and mains flex was wired between each of the three runs and a central location where the controller will be installed along with its light sensor.

The LED tapes were all connected to a bench power supply in parallel for testing.

At the design voltage of 12V, the LEDs are at full brightness and consume around 2A of current for a total of 24W of power. The LEDs are quite bright at this power and the brightness is far too excessive to be used all night, not to mention the high operating costs over the long term.

The voltage was turned down until a sensible brightness for all-night operation was found. This was found to be in the range of 7.90V to 8.10V, with the current varying from 0.05A to 0.10A, and the power from 0.395W to 0.810W. With this in mind, a target voltage of 8.00V was chosen, which should result in a power consumption of only 0.6W (plus overheads from the mains power supply), resulting in low running costs.

Design

The power section of the design was be based around one of the inexpensive and widely available LM2576 buck converter boards. The board was modified to replace the trimmer potentiometer with fixed resistors to avoid future unreliability, and the Enable pin was carefully desoldered from the PCB so that it could be externally driven. A connection was also added to the feedback junction so that an extra resistor could be wired in parallel with the main resistor; this would form the basis of the brightness selection, where this resistor can be left floating or shorted to GND via a transistor to modify the lower resistance value in the feedback network and hence change the output voltage of the buck converter.

Originally I planned to use a comparator wired as a schmitt trigger to control the Enable pin and a 555 timer in monostable mode to control the high brightness mode, but I decided to change to a microcontroller to allow more flexibility and make it easy to implement multiple time-out periods for the high brightness mode which can be stepped through by pressing the button repeatedly. I used a PICAXE-08M (educational microcontroller) since I already had a few, but a bare PIC or ATtiny would also work well.

Schematic

Hardware

I built most of the circuit on stripboard and placed all the components to allow it to fit inside a plastic case.

Some extra resistors have been used in the feedback network compared to the schematic to trim the output voltage more accurately. Polyfuses were also added to each of the three outputs to provide independent short-circuit protection for each channel, which I thought would be a good idea given that the lights are outside.

Assembled project
Interior of the project

The case was screwed to the wall and the LDR was positioned where it could be illuminated by light from outside without being illuminated by very much from the lighting it controls, and it works very well.

Adding an aspect radio switch to CRT TVs

This post is about a simple modification that can be done to many CRT TVs to add an aspect ratio switch. The main uses for this nowadays wo...