Looking to create a device that allows all CAN messages through except for a select few that will be filtered and modified before being passed through.
This is aimed towards automotive testing. Modules in a vehicle are typically split between a few different CAN busses all connected by a gateway module. This gateway can take CAN ID 0x123 on Bus 1 and pass it unmodified to Bus 2, OR this gateway can take CAN 0x123 on Bus 1 and send it out on Bus 2 as 0x456, OR it could send it out as CAN 0x123, but with different data values. I'm looking to build something similar to this, but not sure if the arduino is the right for the application.
An example of my intended device usage might be testing how certain radio touchscreen features are disabled when the vehicle is moving. Let's say above 5 mph, certain settings are disabled. In order for this system to work, vehicle parameters are sent out like speed, gear, accessory power on, etc and are on Bus 1. These go to the gateway module and then are rebroadcasted onto Bus 2 where the radio is located. With my device between the gateway module and the CAN wires for Bus 2, I want to be able to sit in the car, turn it to accessory power mode, and my device allows all signals to go through EXCEPT for vehicle speed. So it would allow accessory power signal to get to the radio and turn it on. Then the device would be capturing vehicle speed & gear and sending a fake signal out so the radio thinks it's in gear and going 5 mph. See attached picture for clarification.
This would require two CAN modules (or one module with two channels).
Real vehicle signals come in from vehicle CAN bus1 -> gateway module -> in arduino CAN CH1 -> Process signal (direct feed or modify) -> out arduino CAN CH2 -> vehicle CAN bus2.
Simple pseudocode:
void loop()
{
if (CAN1.available())
{
CAN_Message = CAN.ReadMessageFromCH1();
if (vehicle speed OR vehicle gear CAN ID)
{
//Modify CAN_Message data as desired
}
CAN2.SendMessage(CAN_Message);
}
}
I guess my question is, is this plausible? If an arduino is not very appropriate this use case, any suggestions on what to look at? My main concern is that the arduino won't be able to keep up with the large amount of signals being passed through.
dtbingle:
I guess my question is, is this plausible? If an arduino is not very appropriate this use case, any suggestions on what to look at? My main concern is that the arduino won't be able to keep up with the large amount of signals being passed through.
Define "large". Do you know how many signals? Do you know the data rate?
I'd start with a Teensy 3.5 or 3.6 which has two CAN interfaces built-in. You just need to add the appropriate voltage conversion and protection chips so it can plug into the CAN bus. Something like a TI SN65HVD230 for conversion and PESD1CAN for protection.
500 Kbps and not sure on exact number, but it will be intended for use in a full vehicle. From what I know, there are 400 - 500 different signals defined, however, many are event triggered and many not used based on vehicle options, configuration, etc. Around 100 are fixed periodic ranging from every 100 ms to every 1000 ms.
500k doesn't seem too fast. It should not be a problem for any Arduino. The Teensy 3.6 is possibly the fastest processor that is easily programmable with the Arduino IDE.
Awesome, so from you what you all have said, it seems like either the Due or Teensy 3.6 should be able to handle this task from a processing power standpoint.
Thanks for the hardware links!
Obviously there are some hardware differences between the Teensy 3.6 and Arduino Due as well as available software libraries. However, both have 2 CAN bus ports and just need the transceivers to interface with the physical vehicle network. To act as a CAN gateway module, is there any major advantages of one over the other? In other words, which board would you choose and why?
Just to re-demonstrate, the gateway would have to support messages going in both directions - from vehicle bus 1 to vehicle bus 2 and backwards from vehicle bus 2 back to vehicle bus 1.
Vehicle Bus 1 -> Receive on device CH1 -> Modify if needed -> Send out on device CH2 -> Vehicle Bus 2
Vehicle Bus 2 -> Receive on device CH2 -> Modify if needed -> Send out on device CH1 -> Vehicle Bus 1
EDIT: Doing some more research, I'm leaning towards the Teensy 3.6. Faster processor, and looks to have libraries available that make it just as easy and many of the libraries available for arduino. The post here is essentially doing exactly what I want.
Teensy 3.6 = $38 on amazon w/ pins
2x CAN transceiver above = $20 total