This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] LP-AM243:如何在 LP-AM243 上创建一个 4 字节计数器(例如 uint32_t)、该计数器在存储器中的条件(例如按钮按下,计时器,信号)下递增、以便 CODESYS 或 Allen - Bradley 可以通过 EDS 读取它

Guru**** 2543280 points
Other Parts Discussed in Thread: LP-AM243

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1546810/lp-am243-how-to-create-a-4-byte-counter-e-g-uint32_t-on-the-lp-am243-that-increments-on-a-condition-e-g-button-press-timer-signal-store-in-memory-so-codesys-or-allen-bradley-can-read-it-via-eds

器件型号:LP-AM243


工具/软件:

以创建 4 字节计数器 (例如,) uint32_tLP-AM243 以便:

  • 按条件递增 (例如,按钮按下,计时器,信号)

  • 通过 EtherNet/IP 输入组件(例如组件 101)暴露

  • 存储在存储器中 CODESYS 或 Allen - Bradley 可以通过 EDS 读取

  • 与 EDS 参数/装配体模型兼容

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Thien:

    为了帮助阐明如何使用汇编语言和属性、我将参考通用器件示例作为参考。 通过查看此示例、您应该能够了解如何实现您的目标。

    在该generic_device.c文件中、该GENERIC_DEVICE_cipSetup函数创建两个0x640x65用于独占所有者连接的汇编实例和。 组装实例0x64负责生成输出流(目标至发起方)、而组装实例0x65负责使用从 PLC/发起 方(发起方至目标)接收到的输入流。

    在将成员添加到 Assemblies 之前、0x701将在GENERIC_DEVICE_cipGenerateContent函数中创建一个包含一个实例(实例 ID)和多个属性的新类(类 ID)。 然后使用此类向每个汇编添加属性。

    对于使用程序集0x65 ()、0x3080x30D将从类0x70实例中添加要的属性1。 类似地、0x3000x305将属性添加到0x64来自同一对象(类,实例)的生成程序集 ()0x701 中。
    由于您的问题与生产部分有关、因此让我们重点关注链接到生产装配体0x64 () 的属性更改如何影响输出流。 例如,如果我们更改属性的值0x300,该属性链接到生产装配体0x64,则更改将反映在输出流中。
    为了说明这一点、我们来思考一种场景、即每当从 PLC/发起方接收到的第一个字节发生变化时、我们希望递增计数器。 以下示例说明了如何修改GENERIC_DEVICE_run函数来实现此目的:

    void GENERIC_DEVICE_run(EI_API_CIP_NODE_T* pCipNode)
    {
        uint32_t errCode = EI_API_CIP_eERR_OK;
        uint8_t  attrValue = 0;
        static uint8_t counter = 0;
        static uint8_t lastAttribute = 0xFF;
    
        EI_API_CIP_getAttr_usint(pCipNode, 0x0070, 0x0001, 0x0308, &attrValue); //read Class 0x70, Instance 1, attribute 0x308, which is linked to consuming assembly.
    
    #ifndef ENABLE_INTERCORE_TUNNELING
            if ( errCode == EI_API_CIP_eERR_OK)
            {
                DRV_LED_industrialSet(attrValue);
            }
    #endif
    
        if(lastAttribute != attrValue)
        {
            EI_API_CIP_setAttr_usint(pCipNode, 0x0070, 0x0001, 0x0300, counter); //change attribute 0x300, which is linked to producing assembly
            ++counter;
            lastAttribute = attrValue;
        }
    
    }