Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Classes | Functions | Variables
Inverter.h File Reference
#include "../ExternalSystem.h"
#include "../Controller/TorqueControl.h"
#include "../../Utils/Constants.h"
Include dependency graph for Inverter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Inverter
 

Functions

void initInverter (Inverter *inverter, TorqueControl *tc, int hz, int maxCurrent, int maxTemp, int maxVoltage)
 Initializes the Inverter with initial settings. More...
 
int startInverter (Inverter *inverter)
 Starts the Inverter. More...
 
int updateInverter (ExternalSystem *external)
 Updates the Inverter. More...
 
int checkInverterHeartbeat (void *self)
 Checks the heartbeat of the Inverter. More...
 

Variables

uint32_t dac1_buffer [DAC1_BUFFER_SIZE]
 

Function Documentation

◆ checkInverterHeartbeat()

int checkInverterHeartbeat ( void *  self)

Checks the heartbeat of the Inverter.

Parameters
selfA pointer to the Inverter structure.
Returns
int _SUCCESS or _FAILURE.

Definition at line 33 of file Inverter.c.

33 {
34 Inverter* inverter = (Inverter*)self;
35 // Check if the inverter is still alive
36 return _SUCCESS;
37}
#define _SUCCESS
Definition: Common.h:5
Here is the caller graph for this function:

◆ initInverter()

void initInverter ( Inverter inverter,
TorqueControl tc,
int  hz,
int  maxCurrent,
int  maxTemp,
int  maxVoltage 
)

Initializes the Inverter with initial settings.

Parameters
inverterA pointer to the Inverter structure.
tcA pointer to the TorqueControl structure.
hzRate at which the inverter is called (in hz).
maxCurrentThe maximum current limit set for the inverter.
maxTempThe maximum temperature limit set for the inverter.
maxVoltageThe maximum voltage limit set for the inverter.

Definition at line 6 of file Inverter.c.

6 {
7 initExternalSystem(&inverter->base, "Inverter", hz, e_INVERTER, updateInverter, checkInverterHeartbeat, inverter);
8 inverter->tc = tc;
9 inverter->maxCurrent = maxCurrent;
10 inverter->maxTemp = maxTemp;
11 inverter->maxVoltage = maxVoltage;
12}
void initExternalSystem(ExternalSystem *external, const char *name, int hz, ExternalType type, int(*updateExternal)(ExternalSystem *external), int(*check_heartbeat)(void *self), void *child)
Definition: ExternalSystem.c:6
@ e_INVERTER
int checkInverterHeartbeat(void *self)
Checks the heartbeat of the Inverter.
Definition: Inverter.c:33
int updateInverter(ExternalSystem *external)
Updates the Inverter.
Definition: Inverter.c:14
int maxCurrent
Definition: Inverter.h:11
ExternalSystem base
Definition: Inverter.h:9
int maxVoltage
Definition: Inverter.h:13
TorqueControl * tc
Definition: Inverter.h:10
int maxTemp
Definition: Inverter.h:12
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startInverter()

int startInverter ( Inverter inverter)

Starts the Inverter.

Parameters
inverterA pointer to the Inverter structure.
Returns
int _SUCCESS or _FAILURE.

◆ updateInverter()

int updateInverter ( ExternalSystem external)

Updates the Inverter.

Parameters
externalA pointer to the Inverter ExternalSystem.
Returns
int _SUCCESS or _FAILURE.

Definition at line 14 of file Inverter.c.

14 {
15 Inverter* inverter = (Inverter*)external->child;
16 // Check if torque control is validated
17 if (inverter->tc->base.state != c_validated) {
18 printf("Inverter: Torque Control Actuator is not validated\r\n");
19 return _FAILURE;
20 }
21
22
23 #ifdef DEBUGn
24 printf("Inverter updated. Torque: %f, Current: %d, Temp: %d, Voltage: %d\r\n",
25 inverter->tc->desiredTorque, inverter->maxCurrent, inverter->maxTemp, inverter->maxVoltage);
26 #endif
27
28 dac1_buffer[0] = ((inverter->tc->desiredTorque) / (inverter->tc->maxAllowedTorque)) * 4096.0;
29
30 return _SUCCESS;
31}
uint32_t dac1_buffer[DAC1_BUFFER_SIZE]
Definition: main.c:116
#define _FAILURE
Definition: Common.h:6
@ c_validated
ControllerState state
ControllerSystem base
Definition: TorqueControl.h:19
float maxAllowedTorque
Definition: TorqueControl.h:22
float desiredTorque
Definition: TorqueControl.h:21
Here is the caller graph for this function:

Variable Documentation

◆ dac1_buffer

uint32_t dac1_buffer[DAC1_BUFFER_SIZE]
extern

Definition at line 116 of file main.c.