Codesys浣跨敤璁板綍-1.png_Codesys浣跨敤璁板綍 - 閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛

閰峰痉缃

HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鎼滅储闄勪欢  
閰峰痉缃 闄勪欢涓績 CODESYS绉绘 IO绉绘 Codesys浣跨敤璁板綍-1.png

Codesys浣跨敤璁板綍-1.png

 

Codesys浣跨敤璁板綍:
鏂囩珷鐩綍





    鍓嶈█涓 Codesys鐨処ODrv鏄粈涔堬紵




    浜屻佷娇鐢ㄦ楠




      1.XML閰嶇疆鏂囦欢2.IODrv缂撳啿鍖烘暟鎹洿鏂
    鎬荤粨


鍓嶈█

鎻愮ず锛欳odesys鐨処ODrv鍔熻兘浣跨敤蹇冨緱锛
CODESYS鏄竴绉嶅箍娉涗娇鐢ㄧ殑宸ヤ笟鑷姩鍖栧紑鍙戠幆澧冿紝鐢ㄤ簬缂栧啓鍜岀鐞哖LC锛堝彲缂栫▼閫昏緫鎺у埗鍣級绋嬪簭銆傚畠鎻愪緵浜嗕竴涓泦鎴愮殑寮鍙戠幆澧冿紝鍖呮嫭缂栬緫鍣ㄣ佽皟璇曞櫒銆佷豢鐪熷櫒鍜岀洃瑙嗗伐鍏凤紝浣垮伐绋嬪笀鑳藉鍒涘缓鍜岃皟璇曞鏉傜殑鑷姩鍖栨帶鍒剁郴缁熴

鎻愮ず锛氫互涓嬫槸鏈瘒鏂囩珷姝f枃鍐呭锛屼笅闈㈡渚嬪彲渚涘弬鑰
涓 Codesys鐨処ODrv鏄粈涔堬紵

codesys鎻愪緵鐨勪竴濂桰/O椹卞姩妗嗘灦锛屽叾涓寘鍚獻/O椹卞姩绋嬪簭鐨勬簮浠g爜妗嗘灦鍜屼竴浜涙弿杩版枃浠讹紙XML锛夈傜敤鎴峰彲浠ラ氳繃鏇存柊IODrv涓殑杈撳叆鍜岃緭鍑虹紦鍐插尯锛屼粠鑰屽皢鎬荤嚎鎴栬呯郴缁熺姸鎬佽窡Codesys杩涜鍛ㄦ湡鎬х殑鏇存柊鍜屼氦浜掋
浜屻佷娇鐢ㄦ楠

1.XML閰嶇疆鏂囦欢

閰嶇疆鏂囦欢锛堢ず渚嬶級濡備笅鎵绀猴紝IODrv閫氳繃ParameterId缁戝畾杈撳叆杈撳嚭鑺傜偣锛孖ODrv婧愮爜涓彧闇瑕佹寜鐓ML鏂囦欢涓厤缃殑鑺傜偣涓暟锛岃繘琛屾暟鎹殑鎷疯礉鍜屼氦鎹㈠嵆鍙


[XML] 绾枃鏈煡鐪 澶嶅埗浠g爜
<?xml version="1.0" encoding="UTF-8"?>
<DeviceDescription xmlns="http://www.3s-software.com/schemas/DeviceDescription-1.0.xsd" xmlns:ts="http://www.3s-software.com/schemas/TargetSettings-0.1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Types namespace="local">
        <BitfieldType basetype="std:BYTE" name="TBitSingleByte">
      <Component identifier="Bit0" type="std:BOOL">
        <Default />
        <VisibleName name="local:TBitSingleByte.Bit0">Bit0</VisibleName>
      </Component>
      <Component identifier="Bit1" type="std:BOOL">
        <Default />
        <VisibleName name="local:TBitSingleByte.Bit1">Bit1</VisibleName>
      </Component>
      <Component identifier="Bit2" type="std:BOOL">
        <Default />
        <VisibleName name="local:TBitSingleByte.Bit2">Bit2</VisibleName>
      </Component>
      <Component identifier="Bit3" type="std:BOOL">
        <Default />
        <VisibleName name="local:TBitSingleByte.Bit3">Bit3</VisibleName>
      </Component>
      <Component identifier="Bit4" type="std:BOOL">
        <Default />
        <VisibleName name="local:TBitSingleByte.Bit4">Bit4</VisibleName>
      </Component>
      <Component identifier="Bit5" type="std:BOOL">
        <Default />
        <VisibleName name="local:TBitSingleByte.Bit5">Bit5</VisibleName>
      </Component>
      <Component identifier="Bit6" type="std:BOOL">
        <Default />
        <VisibleName name="local:TBitSingleByte.Bit6">Bit6</VisibleName>
      </Component>
      <Component identifier="Bit7" type="std:BOOL">
        <Default />
        <VisibleName name="local:TBitSingleByte.Bit7">Bit7</VisibleName>
      </Component>
    </BitfieldType>
    <StructType name="MvbPort_32Byte">
     ........姝ゅ鐪佺暐鍏蜂綋鍙橀噺
    </StructType>
        </Types>
        <Device>
                <DeviceIdentification>
                        <!-- The information of this section is used for management in the device repository. It is not downloaded -->
                        <!-- Range 0-32767 managed by 3S ? Smart Software Solutions; Range 32768 ? end can be used by customer -->
                        <Type>32768</Type>
                        <!-- Id is a unsigned long in hex formnat. First part (unsigned short) of Id is vendor id. 0001 is reserved for template devices. Must be replaced with your vendor id! Second part is vendor specific. -->
                        <Id>0002 0001</Id>
                        <!-- Format has to be 1.2.3.4 -->
                        <Version>1.0.0.0</Version>
                </DeviceIdentification>
                <DeviceInfo>
                        <Name name="local:SubModelName">C104_DLDQ_MVB</Name>
                        <Description name="localeviceDescription">C104 DLDQ MVB</Description>
                        <Vendor name="local:VendorName">Demo Corporation</Vendor>
                        <OrderNumber>0001</OrderNumber>
                </DeviceInfo>
                <!-- Child connector. The moduleType of the connector is evaluated by the IO driver. The interface must be of the same name as in the parent connector -->
                <Connector moduleType="32768" interface="Common.PCI" role="child" explicit="false" connectorId="1" hostpath="-1">
                        <Slot count="1" allowEmpty="false"></Slot>
                </Connector>
                <!-- Parent connector. The moduleType is downloaded and can be evaluated by the IO driver, e.g. with CAL_IoMgrConfigGetFirstConnector .
                      The interface must be of the same name as in the child connector of the submodules-->
                <Connector moduleType="32769" interface="local.myInternalModuleConnector" role="parent" explicit="false" connectorId="2" hostpath="1">
                        <!-- The interface name is used in for the tabs shown in CoDeSys (for example I/O mapping).  The given name is used as a prefix to the specific tab page. -->
                        <InterfaceName name="local:myInternalModuleConnector">Internal</InterfaceName>
                        <DriverInfo needsBusCycle="true"></DriverInfo>
                        <HostParameterSet>
                                <!-- IN  ParameterId -->
                                <arameter ParameterId="1000" type="local:MvbPort_32Byte">
                                  <Attributes channel="input" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="local:in0">Mvb_0x100</Name>
                                </Parameter>
                                <arameter ParameterId="1001" type="local:MvbPort_32Byte">
                                  <Attributes channel="input" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="local:in1">Mvb_0x101</Name>
                                 </Parameter>
                                <arameter ParameterId="1002" type="local:MvbPort_32Byte">
                                  <Attributes channel="input" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="local:in2">Mvb_0x102</Name>
                                </Parameter>
                                <arameter ParameterId="1003" type="local:MvbPort_32Byte">
                                  <Attributes channel="input" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="local:in3">Mvb_0x103</Name>
                                 </Parameter>
                                <arameter ParameterId="1004" type="local:MvbPort_32Byte">
                                  <Attributes channel="input" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="local:in4">Mvb_0x104</Name>
                                 </Parameter>
                                 <!-- OUT  ParameterId -->
                                <arameter ParameterId="2000" type="local:MvbPort_32Byte">
                                  <Attributes channel="output" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="localut0">Mvb_0x001</Name>
                                </Parameter>
                                <arameter ParameterId="2001" type="local:MvbPort_32Byte">
                                  <Attributes channel="output" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="localut1">Mvb_0x002</Name>
                                </Parameter>
                                <arameter ParameterId="2002" type="local:MvbPort_32Byte">
                                  <Attributes channel="output" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="localut2">Mvb_0x003</Name>
                                </Parameter>
                                <Parameter ParameterId="2003" type="local:MvbPort_32Byte">
                                  <Attributes channel="output" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="localut3">Mvb_0x004</Name>
                                </Parameter>         
                                <Parameter ParameterId="2004" type="local:MvbPort_32Byte">
                                  <Attributes channel="output" download="true" functional="false" offlineaccess="readwrite" />
                                  <Default>0</Default>
                                  <Name name="localut4">Mvb_0x005</Name>
                                </Parameter>                                 
                        </HostParameterSet>
                </Connector>
        </Device>
