B
B
BuzzyMan2015-12-10 17:17:25
Arduino
BuzzyMan, 2015-12-10 17:17:25

How to create a network of microcontrollers on the CAN bus?

I am working on a smart home project, I have only just started to get acquainted with microcontrollers, so sometimes there are plugs.
The components of my smart home need to communicate over the network. 1-Wire is too unreliable and slow, Ethernet has a minus the need for a switch, and it’s stupid to hang an Ethernet port on each executive.
I came to the conclusion that you need to use the CAN bus, and the speed is sufficient and the maximum length of the connection is acceptable.
The task is to create a basic element that can receive / send data from the CAN bus, and then process this data according to the firmware.
There is information on the Internet about a bunch of mcp2551 + mcp2515 + avr controller, but when I did not find specific schemes and working examples.
Can someone tell me which way to dig? I would be very grateful if someone shares their experience with CAN

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Max, 2015-12-10
@MaxDukov

does it have to be wired? here is an example of wireless.

S
Stanislav Shendakov, 2016-01-24
@shindax

The HARDWARE didn't say how much information will be circulating on the network. IMHO, hanging CAN on each device is no less stupid than Ethernet, tk. hardware CAN is still exotic for small-footed MKs, but it is probably possible to make software CAN, but this is not much for the faint of heart. There is also an SPI-th MCP2515. The problem can be solved simply and reliably enough by means of RS485, the protocol is MODBUS, which has proven itself well in the industry, there are a lot of examples on the network for different implementations. For him, MK is enough USART, and almost every modern MK has it, even in 8-pin ones (as well as SPI) and add an appropriate transceiver, something like AD485. IMHO, which MK to take - it doesn't matter at all, as long as its resources correspond to a specific task, and what development / debugging tools the performer has.

E
Eddy_Em, 2015-12-11
@Eddy_Em

AVR is the last century. I advise you to look towards STM32. By the way, if you need to save a lot, then instead of STM32 you can pick up a cheaper STM8, they also have a kind of CAN (though not full-fledged).
Plus, you will also need a level converter, but this stuff is on ibei / ali in bulk.
To communicate with a computer, you will either have to buy an expensive PCI CAN controller (by the way, it’s a big problem with them: usually a developer uploads modules for very ancient kernels, so if you don’t know how to write / edit kernel modules, it’s better to discard this idea right away), or make your own USB <-> CAN adapter based on the same STM32. Another option: make a master controller with ethernet, on which the web muzzle will spin. We stick it into a wifi router and from any device with wifi we can see the state of the system.

A
alexpic, 2015-12-17
@alexpic

1-Wire is too unreliable and slow

She is quite reliable. There are many examples of industrial devices in which temperature sensors hang on a single rail up to 60 meters long.
The Japanese policeman answered in sufficient detail. I note that for communication with a computer, you can use fairly cheap CAN-USB adapters, including those with galvanic isolation. We use Marathon - they have good hardware and API.
I will add that CAN is used mainly in a car or industrial automation. The bus is differential and therefore you will have to use twisted pair. Physical layer (PHY) drivers are not particularly cheap (compared to the same 1-Wire, where you can use one transistor). The bus requires terminators at the ends. Everything else is good there.
Still think about the wireless network.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question