Rolling counter and callback functions

Professional Windows® software to communicate with CAN and CAN FD busses and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
Rangey
Posts: 2
Joined: Tue 14. Jun 2022, 23:26

Rolling counter and callback functions

Post by Rangey » Thu 16. Jun 2022, 21:25

Hello folks,
I am using PCAN Explorer 6 to interface with an electric motor system for a new EV that we are building. The motor requires CRC and I followed the topics in this forum to create a .dll and a rolling counter, based on the example that comes with the full install. It seems to "sort-of" work, but I get occasional errors from the motor that report "Bad CRC".

Since I have never developed anything in CAN or in PCAN explorer, I am unclear on what the possible settings should be for the callback functions, and was wondering if there is a tutorial or explanation to guide in selecting "reset counter" versus ID_100 vs Checksum_ID101, etc. Any replies would be appreciated!

-David

Rangey
Posts: 2
Joined: Tue 14. Jun 2022, 23:26

Re: Rolling counter and callback functions

Post by Rangey » Fri 17. Jun 2022, 18:57

Found some comments in the Peak supplied sample file; that shows how to set 3 of the event functions, but there are a total of 7 possible events. I am still not clear on how to set this up and any assistance would be great!

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: Rolling counter and callback functions

Post by K.Wolf » Mon 20. Jun 2022, 10:11

Hi,
to create a rolling counter and calculate the matching CRC for your message the event 'On Before Transmit' is the right one to use. The function 'Rolling_Counter_Checksum_ID201' in the example source code demonstrates how to increase a rolling counter and create the checksum for a specific CAN ID that is sent by PCAN-Explorer.
Note that once you have assigned the function in the Callback Library configuration window to the 'On Before Transmit' event, every message that is sent by PCAN-Explorer goes through the DLL. Therefore, you must make sure that the DLL only modifies the right messages, i.e. which has the correct CAN ID and DLC.

Post Reply