Удалено лишнее: несипользуемые типы аппаратных частей, файлы и прочее. Добавлены объекты ModBus в словарь объектов CAN.
This commit is contained in:
parent
010df1c0a4
commit
ed9cf392dd
@ -1,140 +0,0 @@
|
||||
/*!
|
||||
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 DRV8301_SPI.h
|
||||
\brief Äðàéâåð äëÿ äðàéâåðà êëþ÷åé èíâåðòîðà DRV8301
|
||||
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
|
||||
\version v 2.0 25/03/2016
|
||||
|
||||
*/
|
||||
|
||||
#ifndef DRV8301_INTERFACE_H
|
||||
#define DRV8301_INTERFACE_H
|
||||
|
||||
|
||||
// DRV8301 SPI Input Data bit definitions:
|
||||
struct DRV8301_SPI_WRITE_WORD_BITS { // bit description
|
||||
Uint16 DATA:11; // 10:0 FIFO reset
|
||||
Uint16 ADDRESS:4; // 14:11 Enhancement enable
|
||||
Uint16 R_W:1; // 15 R/W
|
||||
};
|
||||
|
||||
union DRV8301_SPI_WRITE_WORD_REG {
|
||||
Uint16 all;
|
||||
struct DRV8301_SPI_WRITE_WORD_BITS bit;
|
||||
};
|
||||
|
||||
// DRV8301 SPI Status Reister 1 bit definitions:
|
||||
struct DRV8301_STATUS_REG_1_BITS { // bit description
|
||||
Uint16 FETLC_OC:1; // 0 Phase C, low-side FET OC
|
||||
Uint16 FETHC_OC:1; // 1 Phase C, high-side FET OC
|
||||
Uint16 FETLB_OC:1; // 2 Phase B, low-side FET OC
|
||||
Uint16 FETHB_OC:1; // 3 Phase B, high-side FET OC
|
||||
Uint16 FETLA_OC:1; // 4 Phase A, low-side FET OC
|
||||
Uint16 FETHA_OC:1; // 5 Phase A, high-side FET OC
|
||||
Uint16 OTW:1; // 6 Over-temperature warning
|
||||
Uint16 OTSD:1; // 7 Over-temperature shut down
|
||||
Uint16 PVDD_UV:1; // 8 PVDD < 6V
|
||||
Uint16 GVDD_UV:1; // 9 GVDD < 8V
|
||||
Uint16 FAULT:1; // 10 FAULTn pin is asserted
|
||||
Uint16 Reserved:5; // 15:11
|
||||
};
|
||||
|
||||
union DRV8301_STATUS_REG_1 {
|
||||
Uint16 all;
|
||||
struct DRV8301_STATUS_REG_1_BITS bit;
|
||||
};
|
||||
|
||||
// DRV8301 SPI Status Reister 2 bit definitions:
|
||||
struct DRV8301_STATUS_REG_2_BITS { // bit description
|
||||
Uint16 DEVICE_ID:4; // 3:0 Device ID
|
||||
Uint16 Reserved1:3; // 6:4
|
||||
Uint16 GVDD_OV:1; // 7 GVDD > 16V
|
||||
Uint16 Reserved2:8; // 15:8
|
||||
};
|
||||
|
||||
union DRV8301_STATUS_REG_2 {
|
||||
Uint16 all;
|
||||
struct DRV8301_STATUS_REG_2_BITS bit;
|
||||
};
|
||||
|
||||
// DRV8301 SPI Control Reister 1 bit definitions:
|
||||
struct DRV8301_CONTROL_REG_1_BITS { // bit description
|
||||
Uint16 GATE_CURRENT:2; // 1:0 Gate driver peak current, 1.7A (00b), 0.7A (01b), 0.25A (10b), Reserved (11b)
|
||||
Uint16 GATE_RESET:1; // 2 Reset all latched faults (1), Normal Mode (0)
|
||||
Uint16 PWM_MODE:1; // 3 Three (1) or six (0) pwm inputs
|
||||
Uint16 OC_MODE:2; // 5:4 over-current mode, current limit (00b), latched shut down (01b), Report only (10b), OC disabled (11b)
|
||||
Uint16 OC_ADJ_SET:5; // 10:6 Set Vds trip point for OC see the table in the datasheet
|
||||
Uint16 Reserved:5; // 15:11
|
||||
};
|
||||
|
||||
union DRV8301_CONTROL_REG_1 {
|
||||
Uint16 all;
|
||||
struct DRV8301_CONTROL_REG_1_BITS bit;
|
||||
};
|
||||
|
||||
// DRV8301 SPI Control Reister 2 bit definitions:
|
||||
struct DRV8301_CONTROL_REG_2_BITS { // bit description
|
||||
Uint16 OCTW_SET:2; // 1:0 Report OT and OC (00b), Report OT (01b), Report OC (10b), Reserved (11b)
|
||||
Uint16 GAIN:2; // 3:2 Gain of shunt amplifier, 10 (00b), 20 (01b), 40 (10b), 80 (11b)
|
||||
Uint16 DC_CAL_CH1:1; // 4 Shunt amplifier inputs shorted and disconnected from load (1) or shunt amplifier inputs connected to load (0)
|
||||
Uint16 DC_CAL_CH2:1; // 5 Shunt amplifier inputs shorted and disconnected from load (1) or shunt amplifier inputs connected to load (0)
|
||||
Uint16 OC_TOFF:1; // 6 Normal CBC operation (0), off time control during OC (1)
|
||||
Uint16 Reserved:9; // 15:7
|
||||
};
|
||||
|
||||
union DRV8301_CONTROL_REG_2 {
|
||||
Uint16 all;
|
||||
struct DRV8301_CONTROL_REG_2_BITS bit;
|
||||
};
|
||||
|
||||
struct Sdrv8301interface {
|
||||
union DRV8301_CONTROL_REG_1 CTRL1;
|
||||
union DRV8301_CONTROL_REG_2 CTRL2;
|
||||
union DRV8301_STATUS_REG_1 STS1;
|
||||
union DRV8301_STATUS_REG_2 STS2;
|
||||
union DRV8301_SPI_WRITE_WORD_REG writeWord;
|
||||
void (*init)(volatile struct Sdrv8301interface*);
|
||||
void (*write)(volatile struct Sdrv8301interface*, Uint16);
|
||||
void (*read)(volatile struct Sdrv8301interface*);
|
||||
};
|
||||
|
||||
typedef volatile struct Sdrv8301interface Tdrv8301interface;
|
||||
/***************************************************************************************************/
|
||||
//defines
|
||||
/***************************************************************************************************/
|
||||
//DRV8301 Register Addresses
|
||||
#define STAT_REG_1_ADDR 0x00
|
||||
#define STAT_REG_2_ADDR 0x01
|
||||
#define CNTRL_REG_1_ADDR 0x02
|
||||
#define CNTRL_REG_2_ADDR 0x03
|
||||
|
||||
#define DRV8301_INTERFACE_DEFAULTS {0,0,0,0,0,\
|
||||
DRV8301_Interface_Init,\
|
||||
DRV8301_Interface_Write,\
|
||||
DRV8301_Interface_Read}
|
||||
|
||||
/***************************************************************************************************/
|
||||
//function prototypes
|
||||
/***************************************************************************************************/
|
||||
//void DRV8301_SPI_Init(volatile struct SPI_REGS *s);
|
||||
//Uint16 DRV8301_SPI_Read(volatile struct SPI_REGS *s, Uint16 address);
|
||||
//Uint16 DRV8301_SPI_Write(volatile struct SPI_REGS *s, Uint16 address, Uint16 data);
|
||||
|
||||
void DRV8301_Interface_Init (Tdrv8301interface*);
|
||||
void DRV8301_Interface_Write (Tdrv8301interface*, Uint16);
|
||||
void DRV8301_Interface_Read (Tdrv8301interface*);
|
||||
|
||||
#endif
|
@ -39,25 +39,17 @@ extern "C"
|
||||
//! Состояние РАБОТА
|
||||
#define CMD_LOGIC_TURNED_ON 0x2
|
||||
|
||||
#if defined (HW_VECTORCARD_DRV8301_EVM) || defined (HW_VECTORCARD_DRV8312_EVM)
|
||||
#define STARTBUTTON ((NT_GPIOA->DATA & (1 << 14))==0) //îáðàáîòêà íîæêè ñòàðòà
|
||||
#define STOPBUTTON ((NT_GPIOA->DATA & (1 << 13))==0) //îáðàáîòêà íîæêè ñòîïà
|
||||
#define RESETBUTTON 0
|
||||
#endif
|
||||
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
#if defined (HW_MCB3)
|
||||
//Для управления контроллером мы используем внешние дискретные входы с использованием фильтрации (см. V_DIO)
|
||||
#define STARTBUTTON (BIT_IS_SET(input_vect, 0) ? 1 : 0) //Ïðîâåðêà íà óñòàâêó áèòà â âåêòîðå äèñêðåòíûõ âõîäîâ
|
||||
#define STOPBUTTON (BIT_IS_SET(input_vect, 1) ? 1 : 0) //Ïðîâåðêà íà óñòàâêó áèòà â âåêòîðå äèñêðåòíûõ âõîäîâ
|
||||
#define RESETBUTTON (BIT_IS_SET(input_vect, 2) ? 1 : 0) //Ïðîâåðêà íà óñòàâêó áèòà â âåêòîðå äèñêðåòíûõ âõîäîâ
|
||||
|
||||
#define STARTBUTTON (BIT_IS_SET(input_vect, 0) ? 1 : 0) //Ïðîâåðêà íà óñòàâêó áèòà â âåêòîðå äèñêðåòíûõ âõîäîâ
|
||||
#define STOPBUTTON (BIT_IS_SET(input_vect, 1) ? 1 : 0) //Ïðîâåðêà íà óñòàâêó áèòà â âåêòîðå äèñêðåòíûõ âõîäîâ
|
||||
#define RESETBUTTON (BIT_IS_SET(input_vect, 2) ? 1 : 0) //Ïðîâåðêà íà óñòàâêó áèòà â âåêòîðå äèñêðåòíûõ âõîäîâ
|
||||
#elif defined (HW_MCB3_SIMULATOR)
|
||||
#define STARTBUTTON 0
|
||||
#define STOPBUTTON 0
|
||||
#define RESETBUTTON 0
|
||||
#endif
|
||||
|
||||
#if !defined (HW_MOTORCONTROLBOARD) && !defined (HW_VECTORCARD_DRV8301_EVM) && !defined (HW_VECTORCARD_DRV8312_EVM)
|
||||
#define STARTBUTTON 0
|
||||
#define STOPBUTTON 0
|
||||
#define RESETBUTTON 0
|
||||
#endif
|
||||
|
||||
/*! \class TSM_CmdLogic
|
||||
\brief Обработка команд и заданий, поступающих из различных источников.
|
||||
|
@ -38,31 +38,23 @@ extern "C"
|
||||
//! Модуль защит в состоянии аварии (сработала защита)
|
||||
#define PROT_FAIL 2
|
||||
|
||||
//Ìàêðîñ ïðèåìà (åñëè íîëü, òî àâàðèÿ) è ñáðîñà (åñëè 1, òî ñáðîñ) àïïàðàòíîé àâàðèè
|
||||
#if defined HW_VECTOR_MK_40_4
|
||||
#define DRV_FAULT (NT_GPIOA->DATA & (1 << 8))
|
||||
#define RESET_FAULT_BUTTON 0 //êíîïêà ñáðîñà àâàðèé íå ïðåäóñìîòðåíà
|
||||
#endif
|
||||
|
||||
#if defined (HW_VECTORCARD_DRV8301_EVM) || defined(HW_VECTORCARD_DRV8312_EVM)
|
||||
#define DRV_FAULT (NT_GPIOC->DATA & (1 << 4))
|
||||
#define RESET_FAULT_BUTTON 0 //êíîïêà ñáðîñà àâàðèé íå ïðåäóñìîòðåíà
|
||||
#endif
|
||||
|
||||
#if defined (HW_VECTORCARD_SIMULATOR) || defined(HW_NIIET_BOARD_SIMULATOR)
|
||||
#define DRV_FAULT 0 //àâàðèé êëþ÷à â ñèìóëÿòîðå íå ïðåäóñìîòðåíî
|
||||
#define RESET_FAULT_BUTTON 0 //êíîïêà ñáðîñà àâàðèé íå ïðåäóñìîòðåíà
|
||||
#endif
|
||||
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
#define DRV_FAULT (GPIOB->DATA & (1 << 3)) //Ïðèåì îáùåé àâàðèè
|
||||
#define DRV_FAULT1 (GPIOB->DATA & (1 << 4)) //Àâàðèÿ êëþ÷à A0
|
||||
#define DRV_FAULT2 (GPIOB->DATA & (1 << 5)) //Àâàðèÿ êëþ÷à A1
|
||||
#define DRV_FAULT3 (GPIOD->DATA & (1 << 4)) //Àâàðèÿ êëþ÷à A2
|
||||
#define DRV_FAULT4 (GPIOD->DATA & (1 << 5)) //Àâàðèÿ êëþ÷à B0 èëè B1 èëè B2
|
||||
|
||||
//Ìàêðîñû ïðèåìà (åñëè íîëü, òî àâàðèÿ) è ñáðîñà (åñëè 1, òî ñáðîñ) àïïàðàòíûõ àâàðèé
|
||||
#if defined (HW_MCB3)
|
||||
#define DRV_FAULT (GPIOB->DATA & (1 << 3)) //Ïðèåì îáùåé àâàðèè
|
||||
#define DRV_FAULT1 (GPIOB->DATA & (1 << 4)) //Àâàðèÿ êëþ÷à A0
|
||||
#define DRV_FAULT2 (GPIOB->DATA & (1 << 5)) //Àâàðèÿ êëþ÷à A1
|
||||
#define DRV_FAULT3 (GPIOD->DATA & (1 << 4)) //Àâàðèÿ êëþ÷à A2
|
||||
#define DRV_FAULT4 (GPIOD->DATA & (1 << 5)) //Àâàðèÿ êëþ÷à B0 èëè B1 èëè B2
|
||||
//Для сброса аппаратной аварии в данном контроллере используеется внешний дискретный порт ввода
|
||||
#define RESET_FAULT_BUTTON (BIT_IS_SET(input_vect, 2) ? 1 : 0) //Если установлен 3-й бит в векторе дискретных входов
|
||||
#elif defined (HW_MCB3_SIMULATOR)
|
||||
#define DRV_FAULT 0
|
||||
#define DRV_FAULT1 0
|
||||
#define DRV_FAULT2 0
|
||||
#define DRV_FAULT3 0
|
||||
#define DRV_FAULT4 0
|
||||
#define RESET_FAULT_BUTTON 0
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ extern "C" {
|
||||
|
||||
|
||||
// Äåôàéíèì äèñêðåòíûå âõîäû
|
||||
#ifdef HW_MOTORCONTROLBOARD
|
||||
#ifdef HW_MCB3
|
||||
//TODO ïåðåäåëàòü
|
||||
#define D_IN1 ((GPIOM->DATA & (1 << 13)) == 0) //M13 Ñòàðò
|
||||
#define D_IN2 ((GPIOM->DATA & (1 << 11)) == 0) //M11 Ñòîï
|
||||
@ -64,7 +64,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Äåôàéíèì äèñêðåòíûå âûõîäû
|
||||
#ifdef HW_MOTORCONTROLBOARD
|
||||
#ifdef HW_MCB3
|
||||
#define D_OUT1_ON GPIOD->DATAOUTSET = GPIO_PIN_1
|
||||
#define D_OUT1_OFF GPIOD->DATAOUTCLR = GPIO_PIN_1
|
||||
#define D_OUT2_ON GPIOD->DATAOUTSET = GPIO_PIN_2
|
||||
|
@ -34,17 +34,8 @@
|
||||
#define FAN_CONTROL_STATE_OVERHEAT 2
|
||||
|
||||
/* Âêëþ÷åíèå è âûêëþ÷åíèå âåíòèëÿòîðà */
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
|
||||
#define FAN_ON GPIOB->DATAOUTSET = GPIO_PIN_13
|
||||
#define FAN_OFF GPIOB->DATAOUTCLR = GPIO_PIN_13
|
||||
#endif
|
||||
|
||||
#if !defined (HW_MOTORCONTROLBOARD)
|
||||
/* Äåôàéíû äëÿ äðóãèõ êîíòðîëëåðîâ */
|
||||
#define FAN_ON
|
||||
#define FAN_OFF
|
||||
#endif
|
||||
|
||||
|
||||
struct SFanControl{
|
||||
|
@ -40,13 +40,8 @@ extern "C" {
|
||||
//! ñîñòîÿíèå âêëþ÷åíî
|
||||
#define UD_CONTROL_STATE_ON 2
|
||||
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
#define UD_CONTROL_OFF GPIOB->DATAOUTCLR = GPIO_PIN_14;
|
||||
#define UD_CONTROL_ON GPIOB->DATAOUTSET = GPIO_PIN_14;
|
||||
#else
|
||||
#define UD_CONTROL_OFF // îïåðàöèÿ äëÿ âûêëþ÷åíèÿ
|
||||
#define UD_CONTROL_ON // îïåðàöèÿ äëÿ âêëþ÷åíèÿ
|
||||
#endif
|
||||
#define UD_CONTROL_OFF GPIOB->DATAOUTCLR = GPIO_PIN_14;
|
||||
#define UD_CONTROL_ON GPIOB->DATAOUTSET = GPIO_PIN_14;
|
||||
|
||||
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
/*!
|
||||
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 V_usblib.c
|
||||
\brief Íàáîð ôóíêöèé äëÿ èíèöèàëèçàöèè äðàéâåðà USB. Îñíîâàí íà ïðèìåðå
|
||||
USB VCP" îò ÍÈÈÝÒ:
|
||||
https://bitbucket.org/niietcm4/
|
||||
---> / chip / K1921VK01T / GCC / USB / CDC_VCP /
|
||||
|
||||
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru, ÍÈÈÝÒ http://niiet.ru
|
||||
\version v 1.0 08/08/2017
|
||||
|
||||
*/
|
||||
|
||||
#ifndef VINCLUDE_V_USBLIB_H_
|
||||
#define VINCLUDE_V_USBLIB_H_
|
||||
|
||||
int USB_init_hardware(void);
|
||||
void USB_enable_peripheral (void);
|
||||
void SystemInit (void);
|
||||
|
||||
extern Uint8 usbActiveFlag;
|
||||
#endif /* VINCLUDE_V_USBLIB_H_ */
|
@ -22,35 +22,18 @@
|
||||
@{
|
||||
*/
|
||||
|
||||
|
||||
//Выбор типа аппаратной части
|
||||
|
||||
//VectorCARD ñ îòëàäî÷íûì êîìïëåêòîì DRV8301
|
||||
//#define HW_VECTORCARD_DRV8301_EVM
|
||||
|
||||
//VectorCARD ñ îòëàäî÷íûì êîìïëåêòîì DRV8312
|
||||
//#define HW_VECTORCARD_DRV8312_EVM
|
||||
|
||||
//VectorCARD ñ èìèòàöèîííûìè ìîäåëÿìè äâèãàòåëåé
|
||||
//#define HW_VECTORCARD_SIMULATOR
|
||||
|
||||
//Îòëàäî÷íàÿ ïëàòà ÍÈÈÝÒ ñ èìèòàöèîííûìè ìîäåëÿìè äâèãàòåëåé
|
||||
//#define HW_NIIET_BOARD_SIMULATOR
|
||||
|
||||
//Êîíòðîëëåð ÌÊ40.4 ÍÏÔ ÂÅÊÒÎÐ
|
||||
//#define HW_VECTOR_MK_40_4
|
||||
|
||||
//Êîíòðîëëåð Motor Control Board
|
||||
#define HW_MOTORCONTROLBOARD
|
||||
//Êîíòðîëëåð MCB3 ñ ðåôåðåíñíûì ñèëîâûì ïðåîáðàçîâàòåëåì
|
||||
#define HW_MCB3
|
||||
|
||||
//Êîíòðîëëåð MCB3 ñ èìèòàöèîííûìè ìîäåëÿìè äâèãàòåëåé
|
||||
//#define HW_MCB3_SIMULATOR
|
||||
|
||||
//Для UART, выбирается чем его занять - MODBUS или CANtoRS драйвером
|
||||
//#define MODBUS_ENA
|
||||
#define CANTORS_ENA
|
||||
|
||||
// Òàêæå ìîæíî çàäåéñòâîâàòü USB äëÿ CANopen
|
||||
//#define CANTOUSB_ENA
|
||||
|
||||
//Выбор типа тригонометрических операций для преобразований Park и iPark - аппаратно через блок TMU или программно с помощью библиотеки IQMath
|
||||
#define PARK_IPARK_TMU
|
||||
//#define PARK_IPARK_IQMATH
|
||||
@ -143,8 +126,7 @@
|
||||
|
||||
|
||||
|
||||
#if (!defined(HW_VECTORCARD_DRV8301_EVM)) && (!defined(HW_VECTORCARD_DRV8312_EVM)) && (!defined(HW_VECTORCARD_SIMULATOR))\
|
||||
&& (!defined(HW_NIIET_BOARD_SIMULATOR)) && (!defined(HW_VECTOR_MK_40_4)) && (!defined(HW_MOTORCONTROLBOARD))
|
||||
#if (!defined(HW_MCB3)) && (!defined(HW_MCB3_SIMULATOR))
|
||||
#error необходимо определить хотя бы одну версию аппаратной части
|
||||
#endif
|
||||
|
||||
|
@ -62,7 +62,6 @@ extern "C" {
|
||||
#include "V_DPR_eCAP.h"
|
||||
#include "V_QEP.h"
|
||||
#include "V_led.h"
|
||||
#include "DRV8301_SPI.h"
|
||||
#include "V_AutoOffset.h"
|
||||
#include "V_CANtoRS.h"
|
||||
#include "V_SSI_Encoder.h"
|
||||
@ -73,6 +72,7 @@ extern "C" {
|
||||
#include "V_ModBus.h"
|
||||
#include "V_MBVarsConv.h"
|
||||
#include "V_excitation.h"
|
||||
#include "CANOpen_drv.h"
|
||||
#include "X_CANFlashProgData.h"
|
||||
#include "X_CANFlashProgStarter.h"
|
||||
#include "CANBlockTransferInterface.h"
|
||||
@ -171,7 +171,6 @@ extern TSysSwitches sw;
|
||||
|
||||
extern TUserMemory UserMem;
|
||||
extern Tled leds;
|
||||
extern Tdrv8301interface drv8301;
|
||||
extern TCanBTInterface Can1BTInterface;
|
||||
extern TCanBTInterface Can2BTInterface;
|
||||
extern TCANSpeedTableOptions canSpeedTable;
|
||||
|
@ -20,9 +20,6 @@
|
||||
\version v 1.0 2017_02_08
|
||||
|
||||
//=====================================================================================*/
|
||||
#include "DSP.h"
|
||||
#include "co_ODvars.h"
|
||||
#include "CANOpen_drv.h"
|
||||
#include "main.h"
|
||||
|
||||
//! Òàáëèöà ñ íàñòðîéêàìè ñêîðîñòåé CAN äëÿ ìèêðîêîíòðîëëåðîâ ôèðìû ÍÈÈÝÒ. Ðàñêîììåíòèòü íóæíîå.
|
||||
@ -66,19 +63,7 @@ TCANSpeedTableOptions canSpeedTable = { {1, 1, 1, 0, 0,
|
||||
#ifdef CAN_1_ENABLE
|
||||
void co_CAN1GpioInit()
|
||||
{
|
||||
#ifdef HW_MOTORCONTROLBOARD
|
||||
// CAN0: C12 / C13
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN12 = 1; // CAN0_TX
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN13 = 1; // CAN0_RX
|
||||
GPIOC->ALTFUNCSET = GPIO_PIN_12 | GPIO_PIN_13;
|
||||
#endif
|
||||
|
||||
#ifdef HW_VECTORCARD_SIMULATOR
|
||||
// CAN0: C12 / C13
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN12 = 1; // CAN0_TX
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN13 = 1; // CAN0_RX
|
||||
GPIOC->ALTFUNCSET = GPIO_PIN_12 | GPIO_PIN_13;
|
||||
#endif
|
||||
//инициализация ножек в GpioPeripheralInit.c
|
||||
}
|
||||
#endif //CAN_1_ENABLE
|
||||
|
||||
@ -86,19 +71,7 @@ void co_CAN1GpioInit()
|
||||
#ifdef CAN_2_ENABLE
|
||||
void co_CAN2GpioInit()
|
||||
{
|
||||
#ifdef HW_MOTORCONTROLBOARD
|
||||
// CAN1: C14 / C15
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN14 = 1; // CAN0_TX
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN15 = 1; // CAN0_RX
|
||||
GPIOC->ALTFUNCSET = GPIO_PIN_14 | GPIO_PIN_15;
|
||||
#endif
|
||||
|
||||
#ifdef HW_VECTORCARD_SIMULATOR
|
||||
// CAN1: C14 / C15
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN14 = 1; // CAN0_TX
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN15 = 1; // CAN0_RX
|
||||
GPIOC->ALTFUNCSET = GPIO_PIN_14 | GPIO_PIN_15;
|
||||
#endif
|
||||
//инициализация ножек в GpioPeripheralInit.c
|
||||
}
|
||||
#endif //CAN_2_ENABLE
|
||||
//**********************************************************************************************************************************************************************************************************
|
||||
|
@ -1,195 +0,0 @@
|
||||
/*!
|
||||
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 DRV8301_SPI.c
|
||||
\brief Äðàéâåð äëÿ äðàéâåðà êëþ÷åé èíâåðòîðà DRV8301
|
||||
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
|
||||
\version v 2.0 25/03/2016
|
||||
\addtogroup drv8301interface
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "DSP.h"
|
||||
#include "main.h"
|
||||
|
||||
void DRV8301_Interface_Init(Tdrv8301interface*p) {
|
||||
#ifdef HW_VECTORCARD_DRV8301_EVM
|
||||
volatile long delay;
|
||||
volatile Uint32 tempREG;
|
||||
|
||||
// Íàñòðîéêà íîã SPI
|
||||
NT_GPIOC->ALTFUNCSET = (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11);
|
||||
NT_COMMON_REG->GPIOPCTLC_bit.PIN8 = 1;
|
||||
NT_COMMON_REG->GPIOPCTLC_bit.PIN9 = 1;
|
||||
NT_COMMON_REG->GPIOPCTLC_bit.PIN10 = 1;
|
||||
NT_COMMON_REG->GPIOPCTLC_bit.PIN11 = 1;
|
||||
|
||||
// Íàñòðîéêà òàêòèðîâàíèÿ SSP ìîäóëÿ
|
||||
// Âñåãî 4 ìîäóëÿ, íà êàæäûé ìîäóëü ïî 8 áèò èç ðåãèñòðà SSP_CLK_CTRL è ïî äâà áèòà èç UART_SSP_CLK_SEL
|
||||
|
||||
// UART_SSP_CLK_SEL
|
||||
// Âî âòîðîì áàéòå ñëîâà íà êàæäûé èç 4-¸õ ìîäóëåé SSP îòâîäèòñÿ ïî äâà áèòà äëÿ âûáîðà èñòî÷íèêà òàêòèðîâàíèÿ 0x0000XX00
|
||||
// "00" - â êà÷åñòâå èòî÷íèêà òàêòèðîâàíèÿ ìîäóëÿ SSP âûáèðàåòñÿ ñèñòåìíàÿ ÷àñòîòà 100 ÌÃö, òàêèì îáðàçîì f_SSP_IN = SysClk = 100 MHz
|
||||
|
||||
// SSP_CLK_CTRL
|
||||
// Ìëàäøèé áèò ðàçðåøàåò òàêòèðîâàíèå (1 - ðàçðåøèòü)
|
||||
// Âòîðîé áèò ðàçðåøàåò äåëåíèå ÷àñòîòû f_SSP_IN èñòî÷íèêà òàêòîâîãî ñèãíàëà (0 - íå äåëèòü, 1 - äåëèòü)
|
||||
// Ñòàðøèå øåñòü âûáèðàþò äåëèòåëü ÷àñòîòû ýòîãî èñîò÷íèêà:
|
||||
// X - äåëåíèå ïî ôîðìóëå SSPclk = f_SSP_IN /( 2 * (X +1) )
|
||||
// Èç äîêóìåíòàöèè íà áëîê SSP - ìèíèìàëüíàÿ ÷àñòîòà äëÿ ðàáîòû ìîäóëÿ â ðåæèìàõ è ìàñòåð è ñëåéâ,
|
||||
// f_SSP_IN > 22.12 MHz, ïîýòîìó 25 ÌÃö ñäåëàåì
|
||||
tempREG = NT_COMMON_REG->UART_SPI_CLK_SEL;// ×åðåç tempREG, ÷òîáû íå çàäåòü äðóãèå áèòû, îòâå÷àþùèå çà òàêòèðîâàíèå UART'a
|
||||
tempREG &= 0xFFFF00FF;
|
||||
NT_COMMON_REG->UART_SPI_CLK_SEL = tempREG;
|
||||
NT_COMMON_REG->SPI_CLK = 0x07070707;// Ðàçðåøèòü òàêòèðîâàíèå, ðàçðåøèòü äåëåíèå ÷àñòîòû, äåëèòü íà 4 - 25 ÌÃö
|
||||
|
||||
// Íàñòðîéêà ñàìîãî ìîäóëÿ SPI
|
||||
// Ïðîäîëæåíèå íàñòðîéêè òàêòèðîâàíèÿ.
|
||||
// Ïîëó÷åííàÿ ðàíåå ÷àñòîòà f_SSP_IN ïðîõîäèò åù¸ ÷åðåç äâà äåëèòåëÿ.
|
||||
// SSPCPSR - ïåðâûé äåëèòåëü, â äèàïàçîíå 2 ... 254, ìîæåò áûòü òîëüêî ÷¸òíûì (ìëàäøèé áèò âñåãäà õàðäâàðíî ðàâåí 0)
|
||||
// SSPCR0.bit.SCR - âòîðîé äåëèòåëü îò 0 äî 255.
|
||||
// Áèòðåéò â èòîãå BitRate = f_SSP_IN / ( SSPCPSR * (SCR + 1) )
|
||||
|
||||
NT_SPI0->SPI_CR1 = 0;// Ðåæèì - ìàñòåð, LoopBack îòêëþ÷¸í, ñàì ìîäóëü SSP òîæå îòêëþ÷¸í
|
||||
NT_SPI0->SPI_IMSC = 0x0; // Çàïðåòèòü âñå ïðåðûâàíèÿ
|
||||
NT_SPI0->SPI_DMACR = 0; // Çàïðåòèòü DMA
|
||||
NT_SPI0->SPI_ICR = 0x3; // Î÷èñòêà ïðåðûâàíèé ("ïåðåïîëíåíèå FIFO ïðè¸ìà" è "íåîáñëóæåííîå FIFO ïðè¸ìà")
|
||||
|
||||
NT_SPI0->SPI_CPSR = 4; // Äåëåíèå âõîäíîé ÷àñòîòû íà 4 -> 6,25 MHz
|
||||
NT_SPI0->SPI_CR0_bit.DSS = 0xF; // Ðàçìåð äàííûõ - 16 áèò
|
||||
NT_SPI0->SPI_CR0_bit.SCR = 0x3F; // Âòîðîé äåëèòåëü = 15 -> f_SPI = 416 kHz
|
||||
NT_SPI0->SPI_CR0_bit.FRF = 0x0; // Êàêàÿ-òî "ôàçà" äëÿ ïðîòîêîëà Motorola SPI
|
||||
NT_SPI0->SPI_CR0_bit.SPH = 0x1; // Êàêàÿ-òî "ïîëÿðíîñòü" äëÿ ïðîòîêîëà Motorola SPI
|
||||
NT_SPI0->SPI_CR0_bit.SPO = 0x0; // Âûáîð ôîðìàòà êàäðà Motorola/TI/Microwire. "0" - ïî ïðîòîêîëó Motorola SPI
|
||||
NT_SPI0->SPI_CR1_bit.SSE = 1; // Ðàçðåøèòü ðàáîòó
|
||||
|
||||
// Íàñòðîéêà íîã äëÿ ïðè¸ìà àâàðèé îò DRV8301: Ñ4 - Fault, C5 - OCTW
|
||||
NT_GPIOC->ALTFUNCCLR = (1 << 4) | (1 << 5);
|
||||
NT_GPIOC->OUTENCLR = (1 << 4) | (1 << 5);
|
||||
|
||||
// Íàñòðîéêà íîãè äëÿ âêëþ÷åíèÿ DRV8301: G8 - EN_GATE
|
||||
NT_GPIOG->ALTFUNCCLR = (1 << 8);
|
||||
NT_GPIOG->OUTENSET |= (1 << 8); //÷åðåç ÈËÈ, ÷òîáû íå ïîïîðòèòü îñòàëüíûå íîã ïîðòà G
|
||||
NT_GPIOG->DATA |= (1 << 8); //DATA.bit.GPIO8 = 1
|
||||
|
||||
// Âûæäàòü 10 ìñ ïåðåä íàñòðîéêîé
|
||||
delay = 10000000;
|
||||
while (delay > 0)
|
||||
delay--;
|
||||
|
||||
// Íàñòðîéêà ñàìîãî DRV8301
|
||||
p->CTRL1.bit.GATE_CURRENT = 0; // full current 1.7A
|
||||
// p->CTRL1.bit.GATE_CURRENT = 1; // med current 0.7A
|
||||
// p->CTRL1.bit.GATE_CURRENT = 2; // min current 0.25A
|
||||
p->CTRL1.bit.GATE_RESET = 0; // Normal Mode
|
||||
p->CTRL1.bit.PWM_MODE = 0; // six independant PWMs
|
||||
// p->CTRL1.bit.OC_MODE = 0; // current limiting when OC detected
|
||||
p->CTRL1.bit.OC_MODE = 1; // latched OC shutdown
|
||||
// p->CTRL1.bit.OC_MODE = 2; // Report on OCTWn pin and SPI reg only, no shut-down
|
||||
// p->CTRL1.bit.OC_MODE = 3; // OC protection disabled
|
||||
// p->CTRL1.bit.OC_ADJ_SET = 0; // OC @ Vds=0.060V
|
||||
// p->CTRL1.bit.OC_ADJ_SET = 4; // OC @ Vds=0.097V
|
||||
// p->CTRL1.bit.OC_ADJ_SET = 6; // OC @ Vds=0.123V
|
||||
// p->CTRL1.bit.OC_ADJ_SET = 9; // OC @ Vds=0.175V
|
||||
p->CTRL1.bit.OC_ADJ_SET = 15; // OC @ Vds=0.358V
|
||||
// p->CTRL1.bit.OC_ADJ_SET = 16; // OC @ Vds=0.403V
|
||||
// p->CTRL1.bit.OC_ADJ_SET = 17; // OC @ Vds=0.454V
|
||||
// p->CTRL1.bit.OC_ADJ_SET = 18; // OC @ Vds=0.511V
|
||||
p->CTRL1.bit.Reserved = 0;
|
||||
|
||||
// p->CTRL2.bit.OCTW_SET = 0; // report OT and OC
|
||||
p->CTRL2.bit.OCTW_SET = 1; // report OT only
|
||||
|
||||
// p->CTRL2.bit.GAIN = 0; // CS amplifier gain = 10
|
||||
p->CTRL2.bit.GAIN = 1; // CS amplifier gain = 20
|
||||
// p->CTRL2.bit.GAIN = 2; // CS amplifier gain = 40
|
||||
// p->CTRL2.bit.GAIN = 3; // CS amplifier gain = 80
|
||||
|
||||
p->CTRL2.bit.DC_CAL_CH1 = 0; // not in CS calibrate mode
|
||||
p->CTRL2.bit.DC_CAL_CH2 = 0; // not in CS calibrate mode
|
||||
p->CTRL2.bit.OC_TOFF = 0; // normal mode
|
||||
p->CTRL2.bit.Reserved = 0;
|
||||
|
||||
// Çàïèøåì
|
||||
|
||||
p->write(p, CNTRL_REG_1_ADDR);
|
||||
p->write(p, CNTRL_REG_2_ADDR);
|
||||
p->read(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DRV8301_Interface_Write(Tdrv8301interface*p, Uint16 reg) {
|
||||
#ifdef HW_VECTORCARD_DRV8301_EVM
|
||||
Uint16 trash;
|
||||
|
||||
p->writeWord.bit.R_W = 0; //we are initiating a write
|
||||
p->writeWord.bit.ADDRESS = reg; //load the address
|
||||
|
||||
if (reg == CNTRL_REG_1_ADDR)
|
||||
p->writeWord.bit.DATA = p->CTRL1.all; //data to be written;
|
||||
else
|
||||
p->writeWord.bit.DATA = p->CTRL2.all;
|
||||
NT_SPI0->SPI_DR = p->writeWord.all; //send out the data
|
||||
|
||||
while (NT_SPI0->SPI_SR_bit.BSY == 1)
|
||||
; //wait for the packet to complete
|
||||
|
||||
trash = NT_SPI0->SPI_DR;//read returned value of Status Register 1 and clear the INT_FLAG bit
|
||||
#endif
|
||||
}
|
||||
|
||||
void DRV8301_Interface_Read(Tdrv8301interface*p) {
|
||||
#ifdef HW_VECTORCARD_DRV8301_EVM
|
||||
Uint16 trash;
|
||||
// Ñíà÷àëà ãîâîðèì, ÷òî õîòèì ÷èòàòü ïåðâûé ðåãèñòð
|
||||
p->writeWord.bit.R_W = 1; //we are initiating a read
|
||||
p->writeWord.bit.ADDRESS = STAT_REG_1_ADDR; //load the address
|
||||
p->writeWord.bit.DATA = 0; //dummy data;
|
||||
|
||||
NT_SPI0->SPI_DR = p->writeWord.all; //send out the data
|
||||
|
||||
while (NT_SPI0->SPI_SR_bit.BSY == 1)
|
||||
; //wait for the packet to complete
|
||||
|
||||
// Â ýòî âðåìÿ DRV íàì ïðèñëàë ìóñîð (õîòÿ ýòî íå ñîâñåì òàê)
|
||||
trash = NT_SPI0->SPI_DR; //dummy read to clear the INT_FLAG bit
|
||||
|
||||
// Òåïåðü ãîâîðèì, ÷òî ïî÷èòàåì âòîðîé ðåãèñòð
|
||||
p->writeWord.bit.R_W = 1; //we are initiating a read
|
||||
p->writeWord.bit.ADDRESS = STAT_REG_2_ADDR; //load the address
|
||||
p->writeWord.bit.DATA = 0; //dummy data;
|
||||
|
||||
NT_SPI0->SPI_DR = p->writeWord.all; //send out the data
|
||||
|
||||
while (NT_SPI0->SPI_SR_bit.BSY == 1)
|
||||
; //wait for the packet to complete
|
||||
|
||||
// Â ýòî âðåìÿ DRV íàì ïðèñëàë îòâåò íà ïðîøëûé çàïðîñ - òî åñòü ñîäåðæèìîå ïåðâîãî ðåãèñòðà
|
||||
p->STS1.all = NT_SPI0->SPI_DR; //dummy read to clear the INT_FLAG bit
|
||||
|
||||
// Òåïåðü ãîâîðèì, ÷òî óãîäíî
|
||||
p->writeWord.bit.R_W = 1; //we are initiating a read
|
||||
p->writeWord.bit.ADDRESS = STAT_REG_2_ADDR; //load the address
|
||||
p->writeWord.bit.DATA = 0; //dummy data;
|
||||
|
||||
NT_SPI0->SPI_DR = p->writeWord.all; //send out the data
|
||||
|
||||
while (NT_SPI0->SPI_SR_bit.BSY == 1)
|
||||
; //wait for the packet to complete
|
||||
|
||||
// Â ýòî âðåìÿ DRV íàì ïðèñëàë îòâåò íà ïðîøëûé çàïðîñ - òî åñòü ñîäåðæèìîå âòîðîãî ðåãèñòðà
|
||||
p->STS2.all = NT_SPI0->SPI_DR;
|
||||
#endif
|
||||
}
|
@ -33,25 +33,6 @@ void SM_CmdLogicInit(TSM_CmdLogic *p) {
|
||||
p->state = 0;
|
||||
p->state_prev = 0xFF;
|
||||
cmd.all = 0;
|
||||
|
||||
#if defined (HW_VECTORCARD_DRV8301_EVM) || defined (HW_VECTORCARD_DRV8312_EVM)
|
||||
/* Разрешить ногам работать на вход, это кнопки старт и стоп */
|
||||
NT_GPIOA->ALTFUNCCLR = (1 << 13) | (1 << 14);//выключить альт. функцию
|
||||
NT_GPIOA->OUTENCLR = (1 << 13) | (1 << 14);//на вход
|
||||
#endif
|
||||
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
/* Разрешить ногам работать на вход, это кнопки старт и стоп */
|
||||
/* Для включения/выключения данного контроллера использованы внешние дискретные входы */
|
||||
|
||||
/*
|
||||
* Здесь описываются (отключается альтернативная функция,
|
||||
* разрешается работа на выход) ножки для работы с кнопками
|
||||
* на самом контроллере. Но так как для данного контроллера
|
||||
* мы используем внешние дискретные входы (см. V_DIO), оставим
|
||||
* это место пустым.
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
//!Ìåäëåííûé ðàñ÷åò
|
||||
@ -67,8 +48,8 @@ void SM_CmdLogicSlow_Calc(TSM_CmdLogic *p) {
|
||||
//!êîòîðûé ïåðåêëþ÷àåò ãëîáàëüíî ðåæèìû ÐÀÁÎÒÀ è ÎÑÒÀÍÎÂ.
|
||||
//! \memberof TSM_CmdLogic
|
||||
void SM_CmdLogicms_Calc(TSM_CmdLogic *p) {
|
||||
p->StartButton = STARTBUTTON;//обработка ножки старта
|
||||
p->StopButton = STOPBUTTON;//обработка ножки стопа
|
||||
p->StartButton = STARTBUTTON; //îáðàáîòêà íîæêè ñòàðòà
|
||||
p->StopButton = STOPBUTTON; //îáðàáîòêà íîæêè ñòîïà
|
||||
p->ResetButton = RESETBUTTON;
|
||||
|
||||
//Ñòàíäàðòíàÿ îáðàáîòêà äèñêðåòíîãî àâòîìàòà
|
||||
@ -78,19 +59,18 @@ void SM_CmdLogicms_Calc(TSM_CmdLogic *p) {
|
||||
p->E = 0;
|
||||
p->state_prev = p->state;
|
||||
|
||||
#if defined (HW_VECTORCARD_DRV8301_EVM) || defined (HW_VECTORCARD_DRV8312_EVM) || defined (HW_MOTORCONTROLBOARD)
|
||||
#if defined (HW_MCB3)
|
||||
if ((p->StartButton==1) && (p->StartButtonPrev==0)){
|
||||
cmd.bit.start=1;//êîìàíäà íà çàïóñê. Îíà æå ñòàâèòñÿ ÷åðåç CAN
|
||||
}
|
||||
if ((p->StopButton==1) && (p->StopButtonPrev==0)){
|
||||
cmd.bit.stop=1;
|
||||
}
|
||||
|
||||
|
||||
p->StartButtonPrev=p->StartButton;
|
||||
p->StopButtonPrev=p->StopButton;
|
||||
p->ResetButtonPrev = p->ResetButton;
|
||||
#endif
|
||||
|
||||
//îïðåäåëÿåì ðåæèì ðàáîòû
|
||||
switch (p->state) {
|
||||
case CMD_LOGIC_TURNED_OFF: { //ñîñòîÿíèå 0- ÎÒÊËÞ×ÅÍ
|
||||
|
@ -70,7 +70,7 @@ void SM_Net_Init(TSM_Net *p) {
|
||||
|
||||
|
||||
|
||||
#if (defined(CANTORS_ENA)) || (defined(CANTOUSB_ENA))
|
||||
#if defined(CANTORS_ENA)
|
||||
//Ðàáîòà ñ CANopen ÷åðåç UART (ïàðàëëåëüíî ñ CAN, íåò êîíôëèêòà)
|
||||
CANtoRS.nodeID = (Uint16*)&co1_vars.co_nodeID; //Íîìåð óçëà èç CANopen
|
||||
CANtoRS.callback = Z_co_receiveSDOrequest;//Óêàçàòåëü íà ôóíêöèþ îáðàòíîãî âûçîâà èç äðàéâåðà CANopen ïî ïðèõîäó SDO ñîîáùåíèÿ
|
||||
@ -206,7 +206,7 @@ void SM_Net_ms_Calc(TSM_Net *p) {
|
||||
|
||||
co_1ms_calc(&co1_vars); //Ðàñ÷åò äðàéâåðà CANOpen
|
||||
co_1ms_calc(&co2_vars); //Ðàñ÷åò äðàéâåðà CANOpen
|
||||
#if (defined(CANTORS_ENA)) || (defined(CANTOUSB_ENA))
|
||||
#if defined(CANTORS_ENA)
|
||||
CANtoRS.calc(&CANtoRS);
|
||||
#endif
|
||||
#ifdef MODBUS_ENA
|
||||
|
@ -34,13 +34,6 @@ int16 WriteCounter = 0;
|
||||
void SM_Protect_Init(TSM_Protect *p) {
|
||||
p->state_prev = 0xff;
|
||||
p->state = 0x00;
|
||||
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
/*
|
||||
* Инициализация кнопки СБРОС АВАРИЙ не требуется, так как мы используем для этого дискретный вход
|
||||
*/
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//! Быстрый расчет.
|
||||
@ -60,7 +53,6 @@ void SM_Protect_Fast_Calc(TSM_Protect *p) {
|
||||
sm_prot.bit_fault1 |= F_PDPINT;
|
||||
}
|
||||
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
if (!DRV_FAULT1) {
|
||||
//имеется какая-то аппаратная авария
|
||||
sm_prot.bit_fault2 |= F_PDP_SWITCH_A0;
|
||||
@ -80,7 +72,6 @@ void SM_Protect_Fast_Calc(TSM_Protect *p) {
|
||||
//имеется какая-то аппаратная авария
|
||||
sm_prot.bit_fault2 |= F_PDP_SWITCH_LOWER;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*Защита от пуска при незашунтированном реле плавного заряда ЗПТ*/
|
||||
if (udControl.Enabled == 1) { //Если есть цепь шунтирования ЗПТ, то выставляем аварии по выполнению условий
|
||||
@ -129,7 +120,7 @@ void SM_Protect_Fast_Calc(TSM_Protect *p) {
|
||||
sm_prot.bit_fault1 |= F_CTRL_HI_TEMP; // максимальная температура
|
||||
}
|
||||
|
||||
#if defined(HW_VECTORCARD_SIMULATOR) || defined(HW_NIIET_BOARD_SIMULATOR)
|
||||
#ifdef HW_MCB3_SIMULATOR
|
||||
if(model.fault){
|
||||
sm_prot.bit_fault1 |= F_MODEL_FAULT;
|
||||
}
|
||||
@ -208,7 +199,7 @@ void SM_Protect_Fast_Calc(TSM_Protect *p) {
|
||||
PWM2->TZCLR = 0x7;
|
||||
}
|
||||
|
||||
#if defined(HW_VECTORCARD_SIMULATOR) || defined(HW_NIIET_BOARD_SIMULATOR)
|
||||
#ifdef HW_MCB3_SIMULATOR
|
||||
model.fault=0;
|
||||
#endif
|
||||
|
||||
@ -255,23 +246,7 @@ void SM_Protect_ms_Calc(TSM_Protect *p) {
|
||||
|
||||
//! \memberof TSM_Protect
|
||||
void SM_Protect_Slow_Calc(TSM_Protect *p) {
|
||||
/* Проверка аппаратных защит драйвера. Он автоматически вырубает ключи при авариях,
|
||||
* и опускает сигналы /FAULT и /OCTW, но чтобы понять, что именно случилось, надо по SPI прочитать статусы.
|
||||
* Поэтому, видимо, можно в фоне.
|
||||
*/
|
||||
if (p->readDrvSts == 1) {
|
||||
p->readDrvSts = 0;
|
||||
drv8301.read(&drv8301);
|
||||
|
||||
}
|
||||
|
||||
/* Чтобы сбросить аварию, надо прописать ему битик GATE_RESET */
|
||||
if (p->clearDrvFault == 1) {
|
||||
p->clearDrvFault = 0;
|
||||
drv8301.CTRL1.bit.GATE_RESET = 1;
|
||||
drv8301.write(&drv8301, CNTRL_REG_1_ADDR);
|
||||
drv8301.write(&drv8301, CNTRL_REG_2_ADDR);
|
||||
}
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
@ -37,21 +37,17 @@
|
||||
//!Здесь настраивается большинство прерываний
|
||||
//! \memberof TSM_Sys
|
||||
void SM_Sys_Init(TSM_Sys *p) {
|
||||
#if defined (HW_VECTORCARD_DRV8301_EVM)
|
||||
sw.HardwareType = 0;
|
||||
#elif defined (HW_VECTORCARD_DRV8312_EVM)
|
||||
sw.HardwareType = 1;
|
||||
#elif defined (HW_VECTORCARD_SIMULATOR)
|
||||
sw.HardwareType = 2;
|
||||
#elif defined (HW_MOTORCONTROLBOARD)
|
||||
sw.HardwareType = 3;
|
||||
//TODO: äîáàâèòü òåêñòû ïåðå÷èñëåíèé äëÿ êîíôèãóðàöèé â CODEEDIT
|
||||
#if defined (HW_MCB3)
|
||||
sw.HardwareType = 4;
|
||||
#elif defined (HW_MCB3_SIMULATOR)
|
||||
sw.HardwareType = 5;
|
||||
#endif
|
||||
cmd.all = 0;
|
||||
drv_status.all = 0;
|
||||
adc.init(&adc); //Инициализация АЦП
|
||||
sm_net.init(&sm_net); //Сетевая часть
|
||||
sm_prot.init(&sm_prot); //Защиты
|
||||
drv8301.init(&drv8301);//äðàéâåð êëþ÷åé
|
||||
sm_cmd_logic.init(&sm_cmd_logic); //Логика включения/выключения
|
||||
sm_ctrl.init(&sm_ctrl); //Структура системы управления
|
||||
pwm.init(&pwm); //Модуль ШИМ
|
||||
@ -100,7 +96,7 @@ void SM_Sys_Init(TSM_Sys *p) {
|
||||
AutoOffset.FilterK = _IQ(0.00001);//постоянная времени фильтра для автосмещения АЦП
|
||||
AutoOffset.init(&AutoOffset); //авто смещение некоторых каналов АЦП (токи)
|
||||
|
||||
#if defined(HW_VECTORCARD_SIMULATOR) || defined(HW_NIIET_BOARD_SIMULATOR)
|
||||
#if defined (HW_MCB3_SIMULATOR)
|
||||
//model.motorInternals.udc = 540; //задается через словарь объектов
|
||||
model.tpr = _IQ10div(_IQ10(APB0BusClock/1000.0), pwm.Frequency << 1) >> 10; //период частоты ШИМ
|
||||
model.dt = _IQ4mpy(_IQ4(150 / 4), pwm.DeadBand >> 20) >> 4; //величина мертвого времени
|
||||
@ -199,13 +195,12 @@ void SM_Sys_Fast_Calc(TSM_Sys *p) {
|
||||
SSI_Encoder.calc(&SSI_Encoder);//Датчик положения SSI
|
||||
}
|
||||
|
||||
// adc.fast_calc(&adc); //ÀÖÏ
|
||||
dlog.update(&dlog); //Осциллографирование данных
|
||||
sm_prot.fast_calc(&sm_prot); //Защиты
|
||||
sm_ctrl.fast_calc(&sm_ctrl); //Главный дискретный автомат системы управления
|
||||
udControl.calc(&udControl);//Плавная зарядка ЗПТ через термисторы
|
||||
|
||||
#if defined(HW_VECTORCARD_SIMULATOR) || defined(HW_NIIET_BOARD_SIMULATOR)
|
||||
#if defined (HW_MCB3_SIMULATOR)
|
||||
//Передача текущих скважностей таймеров ШИМ в модель
|
||||
model.cmpr0 = PWM0->CMPA_bit.CMPA;
|
||||
model.cmpr1 = PWM1->CMPA_bit.CMPA;
|
||||
@ -288,13 +283,9 @@ void SM_Sys_Slow_Calc(TSM_Sys *p) {
|
||||
|
||||
//вызов расчета смещения АЦП для токов фаз
|
||||
//Делаем расчет только в останове и отсутствии аварии
|
||||
if ((sw.AutoOffset & 1) &&
|
||||
#ifdef HW_VECTORCARD_DRV8301_EVM
|
||||
(sm_prot.state==PROT_ON_OK) && //óñëîâèå îòñóòñòâèÿ àâàðèè ïðîâåðÿåì òîëüêî íà æåëåçå HW_VECTORCARD_DRV8301_EVM, ïîòîìó ÷òî òàì íåëüçÿ èçìåðÿòü òîêè ïðè àâàðèè
|
||||
#endif
|
||||
(sm_ctrl.state == CTRL_STOP)){
|
||||
AutoOffset.Enabled=1;
|
||||
} else
|
||||
if ((sw.AutoOffset & 1) && (sm_ctrl.state == CTRL_STOP))
|
||||
AutoOffset.Enabled=1;
|
||||
else
|
||||
AutoOffset.Enabled=0;
|
||||
|
||||
}
|
||||
|
@ -31,30 +31,8 @@ void usb_irq_dis(void);
|
||||
//! \memberof TCANtoRS
|
||||
void CANtoRS_init(TCANtoRS *p) {
|
||||
#ifdef CANTORS_ENA
|
||||
#ifdef HW_NIIET_BOARD_SIMULATOR
|
||||
//UART TX - ïëàòà ìèêðîêîíòðîëëåðà ðàçúåì XP6 ïèí 57 (ñîîòâåòñòâóåò îáîçíà÷åíèþ UART_TXD1 â øåëêîãðàôèè íà îñíîâíîé ïëàòå)
|
||||
//UART RX - ïëàòà ìèêðîêîíòðîëëåðà ðàçúåì XP6 ïèí 59 (ñîîòâåòñòâóåò îáîçíà÷åíèþ UART_RXD1 â øåëêîãðàôèè íà îñíîâíîé ïëàòå)
|
||||
NT_COMMON_REG->GPIOPCTLA_bit.PIN3 = 1; //UART_TxD1]
|
||||
NT_COMMON_REG->GPIOPCTLA_bit.PIN4 = 1; //UART_RxD[1]
|
||||
NT_GPIOA->ALTFUNCSET = (1 << 3);
|
||||
NT_GPIOA->ALTFUNCSET = (1 << 4);
|
||||
|
||||
NT_COMMON_REG->GPIOPCTLA_bit.PIN3 = 0;
|
||||
NT_COMMON_REG->GPIOPCTLA_bit.PIN4 = 0;
|
||||
|
||||
p->NT_UART=NT_UART1;//Èñïîëüçóåìûé â äðàéâåðå íîìåð UART (1,2,3)
|
||||
|
||||
#elif defined (HW_MOTORCONTROLBOARD)
|
||||
p->NT_UART=UART2;//Èñïîëüçóåìûé â äðàéâåðå íîìåð UART (1,2,3)
|
||||
|
||||
p->NT_UART->CR_bit.UARTEN = 1; // Ðàçðåøèòü ðàáîòó UART
|
||||
#else
|
||||
p->NT_UART=UART2;//Èñïîëüçóåìûé â äðàéâåðå íîìåð UART (1,2,3)
|
||||
p->NT_UART->CR_bit.UARTEN = 1; // Ðàçðåøèòü ðàáîòó UART
|
||||
#endif
|
||||
|
||||
|
||||
p->NT_UART->CR_bit.UARTEN = 1; // Ðàçðåøèòü ðàáîòó UART
|
||||
p->NT_UART=UART2; //Используемый в драйвере номер UART (1,2,3)
|
||||
p->NT_UART->CR_bit.UARTEN = 1; // Разрешить работу UART
|
||||
|
||||
// Íàñòðîéêà ÷àñòîòû â äâóõ ðåãèñòðàõ:
|
||||
// çàäàíèå äåëèòåëÿ ÷àñòîòû äëÿ ïîëó÷åíèÿ BaudRate
|
||||
@ -76,10 +54,7 @@ void CANtoRS_init(TCANtoRS *p) {
|
||||
p->NT_UART->CR_bit.RXE = 1; // Ðàçðåøèòü ïåðåäà÷ó
|
||||
p->NT_UART->LCRH_bit.STP2 = 0; // 1 ñòîï-áèò
|
||||
#endif
|
||||
#ifdef CANTOUSB_ENA
|
||||
USB_init_hardware();
|
||||
|
||||
#endif
|
||||
p->CounterWrongCRC=0;
|
||||
p->CounterRes=0;
|
||||
p->CounterSended=0;
|
||||
@ -115,14 +90,6 @@ Uint16 CANtoRS_SendP(Uint16* Data, int16 len, TCANtoRS *p) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CANTOUSB_ENA
|
||||
usb_irq_dis();
|
||||
if (usbTxBuf.busy == 0 && usbTxBuf.availSpace(&usbTxBuf) > p->all_len){
|
||||
usbTxBuf.put(&usbTxBuf, p->all_len, (Uint8*)p->buf_out);
|
||||
}
|
||||
usb_irq_en();
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -298,11 +265,6 @@ void CANtoRS_Receive(TCANtoRS *p) {
|
||||
CANtoRS_ReceiveRS(p);
|
||||
#endif
|
||||
|
||||
#ifdef CANTOUSB_ENA
|
||||
// Åñëè USB çàäåéñòâîâàí - îáðàáàòûâàåì USB
|
||||
CANtoRS_ReceiveUSB(p);
|
||||
#endif
|
||||
|
||||
// Ïðîâåðÿåì ïðèøåäøèå äàííûå
|
||||
CANtoRS_CheckPacketValid(p);
|
||||
}
|
||||
|
11
Vsrc/V_DIO.c
11
Vsrc/V_DIO.c
@ -55,17 +55,6 @@ TFilter fIn3 = FILTER_DEFAULTS;
|
||||
|
||||
void DIO_Init()
|
||||
{
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
//Проинитим дискретные входы
|
||||
// NT_GPIOB->ALTFUNCCLR = (1 << 5); //выключить альт. функцию
|
||||
// NT_GPIOA->ALTFUNCCLR = (1 << 14) | (1 << 15); //выключить альт. функцию
|
||||
// NT_GPIOB->OUTENCLR = (1 << 5); //на вход
|
||||
// NT_GPIOA->OUTENCLR = (1 << 14) | (1 << 15); //на вход
|
||||
//
|
||||
// //Проинитим дискретные выходы
|
||||
// NT_GPIOB->ALTFUNCCLR = (1 << 6) | (1 << 15) | (1 << 4); //выключить альт. функцию
|
||||
// NT_GPIOB->OUTENSET = (1 << 6) | (1 << 15) | (1 << 4); //на выход
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -117,10 +117,6 @@ void DPReCAP_Init(TDPReCAP* p) {
|
||||
//60 - об/мин, 1000 мс в секунде, 6 меток на эл. оборот
|
||||
p->TsNomMilsec = (60.0*1000 / (6*drv_params.speed_nom * drv_params.p));
|
||||
|
||||
#if (!defined(HW_VECTORCARD_SIMULATOR)) && (!defined(HW_NIIET_BOARD_SIMULATOR))
|
||||
// Íàñòðîéêà íîæåê â GpioPeripheralInit
|
||||
#endif
|
||||
|
||||
DPReCAP_Angle6Calc(p);
|
||||
p->CAP_WrongEdgeCnt = 0;
|
||||
p->SimulatorOmega2IQ_factor=_IQ(60.0/(2*MOTOR_MODEL_PI*drv_params.speed_nom));
|
||||
@ -146,9 +142,8 @@ void DPReCAP_Angle6Calc(TDPReCAP* p) {
|
||||
// Формируем код по состоянию ножек.
|
||||
p->HallCode = 0;
|
||||
|
||||
#if defined(HW_VECTORCARD_SIMULATOR) || defined(HW_NIIET_BOARD_SIMULATOR)
|
||||
#if defined(HW_MCB3_SIMULATOR)
|
||||
p->HallCode = model.hallSensor;
|
||||
|
||||
#else
|
||||
if (p->UserDirection == 0) {
|
||||
if (GPIOM->DATA & (1 << 5))
|
||||
@ -237,7 +232,7 @@ void DPReCAP_AngleCalc(TDPReCAP* p) {
|
||||
// Фиксируем значения переменных на момент начала расчёта
|
||||
Angle6 = p->Angle6;
|
||||
|
||||
#if (!defined(HW_VECTORCARD_SIMULATOR)) && (!defined(HW_NIIET_BOARD_SIMULATOR))
|
||||
#if (!defined(HW_MCB3_SIMULATOR))
|
||||
|
||||
PrevTs = p->PrevTs;
|
||||
// На момент расчёта, запрещаем прерывания по датчикам.
|
||||
@ -302,7 +297,7 @@ void DPReCAP_AngleCalc(TDPReCAP* p) {
|
||||
|
||||
//! \memberof TDPReCAP
|
||||
void DPReCAP_SpeedCalc(TDPReCAP* p) {
|
||||
#if (!defined(HW_VECTORCARD_SIMULATOR)) && (!defined(HW_NIIET_BOARD_SIMULATOR))
|
||||
#if (!defined(HW_MCB3_SIMULATOR))
|
||||
|
||||
_iq speed;
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
//! \memberof TFanControl
|
||||
void FanControl_init(TFanControl *p)
|
||||
{
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
#if defined (HW_MCB3)
|
||||
p->Enabled = 1; //Включаем блок вентилятора
|
||||
//Проинитим выход для управления вентилятором в GpioPeripheralInit
|
||||
#endif
|
||||
|
@ -58,32 +58,19 @@
|
||||
#include "V_ModBus.h"
|
||||
#include "main.h"
|
||||
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
//Макросы для переключения RS485 между приемом и передачей
|
||||
#define MODBUS_RX_RS485 GPIOM->DATAOUTCLR = (1 << 2) //M2
|
||||
#define MODBUS_TX_RS485 GPIOM->DATAOUTSET = (1 << 2) //M2
|
||||
#define MODBUS_GPIO_VALUE (GPIOK->DATA>>10) & 3
|
||||
#else
|
||||
#define MODBUS_RX_RS485 //NT_GPIOC->MASKHIGHBYTE_bit[4].MASKHB = 4
|
||||
#define MODBUS_TX_RS485 //NT_GPIOC->MASKHIGHBYTE_bit[4].MASKHB = 0
|
||||
#define MODBUS_GPIO_VALUE (GPIOC->DATA>>8) & 3
|
||||
#endif
|
||||
//Макрос для осциллографирования ножек UART (удобно для отладки, когда вообще ничего не работает)
|
||||
|
||||
//Частота тактирования блока UART (настраивается в инициализации микроконтроллера)
|
||||
#define UART_CLOCK_FREQ 25000000
|
||||
|
||||
void ModBus_RS_Init(TModBus *p) {
|
||||
|
||||
#if defined (HW_MOTORCONTROLBOARD)
|
||||
|
||||
p->MBInternals.NT_UART = UART2; //Èñïîëüçóåìûé â äðàéâåðå íîìåð UART (1,2,3)
|
||||
|
||||
p->MBInternals.NT_UART = UART2; //Используемый в драйвере номер UART (1,2,3)
|
||||
p->MBInternals.NT_UART->CR_bit.UARTEN = 1; // Разрешить работу UART
|
||||
#else
|
||||
p->MBInternals.NT_UART = UART2; //Èñïîëüçóåìûé â äðàéâåðå íîìåð UART (1,2,3)
|
||||
|
||||
p->MBInternals.NT_UART->CR_bit.UARTEN = 1; // Ðàçðåøèòü ðàáîòó UART
|
||||
#endif
|
||||
|
||||
//Текущая реализация драйвера не использует FIFO, обрабатывает данные по одному байту
|
||||
//и вызывается в прерывании 10кГц. Поэтому частоты обмена больше 57600 не поддерживаются (будет терять байты)
|
||||
|
@ -27,32 +27,9 @@
|
||||
#include "main.h"
|
||||
|
||||
|
||||
#ifdef HW_VECTORCARD_DRV8301_EVM
|
||||
#define GPIO_INV_ON NT_GPIOG->MASKHIGHBYTE_bit[(1<<(8-8))].MASKHB = (1<<(8-8))
|
||||
//Äëÿ äàííîé êîíôèãóðàöèè âûêëþ÷åíèå èíâåðòîðà àïïàðàòíîå íå èñïîëüçóåòñÿ, âûêëþ÷åíèå êëþ÷åé îñóùåñòâëÿåòñÿ âûâîäàìè óïðàëâåíèÿ êëþ÷àìè
|
||||
#define GPIO_INV_OFF NT_GPIOG->MASKHIGHBYTE_bit[(1<<(8-8))].MASKHB = (1<<(8-8))
|
||||
#endif
|
||||
|
||||
#ifdef HW_VECTORCARD_DRV8312_EVM
|
||||
//A[10], F[2], F[4]
|
||||
#define GPIO_INV_ON NT_GPIOA->MASKHIGHBYTE_bit[(1<<(10-8))].MASKHB = (1<<(10-8)); NT_GPIOF->MASKLOWBYTE_bit[(1<<2)].MASKLB = (1<<2);NT_GPIOF->MASKLOWBYTE_bit[(1<<4)].MASKLB = (1<<4)
|
||||
#define GPIO_INV_OFF NT_GPIOA->MASKHIGHBYTE_bit[(1<<(10-8))].MASKHB = 0;NT_GPIOF->MASKLOWBYTE_bit[(1<<2)].MASKLB = 0;NT_GPIOF->MASKLOWBYTE_bit[(1<<4)].MASKLB = 0
|
||||
#endif
|
||||
|
||||
#if defined(HW_VECTORCARD_SIMULATOR) || defined(HW_NIIET_BOARD_SIMULATOR)
|
||||
#define GPIO_INV_ON
|
||||
#define GPIO_INV_OFF
|
||||
#endif
|
||||
|
||||
#if defined(HW_VECTOR_MK_40_4)
|
||||
#define GPIO_INV_ON
|
||||
#define GPIO_INV_OFF
|
||||
#endif
|
||||
|
||||
#if defined(HW_MOTORCONTROLBOARD)
|
||||
#define GPIO_INV_ON
|
||||
#define GPIO_INV_OFF
|
||||
#endif
|
||||
|
||||
|
||||
//! Èíèöèàëèçàöèÿ
|
||||
@ -286,69 +263,6 @@ void PWM_Module_Init(TPWM_Module *p) {
|
||||
PWM1->TZCLR = 0x7;
|
||||
PWM2->TZCLR = 0x7;
|
||||
|
||||
//íàñòðîéêà íîæåê
|
||||
#ifdef HW_VECTORCARD_DRV8301_EVM
|
||||
//ØÈÌ 6 âûâîäîâ
|
||||
NT_GPIOG->ALTFUNCSET = (1 << 2) + (1 << 3) + (1 << 4); //ePWMxA(0), (1), (2)
|
||||
NT_GPIOA->ALTFUNCSET = (1 << 10); //ePWMxB(0)
|
||||
NT_GPIOF->ALTFUNCSET = (1 << 2) + (1 << 4); //ePWMxB(1), (2)
|
||||
|
||||
// Ïåðèôåðèéíàÿ ôóíêöèÿ - PWM
|
||||
NT_COMMON_REG->GPIOPCTLA_bit.PIN10 = 2;//ePWMxB(0)
|
||||
NT_COMMON_REG->GPIOPCTLF_bit.PIN2 = 0;//ePWMxB(1)
|
||||
NT_COMMON_REG->GPIOPCTLF_bit.PIN4 = 0;//ePWMxB(2)
|
||||
|
||||
NT_COMMON_REG->GPIOPCTLG_bit.PIN2 = 0;//ePWMxA(0)
|
||||
NT_COMMON_REG->GPIOPCTLG_bit.PIN3 = 0;//ePWMxA(1)
|
||||
NT_COMMON_REG->GPIOPCTLG_bit.PIN4 = 0;//ePWMxA(2)
|
||||
|
||||
//NT_GPIOG->DATAOUT |= (1 << 6);
|
||||
NT_GPIOG->OUTENSET = (1 << 6); //InvEnable
|
||||
#endif
|
||||
|
||||
#if defined(HW_VECTORCARD_DRV8312_EVM)
|
||||
//ØÈÌ 3 âûâîäà óïðàâëåíèÿ âåðõíèìè êëþ÷àìè (íèæíèå êëþ÷è ØÈÌÿò ñàìè äðàéâåðîì)
|
||||
NT_GPIOG->ALTFUNCSET = (1 << 2) + (1 << 3) + (1 << 4); //ePWMxA(0), (1), (2)
|
||||
|
||||
// Ïåðèôåðèéíàÿ ôóíêöèÿ - PWM
|
||||
NT_COMMON_REG->GPIOPCTLG_bit.PIN2 = 0;//ePWMxA(0)
|
||||
NT_COMMON_REG->GPIOPCTLG_bit.PIN3 = 0;//ePWMxA(1)
|
||||
NT_COMMON_REG->GPIOPCTLG_bit.PIN4 = 0;//ePWMxA(2)
|
||||
|
||||
//âûêëþ÷àåì àëüòåðíàòèâíûå ôóíêöèè (íà âñÿêèé)
|
||||
NT_GPIOA->ALTFUNCCLR = (1 << 10); //A[10]
|
||||
NT_GPIOF->ALTFUNCCLR = (1 << 2) + (1 << 4); //F[2], F[4]
|
||||
|
||||
//A[10], F[2], F[4] íîæêè ðåçåòà
|
||||
NT_GPIOA->OUTENSET = (1 << 10);
|
||||
NT_GPIOF->OUTENSET = (1 << 2);
|
||||
NT_GPIOF->OUTENSET = (1 << 4);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HW_VECTOR_MK_40_4
|
||||
NT_GPIOG->ALTFUNCSET_bit.ALTFUNCSET = (1 << 2) + (1 << 3) + (1 << 4); //ePWMxA(0), (1), (2)
|
||||
NT_GPIOF->ALTFUNCSET_bit.ALTFUNCSET = (1 << 0) + (1 << 2) + (1 << 4); //ePWMxB(0), (1), (2)
|
||||
|
||||
// Ïåðèôåðèéíàÿ ôóíêöèÿ - PWM
|
||||
NT_COMMON_REG->GPIOPCTLF_bit.PIN0 = 0;//ePWMxB(0)
|
||||
NT_COMMON_REG->GPIOPCTLF_bit.PIN2 = 0;//ePWMxB(1)
|
||||
NT_COMMON_REG->GPIOPCTLF_bit.PIN4 = 0;//ePWMxB(2)
|
||||
|
||||
NT_COMMON_REG->GPIOPCTLG_bit.PIN2 = 0;//ePWMxA(0)
|
||||
NT_COMMON_REG->GPIOPCTLG_bit.PIN3 = 0;//ePWMxA(1)
|
||||
NT_COMMON_REG->GPIOPCTLG_bit.PIN4 = 0;//ePWMxA(2)
|
||||
|
||||
//Âõîä àïïàðàòíîé àâàðèè
|
||||
NT_GPIOA->ALTFUNCCLR = (1<<8); //A[8]
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HW_MOTORCONTROLBOARD
|
||||
//ØÈÌ 6 âûâîäîâ
|
||||
// â GpioPeripheralInit
|
||||
#endif
|
||||
|
||||
//Ñèíõðîííûé çàïóñê ØÈÌ
|
||||
SIU->PWMSYNC_bit.PRESCRST= 0b111;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ void TposspeedEqep_Calc(TposspeedEqep *p) {
|
||||
p->Poscnt_res = 0;
|
||||
}
|
||||
p->Poscnt_resPrev=p->Poscnt_res;
|
||||
#if defined(HW_VECTORCARD_SIMULATOR) || defined(HW_NIIET_BOARD_SIMULATOR)
|
||||
#if defined(HW_MCB3_SIMULATOR)
|
||||
p->Poscnt_res = (unsigned long) model.qepCounter; //çàõâàò ïîëîæåíèÿ
|
||||
#else
|
||||
p->Poscnt_res = (unsigned long) QEP0->QPOSCNT; //çàõâàò ïîëîæåíèÿ
|
||||
@ -315,7 +315,7 @@ void TposspeedEqep_Calc(TposspeedEqep *p) {
|
||||
}
|
||||
|
||||
//Â ñèìóëÿòîðå äîñòóïåí òîëüêî îäèí ñïîñîá èçìåðåíèÿ ñêîðîñòè - ïî óãëó ïðîãðàììíî.
|
||||
#if (defined(HW_VECTORCARD_SIMULATOR)) || (defined(HW_NIIET_BOARD_SIMULATOR))
|
||||
#if defined(HW_MCB3_SIMULATOR)
|
||||
p->SpeedCalcType=SPEED_CALC_TYPE_BY_SOFT;
|
||||
#endif
|
||||
|
||||
|
@ -30,23 +30,13 @@
|
||||
|
||||
//! Инициализация
|
||||
|
||||
#define SSI_NT_SPI SPI0 //Íàñòðîéêà íîìåðà SPI
|
||||
|
||||
//! \memberof TSSI_Encoder
|
||||
void SSI_Encoder_init(TSSI_Encoder *p) {
|
||||
volatile long delay;
|
||||
volatile Uint32 tempREG;
|
||||
|
||||
|
||||
// Íàñòðîéêà íîã SPI
|
||||
#ifdef HW_MOTORCONTROLBOARD
|
||||
#define SSI_NT_SPI SPI0 //Íàñòðîéêà íîìåðà SPI
|
||||
// Â GpioPeripheralInit
|
||||
#else
|
||||
|
||||
#define SSI_NT_SPI SPI2 //Íàñòðîéêà íîìåðà SPI
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Настройка самого модуля SPI
|
||||
// Продолжение настройки тактирования.
|
||||
// Полученная ранее частота f_SSP_IN проходит ещё через два делителя.
|
||||
|
@ -31,18 +31,10 @@
|
||||
|
||||
//! \memberof TUdControl
|
||||
void UdControl_init(TUdControl *p) {
|
||||
|
||||
#ifdef HW_MOTORCONTROLBOARD
|
||||
p->Enabled = 1; //Âêëþ÷àåì áëîê çàðÿäà ÇÏÒ
|
||||
//íîæêà, óïðàâëÿþùàÿ öåïüþ çàðÿäà
|
||||
// D GpioPeripheralInit
|
||||
p->Enabled = 1; //Âêëþ÷àåì áëîê çàðÿäà ÇÏÒ
|
||||
UD_CONTROL_OFF; //ńíŕ÷ŕëŕ âűęëţ÷čě
|
||||
p->state = UD_CONTROL_STATE_OFF; //č ĺůĺ â ńîńňî˙íčĺ "âűęëţ÷ĺíî"
|
||||
p->StateOn = 0;
|
||||
#else
|
||||
p->Enabled = 0; //Âûêëþ÷èòü áëîê çàðÿäà ÇÏÒ
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//!Đŕń÷ĺň.
|
||||
|
@ -42,7 +42,7 @@ void excitation_calc(Texcitation *v)
|
||||
GammaF = _IQ16mpy(GammaF, _IQ16(pwm.k_pwm)); // (IQ16) переводим скважность в величину для загрузки в регистр сравнения.
|
||||
GammaF = pwm.k_pwm - (GammaF >> 16); // (IQ0) Загружем целую часть в регистр сравнения.
|
||||
|
||||
#if defined(HW_VECTORCARD_SIMULATOR) || defined(HW_NIIET_BOARD_SIMULATOR)
|
||||
#if defined(HW_MCB3_SIMULATOR)
|
||||
model.cmpr3 = (Uint16) GammaF;
|
||||
#endif
|
||||
}
|
||||
|
115
Vsrc/cood1.c
115
Vsrc/cood1.c
@ -1,7 +1,7 @@
|
||||
// Ôàéë:
|
||||
// Ïðîôèëü: E:\VectorWork\motorcontroldemo_028\cood.xml
|
||||
// Êîíôèãóðàöèÿ: Áàçîâûé ïðîôèëü
|
||||
// Äàòà ñîçäàíèÿ: 23.07.2019 12:58:12
|
||||
// Äàòà ñîçäàíèÿ: 31.07.2019 12:49:20
|
||||
// Ïîëüçîâàòåëü: default
|
||||
// COODEdit Basic v.7.3.8
|
||||
#include "DSP.h"
|
||||
@ -9,13 +9,13 @@
|
||||
#include "cood1.h"
|
||||
#include "co_ODvars.h"
|
||||
|
||||
// âñåãî 128 èíäåêñîâ â ñëîâàðå
|
||||
// âñåãî 865 ýëåìåíòîâ â ñëîâàðå
|
||||
Uint16 const co1_numOfInd = 128;
|
||||
// âñåãî 129 èíäåêñîâ â ñëîâàðå
|
||||
// âñåãî 878 ýëåìåíòîâ â ñëîâàðå
|
||||
Uint16 const co1_numOfInd = 129;
|
||||
// Íîìåð ïåðå÷åñëåíèÿ äëÿ ãðóïï
|
||||
Uint16 const co1_groupEnum = 15;
|
||||
// Õýø-ñóììà:
|
||||
Uint32 const co1_odHash[4] = {0xF8B5F27F, 0x9B6F7CA3, 0x7802BC66, 0xD1B686E2};
|
||||
Uint32 const co1_odHash[4] = {0xCAF3E7B6, 0x8A796772, 0x3F22293F, 0x9BF10F78};
|
||||
// Òàáëèöà ñ àäðåñàìè ïåðåìåííûõ
|
||||
long const CO1_OD_TBL3[] = {
|
||||
(long)(&co1_vars.co_deviceType), //[1000h.00h], Íàçâàíèå: Òèï óñòðîéñòâà, ÒåêñòÏÓ: Device Type, Ãðóïïà: CAN
|
||||
@ -756,6 +756,18 @@ long const CO1_OD_TBL3[] = {
|
||||
(long)(&model.motorInternals.torque_a), //[5186h.0Dh], Íàçâàíèå: Ìîìåíò ôàçû A, ÒåêñòÏÓ: Ìîìåíò A, Ãðóïïà: Ìîäåëü (ÂÈÄ)
|
||||
(long)(&model.motorInternals.torque_b), //[5186h.0Eh], Íàçâàíèå: Ìîìåíò ôàçû B, ÒåêñòÏÓ: Ìîìåíò B, Ãðóïïà: Ìîäåëü (ÂÈÄ)
|
||||
(long)(&model.motorInternals.torque_c), //[5186h.0Fh], Íàçâàíèå: Ìîìåíò ôàçû C, ÒåêñòÏÓ: Ìîìåíò C, Ãðóïïà: Ìîäåëü (ÂÈÄ)
|
||||
(long)(&ModBus.Enabled), //[5A20h.01h], Íàçâàíèå: Âêëþ÷åí, ÒåêñòÏÓ: Âêë, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.RSNodeID), //[5A20h.02h], Íàçâàíèå: Íîìåð â ñåòè ModBus, ÒåêñòÏÓ: ModBus_ID, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.BaudRate), //[5A20h.03h], Íàçâàíèå: Ñêîðîñòü, ÒåêñòÏÓ: ñêîð, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.OfflineCounterMax), //[5A20h.04h], Íàçâàíèå: Òàéìàóò ïîòåðè ñâÿçè, ÒåêñòÏÓ: OfflineCounterMax, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.AutoRestart), //[5A20h.05h], Íàçâàíèå: Ïåðåçàïóñê ïðè ñáîÿõ íà ëèíèè, ÒåêñòÏÓ: auto_res, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.OfflineCounter), //[5A20h.06h], Íàçâàíèå: Ñ÷åò÷èê ïîòåðè ñâÿçè, ÒåêñòÏÓ: OfflineCounter, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.isOnline), //[5A20h.07h], Íàçâàíèå: MODBUS online, ÒåêñòÏÓ: MODBUS online, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.received_data), //[5A20h.08h], Íàçâàíèå: rs485_last_received_data, ÒåêñòÏÓ: 485_RD, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.MBInternals.TxState), //[5A20h.09h], Íàçâàíèå: Ñîñòîÿíèå ïåðåäà÷è ïîñûëêè, ÒåêñòÏÓ: TXState, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.GPIOsValue), //[5A20h.0Ah], Íàçâàíèå: GPIOsValue, ÒåêñòÏÓ: GPIOsValue, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.ReceivePacketCounter), //[5A20h.0Bh], Íàçâàíèå: Ïàêåòîâ ïðèíÿòî, ÒåêñòÏÓ: ReceivePacketCounte, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.ReceiveByteCounter), //[5A20h.0Ch], Íàçâàíèå: Áàéò ïðèíÿòî, ÒåêñòÏÓ: ReceiveByteCounter, Ãðóïïà: MODBUS
|
||||
(long)(&RotorObserver.Tr), //[5B04h.01h], Íàçâàíèå: Ïîñò. âðåìåíè ðîòîðà, ÒåêñòÏÓ: Tr, Ãðóïïà: Íàáëþäàòåëü ðîòîðà ÀÄ
|
||||
(long)(&RotorObserver.FluxCurrentRatio), //[5B04h.02h], Íàçâàíèå: Ñîîòíîøåíèå òîêà âîçá. X ê òîêó Y, ÒåêñòÏÓ: FluxCurrentRatio, Ãðóïïà: Íàáëþäàòåëü ðîòîðà ÀÄ
|
||||
(long)(&RotorObserver.FluxCurrentMin), //[5B04h.03h], Íàçâàíèå: Ìèíèìàëüíûé òîê âîçáóæäåíèÿ, ÒåêñòÏÓ: FluxCurrentMin, Ãðóïïà: Íàáëþäàòåëü ðîòîðà ÀÄ
|
||||
@ -3697,47 +3709,85 @@ Uint16 const CO1_OD_TBL2[] = {
|
||||
0,
|
||||
0,
|
||||
|
||||
19641,
|
||||
566,
|
||||
3,
|
||||
15149, 589, 738,
|
||||
(Uint16)(1),
|
||||
0,
|
||||
15149, 567, 739,
|
||||
(Uint16)(1),
|
||||
0,
|
||||
14637, 437, 740,
|
||||
(Uint16)(9600), (((Uint32)9600)>>16),
|
||||
14637, 581, 741,
|
||||
(Uint16)(20000), (((Uint32)20000)>>16),
|
||||
15149, 583, 742,
|
||||
(Uint16)(1),
|
||||
0,
|
||||
31021, 582, 743,
|
||||
0,
|
||||
0,
|
||||
31533, 568, 744,
|
||||
0,
|
||||
0,
|
||||
31533, 569, 745,
|
||||
0,
|
||||
0,
|
||||
31533, 578, 746,
|
||||
0,
|
||||
0,
|
||||
31533, 467, 747,
|
||||
0,
|
||||
0,
|
||||
31533, 579, 748,
|
||||
0,
|
||||
0,
|
||||
31533, 580, 749,
|
||||
0,
|
||||
0,
|
||||
|
||||
20149,
|
||||
399,
|
||||
7,
|
||||
12453, 571, 738,
|
||||
12453, 571, 750,
|
||||
(Uint16)(16777216), (((Uint32)16777216)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
12453, 572, 739,
|
||||
12453, 572, 751,
|
||||
(Uint16)(5033165), (((Uint32)5033165)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
12613, 573, 740,
|
||||
12613, 573, 752,
|
||||
(Uint16)(5033165), (((Uint32)5033165)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
28997, 574, 741,
|
||||
28997, 574, 753,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
28997, 575, 742,
|
||||
28997, 575, 754,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
28837, 536, 743,
|
||||
28837, 536, 755,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
28837, 537, 744,
|
||||
28837, 537, 756,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
30501, 576, 745,
|
||||
30501, 576, 757,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@ -3748,54 +3798,54 @@ Uint16 const CO1_OD_TBL2[] = {
|
||||
20139,
|
||||
626,
|
||||
7,
|
||||
17709, 631, 746,
|
||||
17709, 631, 758,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
15149, 627, 747,
|
||||
15149, 627, 759,
|
||||
(Uint16)(2000),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
10661, 628, 748,
|
||||
10661, 628, 760,
|
||||
(Uint16)(15099494), (((Uint32)15099494)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
10661, 629, 749,
|
||||
10661, 629, 761,
|
||||
(Uint16)(11744051), (((Uint32)11744051)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
28837, 630, 750,
|
||||
28837, 630, 762,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
12453, 632, 751,
|
||||
12453, 632, 763,
|
||||
(Uint16)(0), (((Uint32)0)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
|
||||
20141,
|
||||
635,
|
||||
7,
|
||||
31521, 636, 752,
|
||||
31521, 636, 764,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
12793, 637, 753,
|
||||
12793, 637, 765,
|
||||
(Uint16)(41943040), (((Uint32)41943040)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
12793, 638, 754,
|
||||
12793, 638, 766,
|
||||
(Uint16)(25165824), (((Uint32)25165824)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
12793, 640, 755,
|
||||
12793, 640, 767,
|
||||
(Uint16)(67108864), (((Uint32)67108864)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
};
|
||||
@ -3926,9 +3976,10 @@ int16 const CO1_OD_TBL1[] = {
|
||||
20868, 4581,
|
||||
20869, 4746,
|
||||
20870, 4776,
|
||||
23300, 4914,
|
||||
23301, 4989,
|
||||
23302, 5046,
|
||||
23072, 4914,
|
||||
23300, 4977,
|
||||
23301, 5052,
|
||||
23302, 5109,
|
||||
};
|
||||
Uint16 const co1_SPIrange1rw = CO1_SPI_START_ADDR+0;
|
||||
Uint16 const co1_SPIrange1rwCRC = CO1_SPI_START_ADDR+8;
|
||||
@ -3955,11 +4006,11 @@ Uint16 const co1_SPIrange4rwpCRC = CO1_SPI_START_ADDR+692;
|
||||
Uint16 const co1_SPIrange4rwps = CO1_SPI_START_ADDR+694;
|
||||
Uint16 const co1_SPIrange4rwpsCRC = CO1_SPI_START_ADDR+694;
|
||||
Uint16 const co1_SPIrange5rw = CO1_SPI_START_ADDR+696;
|
||||
Uint16 const co1_SPIrange5rwCRC = CO1_SPI_START_ADDR+1323;
|
||||
Uint16 const co1_SPIrange5rwp = CO1_SPI_START_ADDR+1325;
|
||||
Uint16 const co1_SPIrange5rwpCRC = CO1_SPI_START_ADDR+1329;
|
||||
Uint16 const co1_SPIrange5rwps = CO1_SPI_START_ADDR+1331;
|
||||
Uint16 const co1_SPIrange5rwpsCRC = CO1_SPI_START_ADDR+1331;
|
||||
Uint16 const co1_SPIrange5rwCRC = CO1_SPI_START_ADDR+1337;
|
||||
Uint16 const co1_SPIrange5rwp = CO1_SPI_START_ADDR+1339;
|
||||
Uint16 const co1_SPIrange5rwpCRC = CO1_SPI_START_ADDR+1343;
|
||||
Uint16 const co1_SPIrange5rwps = CO1_SPI_START_ADDR+1345;
|
||||
Uint16 const co1_SPIrange5rwpsCRC = CO1_SPI_START_ADDR+1345;
|
||||
Uint16 const co1_first1000 = 0;
|
||||
Uint16 const co1_first2000 = 82;
|
||||
Uint16 const co1_first3000 = 194;
|
||||
@ -4092,6 +4143,7 @@ Uint16 const CO1_TYPE_DEF_TABLE[] = {
|
||||
(Uint16)50,\
|
||||
(Uint16)19,\
|
||||
(Uint16)51,\
|
||||
(Uint16)3,\
|
||||
(Uint16)20,\
|
||||
(Uint16)46,\
|
||||
(Uint16)45,\
|
||||
@ -4224,6 +4276,7 @@ long const CO1_OD_CALLBACK_TBL[]={
|
||||
0, // 5184h.00h
|
||||
0, // 5185h.00h
|
||||
0, // 5186h.00h
|
||||
0, // 5A20h.00h
|
||||
0, // 5B04h.00h
|
||||
0, // 5B05h.00h
|
||||
0, // 5B06h.00h
|
||||
|
115
Vsrc/cood2.c
115
Vsrc/cood2.c
@ -1,7 +1,7 @@
|
||||
// Ôàéë:
|
||||
// Ïðîôèëü: E:\VectorWork\motorcontroldemo_028\cood.xml
|
||||
// Êîíôèãóðàöèÿ: Áàçîâûé ïðîôèëü
|
||||
// Äàòà ñîçäàíèÿ: 23.07.2019 12:58:27
|
||||
// Äàòà ñîçäàíèÿ: 31.07.2019 12:50:00
|
||||
// Ïîëüçîâàòåëü: default
|
||||
// COODEdit Basic v.7.3.8
|
||||
#include "DSP.h"
|
||||
@ -9,13 +9,13 @@
|
||||
#include "cood2.h"
|
||||
#include "co_ODvars.h"
|
||||
|
||||
// âñåãî 128 èíäåêñîâ â ñëîâàðå
|
||||
// âñåãî 865 ýëåìåíòîâ â ñëîâàðå
|
||||
Uint16 const co2_numOfInd = 128;
|
||||
// âñåãî 129 èíäåêñîâ â ñëîâàðå
|
||||
// âñåãî 878 ýëåìåíòîâ â ñëîâàðå
|
||||
Uint16 const co2_numOfInd = 129;
|
||||
// Íîìåð ïåðå÷åñëåíèÿ äëÿ ãðóïï
|
||||
Uint16 const co2_groupEnum = 15;
|
||||
// Õýø-ñóììà:
|
||||
Uint32 const co2_odHash[4] = {0xF8B5F27F, 0x9B6F7CA3, 0x7802BC66, 0xD1B686E2};
|
||||
Uint32 const co2_odHash[4] = {0xCAF3E7B6, 0x8A796772, 0x3F22293F, 0x9BF10F78};
|
||||
// Òàáëèöà ñ àäðåñàìè ïåðåìåííûõ
|
||||
long const CO2_OD_TBL3[] = {
|
||||
(long)(&co2_vars.co_deviceType), //[1000h.00h], Íàçâàíèå: Òèï óñòðîéñòâà, ÒåêñòÏÓ: Device Type, Ãðóïïà: CAN
|
||||
@ -756,6 +756,18 @@ long const CO2_OD_TBL3[] = {
|
||||
(long)(&model.motorInternals.torque_a), //[5186h.0Dh], Íàçâàíèå: Ìîìåíò ôàçû A, ÒåêñòÏÓ: Ìîìåíò A, Ãðóïïà: Ìîäåëü (ÂÈÄ)
|
||||
(long)(&model.motorInternals.torque_b), //[5186h.0Eh], Íàçâàíèå: Ìîìåíò ôàçû B, ÒåêñòÏÓ: Ìîìåíò B, Ãðóïïà: Ìîäåëü (ÂÈÄ)
|
||||
(long)(&model.motorInternals.torque_c), //[5186h.0Fh], Íàçâàíèå: Ìîìåíò ôàçû C, ÒåêñòÏÓ: Ìîìåíò C, Ãðóïïà: Ìîäåëü (ÂÈÄ)
|
||||
(long)(&ModBus.Enabled), //[5A20h.01h], Íàçâàíèå: Âêëþ÷åí, ÒåêñòÏÓ: Âêë, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.RSNodeID), //[5A20h.02h], Íàçâàíèå: Íîìåð â ñåòè ModBus, ÒåêñòÏÓ: ModBus_ID, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.BaudRate), //[5A20h.03h], Íàçâàíèå: Ñêîðîñòü, ÒåêñòÏÓ: ñêîð, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.OfflineCounterMax), //[5A20h.04h], Íàçâàíèå: Òàéìàóò ïîòåðè ñâÿçè, ÒåêñòÏÓ: OfflineCounterMax, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.AutoRestart), //[5A20h.05h], Íàçâàíèå: Ïåðåçàïóñê ïðè ñáîÿõ íà ëèíèè, ÒåêñòÏÓ: auto_res, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.OfflineCounter), //[5A20h.06h], Íàçâàíèå: Ñ÷åò÷èê ïîòåðè ñâÿçè, ÒåêñòÏÓ: OfflineCounter, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.isOnline), //[5A20h.07h], Íàçâàíèå: MODBUS online, ÒåêñòÏÓ: MODBUS online, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.received_data), //[5A20h.08h], Íàçâàíèå: rs485_last_received_data, ÒåêñòÏÓ: 485_RD, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.MBInternals.TxState), //[5A20h.09h], Íàçâàíèå: Ñîñòîÿíèå ïåðåäà÷è ïîñûëêè, ÒåêñòÏÓ: TXState, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.GPIOsValue), //[5A20h.0Ah], Íàçâàíèå: GPIOsValue, ÒåêñòÏÓ: GPIOsValue, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.ReceivePacketCounter), //[5A20h.0Bh], Íàçâàíèå: Ïàêåòîâ ïðèíÿòî, ÒåêñòÏÓ: ReceivePacketCounte, Ãðóïïà: MODBUS
|
||||
(long)(&ModBus.ReceiveByteCounter), //[5A20h.0Ch], Íàçâàíèå: Áàéò ïðèíÿòî, ÒåêñòÏÓ: ReceiveByteCounter, Ãðóïïà: MODBUS
|
||||
(long)(&RotorObserver.Tr), //[5B04h.01h], Íàçâàíèå: Ïîñò. âðåìåíè ðîòîðà, ÒåêñòÏÓ: Tr, Ãðóïïà: Íàáëþäàòåëü ðîòîðà ÀÄ
|
||||
(long)(&RotorObserver.FluxCurrentRatio), //[5B04h.02h], Íàçâàíèå: Ñîîòíîøåíèå òîêà âîçá. X ê òîêó Y, ÒåêñòÏÓ: FluxCurrentRatio, Ãðóïïà: Íàáëþäàòåëü ðîòîðà ÀÄ
|
||||
(long)(&RotorObserver.FluxCurrentMin), //[5B04h.03h], Íàçâàíèå: Ìèíèìàëüíûé òîê âîçáóæäåíèÿ, ÒåêñòÏÓ: FluxCurrentMin, Ãðóïïà: Íàáëþäàòåëü ðîòîðà ÀÄ
|
||||
@ -3697,47 +3709,85 @@ Uint16 const CO2_OD_TBL2[] = {
|
||||
0,
|
||||
0,
|
||||
|
||||
19641,
|
||||
566,
|
||||
3,
|
||||
15149, 589, 738,
|
||||
(Uint16)(1),
|
||||
0,
|
||||
15149, 567, 739,
|
||||
(Uint16)(1),
|
||||
0,
|
||||
14637, 437, 740,
|
||||
(Uint16)(9600), (((Uint32)9600)>>16),
|
||||
14637, 581, 741,
|
||||
(Uint16)(20000), (((Uint32)20000)>>16),
|
||||
15149, 583, 742,
|
||||
(Uint16)(1),
|
||||
0,
|
||||
31021, 582, 743,
|
||||
0,
|
||||
0,
|
||||
31533, 568, 744,
|
||||
0,
|
||||
0,
|
||||
31533, 569, 745,
|
||||
0,
|
||||
0,
|
||||
31533, 578, 746,
|
||||
0,
|
||||
0,
|
||||
31533, 467, 747,
|
||||
0,
|
||||
0,
|
||||
31533, 579, 748,
|
||||
0,
|
||||
0,
|
||||
31533, 580, 749,
|
||||
0,
|
||||
0,
|
||||
|
||||
20149,
|
||||
399,
|
||||
7,
|
||||
12453, 571, 738,
|
||||
12453, 571, 750,
|
||||
(Uint16)(16777216), (((Uint32)16777216)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
12453, 572, 739,
|
||||
12453, 572, 751,
|
||||
(Uint16)(5033165), (((Uint32)5033165)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
12613, 573, 740,
|
||||
12613, 573, 752,
|
||||
(Uint16)(5033165), (((Uint32)5033165)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
28997, 574, 741,
|
||||
28997, 574, 753,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
28997, 575, 742,
|
||||
28997, 575, 754,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
28837, 536, 743,
|
||||
28837, 536, 755,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
28837, 537, 744,
|
||||
28837, 537, 756,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
30501, 576, 745,
|
||||
30501, 576, 757,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@ -3748,54 +3798,54 @@ Uint16 const CO2_OD_TBL2[] = {
|
||||
20139,
|
||||
626,
|
||||
7,
|
||||
17709, 631, 746,
|
||||
17709, 631, 758,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
15149, 627, 747,
|
||||
15149, 627, 759,
|
||||
(Uint16)(2000),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
10661, 628, 748,
|
||||
10661, 628, 760,
|
||||
(Uint16)(15099494), (((Uint32)15099494)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
10661, 629, 749,
|
||||
10661, 629, 761,
|
||||
(Uint16)(11744051), (((Uint32)11744051)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
28837, 630, 750,
|
||||
28837, 630, 762,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
12453, 632, 751,
|
||||
12453, 632, 763,
|
||||
(Uint16)(0), (((Uint32)0)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
|
||||
20141,
|
||||
635,
|
||||
7,
|
||||
31521, 636, 752,
|
||||
31521, 636, 764,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
12793, 637, 753,
|
||||
12793, 637, 765,
|
||||
(Uint16)(41943040), (((Uint32)41943040)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
12793, 638, 754,
|
||||
12793, 638, 766,
|
||||
(Uint16)(25165824), (((Uint32)25165824)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
12793, 640, 755,
|
||||
12793, 640, 767,
|
||||
(Uint16)(67108864), (((Uint32)67108864)>>16),
|
||||
(Uint16)(0), (((Uint32)0)>>16), (Uint16)(0), (((Uint32)0)>>16),
|
||||
};
|
||||
@ -3926,9 +3976,10 @@ int16 const CO2_OD_TBL1[] = {
|
||||
20868, 4581,
|
||||
20869, 4746,
|
||||
20870, 4776,
|
||||
23300, 4914,
|
||||
23301, 4989,
|
||||
23302, 5046,
|
||||
23072, 4914,
|
||||
23300, 4977,
|
||||
23301, 5052,
|
||||
23302, 5109,
|
||||
};
|
||||
Uint16 const co2_SPIrange1rw = CO2_SPI_START_ADDR+0;
|
||||
Uint16 const co2_SPIrange1rwCRC = CO2_SPI_START_ADDR+8;
|
||||
@ -3955,11 +4006,11 @@ Uint16 const co2_SPIrange4rwpCRC = CO1_SPI_START_ADDR+692;
|
||||
Uint16 const co2_SPIrange4rwps = CO1_SPI_START_ADDR+694;
|
||||
Uint16 const co2_SPIrange4rwpsCRC = CO1_SPI_START_ADDR+694;
|
||||
Uint16 const co2_SPIrange5rw = CO1_SPI_START_ADDR+696;
|
||||
Uint16 const co2_SPIrange5rwCRC = CO1_SPI_START_ADDR+1323;
|
||||
Uint16 const co2_SPIrange5rwp = CO1_SPI_START_ADDR+1325;
|
||||
Uint16 const co2_SPIrange5rwpCRC = CO1_SPI_START_ADDR+1329;
|
||||
Uint16 const co2_SPIrange5rwps = CO1_SPI_START_ADDR+1331;
|
||||
Uint16 const co2_SPIrange5rwpsCRC = CO1_SPI_START_ADDR+1331;
|
||||
Uint16 const co2_SPIrange5rwCRC = CO1_SPI_START_ADDR+1337;
|
||||
Uint16 const co2_SPIrange5rwp = CO1_SPI_START_ADDR+1339;
|
||||
Uint16 const co2_SPIrange5rwpCRC = CO1_SPI_START_ADDR+1343;
|
||||
Uint16 const co2_SPIrange5rwps = CO1_SPI_START_ADDR+1345;
|
||||
Uint16 const co2_SPIrange5rwpsCRC = CO1_SPI_START_ADDR+1345;
|
||||
Uint16 const co2_first1000 = 0;
|
||||
Uint16 const co2_first2000 = 82;
|
||||
Uint16 const co2_first3000 = 194;
|
||||
@ -4092,6 +4143,7 @@ Uint16 const CO2_TYPE_DEF_TABLE[] = {
|
||||
(Uint16)50,\
|
||||
(Uint16)19,\
|
||||
(Uint16)51,\
|
||||
(Uint16)3,\
|
||||
(Uint16)20,\
|
||||
(Uint16)46,\
|
||||
(Uint16)45,\
|
||||
@ -4224,6 +4276,7 @@ long const CO2_OD_CALLBACK_TBL[]={
|
||||
0, // 5184h.00h
|
||||
0, // 5185h.00h
|
||||
0, // 5186h.00h
|
||||
0, // 5A20h.00h
|
||||
0, // 5B04h.00h
|
||||
0, // 5B05h.00h
|
||||
0, // 5B06h.00h
|
||||
|
@ -61,7 +61,6 @@ TposspeedEqep posspeedEqep = POSSPEED_DEFAULTS; //!<
|
||||
TCurPar cur_par = TCUR_PAR_DEFAULTS; //!< Модуль расчета и хранения текущих показателей привода - мощность, скорость
|
||||
TUserMemory UserMem = USERMEMORY_DEFAULTS; //!< Модуль работы с энергонезависимой памятью.
|
||||
Tled leds = LED_DEFAULTS; //!< модуль для красивого мигания светодиодами
|
||||
Tdrv8301interface drv8301 = DRV8301_INTERFACE_DEFAULTS; //!< Ìîäóëü äëÿ íàñòðîéêè äðàéâåðà êëþ÷åé drv8301
|
||||
TCanBTInterface Can1BTInterface = T_CANBT_INTERFACE_DEFAULTS;//!<Пакетная передача CANopen
|
||||
TCanBTInterface Can2BTInterface = T_CANBT_INTERFACE_DEFAULTS;//!<Пакетная передача CANopen
|
||||
TRTCClock RTCclock = RTC_CLOCK_DEFAULTS; //!< Модуль работы с часами реальноговремени. "spi" - по историческим причинам совместимости
|
||||
|
@ -5,8 +5,7 @@
|
||||
* Created on: 15 ìàð. 2019 ã.
|
||||
* Author: Dmitry
|
||||
*/
|
||||
#include "DSP.h"
|
||||
#include "build.h"
|
||||
#include "main.h"
|
||||
|
||||
void gpioPeripheralInit (void) {
|
||||
// Ðàçðåøåíèå ðàáîòû âñåõ íîæåê íà ïðîöå
|
||||
@ -71,6 +70,20 @@ void gpioPeripheralInit (void) {
|
||||
GPIOB->ALTFUNCSET = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 |
|
||||
GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
|
||||
|
||||
#ifdef CAN_1_ENABLE
|
||||
// CAN0: C12 / C13
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN12 = 1; // CAN0_TX
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN13 = 1; // CAN0_RX
|
||||
GPIOC->ALTFUNCSET = GPIO_PIN_12 | GPIO_PIN_13;
|
||||
#endif
|
||||
|
||||
#ifdef CAN_2_ENABLE
|
||||
// CAN1: C14 / C15
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN14 = 1; // CAN0_TX
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN15 = 1; // CAN0_RX
|
||||
GPIOC->ALTFUNCSET = GPIO_PIN_14 | GPIO_PIN_15;
|
||||
#endif
|
||||
|
||||
#ifdef CANTORS_ENA
|
||||
// UART2: Ñ8 / Ñ9 (USB-UART)
|
||||
GPIOC->ALTFUNCNUM1_bit.PIN8 = 2; // UART2_RX
|
||||
|
Loading…
Reference in New Issue
Block a user