Over the last few weeks I have been helping out the guys over at OpenTRV with an implementation of the FHT protocol for use with HopeRF RFM22B and RFM23B modules. My as-yet unreleased sensor modules (as seen in another post) make use of an RFM23B, and I have an interest in evaluating the Conrad/ELV FHT8V valve head as part of my own central heating upgrades, so this was a job that I needed to do anyway.
The FHT protocol is similar to FS20, but the receivers are battery powered and so use a timeslot technique to avoid the need for a permanently powered receiver. This necessitates a synchronisation procedure between the controller and its valve. Once completed, the controller will send a packet approximately every two minutes, keeping the valve in sync. This means that it can take up to two minutes for a change to take effect, but it does mean that the receiver remains un-powered for most of the time.
This example implements the protocol using the module’s FIFO mode, requiring minimal intervention from the host MCU. Source is available for ATMEGA328, so it should work on an Arduino, although I have not tested it yet.
I’m going to start by admitting that this isn’t going to be a tirade of abuse against the oddly named 802.15.4-based wireless tech, but rather a request for comments on an open, lightweight alternative, particularly for low-cost sub-GHz applications. I know what the point of ZigBee is, and the ability to form into self-organising mesh networks is an obvious advantage for large scale industrial automation, but for domestic applications it feels like overkill.
The industry is apparently thinking along the same lines, because the vast majority of DIY Home Automation (HA) stuff on the market in the UK at least is using proprietary sub-GHz like LightwaveRF. The driver here is probably cost, but it is my view that the lack of interoperability that this leads to is holding back the mass-market acceptance of HA, and is unnecessary.
What I am looking for is a simple, open (as in freely available, properly documented, royalty free) standard for sub-GHz RF that could be implemented on the cheapest of radios in minimal code space. I am aware of MQTT-S, although even that looks too complicated for simple sensor/actuator applications, and it doesn’t define the lower layers, instead running on top of something like ZigBee or 6LoWPAN.
As part of my project to bring our central heating into the 21st century I have been working on a custom wireless sensor platform. My key aim here is to develop a low-cost, open solution with security designed in from the start; something that a lot of sub-GHz protocols seem to totally omit. I’m avoiding ZigBee because, as much as I want to like it, I keep coming back to the issue that its complexity just pushes up the system cost. In a domestic environment a simple sub-GHz solution can easily cover a typical property without resorting to meshing.
The design I have gone for combines temperature and light sensing with a pulse input for connection to the gas and electricity meters. The microcontroller is an ATMEGA328 and the radio is a Hope RF RFM23B, which is based on a SiLabs Si4431. This is a synthesised transceiver so the potential for congestion can be avoided through the use of listen-before-talk and frequency hopping, the latter also offering a way around the duty cycle restrictions in the 868 MHz band.
The printed antenna needs to be tuned by trimming it to length, which will no doubt be the subject of a future post. Once the optimal dimensions have been determined this can be applied to any future spin of the boards in advance. No prizes for spotting the deliberate mistake with the microstrip track passing under the RF module – I am hopeful it won’t have too great an effect!
The boards in the photograph just came back from iTeadStudio in about a fortnight. The quality is absolutely excellent considering the <£10 price tag for the 10 circuits. I have loaded a couple and firmware development is in progress.
I have an ongoing project to improve the performance and automation of the heating system in our house, given the ever-rising cost of energy. As part of this project I am planning to zone the central heating system to allow the temperature of each room to be controlled independently, and to do this I need a way of remotely controlling the radiators. Because of the level of integration I am looking for I’ve been unable to find an off-the-shelf solution that meets my needs at a price that is acceptable. Time to start hacking!
The Conrad FHT8V wireless thermostatic radiator valves (TRVs) are available for around £30, which is the sort of price I’m prepared to pay to get this project up and running. I would ideally like to talk directly to these valves from my own controller, so I bought one of the £60 starter kits which includes the remote thermostat and took a look at the on-air protocol using Gnuradio.
To receive the signal a cheap RTL SDR dongle was used. This has the Elonics E4000 tuner, which has almost continuous coverage from about 65 MHz to nearly 2 GHz. The TRVs operate in an ISM band on 868.35 MHz. Helpfully, the protocol has already been reverse engineered, making building a receiver a simple task. The modulation is on-off keying with the symbols encoded as mark and space times of two different lengths, so a custom block was needed in order to decode and frame the messages. This was written in C++ and integrated with the rest of the receiver in Python.
The code can be found here, and should serve as a simple introduction into writing custom Gnuradio blocks.
So as promised I spent a bit of the bank holiday weekend hacking on the FPGA Spectrum to fix a few bugs. In the end I got carried away and finished up with a full implementation of the 128K Spectrum +2A running ResiDOS and loading emulator images from an SD card. It’s still not cycle accurate, but it is feature complete apart from the disk controller, which isn’t really needed thanks to the ZXMMC+ compatibility that went in as well.
Emulating bus contention and improving the cycle accuracy of the T80 core is definitely on the cards, but for now the ability to finally load emulator images from SD makes the machine extremely usable. An explanation of how to get this up and running is a job for another post (hint: format the card as IDEDOS and bootstrap ResiDOS into the extra RAM), but for the time being here is a detailed write-up and the full VHDL source.
And let’s not forgot the obligatory eye candy…
As promised, some more detailed design notes for my BBC B design are now available.
Planning to revisit the Spectrum design next for some bug fixes, as it is clear there is still quite a bit of interest in that.
I added a video of the FPGA BBC in action, shot straight off the TV.
You can see the MMBEEB ROM extensions providing access to multiple disk images on the SD card, then some messing about on Chuckie Egg and Boffin.
BBC Micro boot screen running on FPGA
It’s been a while since the Spectrum project and, although there is still work left to do on that, I eventually gave in and did another great British computer from my childhood – the BBC B. Getting this machine up and running has been an interesting job given its complexity. For something that first came out in 1981 it really is a sophisticated computer, and one that I’m sure anyone who grew up in the UK in the 80’s and early 90’s will remember.
I’ve written this one up on its own page so that it doesn’t disappear, and the Speccy will get the same treatment in the next few weeks. A bitstream image is provided for you to run on your own DE1 board, if you have one, and the full VHDL source code is available too.
A detailed description of the design is also in the works, and should be ready in a day or two.
Sorry it took so long, but I’ve finally cleaned up the source code ready for publishing, and here it is. This contains a Quartus project file, so it should load and compile straight away. I used Quartus 9.1 Web Edition, available from the Altera website. There is also a pre-compiled .sof image which should work straight away if you have a DE1.
A full write-up will follow, but here is a quick summary:
Last week I was made aware of this post on RS DesignSpark about a project, currently in the very early planning stage, to build a Sinclair Spectrum on an FPGA. As it happens I have a similar project well under way, and I have promised to write it up…
Several years ago I implemented most of the ULA in VHDL on a MAX7000 CPLD, mainly as an exercise to brush up on my HDL. I didn’t have enough space to fit the keyboard interface so it was pretty useless, but it did boot! The complete system used a pair of SRAMs, real Z80 and the Sinclair ROM in flash.
Back at the beginning of this year I decided to brush up on my HDL again and I bought myself an Altera DE1 development kit. The heart of this board is a Cyclone II FPGA with a range of support hardware including 512KB SRAM, 8MB SDRAM, 4MB flash, an I2S audio codec, VGA port and the usual switches, LEDs and buttons. I would highly recommend it for anyone looking for a relatively cheap way to play with FPGAs.