CAN Bus set up

Use this section to discuss your embedded Flowcode projects.
Post Reply
kramtlas
Posts: 13
http://meble-kuchenne.info.pl
Joined: Mon Dec 14, 2020 7:22 am
Has thanked: 1 time

CAN Bus set up

Post by kramtlas »

Hi, I have a project which requires connection to a vehicle CAN bus and to look for a "Ign ON" status to trigger a response from my circuit.This is my first time using CAN and I am not sure how to set this up. It is a 8 byte message in hex ( 17F00010 ) and I wondered if anyone had an example I could have to help me get this working.
I want to use a BL0061 board and a BL0140 Can bus module.
Thanks

BenR
Matrix Staff
Posts: 1706
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: CAN Bus set up

Post by BenR »

Hello,

Here's an example that should hopefully help to get you started. It will check for any incoming CAN packets and write the ID and data to the LCD. The data will probably be far too fast to see on the LCD but it should at least get you started.

LCD is connected to PortA and CAN to PortD with switches on the board set to EXT and Off.

As for your data you have only posted hex data for 4-bytes. A CAN message consists of an ID and up to 8 data bytes and so you will have to try and find out exactly what your looking for, you can maybe do this by trial and error and see how you get on. I've added a decision looking for the data you posted but this may or may not work depending on how the data is formatted in the 8-data bytes.

You might also have to play around with the CAN component Bus Rate property to match the baud of the bus on your car.

BL0061_CAN_Demo.fcfx
(17.64 KiB) Downloaded 123 times

If you know the ID of the message then you can change the CAN component RX Buffer accept all property to mask and filter and this way you can configure the messages to only accept the ones your interested in.

Post Reply