123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- #ifndef HVCALLBACK_H_
- #define HVCALLBACK_H_
- #include <uavcan/uavcan.hpp>
- #include <AP_HAL/CAN.h>
- #include <AP_HAL/Semaphores.h>
- #include <AP_Param/AP_Param.h>
- #include <uavcan/helpers/heap_based_pool_allocator.hpp>
- #include "AP_UAVCAN_Servers.h"
- #define Fault_ACK {0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
- #define TorqueMax 15000
- #define TorqueMin 500
- #define HVspeedMax 2200
- #define HVspeedMin 250
- #define Start 0x18
- #define Stop 0x20
- #define ELT_IDENTIFIER_POS 6U
- #define TYPE_POS 3U
- #define TYPE_DATA_8BIT (1U << TYPE_POS)
- #define TYPE_DATA_16BIT (2U << TYPE_POS)
- #define TYPE_DATA_32BIT (3U << TYPE_POS)
- #define TYPE_DATA_RAW (5U << TYPE_POS)
- /* TYPE_DATA_8BIT registers definition */
-
- #define MC_REG_STATUS ((1U << ELT_IDENTIFIER_POS) | TYPE_DATA_8BIT )
- #define MC_REG_CONTROL_MODE ((2U << ELT_IDENTIFIER_POS) | TYPE_DATA_8BIT )
- #define MC_REG_RUC_STAGE_NBR ((3U << ELT_IDENTIFIER_POS) | TYPE_DATA_8BIT )
-
- /* TYPE_DATA_16BIT registers definition */
- #define MC_REG_SPEED_KP ((2U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_SPEED_KI ((3U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_SPEED_KD ((4U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_Q_KP ((6 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_Q_KI ((7 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_Q_KD ((8 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_D_KP ((10 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_D_KI ((11 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_D_KD ((12 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_C1 ((13 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_C2 ((14 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOCORDIC_C1 ((15 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOCORDIC_C2 ((16 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_KI ((17 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_KP ((18 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_BUS_VOLTAGE ((22U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_HEATS_TEMP ((23U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_MOTOR_POWER ((24U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_A ((31U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_B ((32U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_ALPHA_MEAS ((33U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_BETA_MEAS ((34U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_Q_MEAS ((35U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_D_MEAS ((36U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_Q_REF ((37U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_D_REF ((38U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_V_Q ((39U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_V_D ((40U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_V_ALPHA ((41U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_V_BETA ((42U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_EL_ANGLE ((45U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_ROT_SPEED ((46U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_I_ALPHA ((47U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_I_BETA ((48U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_BEMF_ALPHA ((49U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_BEMF_BETA ((50U << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_SPEED_KP_DIV ((81 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_SPEED_KI_DIV ((82 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_SPEED_KD_DIV ((83 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_D_KP_DIV ((84 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_D_KI_DIV ((85 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_D_KD_DIV ((86 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_Q_KP_DIV ((87 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_Q_KI_DIV ((88 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_I_Q_KD_DIV ((89 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_KI_DIV ((99 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STOPLL_KP_DIV ((100 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_STARTUP_CURRENT_REF ((105 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
- #define MC_REG_PULSE_VALUE ((106 << ELT_IDENTIFIER_POS) | TYPE_DATA_16BIT )
-
- /* TYPE_DATA_32BIT registers definition */
- #define MC_REG_FAULTS_FLAGS ((0 << ELT_IDENTIFIER_POS) | TYPE_DATA_32BIT )
- #define MC_REG_SPEED_MEAS ((1 << ELT_IDENTIFIER_POS) | TYPE_DATA_32BIT )
- #define MC_REG_SPEED_REF ((2 << ELT_IDENTIFIER_POS) | TYPE_DATA_32BIT )
- #define MC_REG_STOPLL_EST_BEMF ((3 << ELT_IDENTIFIER_POS) | TYPE_DATA_32BIT ) /* To be checked shifted by >> 16*/
- #define MC_REG_STOPLL_OBS_BEMF ((4 << ELT_IDENTIFIER_POS) | TYPE_DATA_32BIT ) /* To be checked shifted by >> 16*/
-
- #define MC_REG_SPEED_RAMP ((6U << ELT_IDENTIFIER_POS) | TYPE_DATA_RAW )
- #define MC_REG_TORQUE_RAMP ((7U << ELT_IDENTIFIER_POS) | TYPE_DATA_RAW )
- #define MC_REG_REVUP_DATA ((8U << ELT_IDENTIFIER_POS) | TYPE_DATA_RAW ) /* Configure all steps*/
- #define MC_REG_CURRENT_REF ((13U << ELT_IDENTIFIER_POS) | TYPE_DATA_RAW )
- struct HVmes
- {
- int16_t voltage;
- int32_t speed;
- uint32_t fault;
- uint16_t state;
- int16_t power;
- int16_t temperature;
-
- };
- extern uint8_t hv_motor_cmd_temp ;
- extern uint8_t hv_motor_cmd;
- extern int16_t hv_motor_speed_32 ;
- void HVregs_v5y4(uint8_t _buffer[],int32_t data[]);
- void HVcycle(uint8_t _code,uint8_t _buffer[6],HVmes &Thruster);
- #endif
|