Using Can Bus  

Page 1 / 2
  RSS

DanKramer
(@dankramer)
Active Member
Joined: 3 months ago
Posts: 6
2020-02-05 10:24 pm  

Another topic I can see as useful as using a Can bus as an I2C replacement that is far more robust against noise and can work with much longer wires. I'm looking into it now for my R2 build as there are a lot of lengthy wires for sensor routing to control boards.


Quote
NewburyPi
(@dale)
Trusted Member
Joined: 9 months ago
Posts: 87
2020-02-06 5:12 am  

I agree with the CAN BUS suggestion. In fact I'm investigating it now to see if I can crowbar it into ARDVARC (might be too late). It does seem to be very versatile, but I'm worried about the underlying complexity. Issues with bus arbitration, priority tuning, transmitting large data blocks, and the whole idea of masterless communications. Looking into hardware support as well. 

--
Dale


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 10 months ago
Posts: 1590
2020-02-06 5:54 pm  

I would like to learn about the CAN bus too.

In fact, I already have a question:  Can the CAN bus be used with I2C devices?  Since many sensors designed for use with microcontrollers use I2C communications, then wouldn't the CAN bus need to be compatible with I2C in order to be used as a replacement for an I2C bus?

I don't know whether CAN is compatible with I2C or not.  That's why I'm asking. ? 

If Bill makes a video on CAN I hope he includes information on how it can be used with I2C devices.

 

DroneBot Workshop Robotics Engineer
James


ReplyQuote
NewburyPi
(@dale)
Trusted Member
Joined: 9 months ago
Posts: 87
2020-02-06 6:36 pm  

@robo-pi

What I have read on CAN BUS seems to say that it and I2C are not compatible. The protocols are quite different. While I2C runs in a master/slave configuration, CAN BUS is masterless (my term), and runs a little like Ethernet. Each device on the bus tries to get permission to use the bus, by saying "I Want On" and spitting out a priority. All other devices will react accordingly. That is what I can bring quickly to mind, but there seems to be some kind of bus arbitration going on between the connected devices. 

--
Dale


ReplyQuote
NewburyPi
(@dale)
Trusted Member
Joined: 9 months ago
Posts: 87
2020-02-06 7:11 pm  

This looks like a good overview of CAN bus.

https://copperhilltech.com/a-brief-introduction-to-controller-area-network/

--
Dale


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 10 months ago
Posts: 1590
2020-02-06 9:43 pm  

@dale

I'm still not clear on exactly what would  be required to make it work for multiple sensors.

It appears to me that at least one of these boards is required for every sensor node:

And then I'm still not clear on how a standard I2C sensor would be interfaced with these CAN nodes?

Would special sensors then also be required?

While it looks like it may be a very dependable system over large distances, it appears at first sight to be fairly hardware extensive.   I'm sure there are applications where it makes a lot of sense, such as in the automotive industry.  But I'm still wondering whether it would be a practical replacement for I2C on something like DB1?

I'd like to learn about CAN either way.  But at this point it's still unclear exactly what would be required to use it with standard I2C devices.  Of if that would even be possible?

Clearly I know nothing about CAN. ? 

So I vote for a CAN tutorial too.  I'd like to learn about it and which situations it might best be used for.

DroneBot Workshop Robotics Engineer
James


ReplyQuote
NewburyPi
(@dale)
Trusted Member
Joined: 9 months ago
Posts: 87
2020-02-06 10:02 pm  

I'm certain that it would work with multiple sensors. My understanding is that the sensor would be connected to a CAN bus module and the CAN bus module would be configured to take a reading from the sensor and push the data out onto the CAN bus. There would be another device on the bus that would capture the readings and process them as required. I am not familiar with the modules shown in your post. They may be accessible via I2C. If so you may need a controller chip to make the reading from the sensor and push it to the module via I2C.

Could you post the part number, and manufacturer, for the modules?

--
Dale


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 10 months ago
Posts: 1590
2020-02-06 10:17 pm  
Posted by: @dale

Could you post the part number, and manufacturer, for the modules?

The module number is MPC2515.  Not sure who manufactures it.  I saw it being used in a couple YouTube videos for connecting to an Arduino.    Apparently you need at least two of the MPC2515 to connect two Arduinos together via a CAN Bus?   I don't know.  I'm just going by the limited information I currently have.

I also haven't yet been able to find any information on how to use a CAN bus to connect directly to a sensor.

So I'm clearly clueless on the whole CAN bus topic. ? 

My current "knowledge" may itself be nothing more than a CAN of confusion at the moment. ? 

DroneBot Workshop Robotics Engineer
James


