FHZ1000PC

fhz1000pc

FHZ 1000 PC (and the newer version FHZ 1300 PC) is an interface device between the FS20 radio protocol and a PC via an USB interface. It is sold by Conrad in Sweden (http://www.conrad.se), Germany and probably in many other countries.

Hardware

fhz1000pc inside

FHZ1000PC has a fairly straight forward structure based on standard components. It is build around a PIC16F628 processor and uses a FT232AM chip from FTDI for USB communication. Looking at the picture above you will see from right:

The software in the PIC-processor communicates with standard asynchronous serial communication with the FT232AM chip using 9600 baud, 1 stop bit and no parity.

There are some german sites where they describe how to modify the hardware:

Interfacing

The software accompanying the device when purchased from Conrad is unfortunately in German only. To make things even worse, the software has no documented external interface allowing direct access to the device. So we are left to do this interfacing ourselves. Fortunately FTDI provides both drivers and API:s to their chips for free (they live on selling the chips), so the drivers can be downloaded from their site. Through their drivers we get access to the serial communication with the PIC-processor. The protocol used here has been reversed engineered by fhz4linux.

Interfacing from Windows

I want to access the protocol on Windows from Java, but FTDI only supply drivers for C/C++ so I also need some kind of conversion here. I actually considered writing a small C-daemon to talk TCP/IP with, but I found a nice set of Java drivers for the FT232AM-chip (D2XX-drivers) on https://jd2xx.dev.java.net. So I was finally able to write a Java class that represents a FHZ1000PC-device and allow my software to control the FS20 system.

Interfacing from Linux

Since Java is a platform independent language, we want the software to work for Linux as well. On Linux, there are no specific drivers for this device available but we can still use the fact that there is a standard FTDI-Chip. The trick here is to persuade Linux that this is really just a USB serial device. There are at least three ways of doing this, and they are described on the fhz4linux-site. I prefer method number 3, and it has worked fine on my Ubuntu.

The Java interface class I have written actually checks which OS it is running under (a bit ugly) and adapts its access methods accordingly.

Software on Windows

To use the interface you have to do the following steps:

This class is used by the fhz1000pcport-class in the NetHomeServer

Example

public class HomeManager {
   static int houseCode = FHZ1000PC.StringFS20ToInt("11112433");
   static byte lamp = (byte)FHZ1000PC.StringFS20ToInt("1113");
   static byte button = (byte)FHZ1000PC.StringFS20ToInt("1141");
   static FHZ1000PC port;
   public static void main(String[] args) {
      try {
         port = new FHZ1000PC();
         port.fs20Init();
         // Turn the lamp off
         port.sendFS20Command(houseCode, lamp, FHZ1000PC.COMMAND_OFF);
         port.registerEventListener(new FS20EventListener(){
            public void fs20Event(FS20Event event){
               if ((event.getHouseCode() == houseCode) && (event.getButton() == button)){
                  try {
                     // If I receive a command from the button, resend it to the lamp
                     port.sendFS20Command(houseCode, lamp, event.getFunction());
                  }
                  catch  (IOException e){
                     e.printStackTrace();
                  }
               }
            }
         });
         Thread.sleep(10000);
      }
      catch (IOException e){
         e.printStackTrace();
      }
      catch (InterruptedException e){
         e.printStackTrace();
      }
   }
}