</DeviceDescription>



XML鏂囦欢鍙互瀹夎鍒癈odesys涓婁綔涓轰竴涓澶囦娇鐢紝鍜屽伐绋嬩腑鐨勫彉閲忓仛涓浜涙槧灏勫叧绯伙紝濡備笅鍥炬墍绀猴細



2.IODrv缂撳啿鍖烘暟鎹洿鏂

鍥犱负Codesys鎻愪緵浜嗗畬鏁寸殑I/O鏄犲皠浠g爜妗嗘灦锛屾垜浠彧闇瑕佹洿鏀笽oDrvStartBusCycle鎺ュ彛涓殑浠g爜鍗冲彲锛屽涓嬩唬鐮佹墍绀轰负鐩墠椤圭洰涓殑鏁版嵁鏇存柊鎺ュ彛锛屽皢MVB婧愮鍙e拰瀹跨鍙f暟鎹氳繃input鍜宱utput缂撳啿鍖哄拰Codesys涓婂眰I/O鏄犲皠鍏宠仈璧锋潵锛岄傚悎涓嶅悓瀹㈡埛鐨勯」鐩紑鍙戯紝涔熸柟渚跨敤鎴峰涓婂眰閫氫俊鐩稿叧閫昏緫搴旂敤鐨勭紪鍐欍

[C] 绾枃鏈煡鐪 澶嶅埗浠g爜
STATICITF RTS_RESULT CDECL IoDrvStartBusCycle(RTS_HANDLE hIoDrv, IoConfigConnector *pConnector)
{
        int i = 0;
        int j = 0;
       
        if (pConnector->wType != 32769)
                return ERR_OK;
       
        if (head._sourcePortNum == 0 && head._sinkPortNum == 0)
        {
                return ERR_OK;
        }
        /* Our dummy driver: Copy outputs to inputs. Remove this code in your real driver */
        //        for (i=0; i< MAX_CHANNELS; i++)
        //        {
        //                memcpy(&s_uInputs, &s_uOutputs, sizeof(InOutInfo));
        //        }
       
        for (i = 0; i < head._sourcePortNum; i++)
        {
                memcpy(&(head._sourcePortList->_portInfo._portData[0]), &s_uOutputs, sizeof(InOutInfo));
        }
       
        for (j = 0; j < head._sinkPortNum; j++)
        {
                memcpy(&s_uInputs[j], &(head._sinkPortList[j]->_portInfo._portData[0]), sizeof(InOutInfo));
        }
        return IoDrvGetModuleDiagnosis(hIoDrv, pConnector);
}



鎬荤粨

浠ヤ笂灏辨槸浠婂ぉ瑕佽鐨勫叧浜嶤odesys鐨処ODrv鐩稿叧鍐呭锛屾湰鏂囦粎浠呯畝鍗曚粙缁嶄簡椤圭洰涓娇鐢↖ODrv鐨勮繃绋嬶紝IODrv璇︾粏鐨勫彲浠ユ煡闃匔odesys瀹樻柟璧勬枡锛屾湰鏂囦粎浣滀负涓涓棩甯歌褰曘


Codesys浣跨敤璁板綍-1.png
椤堕儴qrcode搴曢儴
鍏虫敞閰峰痉缃戣闃呭彿锛岃幏鍙栨洿澶氳祫璁紒

QQ|Archiver|鎵嬫満鐗|灏忛粦灞|閰峰痉璁哄潧 ( 鑻廔CP澶16065247鍙-1 )|缃戠珯鍦板浘

GMT+8, 2026-4-1 03:57 , Processed in 0.086410 second(s), 22 queries .

閰峰痉缃

© 2001-2013 Hicodesys. 鎶鏈敮鎸 by 閰峰痉缃

杩斿洖椤堕儴