Page 1 of 1

dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 03, 2018 11:14 am
by Chip7882
Hello,

I´m working with a dsPIC33EP128GM604 and I have Problems with the CAN BUS component (CAN Internal 1 and CAN INternal 2).

Internal CAN 1 sends correct Data and correct ID when the Data and the ID in the Component "set tx data" are fix. But when i use variables for the data and the ID, then the received data on my CANalyzer are wrong.


Internal CAN 2
always sends wrong Data and wrong ID.
For example:
ID 0xa8
Data 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa
=> should be send (with component "set tx data")

=> but i recieve:
ID 0x00
DLC = 0
(see picture in atachments)

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 03, 2018 12:02 pm
by Benj
Hello,

Many thanks for letting us know.

We are aware of a problem with Internal CAN channel 2. I'm investigating it but currently there is a lot on my plate.

viewtopic.php?f=63&t=20406&p=90469

How urgent is the project for you. I can jump back on this later today if it's urgent.

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 03, 2018 1:11 pm
by Chip7882
Hello Benj,

thanks for your answer.
It would be great if there was a solution to this problem soon, as I am under some time pressure and have not progressed for a few days. :|

In my project, i have to manipulate data in a CAN network, so the 2nd CAN channel is necessary for me.


Thanks for your help in forward

Best regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 03, 2018 1:40 pm
by Benj
Thanks Daniel,

I'll have an investigation for you this afternoon and see where I get.

Edit: I have now done a bit of testing and it looks like both internal CAN channels are transmitting data ok. The problem seems to be to do with receiving.

Here I have CH1 sending ID1 with Data bytes all 1s and CH2 sending ID2 with Data bytes all 2s.
CANTest.jpg
CANTest.jpg (106.94 KiB) Viewed 18630 times

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 03, 2018 4:09 pm
by Chip7882
Hello Benj,

ok, can you send me your current CAL_CAN file?

With the CAL_CAN file from your post in the other chat is transmitting with Ch1 ok, Ch2 sends wrong data and 2 different ID`s and I send only one ID.

The ID I want to send is 0xa7...but with the CANalyzer I see ID 0x280 and 0xFC3FC0x...

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 03, 2018 5:04 pm
by Benj
Hello,

Here's the current CAL file.
PIC16BIT_CAL_CAN.c
(66.07 KiB) Downloaded 455 times

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 03, 2018 5:29 pm
by QMESAR
Hi All,

Just my 2 cents from a past problem very similar to this is that if you look at your CANalyser you will notice you see 1 extended messgage ID with a DLC (Data length code )of 15 this is a PC CANalyser Driver issue specially if you use win 8 or 10 ,There is no way the PIC can send a DLC of 15
I had this issue and it drove me nuts until I found the correct driver(this was with PeakCAN though :D
I not saying this is the issue however the DLC of 15 is suspicious .
P1.jpg
P1.jpg (56.67 KiB) Viewed 18614 times

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 03, 2018 5:55 pm
by Chip7882
Hi QMESAR,

thanks for your help. You`re right, dlc 15 can not be, but i think the CANalyzer shows this because the data from the pic are not plausible.
(i`m using Vector CANalyzer)

With the last CAL_CAN file from benj is transmitting ok now. The Problem now is the receive part...

Best regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Thu Oct 04, 2018 12:38 pm
by Chip7882
Hello Benj,

do you have any news about the receiving?

regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Fri Oct 05, 2018 1:02 pm
by Chip7882
Hello Benj,

when do you think you will have a solution for this issue?


Best regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Fri Oct 05, 2018 2:33 pm
by LeighM
Hi
Can I suggest that for the receive buffer you try the property setting of "Use Mask and Filter" and set the Mask and Filter values manually.
I suspect that the "Accept All" does not work.

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Fri Oct 05, 2018 2:43 pm
by Chip7882
Hi LeighM,

thanks for your answer. Ok i will test it and give feedback.

Best regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Sat Oct 06, 2018 10:09 am
by Chip7882
Hi LeighM,

you`re right, it works when i set the mask and filter values manually. :)

The next problem is the ID type setting in CAN 2.
When "standard & extended ID" is set, i can not compile (see attachment).
=> Some ")" were missing in the CAL_CAN file.
I fixed this, but the funktion is still not working correctly. There is a issue when I receive standard and extended ID`s on CAN 1 and want to send this ID`s on CAN 2.

Could you help me again please?

Thanks and regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Mon Oct 08, 2018 8:55 am
by LeighM
Thanks for the spot.
Can you try this fixed CAL file, it should now compile OK.

What function is not working?
Could you send the program that demonstrates the issue?

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Mon Oct 08, 2018 12:10 pm
by Chip7882
Hi LeighM,

thanks, compile is ok now.

In the atachement is a simple the program to demonstrate. CAN 1 should receive some messages (extended and also standard IDs) and send this on CAN 2.



regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Mon Oct 08, 2018 12:29 pm
by LeighM
Hi Daniel,
What works, and what does not work?
Do you receive OK?
Leigh

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Mon Oct 08, 2018 5:42 pm
by Chip7882
Hello Leigh,

with your CAL_CAN file, i can´t send any message with CAN2. Benj has already fixed this Problem and has sent me a new Version (in his post in this chat). In this file i added the missing ")". => see the atachement
Here is receiving and sending with both CAN ok, but only for standard ID`S and setting "only standard" ID type.
When the ID type is set to "standard and extended" for both Channels and I send with my CANalyzer a standard ID message on CAN 1, than the receiving is not ok. In my program i want to send the received message on CAN2. CAN2 sends then an extended ID (see atachement)

regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Tue Oct 09, 2018 9:09 am
by LeighM
Hi Daniel,
The component code is currently written such that the CAN channel either works in base frame format (11 bit ID), or extended frame format (29 bit ID) mode. Are you expecting both types on the same bus?

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Tue Oct 09, 2018 9:56 am
by Chip7882
Hello Leigh,

yes i´m expecting both ID types on the same bus and have to send both types on CAN2.

That means I can´t do this with the current component?
Do you plan to change this?

regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Tue Oct 09, 2018 2:09 pm
by LeighM
Hi Daniel,

Having looked at the CAL code it looks like a channel set to "standard & extended" should receive a standard ID message OK,
as the MIDE flag is set to 0. Although the GetRxIdent will most likely not return the expected ID.
Changing the code to support mixed receiving and sending will be quite a task, but we might be able to push it along,
it depends on what does actually work and how much more you need.

So, can we just summarize what you have so far...
Set both channels Id type to "standard": Receive standard id message on channel 1 and send standard id message on channel 2: OK
Set both channels Id type to "standard & extended": Receive extended id message on channel 1 and send extended id message on channel 2: OK ?
Set both channels Id type to "standard & extended": Receive standard id message on channel 1? Does CheckRx return true?

Do you need to receive and send on both channels? And does that work with standard IDs, if not extended IDs?

Leigh

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Tue Oct 09, 2018 3:40 pm
by LeighM
Hi Daniel,

I've got hold of some hardware (nicked off Ben :) and I've been testing sending and receiving between channel 1 and channel 2
All seems to be well as far as I can see.
I've successfully sent a standard ID message from one channel (set to "standard") and received it OK on the other channel set to "standard & extended"

I've fixed the GetRxIdent such that it uses the IDE flag from the received ID (rather than the component property mode)
So if you use the attached updated CAL file you will get the correct received message ID

The only thing we cannot do at present is dynamically change the transmit ID mode of a channel,
that's something I could have a look into, depending upon if you need it?

You made a comment earlier that you need to receive "standard" and "standard & extended" ID messages,
but send them on channel 2 as "standard & extended",
is that correct?

Leigh

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Tue Oct 09, 2018 7:11 pm
by Chip7882
Hi Leigh,

many thanks for your help. :D
i have tested it, it works the way you say.


"The only thing we cannot do at present is dynamically change the transmit ID mode of a channel,
that's something I could have a look into, depending upon if you need it?"

=> That would be awesome :D

I`ve many projects with CAN networks in cars and often have to modify data from a control unit which receive the rest of the car. I seperate the bus for this, thats why i have to put through many messages (with standard IDs and also extended IDs) to the other channel.
In short I have to receive standard ID and extended ID on both Channels and send them as i received on the respective other channel. (CAN to CAN gateway)
I hope I could explain it reasonably well with my bad english :lol:

Many thanks in advance
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 10, 2018 10:34 am
by LeighM
Hi Daniel,

You could force the sending of a standard ID with the following C code, used instead of the SetTxIdent
can_std.jpg
can_std.jpg (31.41 KiB) Viewed 18406 times

Code: Select all

MX_MEMBUF_2[0][0] = (FCV_CAN_1_RX_ID_B0) << 2;

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Wed Oct 10, 2018 6:20 pm
by Chip7882
Hi Leigh,

everything works perfectly now! :D :D

i did the same with "MX_MEMBUF_1[0][0]" for sending on CAN 1.
And when ID > 0x7FF => i use the component "SetTxIdent"

Thank you very much for the your great support 8)

regards
Daniel

Re: dspic33ep128gm604 CAN BUS Problems

Posted: Fri Jul 12, 2019 10:37 am
by Chip7882
Hello Leigh and Ben,

i have another Problem with the CAN BUS. In my project i have a CAN to CAN gateway. so i have to send on CAN 2 all messages which i recieved on CAN 1, and the same from CAN 2 to CAN 1.
If there are many messages on the BUS sometimes messages get lost. I use "RX Buffer 1". Do you think the Buffer size is to small or what do you think is the Problem? Do you have an idea?

best regards
Daniel