Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7e0b1c6
adding in linter w/ rules and step
RCMast3r Jan 5, 2025
6a48d29
added in check steps
RCMast3r Jan 5, 2025
b728f9c
updating clang / ide stuff
RCMast3r Jan 5, 2025
29b73b1
adding in linter w/ rules and step
RCMast3r Jan 5, 2025
c8e4f28
added in check steps
RCMast3r Jan 5, 2025
ab999fe
updating clang / ide stuff
RCMast3r Jan 5, 2025
79206ee
WIP: Fixing linter errors
jhwang04 Jan 6, 2025
4c027b4
Merge branch 'feature/linter_formatter' of github.com:hytech-racing/V…
RCMast3r Jan 6, 2025
9da3d5b
WIP: Fixing Linter errors
jhwang04 Jan 6, 2025
6a85a4b
Merge branch 'feature/linter_formatter' of github.com:hytech-racing/V…
RCMast3r Jan 6, 2025
72fb475
Updated code to abide by clangtidy rules
jhwang04 Jan 6, 2025
1896d4b
Merge branch 'feature/linter_formatter' of github.com:hytech-racing/V…
RCMast3r Jan 6, 2025
e4045dd
(feat) changed some more linting rules
RCMast3r Jan 6, 2025
5e6453e
adding in v2 for now
RCMast3r Jan 9, 2025
82b7724
progress on drivetrain system
RCMast3r Jan 11, 2025
c14d410
added reqs / todos
RCMast3r Jan 12, 2025
b83d447
working through more of the state machine
RCMast3r Jan 12, 2025
bf03f2d
added current docs for drivetrain state machine
RCMast3r Jan 13, 2025
93d08a1
new adds to drivetrain system
RCMast3r Jan 13, 2025
452100c
added more design docs to the drivetrain system
RCMast3r Jan 18, 2025
9adec30
added description for the inverter command messages
RCMast3r Jan 19, 2025
da5c80f
updated system and interface docs for inverter / drivetrain
RCMast3r Jan 20, 2025
015cd9f
updated inverter messaging
RCMast3r Jan 20, 2025
0ff34ec
adding in feedback types for the inverter interface
RCMast3r Jan 20, 2025
0fa1c43
working through state machine
RCMast3r Jan 21, 2025
0d560e3
adding in drivetrain system
RCMast3r Jan 22, 2025
e542af4
addressing linter errors
RCMast3r Jan 22, 2025
1b4110c
merging with main
RCMast3r Jan 22, 2025
e1d0932
Add Inverter Interface
KrishKittur Jan 26, 2025
dfead07
first stab at CAN interface
KrishKittur Jan 26, 2025
3f91ea0
Add library to ini and fix small build errors
KrishKittur Jan 26, 2025
6bba319
Changed CAN interface and updated inverter inverter interface with ne…
KrishKittur Jan 27, 2025
e57b664
merging main in
RCMast3r Feb 8, 2025
42aca00
changed inverter interface
KrishKittur Feb 13, 2025
40893fe
merge
KrishKittur Feb 13, 2025
296628d
builds
KrishKittur Feb 13, 2025
45d3f5b
pluh
KrishKittur Feb 13, 2025
d3d879c
drivetrain system inital rev w/o torque and speed modes
KrishKittur Feb 14, 2025
64da786
chill
KrishKittur Feb 14, 2025
ebea17e
add inverter params
KrishKittur Feb 14, 2025
f725a8d
Resolve PR comments
KrishKittur Feb 14, 2025
8480610
Updated the inverter interface to include new CAN descriptions
KrishKittur Feb 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/interfaces/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ below is the description of the control messages that will be configured within

- Control Input Message (will be attempted to be sent every 5ms, monitored by the inverter to be expected at least every 20ms)
- `int16_t speed_setpoint`
- __NOTE: active only when in speed control mode__
- AKA (`AMK_TargetVelocity`) / Special Signal index 6 / AKA 16-bit version of SERCOS parameter ID36 (unknown why this is 16 bit vs the 32 bit SERCOS parameter in manual)
- the RPM setpoint for the inverter in units of RPM.
- `int16_t positive_torque_limit`
Expand All @@ -33,10 +32,6 @@ below is the description of the control messages that will be configured within
- `int16_t negative_torque_limit`
- AKA (`AMK_TorqueLimitNegativ`) / SERCOS parameter ID83 / Special Signal index 14
- `positive_torque_limit` with a negative sign.
- `int16_t torque_setpoint`
- __NOTE: active only when in torque control mode.__
- AKA SERCOS parameter ID80 / Special Signal index 17
- the torque setpoint for the inverter in units of percentage as described in the `positive_torque_limit` message member above

- Control parameter message (will be sent intermitently, not monitored by the inverter to be expected at any regular period)
- `uint16_t speed_control_kp`
Expand Down
134 changes: 125 additions & 9 deletions lib/interfaces/include/InverterInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
#define INVERTERINTERFACE_H
#include <stdint.h>

#include "FlexCAN_T4.h"
#include "MessageQueueDefine.h"

#include <hytech.h>
#include "DrivetrainSystem.h"
#include <CANInterface.h>

