Saturday, May 18, 2013

The Ventilator Controller

here I like to spend few words about the ventilator controller I have created. I bought two ventilators which need 220V to drive its motors. Probably I could have used something commercial to switch and drive them, but I wanted to use CAN. Therefore I decided to create my own circuit with mikrocontroller, CAN interface and 220V drivers for the ventilators. 

 The mikrocontroller

I used the same type of mikrocontroller as for the one-wire controller: AT90CAN128. It has a CAN interface, which I knew how to use. The PCA82C250 I use for the CAN transceiver.  

The power supply

The power supply contains the same chips as for the one-wire controller. The step down contoller
LM2575 converts 12V DC to 5V DC and drives the digital chips. The 12V DC comes along with the CAN bus cable, which I have installed inside my basement.

The 220V drivers

To drive the ventilators, I use two S202 S12 solid state relais. Each relais contains a digital input, which can be directly connected to the mikrocontroller. I also added varistors and fuses for circuit protection.

Below a picture of the circuit I created. The red lines indicate the chip positions.


Saturday, May 4, 2013

The One Wire Controller

In this section I want to describe the one wire controller in more detail. Before I started the home automation project I have completed few projects with atmel 8 bit controllers, so I was familiar with this type of controller. But I still made few thoughts about alternatives such as the logo device, or other programmable logic controllers from Siemens. Logo is a simple device, but I did not like that I can only attach peripherals with a proprietary bus system. And the perpherials and the bus system was expensive. I knew from the beginning, that I wanted to add a humidity sensor, which needs data conversion. It could have been an analog/digital converter or a signal converter, depending on the humidity sensor chip.
It became clear to me, that I will be most flexible, if I design my own controller. But I had to decide which components I wanted to include to the controller; components such as power supply, sensors, memory etc. So I created a list of sensors, which I present here:
  • Temperature Sensor
  • Humidity Sensor
  • Real Time Clock (is this a sensor? Let's say yes)
  • Rain Sensor
The temperature sensors had to be distributed around the basement, because I wanted to sense condensation at certain locations, and this can be done, if I measure humidity at certain spots together with temperature.
Due to this distribution of sensors around the basement, it was necessary to think about a bus system, or alternatively wireless. The decission came in favor of a bus system. The rationals are listed in one of the posts below, so I will not elaborate. After doing some research and discussions with colleagues, I found a bus system called one wire from Dallas instruments (now Maxim). The one wire bus looked very promissing because:
  •  the wire needs only one strand (in theory)
  • sensors are available, such as the temperature sensor (DS18B20)
  • drivers are available, it converts I2C into one wire signals (DS2482S-100)
Since I know the CAN bus very well, it could have been an alternative for accessing sensors. Unfornuately, there are not many inexpensive sensors available which I can connect directly to CAN. This is different with one wire. So I decided to use one wire.

The one wire driver

The one wire driver DS2482S-100 is the device interface between a master processor and the devices attached on the one wire bus. Unfortunately I realized pretty late that this chip actually implements only the physical layer of the one wire protocol, so there was a lot work left for me to implement the driver software. However this presentation has helped me to implement the driver: one wire overview.

The real time clock

I tried to find a real time clock which has a I2C or SPI interface, so it can be connected to an atmel processor. I chose the RV 3029-C2, because it was available from the distributor from where I usually order. This real time clock is convenient, because it has a crystal included and that it can be powered with 5V and 3,3V.

The power supply

I created a couple of circuits before and I always used the LM2575 from National Semiconductors (or Texas Instruments) to generate regulatated 5V. It is a step down regulator and it is supposed to use less power than a linear voltage regulator.

The CAN drivers

CAN pins from the processor cannot be connected directly to the CAN bus. The signals need to be leveled and there are chips available for this. They are called CAN tranceivers. One widely available chip is the PCA82C250 from NXP. The drawback of this chip is that it can only be powered with 5V. But there are also other chips with the same packaging and pinout which can be powever by 3,3V (e.g. the SN65HVD230D).

The EEPROM

There is persistent memory needed for the data the processor collects, so I tried to find an eeprom with large memory capacity.  My distributor had the 24AA1025 available, so I decided to use this one. It can store up to 125kBytes of data, but it needs an extra pin to select the two separate devices on the same chip. The protocol for accessing the chip is I2C.

The USB driver

I had to add an interface to access the data from the processor and the eeprom from my laptop. I used a FT232R from FTDI for this purpose. This chip can be connected to the processor via the RS232 interface and it converts the signals to USB. A special driver needs to installed on the laptop to access the chip. I used windows terminal for this purpose.

The processor

As mentioned above, I used to work with atmel processors before and it came natural that I choose an atmel processor for this project again. There is one atmel processor which has a CAN interface which is the AT90CAN128. It has 128kByte flash size. The gcc compiler for this processor is available here, and jtag devices for program download is widely available.

 The one wire controller

Below a picture of my one wire controller. I used eagle from CADSoft to create the schematics and the layout. A PCB manufacturer created the board for me. Like always I created layout mistakes, which I had to correct somehow, such as I underestimated the package size of the eeprom. Somehow I was able to solder it on the board anyway.

 Final Words

Before I would create such a layout again, I would do some research if I could use one of the Arduino boards. I am not sure if these boards were available during the time I created my cicuit, however they became pretty popular by now.
I would probably completely take out the USB port, because it became quite useless, since I access the one wire controller from the raspberry pi through CAN. For debugging it was very useful, but I could do the same now through CAN as well.