combined switch and relay module

Post Reply
gkasprow
Posts: 5
Joined: 25 Feb 2018, 13:49

combined switch and relay module

Post by gkasprow »

While designing my house installation, I assumed RS485 connection between all light switches and I routed CAT5 cable between all the places where are the devices that potentially will be controlled. I wanted to build my home system based on Cayenne IoT builder. But finally figured out that MODBUS RTU is not the best way of doing it. It works for some sensor readout and remote control, but it's hard to make it working with low latency for complex installation.
The initial idea was that under every light switch there will be a relay which can overtake the manual switch function. Such solution has one advantage - in case of complete system failure, all basic light switches work. So even after serious damage caused by thunderstorm we loose all home automation, but basic functions remain intact.
So I was looking for better solution and found HAPCAN which seem to fit my needs.
The question is simple - how to combine relay and button function in the same device without using 2 processors.
I want to build a tiny device that it would accept its own button messages in the same way as external ones and control its own relay. I have quite constrained area under the light switch.
The simplest solution is using 2 MCUs + 2 CAN transceivers, but I believe one can do it simpler.
I looked at the source codes, they are written in PIC assembly which I never used. I am familiar with AVR and 8051 assembly but prefer programming in C. I found a C template but there are just bare CAN Rx/Tx functions.
Is there some more detailed description of the assembly code?

Yet another idea touches the problem of device identification. Are the ID numbers assigned at the compilation time?
I use in my devices (i.e. here https://github.com/m-labs/sinara/wiki) unique ID chips wit EIU48 number carved in stone. It is 48bit number and I'd like to use it instead of manually assigned ID numbers. I know CAN uses 29bit addresses, but anyway first MSBs of these 48bits are fixed. This involves readout of the I2C memory but it is trivial.
Bartek
Posts: 326
Joined: 14 Jul 2011, 19:36
Location: Wrocław
Contact:

Re: combined switch and relay module

Post by Bartek »

in case of complete system failure
That was my fear, when I was at planning stage. I want to make every system redundant in case of... But then I realized it's not a big deal if I can't switch my lights on. Electronic systems work many years without any failure in much worst environment than house :).

In Hapcan, the posibility of complete failure is rather small. There are no central unit which can make everything stops working - oh, maybe the power supply is the only one weak spot - but it is available in few houres max. So after almost 5 years of usage I don't feel any fear that my system will crash and all goes down :).
The question is simple - how to combine relay and button function in the same device without using 2 processors.
Such module not exists for now in Hapcan palette, but take a look on my Hapcanuino project, which alows You to create Hapcan compatible products using Arduino. You can always build Your own module using UNIV3 module processor, but I guess Arduino i far more user friendly platform.
gkasprow
Posts: 5
Joined: 25 Feb 2018, 13:49

Re: combined switch and relay module

Post by gkasprow »

Thanks,
I ordered some basic HACAN components - relays, switch and RS232 interface. I also ordered MCP2515 modules for Arduino. Once they arrive, will try to connect them and see how it works with Hapcanuino.
Greg
Jacek
Posts: 561
Joined: 17 Feb 2007, 18:00

Re: combined switch and relay module

Post by Jacek »

gkasprow wrote: The question is simple - how to combine relay and button function in the same device without using 2 processors.
It is possible, but requires a bit of coding. All firmware source code of the project is in assembly at github. The C template was created by someone else, so I can't help.
gkasprow wrote: Are the ID numbers assigned at the compilation time?
Yes, but implementing ID chips is also possible.
Regards
Jacek
gkasprow
Posts: 5
Joined: 25 Feb 2018, 13:49

Re: combined switch and relay module

Post by gkasprow »

So I ordered some HAPCAN components. I got message that were already shipped.
In the meantime I designed simple board based on Arduino - compatible MCU.

I summarized it here https://github.com/gkasprow/Sensor-Box/issues/9
The design files are also available here https://github.com/gkasprow/Sensor-Box/ ... switch.PDF

So there is going to be fun. If somebody wants to play, I can make a few more boards.
Bartek
Posts: 326
Joined: 14 Jul 2011, 19:36
Location: Wrocław
Contact:

Re: combined switch and relay module

Post by Bartek »

The relay You have used is bistable or simple monostable one? I'm a fan of bistable relays because they do not consume more power than the device beeing controled :)
gkasprow
Posts: 5
Joined: 25 Feb 2018, 13:49

Re: combined switch and relay module

Post by gkasprow »

It's bistable, single coil relay. I used it due to zero static power.
gkasprow
Posts: 5
Joined: 25 Feb 2018, 13:49

Re: combined switch and relay module

Post by gkasprow »

I managed to compile HAPCANDUINO, made it running on Arduino Pro Micro with attached CAN controller.
It is now visible under HAPCAN Programmer as ordinary UNIV3 relay module. I can control LEDs connected to MCU ports with commands Turn on/off/toggle.
I can even read processor EEPROM and I see there the name I assigned. I cannot read FLASH and get error.
Then I tried to configure and link devices, I cannot read it - it displays error (below) when I click Read. Of course I cannot link devices.
And the question is if I do something wrong or some additional EEPROM access need to be done.
Here https://github.com/Onixarts/Hapcanuino/ ... M-handling is brief description how to do it, but I don't know the system enough to be brave to try it :)
error.PNG
error.PNG (6.68 KiB) Viewed 9849 times
Bartek
Posts: 326
Joined: 14 Jul 2011, 19:36
Location: Wrocław
Contact:

Re: combined switch and relay module

Post by Bartek »

I have answered at GitHub :).
Post Reply