Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

CANOpen - sample rate problem

Solved!
Go to solution

Hi,

 

I am using the CANOpen toolkit to communicate with a sensor which can be set to a sample rate of 1kHz. Before I've used the standard Frame API and there I've received my PDO-objects every ms. Because I want to make the programming more easy I would like to use the CANOpen. But I can't set the sample rate to 1ms. When using 2ms the data isn't transmitted with the correct timestamp intervall.

 

I've attached the errorcode message when using 1ms as sample rate and the part of the block diagram with the PDO initialization.

 

Maybe somebody can give me a hint.

 

Best Regards,

 

--
Joachim

Download All
0 Kudos
Message 1 of 5
(8,260 Views)

Thats more a harware limitation then a CANopen driver limitation.

The Remote PDO Request approach sends a remote frame to the CANoipen Slave every 2 ms for example and receives the data as a reply to this remote message.

The CANopen driver uses NI_CAN Frame API periodic Object for this remote frame ID and this object is limited to 2 ms. If you would use two of them the limit would be 4 ms each and so on.

You would need to change to a different approach in order to overcome this limitation.

Perhaps it is possible to create sync signal at your slave or another slave in your network and enable your slave to send data on every sync message?

Or perhaps you could use just the read PDO  or wait PDO vi within a loop timed for ms execution. That would require your sensor to send data without any trigger.

 

DirkW

0 Kudos
Message 2 of 5
(8,250 Views)

Hello DirkW,

 

thanks for your reply. I've attached 2 example VIs. One with the communication via Frame API (Interface NET) and one via CanOPEN (Frame API (Interface Object)). When running the example with Interface NET I can poll my data every ms. I only have to start the communication via ncWriteNET.vi. After that I am receiving my PDO objects. That means my hardware (slave) is able to deliver data every ms. I've seen that the CanOpen library uses the  method 'coPdoCreate' from the ni_cano.* - library. How can I adapt this CanOpen object to communicate via the Interface NET method. I need for starting the PDO-transfer the PDO-object reference for the PDO Create Object.

 

My aim is to communicate with the maximum sample rate via CanOpen.

 

-- 

Joachim

Download All
0 Kudos
Message 3 of 5
(8,241 Views)
Solution
Accepted by Joachim082

Thats good, your sensor starts sending frames as soon as you start communication.

You could delete the remote frame function and then it would behave like your old Frame API application, except one detail.

Your old frame api app. ses the read mult to read all frames available.

The CANopen Read is only a single point read. Thus it reads only a single frame. That means you have to run the loop in ms rate, which is realy risky with windows.

You could enable buffering, but that may lead to overflow errors or disable buffering as is now and read the most recent value.

See the modified example.

 

DirkW

Message 4 of 5
(8,235 Views)

Thanks for the hints,

 

I am working with a Desktop-RT System - therefore no Windows risks. When using the Frame API I can achieve a sample rate of a millisecond. With the canopen I get a new pdo every 1-2 ms - satisfying enough.

 

-- 

Joachim

0 Kudos
Message 5 of 5
(8,224 Views)