ReplyQuote
NewburyPi
(@dale)
Trusted Member
Joined: 9 months ago
Posts: 87
2020-02-06 10:48 pm  

OK... So... First the bad news. The MCP2515 interfaces through the SPI bus. I may be wrong here but it look as though the MCP2515 module needs a hardware driver component to interface with a proper CAN bus. I've seen two parts that fit the bill, but you will need one for each MCP2515 node (MCP2551 or TJA1050 - There are probably others). All that being said, at least SPI is a standard arduino interface. So while it may not be suitable for Bill's DB1, it is ATmega/ATtiny/ESPx/SAMD/etc compatible. I came across a github repository that seems to have the whole arduino business wrapped up.

https://github.com/autowp/arduino-mcp2515

--
Dale


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 10 months ago
Posts: 1590
2020-02-07 12:35 am  
Posted by: @dale

So while it may not be suitable for Bill's DB1, it is ATmega/ATtiny/ESPx/SAMD/etc compatible.

That's what I'm thinking.  It may not be useful for a direct replacement for I2C, but it may be useful for other applications.

Posted by: @dankramer

Another topic I can see as useful as using a Can bus as an I2C replacement

Dan mentioned in the OP of maybe using CAN as a replacement for I2C.   So that's the question we need to have answered I guess.

Like I say, I would like to learn about CAN either way.

DroneBot Workshop Robotics Engineer
James


ReplyQuote
DanKramer
(@dankramer)
Active Member
Joined: 3 months ago
Posts: 6
2020-02-07 3:55 pm  

The way I understand it, is this...

The Can bus interface would allow different control boards like Arduinos to talk to each other. Sensors don't really connect to the Can alone. The sensors would go to a local Arduino, a small one would do, and then that board uses the Can to send the info to the network. There is no master, they're all equal peers that respond to info on the network being relevant for that node.
An example of it in use in a robot is here:


He talks about the Can at around 8:30 in. This is where I got the idea of using it in my R2.

I've learned a lot from James over the last few years, and I'm a Patron of his channel. He's one of my inspirations for going back to school for electronics.
He shares most of his code and CAD here- https://github.com/XRobots


NewburyPi liked
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 10 months ago
Posts: 1590
2020-02-07 5:55 pm  
Posted by: @dankramer

The Can bus interface would allow different control boards like Arduinos to talk to each other

That's basically what I was thinking it was.  So it not only requires a CAN transceiver at each node, but it also requires a microcontroller at each node as well.

It's certainly an interesting means of connecting microcontrollers.   But that's hardly a replacement for I2C in general.   I2C is used for a lot of Arduino Modules.   So apparently you'd still need to have I2C working locally with each microcontroller.  And then the CAN bus would simply be used to communicate the resulting information a longer distance (or past noisy environments) to other microcontrollers.

Still worth learning about to be sure.   But not exactly a replacement for I2C.

DroneBot Workshop Robotics Engineer
James


ReplyQuote
NewburyPi
(@dale)
Trusted Member
Joined: 9 months ago
Posts: 87
2020-02-07 6:07 pm  

@dankramer

That's what I see, as well. Except that there is a bus arbitration/priority scheme that helps to reduce collisions. 

What I am trying to get my head around now, is how this masterless communication system would fit into my robot. The current system has a "master" processor (Raspberry Pi) that pushes commands to three other processors (Arduion Nanos). Under CAN bus the outlying processors would collect data from their sensors and push the data to the bus. The main processor would sit and sniff this data. The main would also push commands (faster, turn right, etc) on the bus, and the outlyers would read these commands of the bus and react. Le major benifit for me, is that I would be able to more easily manage communications between the outlying processors. No need for the master to get involved. 

 

PS: yes James Bruton. The guy is amazing. Although I often come away equipment shamed. 

--
Dale


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 10 months ago
Posts: 1590
2020-02-07 8:20 pm  
Posted by: @dale

PS: yes James Bruton. The guy is amazing. Although I often come away equipment shamed. 

That's my problem as well.  His robotic projects are beyond my financial reach.   His videos can still be useful for general ideas though. 

DroneBot Workshop Robotics Engineer
James


NewburyPi liked
ReplyQuote
byron
(@byron)
Estimable Member
Joined: 10 months ago
Posts: 197
2020-02-08 6:26 pm  

Another vote for a DroneBot episode on the CAN bus.  I bought a couple of CAN boards a while back but have not done anything with them as yet. I see that several micro controller boards come with the CAN bus on board.  Also I found a web shop https://shop.omzlo.com that has what they call a NoCAN kit which may be of interest.


ReplyQuote
Page 1 / 2

Please Login or Register