From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX Callback Performance Problem

Hi all


I have an USB 2 CAN Converter which I controll with an activex Container element.

The Converter has to access an ECU via the CAN Calibration Protocol (CCP; Point to Point)

That means I send via the converter an 8 byte CAN message to the ECU and the ECU sends me an adequate message back. For the sending I have to use use an activex Invoke node.
The reception of an ECU message is just possible via event callback. For that I first register an activex event callback at the start of my program. I pass a reference to the displaydata(Anzeigedaten) as a user parameter of the callback.

After sending the message to the ECU I wait inside a while loop as long as the state of my displadata is receiving a CAN message(via Property node; Status 1). Then I have to setting back the property node to Status 0. Now it is possible to process the displaydata.
And so on. I send a message wit for the receive......


So far so good. Everything works fine just very slow. With other USB to CAN hardware (peak system technik, esd electronics) this works for about ten times faster. But there I work with a dll. My experience with activex is very poor. So im not sure is there a possibility to increase the speed of my labview code.

For to spell the problem out you here is a picture.
or http://www.labviewforum.de/download.php?id=2167


Thanks in advance

Baesi

0 Kudos
Message 1 of 9
(3,430 Views)
ActiveX has an overhead if you compare it to direct dll access, so it can be possible that the API is simply slower then the API of your other devices. You should consult the manufactuer of this USB to CAN converter.
0 Kudos
Message 2 of 9
(3,419 Views)
Thanks for your answer,

You are right.

the activex is Hardware is slower(4x) than the dll Harware is. But my main problem is Labview. I builded the same software with the same hardware (activex) twice. One in Labview the other in C#.

The procedure is :

Send 100 times a message to an ECU wait for the answer(Event).

Please look at the picture. The differnces between the answer times are huge. I dont know why the registered event callback of the answer is so mutch slower in labview than in C#!
0 Kudos
Message 3 of 9
(3,406 Views)

hi there

you wrote  "The reception of an ECU message is just possible via event callback. For that I first register an activex event callback at the start of my program. I pass a reference to the displaydata(Anzeigedaten) as a user parameter of the callback.

Ok!

then: "After sending the message to the ECU I wait inside a while loop as long as the state of my displadata is receiving a CAN message".

why do you use a while loop for polling status when there is a callback function? maybe thats causing the poor performance. can you please post some code?

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 4 of 9
(3,403 Views)
Hi chris

Thx for your reply.

...why do you use a while loop for polling status when there is a callback function? maybe thats causing the poor performance. can you please post some code?...

the problem is I have already a program which works very well with another hardware. All I want to do is to replace the current hardware whitch this new one because we use this CAN converter for another bigger project.
I wrote this software long time ago. And it is not really scaleable and maintainable. But it works without any errors.

I think the best way would be to use an event structure in the future. But in the current software I use a state machine.

I send you for better understanding my code with which it would be possible to replace the current functions in my main software.

Thank you all for your time

kind regards

baesi

0 Kudos
Message 5 of 9
(3,396 Views)
I forgott to add the ocx file....
0 Kudos
Message 6 of 9
(3,386 Views)

 

hi there

ah, i see, sorry, it was my mistake: i thought you are polling the status of ActiveX property, but you are polling a control.  that should be ok. but anyway: i would try to use an event structure as you mentioned. or have you tried to add a simple "wait ms"- function in the polling while loop?

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 7 of 9
(3,380 Views)
hi chris

I tried a to use "wait ms"(0 or 1 ms). But I couldnt improve the prformance.
I think the only way is to use an event structure. But I afraid as long I have to use a proprty node inside my event callback it will be too slow .

kind regards

baesi

0 Kudos
Message 8 of 9
(3,361 Views)

hi there

well, you could use a good ole occurence or fire an user event inside your callback vi. when you register the user event you can catch it with a event structure (using dynamic events). or have you thougt about a queue? then you could buffer the callback events data and read it in a parallel loop.

let us know!

 

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 9 of 9
(3,349 Views)