| Electronics > Projects, Designs, and Technical Stuff |
| How can I artificially cause CAN bus errors for testing? |
| (1/2) > >> |
| HwAoRrDk:
I'm looking for ideas about how I can artificially cause errors in CAN bus transmissions, so that I can test some error handling code I have written. I mainly want to see whether it will properly fire an interrupt when the CAN peripheral enters the passive and/or bus-off error states. I have a very basic test network set up on the bench consisting of two nodes: the development device running my code, just receiving messages; the other a transmitting node (an Arduino with MCP2515 CAN shield), sending out a variety of sample messages at varying rates. The 'bus' is at present just 20cm of breadboard jumper wires, but I also have a couple of meters of twisted-pair wiring that I was also using. Maybe something dumb, like putting a momentary switch in-line on the H or L bus wire? Then just randomly stab the button to induce errors? |
| rvalente:
On automotive, you can try these tests easily: Short can Low and high to chassis ground and battery voltage, one, another, the communication must remain. Them short both Ground plane offset, add a power supply between the chassis ground and your equipment ground, float the voltage +2.5V and -2.5V. No damage may occur during in any testing, as soon the interference is removed, the communication must be reestablished, without human interference Take a look at canopen standards |
| IDEngineer:
Get one of the many CAN to USB interfaces with their free entry level PC application. Every one I've seen allows you to create various kinds of soft errors (the data format kind that aren't just shorting CANH or CANL to something). Peak and Kvaser are two names to investigate. I went through this several years ago, nearly built my own from scratch, but in the end it was cheaper and faster to buy off the shelf. |
| Berni:
A good way is to connect CAN-L to a metal file and drag the CAN-H line lightly across the file teeth. This creates very short intermittent shorts on the bus that might only corrupt only a few bits in a CAN message rather than kill the bus completely for the duration of holding a pushbutton. |
| HwAoRrDk:
I'm not really looking to test robustness of the CAN interface, so I'm not keen on any methods that have the potential to damage my test setup (yes, I know CAN transceivers have protection against things like short circuit and transients, but I'd rather not test them :)). --- Quote from: IDEngineer on February 27, 2020, 05:12:24 am ---Get one of the many CAN to USB interfaces with their free entry level PC application. Every one I've seen allows you to create various kinds of soft errors (the data format kind that aren't just shorting CANH or CANL to something). Peak and Kvaser are two names to investigate. I went through this several years ago, nearly built my own from scratch, but in the end it was cheaper and faster to buy off the shelf. --- End quote --- That sounds great, but having previously seen prices for Peak and Kvaser stuff, I almost certainly don't have the budget for such things. This is an amateur project, after all (as evidenced by my test setup :P). By the way, how would be they creating soft-error traffic? Don't CAN controllers (whether MCU peripheral or discrete) not allow you to create invalid CAN frames? Like, with bad CRCs, incorrect bit stuffing, etc; because those features are all handled automatically, and not exposed to the user. I guess maybe they are forming their CAN frames 'by hand'? --- Quote from: Berni on February 27, 2020, 07:25:33 am ---A good way is to connect CAN-L to a metal file and drag the CAN-H line lightly across the file teeth. This creates very short intermittent shorts on the bus that might only corrupt only a few bits in a CAN message rather than kill the bus completely for the duration of holding a pushbutton. --- End quote --- Not sure if serious... ??? ;D I do have a large metal file in the toolbox, though... But would there be a different approach to constructing a way of intermittently shorting the bus? Maybe an N-channel MOSFET between H and L, with gate triggered for a millisecond or two pulse on a frequent randomised basis by RNG on transmitting micro? |
| Navigation |
| Message Index |
| Next page |