Problem to control LIN device via CAN

RS-232 to CAN/LIN Interface
Post Reply
alcapone
Posts: 2
Joined: Tue 24. Sep 2019, 20:01

Problem to control LIN device via CAN

Post by alcapone » Tue 24. Sep 2019, 20:21

Dear all,

I need to control a LIN slave device via CAN.

The LIN slave device to control sends data on 2 ID's (1F and 21) and I need to send a signal on ID 1E to set a speed of the LIN device. I need to recieve the LIN data via CAN and send the required speed via CAN to LIN.

It is almost working fine, but I can only recieve data from the LIN device or set speed. It is not working if I try to do both. If I turn off the master functionality in PCAN-LIN CT I am able to set speed via CAN, but I don't recieve any data from the LIN slave. If I turn it on again, I recieve data, but I am not able to set speed via CAN.

Attached you can find my configuration. In the Sceduler there are only the 2 ID's (1F and 21) defined. In the frame configuration there are 3 ID's configured. (1F and 21 as subscribers and 1E as publisher)

I would be very glad to hear from you.

Best regards

Andreas
Attachments
PCAN_LIN_Profile.pclin
(45.66 KiB) Downloaded 190 times

M.Maidhof
Support
Support
Posts: 1307
Joined: Wed 22. Sep 2010, 14:00

Re: Problem to control LIN device via CAN

Post by M.Maidhof » Wed 25. Sep 2019, 10:01

Hi,

to control a LIN slave with PCAN-LIN through CAN you have two options:

1. use the PCAN-LIN as LIN master with active scheduler
2. use the PCAN-LIN as CAN-LIN gateway and send all subscriber and publisher frames by CAN

To use the PCAN-LIN as a LIN master, you have to set the termination to master, this was not done in your attached config!

here the details for solution 1:
- you have set the publisher frames in the frame config and set some default data for them. You need to setup a scheduler for all messages (subscriber and publisher frames) with the timing as defined in your ldf (you forgot 0x1E in your scheduler list). You also have to take care for the correct length code and checksum type. As long as the scheduler is active, PCAN-LIN will send out the defined default data for the publisher frames and will get the LIN slave data for the subscriber frames. If you want to change the default publisher data by CAN, you have to send a CAN frame with the following ID: LIN-ID +0x40 + CAN-ID Offset. In you case you have to send CAN ID 0x5E with 8 data bytes, to change the publisher frame 0x1E while the scheduler is active. Please see also the online help of PCAN-LIN CT, where you will find examples for this use case.

here the details for solution 2:
- you have to setup all frames to subscriber, but set the length code and checksum type to the needed values of your LIN system (see ldf). Now, while no scheduler is active, you can generate publisher frames on the LIN with a normal CAN message (e.g. 0x1E with 8 databytes) and generate subscriber frames with a CAN RTR message (e.g 0x21 dlc 8 RTR and 0x1F dlc 8 RTR).

regards

Michael

alcapone
Posts: 2
Joined: Tue 24. Sep 2019, 20:01

Re: Problem to control LIN device via CAN

Post by alcapone » Mon 30. Sep 2019, 08:49

Hello Michael,

thank you for your support. We got it running with solution 2! :)

Best regards

Andreas

Post Reply