Unable to write CAN-FD data

A free API for the transfer of data packages according to ISO-TP (ISO 15765-2)
Post Reply
Pujari
Posts: 8
Joined: Sat 7. Oct 2023, 08:45

Unable to write CAN-FD data

Post by Pujari » Fri 13. Oct 2023, 15:49

Hello,

I have modified the sample code with the below, for
PCAN_BITRATE_SAE_J2284_4 = create_string_buffer(b'f_clock=80000000,nom_brp=1,nom_tseg1=5,nom_tseg2=2,nom_sjw=2,data_brp=2,data_tseg1=7,data_tseg2=2,data_sjw=1')

as per APIs, write is successful, but no data is seen on PCAN view
PCAN-ISO-TP API Version: b'3.5.0.344'
Initialize transmitter: OK
Create a receive event on receiver: OK
Allocate tx message: OK
Allocate rx message: OK
Initialize tx message: OK
Write "42" message: OK
Wait a message on receiver: KO
Free tx message: OK
Free rx message: OK
Stop receive event on receiver: OK
Close receive event: OK
Uninitialize transmitter: OK

Can you please help/guide.

Regards
Anand Pujari
Attachments
can-fd.png
can-fd.png (107.69 KiB) Viewed 3585 times

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Unable to write CAN-FD data

Post by K.Wagner » Fri 13. Oct 2023, 15:56

Hello,

this question is kind of duplicated. As I already answered you in your topic Unable to view the data on the PCAN-View, all participants need to have exact the same bit rate. SAE J2284-4 doesn't use 1MB for nnominal, as you are showing in your PCAN-View picture.
Best regards,
Keneth

Pujari
Posts: 8
Joined: Sat 7. Oct 2023, 08:45

Re: Unable to write CAN-FD data

Post by Pujari » Fri 13. Oct 2023, 17:24

Hello,

I have used the same variable "PCAN_BITRATE_SAE_J2284_4" to set the clock.
But my end controller is using 1mbps. So to match the 80000000 Hz clock, I have modified the clock. Sample code, and PCAN View are all on the same configuration.

Also when I execute the sample code with the modified configuration, the led stay green only. I am attaching the modified code here.
Attachments
mod_canfd_read_write.txt
(4.61 KiB) Downloaded 1243 times

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Unable to write CAN-FD data

Post by K.Wagner » Mon 16. Oct 2023, 09:15

Hello,
Pujari wrote:
Fri 13. Oct 2023, 17:24
But my end controller is using 1mbps. So to match the 80000000 Hz clock, I have modified the clock. Sample code, and PCAN View are all on the same configuration.
Please note that the bit rate parameters you are using (f_clock=80000000,nom_brp=1,nom_tseg1=5,nom_tseg2=2,nom_sjw=2,data_brp=2,data_tseg1=7,data_tseg2=2,data_sjw=1) correspond to a bit rate of 10 Mbit/nominal and 4 MBit/s data. This makes at least for me no sense and it is also not 1MB as your controller is using.
Bit rate of 10 Mbit/s / 4Mbit/s
Bit rate of 10 Mbit/s / 4Mbit/s
Bit rate.PNG (33.07 KiB) Viewed 3563 times
Pujari wrote:
Fri 13. Oct 2023, 17:24
Sample code, and PCAN View are all on the same configuration.
I still do not think this is the case. It is as it always has been, you have a bit rate problem. The red marked part in you post let me know that you are not sure how to define or calculate a bit rate. So I keep my last answer as current answer:
K.Wagner wrote:
Fri 13. Oct 2023, 15:56
this question is kind of duplicated. As I already answered you in your topic Unable to view the data on the PCAN-View, all participants needs to have exact the same bit rate.
Best regards,
Keneth

Pujari
Posts: 8
Joined: Sat 7. Oct 2023, 08:45

Re: Unable to write CAN-FD data

Post by Pujari » Mon 16. Oct 2023, 09:40

Hello,

I am using the setting provided by the PCAN for 1Mbps nominal and 2Mbps for data. Please see the attachment. If its not correct can you please help me with the exacting setting for the clock for 1Mbps nominal and 2Mbps for data.
Attachments
clock setting from PCAN.png
clock setting from PCAN.png (102.62 KiB) Viewed 3560 times

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Unable to write CAN-FD data

Post by K.Wagner » Mon 16. Oct 2023, 10:15

Pujari wrote:
Mon 16. Oct 2023, 09:40
I am using the setting provided by the PCAN for 1Mbps nominal and 2Mbps for data.
No. You are not. Here is a picture of your own code (file mod_canfd_read_write.txt)
Code.JPG
Code.JPG (37.64 KiB) Viewed 3559 times
As you can see, these are not the same paraemters you are shwoing us in the PCAN-View picture. I have already shown that these values represent a different bit rate in my previous post.

Do you know the exact bit rate parameters used by your device? As long as you do not know this value, it makes no sense to configure anything in your code, because this will potentially never work. The 1 MB bit rate can have several configurations. For example, our Bit rate Calculation tools lists 700 possible values for the combination 1MB/2MB:
Results.JPG
Results.JPG (82.24 KiB) Viewed 3559 times
Again, if this is not exact the same bit rate, it will not work (even when they represent both 1 MB).
Pujari wrote:
Mon 16. Oct 2023, 09:40
If its not correct can you please help me with the exacting setting for the clock for 1Mbps nominal and 2Mbps for data.
  1. Open the connection windows of PCAN-View,
  2. Select the device you want to connect
  3. In the "CAN Setup" tab, select "Mode: ISO CAN FD", "Clocl Frequency: 80 MHz", "Bit Rate Preset: None", "Nominal Bit rate"/"Database Entry: 1 MBit/s", "Data Bit rate"/"Database Entry: 2 MBit/s"
  4. Copy the whole value by using the copy button located in the nominal or data bit rate area (any of them copy the whole bit rate string)
  5. Use that string in your code for connecting the channel
PCAN-View.JPG
PCAN-View.JPG (82.27 KiB) Viewed 3559 times
Youc an also use our fee free Bitrate Calculation tool for checking bit rates parameters.

I have written all information already about bit rate. Please understand tha this is not our work to help you finding a configuration of your devices. The PCAN device works, the API works and PCAN-View works. It is up to you to configurate things correctly. Thanks for your understanding.
Best regards,
Keneth

Post Reply