如何对简单的CANopen层进行编程 [英] How to program a simple CANopen layer

查看:214
本文介绍了如何对简单的CANopen层进行编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个机器人项目,其中电机控制器使用 CANopen 进行通信.我需要使用主微控制器与这些电机控制器进行通信.问题是我需要在该微控制器中开发一个CANopen层,但是我只知道如何在低电平(CAN)上发送和接收.

We have a robot project where the motor controllers use CANopen for communication. I need to communicate with these motor controllers using a master microcontroller. The problem is that I need to develop a CANopen layer in this microcontroller, but I only know how to send and receive at the low level (CAN).

我对CANopen知之甚少(PDO,SDO,心跳,对象字典等).我试图阅读CiA规范,但这非常复杂.如果有人可以指出正确的方向或给我一个好的教程来编写简单的CANopen层,我将不胜感激.

I don't know much about the CANopen (PDO, SDO, Heartbeat, object dictionary, etc.). I tried to read the CiA specifications, but it was very complicated. I would appreciate it if someone could point me in the right direction or give me a good tutorial to program a simple CANopen layer.

推荐答案

由于这似乎是人们普遍关注的话题-我同意理解完整的原始规范可能会有些痛苦.因此,这里有一个建议,那就是推动您的前进",而不是实现整个过程":

Since this seems to be a topic of general interest - I agree that understanding the full original specs can be a somewhat painful experience. So here is a suggestion for "get your drive going", as opposed to "implementing the whole thing":

  • 检查您的CANopen驱动器是否可以通过CiA 402标准对象进行操作,并且出于性能方面的考虑,最好不要配置和使用PDO,这样您就不需要心跳了.通常是切换驱动器的状态机(对象6040h,控制字),设置操作模式(对象6060h),以及设置其他参数,例如轮廓位置速度".

  • Check if your CANopen drives can be operated via the CiA 402 standard objects and for performance reasons it would be perfectly fine to NOT configure and use PDOs, and you don't really need heartbeat, a.s.o. It's usually switching the drive's state machine (object 6040h, control word), setting operation mode (object 6060h), and setting additional parameters like "profile position velocity".

然后仅实施快速SDO传输. (请参见 http://en.wikipedia.org/wiki/CANopen .)SDO下载用于编写/更改对象.在您的驱动器中. SDO上传用于读取对象.

Then implement expedited SDO transfers only. (See http://en.wikipedia.org/wiki/CANopen.) SDO download is for writing/changing an object in your drive. SDO upload is for reading an object.

我建议使用可以读取和写入SDO并具有CAN总线监视器的PC软件. (我们的 Kickdrive Zero 免费软件可以做到这一点,但实际上,任何其他适用于CANopen的PC工具都可以使用.)做一些示例,以读取和写入所需的数据类型和对象.看看这是如何转换成CAN级别的帧的.对于基本的整数数据类型,对于请求来说总是一帧,对于回答来说只有一帧.

I suggest to take a PC software that can read and write SDOs and has a CAN Bus Monitor. (Our Kickdrive Zero freeware can do that, but really, any other PC tool for CANopen should work.) Do some example reads and writes for the data types and objects you need. Look how this translates into frames on a CAN level. For basic integer data types, it's always just one frame for the request, one for the answer.

现在在您的微控制器上构建一个简单的协议栈,该协议栈可以发送SDO下载/上传请求并处理答案.

Now build a simplistic protocol stack on your microcontroller that can send the SDO download/upload requests and process the answers.

免责声明-以上内容与实施CANopen",支持CANopen"甚至与CANopen兼容"甚至还不接近.这是关于使驱动器尽快移动而没有第三方代码".有时候这是正确的做法.

Disclaimer - the above is not even close to "implementing CANopen", or "supporting CANopen", or even "CANopen compliant". It's about "make your drive move ASAP and without third-party code". Which is sometimes the right thing to do.

这篇关于如何对简单的CANopen层进行编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