11-28-2018 04:49 AM
Hey everyone 🙂 Me again!
right now I develop a Labview Software using the CAN BUS protocol.
I use a PCAN adapter that is connected via USB. Communication works via PCAN_Driver_LV2010 v1.0.0
https://lavag.org/files/file/211-pcan-driver_lv2009/, I can send and receive and control the device.
BUT: I do have a strange time lag reading. An example: I read the can message for voltage and display them in a diagram. The device is continuously sending the voltage can message. If I switch off the device, data continues to be displayed for a minute or so, unless the device is already turned off and stopped to send data some time ago. I verified it with PCAN viewer, that uses the same connection and immediately stops to receive data when I switch off the device... So - principally it is possible.
I posted a screenshot to clarify what happenes and I posted my reading vi. If you need further information please let me know.
Precise questions:
1) Is there a buffer, the driver is reading from?
2) Do I read too slow (not often enough)?
If anyone has experience with the use of the PCAN Dongle and the driver mentioned or an idea, please let me know 🙂
Best regards
Anna
11-28-2018 08:40 AM
Your read buffer is filling up because you aren't reading from the device as fast as data is coming in. You have a control Ze wartende which is set to 10 ms. Well after that 10ms wait you go and read a single frame. Even at 125Kbaud you will likely get a message must faster than once every 10ms. What you should be doing is every 10ms read ALL messages in your buffer, then wait another 10ms and then read ALL messages in your buffer. An easy way to do this is to put a while loop around around your read and keep reading all messages until there are no more to read.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
11-29-2018 04:00 AM
Hi,
thx for your answer! Good idea! Sounds very simple and now, that I read it, I wonder why I didn't come up with it myself 😛
I will give it a go and report...
regards
Anna
11-29-2018 04:15 AM
11-29-2018 09:48 AM
A lot of these cheaper CAN devices are just DLL wrappers of function calls. Several I've seen just read a single frame at a time, some don't have an ability to read the number of frames waiting in the buffer, which is why I suggested just reading in a while loop until an error is returned (or no new frame comes in). Just another reason why I love the flexibility of XNet. That being said I've used cheap less functional hardware many times for simple things, you just need to know extra software layers like this might be needed to do things like read all remaining frames.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-19-2019 04:15 AM
Hello,
Is it possible to use 2 PEAK CAN adapters (for 2 different CAN buses) with PCAN_Driver_LV2010 v1.0.0 library?
03-19-2019 08:43 AM
It doesn't look like the DLL has the ability to specify the device to talk to. It could be that there are newer version of the DLL from the manufacturer but that driver seems very limited. Might I recommend an XNet device. The USB-8205 has two High speed or CAN FD ports via USB and supports all kinds of useful features with different sessions types, frame signal API and database management, with lots of shipped examples.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-19-2019 08:53 AM
Thank you for fast reply.
08-23-2019 12:45 AM
Hello,
I have implemented the same reading CAN messages in while loop.The baud rate is 250 Kbps.My device sends a message with transmission rate 25ms. But when I log the data I cant see the difference in two CAN frames of same message near to 25ms, its almost 1 ms.I am using High resolution Relative Seconds.vi for timing reference in log.
If I take trace from PCAN View the same message shows cycle time of 25 ms correctly.
So my doubt is -
How can I use PCAN_Read.vi effectively to read CAN messages and get correct transmission rate.
How the PCAN_USB.dll is working for storing data in buffer?
08-23-2019 12:59 AM