Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAN support #9

Open
gkasprow opened this issue Mar 3, 2018 · 1 comment
Open

CAN support #9

gkasprow opened this issue Mar 3, 2018 · 1 comment

Comments

@gkasprow
Copy link
Owner

gkasprow commented Mar 3, 2018

I have build a house and started looking for a home automation system that has several features:

  • it is not wireless. I have so much issues with wireless systems that I simply do not trust them. They are easy to jam and usually run on battery.
  • the home automation system need to be failure proof, I mean that once electronics is dead, all critical switches must work.
  • ideally it should be decentralised.
    I told the electricians to install twisted pair cable along all switches and places where potentially will be equipment installed which I want to control. This includes gas furnace, recuperation, alarm, fire sensors, shutters etc.
    I started looking for a system that supports such operation mode over twisted pair and the only dedicated standard I found is KNX.
    The drawback is that in every device one must use quite expensive transceiver. There are a few vendors, but the cheapest transceivers are 6$ at 100pcs. I'd like to keep the entire price of the switch node at such level. And the KNX is centrally managed.
    Another standard that is gaining popularity in home automation is CAN, known from automotive industry.
    And I found quite interesting, decentralised home automation system based on CAN.
    HAPCAN is open source, open hardware. It was initially based on PIC MCU with embedded CAN interface and written in assembly, but there are Arduino-based implementations based on AVR CPU.
    I found that Arduino-based solution including MCU, CAN interface, CAN transceiver, relay and PCB can be well below 6$ which is far cheaper than KNX solution. And it does not require central processing system because every HAPCAN device can be programmed to interpret messages from other nodes.
    The price of the PIC18F26K80 used in HAPCAN is similar to the price of ATMEGA328PA + external CAN interface.
    The only problem is that HAPCAN devices can be either switches or relays. I need both in one, because I want to install it under the light switches. So the device need to:
  • detect state of the light switch
  • turn on/off the light using bistable electromechanical relay
  • in case of CAN/DC power failure, the light switch functionality must be preserved.

So the idea is to use:

  • SPDT bistable relay,
  • SPDT (3 way) light switch
  • detector of AC voltage on the lamp circuit
  • DC-distributed 12V supply together with CAN bus
  • Arduino HAPCAN library and client modified to support both relay and switch functionalities.

I designed simple circuit based on ATMEGA328PB which is ~1$ CPU and supports HAPCAN.
I added CAN chipset (MCP2551 & MCP2515) - another 1.5$ and bistable relay - another 2$. There is also AC power detector (LM358 diff amplifier) and DC/DC converter (AP65111A)
The PCB fits easily under the light switch
obraz
The schematic is here
PCB was quickly auto-routed to confirm the components placement. I will route it manually later on.

I also ordered switch, relay and programmer from the company who develops HAPCAN. They already shipped so I will play with it soon.

@gkasprow
Copy link
Owner Author

To add support to Linux module, I initially implemented MCP2515 CAN controller.
But it is not well supported in Linux due to lack of buffering. One can write bit-bang Linux driver that is not very elegant solution
Another solution is to use existing implementation of UART/USB to CAN based on small MCU.
I found a few, the most interesting is one based on low cost STM32 Cortex M0 CPU (~2$ chip).
I ordered 2 pcs on Tindie and will test them once they arrive.
I also replaced MCP2515 with STM32 solution to get rid of future problems with decoding of CAN frames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant