motorcontroldemo_028/Vsrc/mbod.c
2019-07-29 08:18:57 +03:00

80 lines
3.0 KiB
C

/*!
Copyright 2017 ÀÎ "ÍÈÈÝÒ" è ÎÎÎ "ÍÏÔ ÂÅÊÒÎÐ"
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\file mbod.c
\brief Ñëîâàðü îáúåêòîâ MODBUS
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
\version v 2.0 25/03/2017
*/
/** \addtogroup MODBUS */
/*@{*/
#include "mbod.h"
#include "main.h"
/* Òåñòîâûå ïîñûëêè
* Ôîðìàò áàéò â ïîñûëêå:
* Íîìåð óçëà 1 áàéò, ôóíêöèÿ 1 áàéò, àäðåñ 2 áàéòà, äàííûå/êîë-âî ïåðåìåííûõ 2 áàéòà, êîíòðîëüíàÿ ñóììà CRC16(LH)
* Óäîáíî òåñòèðîâàòü, íàïðèìåð, ïðîãðàììîé COMpump
*
01 06 07 D0 00 01 48 87 - çàïóñòèòü ïðèâîä (çàïèñü â 2000 çíà÷åíèÿ 1)
01 06 07 D1 00 64 D9 6C - çàäàòü ÷àñòîòó âðàùåíèÿ (2001) ðàâíîé 100 îá/ìèí
01 06 A8 6C 00 64 68 5C - çàäàòü çàùèòó ïî íàïðÿæåíèþ Udc ðàâíîé 100Â
01 03 9C 42 00 01 0A 4E - çàïðîñ òåêóùåé ÷àñòîòû âðàùåíèÿ
01 03 9C 76 00 01 4B 80 - çàïðîñ êîäîâ àâàðèé
 ìàññèâàõ:
mbodHR - ïåðåìåííûå Holding Registers (íà ÷òåíèå è çàïèñü). Êîä ôóíêöèè 0x03(íà ÷òåíèå) 0x06(íà çàïèñü)
mbodIR - ïåðåìåííûå Input Registers (íà ÷òåíèå). Êîä ôóíêöèè 0x04
mbodC - áèòîâûå ïåðåìåííûå Coil (äëÿ çàïèñè). Êîä ôóíêöèè 0x05(íà çàïèñü)
mbodDI - áèòîâûå ïåðåìåííûå Discrete Inputs (äëÿ ÷òåíèÿ). Êîä ôóíêöèè 0x02(íà ÷òåíèå)
Ïåðâàÿ öèôðà ìàññèâà - àäðåñ ïåðåìåííîé â ñëîâàðå ModBus.
Âòîðàÿ - íîìåð áèòà äëÿ áèòîâûõ ïåðåìåííûõ â ïåðåìåííîé êîíòðîëëåðà.
Òðåòüÿ - àäðåñ ïåðåìåííîé.
*/
volatile MB_Record mbodHR[] = {\
2000, 0,(long)(&MBVarsConv.Vars.Command),/*Ñëîâî óïðàâëåíèÿ. 0é áèò - ïóñê, 1é áèò - ñòîï, 2é áèò - ñáðîñ àâàðèè */\
2001, 0,(long)(&MBVarsConv.Vars.speed_ref), /*Çàäàíèå ÷àñòîòû âðàùåíèÿ â îá/ìèí*/\
40002, 0,(long)(&MBVarsConv.Vars.CurSpeed),/* Òåêóùàÿ ÷àñòîòà âðàùåíèÿ (îá/ìèí) */\
40007, 0,(long)(&MBVarsConv.Vars.CurIs),/*Òîê ñòàòîðà àìïëèòóäíûé (À)*/\
40054, 0,(long)(&MBVarsConv.Vars.Main_ErrorCode),/*Êîä àâàðèè (ñìåíÿåòñÿ, åñëè àâàðèé íåñêîëüêî)*/\
43116, 0,(long)(&MBVarsConv.Vars.Umax_protect),/*Óñòàâêà ìàêñ. íàïðÿæ ÇÏÒ*/\
0,0,0 // êîíåö ìàññèâà, íå óäàëÿòü - ïî íóëÿì îïðåäåëÿòåñÿ ðàçìåð ñëîâàðÿ.
};
volatile MB_Record mbodIR[] = {\
0,0,0 // êîíåö ìàññèâà, íå óäàëÿòü - ïî íóëÿì îïðåäåëÿòåñÿ ðàçìåð ñëîâàðÿ.
};
volatile MB_Record mbodC[] = {\
0,0,0 // êîíåö ìàññèâà, íå óäàëÿòü - ïî íóëÿì îïðåäåëÿòåñÿ ðàçìåð ñëîâàðÿ.
};
volatile MB_Record mbodDI[] = {0,0,0 // êîíåö ìàññèâà, íå óäàëÿòü - ïî íóëÿì îïðåäåëÿòåñÿ ðàçìåð ñëîâàðÿ.
};
/*@}*/