Can we integrate 4 CAN buses with Arduino Mega?

Hi, I need to integrate 4 force/torque sensors (with CAN bus connections) for a parallel force sensing measurements. Is there a way I could connect all 4 CAN buses to Arduino Mega to have the measurements read at once?

I tested 1 force sensor CAN bus connected to Arduino Mega via the CAN bus shield with MCP2515 and it works great. I am not sure how to extend that to cater for 4 of them and I couldn't find any reference on such integration.

Any advice/suggestions/recommendations would be greatly appreciated. Thank you.

From my very basic understanding of the topic, it is the plan of a CAN bus to host many devices.

1 Like

@felisyne, your topic has been moved to a more suitable location on the forum.

1 Like

so long as the devices have different IDs you can communicate with each device in turn or the devices can send messages at regular intervals

I agree with @horace you can have 4 (or many more) devices on one CAN bus. As long as they have different address' . Similar to and I2C bus.

From your post you might have 4 of the same sensors (with the same address). In which case you will need 4 CAN bus UNLESS it is possible to disable the force sensors. I tried this once with a motor controller with little luck, but you may be able to easily shutdown each sensor.

You might want to look at this link

Hi,

Tom.. :smiley: :+1: :coffee: :australia:

Hi, thank you.

Hi @JohnRob and @horace , thank you.
Yes, indeed. I have 4 of the same sensors and I need to get the measurements from all of them at once :worried: I only have space for 1 arduino mega and currently with only 1 CAN bus shield (which I wonder if that alone could take 4 CAN buses).

By shutting down each sensor, does it mean that only 1 sensor works at one time?

Thanks for the link, I will take a look at it.

Hi @TomGeorge , thanks for the schematics. I guess, with my very minimal knowledge of CAN bus, I am wondering how I could connect all 4 of them to the 1 arduino mega I have with the CAN bus shield which seems to be only able to take in one CAN bus connection (i.e. 1 force sensor)? Please correct me if I am wrong.

What are your sensors?
Please post a link to data/specs so we can advise you.
Some of these devices can be given unique addresses so only one canbus is needed for the four to hang from.

Tom... :smiley: :+1: :coffee: :australia:

1 Like

This is probably the best solution. However we may want to know the library and software used for this. The MCP2515 only has two receive buffers. It looks like it could support ternary filtering. I do not know if the library does or not. If all broadcast at the same time there may not be enough time to pull them all in.

The MEGA does not support DMA, but I doubt that would matter here. These controllers are remote and limited in collection capacity. Internal and larger ones would fair better. The software design if very responsive may have enough time, assuming high SPI clock and decent CAN overhead. There are enough buffers for ping pong reception. This controller may also assume most of the bandwidth will be used by other nodes talking back and forth to other nodes.

Alternatives include building a custom shield with four MCP2515's. This would enable the sensors to use the same address and get both buffers. These could exist off a single SPI port. The software could create an object for each and round robin.

A more expensive version of that is to buy four shield and make intermediate shields which reroute the chip select line. This is very expensive and a huge tower, and may have signal performance.

What are your sensors?
Please post a link to data/specs so we can advise you.

Hi @TomGeorge and @dthacher ,
Thanks. Sorry, I missed sharing the info on the force sensors I have.
It's Robotous RFT80-6A01:
[http://www.eleparts.co.kr/data/goods_old/design/product_file/RFT_Manual(English)_REV1.1.pdf]

The force sensors that I have come with 2 pairs of wires. I have connected one of the sensors to the CAN bus shield as shown in the figure attached:


This CAN bus shield only has one CANH and CANL for connection so I am wondering if I need to get another 3 shields for the remaining 3 sensors (then comes the question on how do I connect all the shields onto 1 arduino board :thinking:)

I am still trying to understand from the manual if I can change the receiver ID (I am assuming that the receiver is on the force sensor side) -- so arduino can send different transmitter IDs to individual sensor..? (Not sure if I am getting this right :sweat_smile:)

Hi

That cannot happen, part of the CanBus protocol is to look to see if the bus is busy.
You would have the master poll each slave, no clashes then.
Not sure how quickly @felisyne wants to sample.

Tom.... :smiley: :+1: :coffee: :australia:

Hi @dthacher, ultimately I am supposed to be getting signals from all four sensors in real-time, hence it should be almost immediately. I am currently obtaining the force readings from one sensor at 115200 baud on arduino. I hope that makes sense

Hi,
Thanks for the specs/manual.
You only need a shield for the Mega, the sensors have them built in.
You connect ALL CanHi wires together, and ALL CanLo wires together, you are best to connect them to a common bus as in post #6, with the 120R resistors as shown.
This relies on each unit having its own ID.

However I can't see with a brief look at the manual, but you may be able to do this.

You may have to contact (email) the distributor or manufacturer to see how it is done as I am not familiar with the sensor.

No matter how you do it, you cannot instantly read all sensors at once.
Sequentially yes, how fast will depend on the hardware.
Again you may need to contact the people who sell/make the sensor.

Tom... :smiley: :+1: :coffee: :australia:

I think this was obvious from my statement. If they come at full speed the buffers could be filled up. There may only be enough room for two to be captured. Then the others are dropped and maybe retransmitted. Priority gets in there, but if I am not mistaken it uses an I2C like back off protocol.

If they get directly in line with each other they are effectively at the same time. If you shift them by creating a delay you may have enough time. If you have a deep buffer you can capture them all. They will not arrive exactly at the same time, without multiple buses. However the sensors and bus arbitration determine that.

What’s your budget?

What kind of trouble fun are you looking to get into?

How important is the simultaneous reading?

A defensible approach would be to use 4 Arduino w/ CAN shields, one of which could also be the master and control and solicit readings from the other three. Or 4 identical and a fifth to control them all. Arduinos be cheap.

If the device has a configurable address, that would be easiest but then you have some small time betwixt the four readin.

a7

My impression is that you can change them with commands 4 and 5, but this is based on skimming only. I do not know if these settings are stored or not. It looks like you can set the output rate also, which varies from 200Hz-1kHz. (Bandwidth may not be an issue.)

If the settings are non-volatile you can set them up one by one. Then wire them together.

They only support 1Mbps for CAN. Which is standard CAN.

section 3.6.5 Set Communication ID (only CAN) allows the setting of individual device CAN IDs
you connect each one in turn and send a command(s) to set the ID
you can then connect all the devices to the Arduino and access then via the set IDs
I would recommend you get a USB-CAN converter/analyser for a PC

  1. it simplifies setting up and testing CAN devices using code on a PC (I use C++ or java)
  2. allows monitoring of the CAN message flows between the Arduino and devices
1 Like

On a Mega each SPI read from a MCP2515 takes 1.6 milliseconds which sets an upper limit on the number of packets you can receive per second, and each packet has a maximum of 8 bytes. Adding more shields doesn't increase the bandwidth as the microcontroller SPI read speed is the limiting factor.

Do some calculations to see if this is bandwidth is going to be sufficient for your project.

1 Like