Can we integrate 4 CAN buses with Arduino Mega?

If the individual shields or CAN busses can all get a sensor reading at a given time indicated by the master, then they can report those simultaneous acquired values at their leisure.

So you might have some limits as to overall samples per second, but getting four up at once shouldn’t be hard.

a7

1 Like

Correct. The parallel only gets you buffering. The CPU is the limiting factor. I do not know if the sensors support retransmission, and I forgot to check the datasheet. If they emit on specific time values they may not.

According to your math you will get 625 samples off the SPI, which means you will lose samples. Even if each is configured for 200 samples a second. If okay with this, using masks will allow round robin of each ID. Note I have not done the math myself.

There could be an issue of CAN bandwidth, but I am thinking this is not a concern. It was technically unknown until the datasheet was added in. However in all fairness this was almost assured. Technically there could be an issue if the data is critical however this is kind of extreme.

The SPI bandwidth is a concern as this will have decent amount of overhead due to the nature of this controller. There is only so many SPI ports available, but the CPU can only be in one place. DMA would change this however it does not increase the SPI ports or RX buffer size.

These probably support ping pong. So in theory you could read one from SPI and CAN write to the other. However this only works if certain conditions are correct. Which is looking doubtful.

Note this is not my project. However I was agreeing with the idea of reprogramming multiple on a single bus. I think the parallel approach is only really needed if there is really critical timing or bandwidth concerns.

it may be worth considering an Arduino Due which has two on-board CAN interfaces

2 Likes

You might consider a Teensy 4.0 It has 3 CAN bus' so I guess you would need two.

Perhaps you can read them with I2C.

2 Likes

Any of these will likely work just fine in this case for a single bus. The internal CAN hardware will automatically serialize them due to priorities. (Assuming timing is not completely critical.) The internal hardware should move them into memory. This would all happen automatically in the background.

The MCP2551is really cool, but I am not sure this is the intended application. It can do a lot of things, but this may be pushing it.

1 Like

Hi Tom, thanks for the advice. It's be great to be able to connect all the CanHi and CanLo wires together due to space constraint. I will check if I could assign individual IDs to each sensor. Is there a link to post #6 I could refer to? (sorry I am still trying to figure out how to navigate around here :sweat_smile:)

Hi @dthacher and @horace , thanks for the guidelines. I took a look at the manual again and read through the commands and section you mentioned. I will definitely give that a go. Hopefully the individual IDs get stored.

Hi mikb55, @alto777, @dthacher , thanks. Technically, I would need to take an average of all the force sensor readings for a real time augmented reality application with respect to finger motions, but I guess a slight delay or buffering in terms of millisecs between the reading of each sensor shouldn't make much of a difference even if I would need to get the readings 'simultaneously'.

Hi,
If you google,

can bus tutorial arduino

This will pull up some info that can help.

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

Cool! Thanks, Tom! :smiley: