Hi,
Can anybody point me to an flowcode 8 example of using the CAN bus component makro to recieve packets, the example looks to be transmit only?
Best Regards
James
CanBus Read Example
Moderator: Benj
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: CanBus Read Example
Hi James
You need to setup your CAN component RX buffer properties (mask and filter if needed, or just Accept All)
Program flow is then a case of doing an Initialise at startup.
Then loop calling CheckRx (with the required buffer as a parameter)
If it returns true, then a message is waiting to be read.
At which point call GetRxDataCount, GetRxData etc
Hope that helps
You need to setup your CAN component RX buffer properties (mask and filter if needed, or just Accept All)
Program flow is then a case of doing an Initialise at startup.
Then loop calling CheckRx (with the required buffer as a parameter)
If it returns true, then a message is waiting to be read.
At which point call GetRxDataCount, GetRxData etc
Hope that helps
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: CanBus Read Example
Hi Leigh,
I am trying to recieve a standard can bus message of 8 bytes from id 0x611 and am having a few issues, please see program attached.
No matter how i set the filter in the component proterties, it makes no difference to the recieved data. Data is recieved even if i select reject all. Secondly the recieved data, i.e can message id and length seem random? As far as i undertand it the id should be 0x??? and the data length for a standard message 8 bytes?
Hardware in a ecio 40 and a mcp2515.
Would you mind taking a look at the attched?
Best Regards
James
I am trying to recieve a standard can bus message of 8 bytes from id 0x611 and am having a few issues, please see program attached.
No matter how i set the filter in the component proterties, it makes no difference to the recieved data. Data is recieved even if i select reject all. Secondly the recieved data, i.e can message id and length seem random? As far as i undertand it the id should be 0x??? and the data length for a standard message 8 bytes?
Hardware in a ecio 40 and a mcp2515.
Would you mind taking a look at the attched?
Best Regards
James
- Attachments
-
- Can V 0.2.fcfx
- (20.88 KiB) Downloaded 233 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: CanBus Read Example
A few possibilities:
What MCP2515 hardware are you using? Does it have 20MHz crystal? (Some Arduino modules have 16MHz)
You could use the ShowLEDs() macro to toggle outputs on the MCP2515 to check that the SPI is connected and working?
What is the incoming rate of the CAN messages? You have got quite some delays and printing, is there enough time to do that between messages?
You have an extra ID=GetRxIdent() - but that's not a major issue
What MCP2515 hardware are you using? Does it have 20MHz crystal? (Some Arduino modules have 16MHz)
You could use the ShowLEDs() macro to toggle outputs on the MCP2515 to check that the SPI is connected and working?
What is the incoming rate of the CAN messages? You have got quite some delays and printing, is there enough time to do that between messages?
You have an extra ID=GetRxIdent() - but that's not a major issue
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: CanBus Read Example
Hi Leigh,
Thank you for getting back to me. The hardware is an old Elektor project, i have checked the crystal and it is 20Mhz. It looks like the SPI is connected and working as if i disconnect the can bus i no longer receive messages, but I will try toggling the outputs as you suggest.
I also have a Raspberry pi and usb can interface on the bus where i can recieve and decode the messages, so i know they are present on the bus.
I added the delays as an experiment as i have found on previous flowcode projects that if i don’t add delays between spi transactions it just doesn’t work, so I can remove these if they are not required in this case.
Best Regards
James
Thank you for getting back to me. The hardware is an old Elektor project, i have checked the crystal and it is 20Mhz. It looks like the SPI is connected and working as if i disconnect the can bus i no longer receive messages, but I will try toggling the outputs as you suggest.
I also have a Raspberry pi and usb can interface on the bus where i can recieve and decode the messages, so i know they are present on the bus.
I added the delays as an experiment as i have found on previous flowcode projects that if i don’t add delays between spi transactions it just doesn’t work, so I can remove these if they are not required in this case.
Best Regards
James
- Attachments
-
- Capture.PNG
- (74.95 KiB) Downloaded 466 times
-
- Posts: 65
- Joined: Thu Jan 31, 2019 3:46 pm
- Has thanked: 11 times
- Been thanked: 12 times
- Contact:
Re: CanBus Read Example
Hi Leigh,
Following your advise a found I was unable to toggle the binary outputs.I subseqently found a connection issue between the MCP2515 and the MCP2551. Fixing this resolved everything. Outputs now toggle and the recieved CAN data is as expected.
Thanks for pointing me in the right direction.
Best Regards
James.
Following your advise a found I was unable to toggle the binary outputs.I subseqently found a connection issue between the MCP2515 and the MCP2551. Fixing this resolved everything. Outputs now toggle and the recieved CAN data is as expected.
Thanks for pointing me in the right direction.
Best Regards
James.