namespace HTUnits
{
using celcius = float;
Expand All @@ -12,10 +19,56 @@ namespace HTUnits
using volts = float;
};

// for the most part these are mirrors of the lower-level CAN struct data, except with already fully float-ized data
struct InverterParams_s
{
float MINIMUM_HV_VOLTAGE;
};

/**
* Struct containing id info for this specific inverter interface
*/
struct InverterIds_s
{
uint32_t inv_control_word_id;
uint32_t inv_control_input_id;
uint32_t inv_control_parameter_id;
};

/**
* Drivetrain system accessible structs for
* requesting change of state
*/
struct InverterControlWord_s
{
bool inverter_enable : 1;
bool hv_enable : 1;
bool driver_enable : 1;
bool remove_error : 1;
};

struct InverterControlInput_s
{
int16_t speed_rpm_setpoint;
int16_t positive_torque_limit;
int16_t negative_torque_limit;
};

struct InverterControlParams_s
{
uint16_t speed_control_kp;
uint16_t speed_control_ki;
uint16_t speed_control_kd;
};

/**
* For the most part these are mirrors of the lower-level CAN struct data,
* except with already fully float-ized data
**/
struct InverterStatus_s
{
bool hv_present : 1;
bool connected : 1;
bool new_data : 1;
bool system_ready : 1;
bool error : 1;
bool warning : 1;
Expand All @@ -30,26 +83,30 @@ struct InverterStatus_s

struct InverterTemps_s
{
bool new_data : 1;
HTUnits::celcius motor_temp;
HTUnits::celcius inverter_temp;
HTUnits::celcius igbt_temp;
};

struct InverterPower_s
{
bool new_data : 1;
HTUnits::watts active_power;
HTUnits::var reactive_power;
};

struct MotorMechanics_s
{
bool new_data : 1;
HTUnits::watts actual_power;
HTUnits::torque_nm actual_torque;
HTUnits::speed_rpm actual_speed;
};

struct InverterControlParams_s
struct InverterControlFeedback_s
{
bool new_data : 1;
uint16_t speed_control_kp;
uint16_t speed_control_ki;
uint16_t speed_control_kd;
Expand All @@ -61,16 +118,75 @@ struct InverterFeedbackData_s
InverterTemps_s temps;
InverterPower_s power;
MotorMechanics_s motor_mechanics;
InverterControlParams_s control_params;
InverterControlFeedback_s control_feedback;
};

// struct InverterMotorControl_s
// {

// }

/**
* Inverter interface
*/
class InverterInterface
{

public:

InverterInterface(
CANBufferType *msg_output_queue,
uint32_t inv_control_word_id,
uint32_t inv_control_input_id,
uint32_t inv_control_params_id,
InverterParams_s inverter_params) : msg_queue_(msg_output_queue), _inverter_params(inverter_params)
{
inverter_ids.inv_control_word_id = inv_control_word_id;
inverter_ids.inv_control_parameter_id = inv_control_params_id;
inverter_ids.inv_control_input_id = inv_control_input_id;
}

// TODO un-public these (they are public for testing)

/* receiving callbacks */
void receive_INV_STATUS(CAN_message_t &can_msg);

void receive_INV_TEMPS(CAN_message_t &can_msg);

void receive_INV_DYNAMICS(CAN_message_t &can_msg);

void receive_INV_POWER(CAN_message_t &can_msg);

void receive_INV_FEEDBACK(CAN_message_t &can_msg);

/* Sending */
void send_INV_SETPOINT_COMMAND();

void send_INV_CONTROL_WORD();

void send_INV_CONTROL_PARAMS();

/* Inverter Functs */
void set_speed(float desired_rpm, float torque_limit_nm);

void set_idle();

void set_inverter_control_word(InverterControlWord_s control_word);

InverterStatus_s get_inverter_status();

private:

InverterIds_s inverter_ids;
InverterControlInput_s _inverter_control_inputs;
InverterControlWord_s _inverter_control_word;
InverterControlParams_s _inverter_control_params;
InverterFeedbackData_s _feedback_data;
InverterParams_s _inverter_params;

/* Getters */
InverterStatus_s get_status();
InverterTemps_s get_temps();
InverterPower_s get_power();
MotorMechanics_s get_motor_mechanics();
InverterControlFeedback_s get_control_params();

CANBufferType *msg_queue_;
};
#endif // __INVERTERINTERFACE_H__
#endif // __INVERTERINTERFACE_H__

8 changes: 8 additions & 0 deletions lib/interfaces/include/MessageQueueDefine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef MESAGE_QUEUE_DEFINE_H
#define MESAGE_QUEUE_DEFINE_H

#include "FlexCAN_T4.h"

using CANBufferType = Circular_Buffer<uint8_t, (uint32_t)128, sizeof(CAN_message_t)>;

#endif
13 changes: 13 additions & 0 deletions lib/interfaces/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "interfaces-lib",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"can_lib": "*",
"shared_data": "*",
"CASE_lib": "*",
"nanopb": "*"
},
"frameworks": "*",
"platforms": "*"
}
Loading
Loading