Reading CAN-BUS data

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
ChrisD
Posts: 4
Joined: Wed Sep 15, 2010 4:31 pm

Reading CAN-BUS data

Post by ChrisD »

Hello

I am experimenting with CAN-BUS and I am having a problem reading the can signal
I am checking the buffer and then read the can data, I use the "GetRXData" macro using Parameters buffer 0 index 0 and returning the Value to a variable but the data in the variable is always the same value, I have tried sending a can data Via a PIC chip or “PEAK” can-bus reader/transmitter but it still comes up with the same value, I have proved that can signal is getting through the RX buffer filtering. If use a different chip it returns a different value but again always the same value

Looking at the example programs and instructions I believe I am doing this correctly but as this does not work I am thinking that I am missing something?

I am running 2 PIC18f2585 using the internal can

Any help would be much appreciated

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Reading CAN-BUS data

Post by Benj »

Hello,

The GetRXData macro should only be used after calling the CheckRX function.

The CheckRX function checks for incoming messages and if there are any available it will return a non 0 value and add the message to the internal buffer. It is then this buffer that you are reading from when calling the GetRXData function.

ChrisD
Posts: 4
Joined: Wed Sep 15, 2010 4:31 pm

Re: Reading CAN-BUS data

Post by ChrisD »

Hello
I have included a very simple program that I believe should work? I am using the CheckRX function then the using the GetRxData function but it always returns the same value? I can see the can data I am sending via my can-bus reader so I know what value I should be getting just don’t
I am using the internal can on the chip so have used a prototype board to connect the chips together using the 2 MCP2551 chips as per the information for internal can on the forums, as I can send data ok I have to presume I have done this correctly?
Many thanks
Attachments
Node2.fcf
(9 KiB) Downloaded 165 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Reading CAN-BUS data

Post by Benj »

Hello Chris,

Are you using a 20MHz crystal?

Also I noticed that in your chip configuration you have the following settings enabled which should be disabled instead.

Watchdog Timer
Low Voltage Program
Extended CPU Enable

What are you using to transmit the CAN messages? Is it using a baud of 125KBPs to match your Flowcode CAN baud?

ChrisD
Posts: 4
Joined: Wed Sep 15, 2010 4:31 pm

Re: Reading CAN-BUS data

Post by ChrisD »

Hello
Yes I am using a 20MHZ crystal
I will change the setting I was unsure what they should be
I have tried two ways of sending messages first was via a second chip I could connect a key pad up to and to change the can data using this and send it, I know I am sending a message because I am using a Peak P-Can can bus reader to check this reader can also transmit a message but I still get know joy from either off this two methods and all running at 125KBPs

http://www.peak-system.com/Product-Deta ... howUid]=16

Many thanks

ChrisD
Posts: 4
Joined: Wed Sep 15, 2010 4:31 pm

Re: Reading CAN-BUS data

Post by ChrisD »

Hello Ben
Thank you very much I changed the chip configurations you mentioned and it worked instantly.
Thanks Again
Chris

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Reading CAN-BUS data

Post by Benj »

Hi Chris,

Thats great thanks for letting me know. Those config settings can be a little daunting if you've not experienced them before.

Post Reply