SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
MotorControl.h
Go to the documentation of this file.
1
23#ifndef __ECU_MOTORCONTROL_H__
24#define __ECU_MOTORCONTROL_H__
25
26#include "Canbus.h"
27#include "Heartbeat.h"
28#include "stdint.h"
29
34namespace MC {
35
39#define CONF_MAXIMUM_SWITCHING_SPEED 5
40
44void setup(void);
45
49void setupBuffers(void);
50
54void clearFaults(void);
55
61void enableMotorBeating(bool enable);
62
73void sendTorque(uint32_t MC_ADD, int torque, bool direction, bool enableBit);
74
80void setDirection(bool runForward);
81
88bool isForward(void);
89
96int getLastTorqueValue(bool mc0);
97
104
111
118
125int32_t motorSpeed(int motor = -1);
126
136void setTorque(int pedal, int brake, int steer);
137
138} // namespace MC
139
140// Add reverse control
141#endif // __ECU_MOTORCONTROL_H__
FlexCAN_T4 wrapper.
Make one ECU tell the other it is alive.
Methods used to more easily interface with RMS Motor controllers over CAN bus.
void sendTorque(uint32_t MC_ADD, int torque, bool direction, bool enableBit)
Send a raw torque command to a MC.
void setTorque(int pedal, int brake, int steer)
Calculate and set the torque of both MCs.
int getLastSteerValue()
Get the last steer value that was internally used.
int getLastBrakeValue()
Get the last brake value that was internally used.
void setDirection(bool runForward)
Set the direction of the motors.
void setupBuffers(void)
Only initialize MC buffers, called by MC::setup.
bool isForward(void)
Get whether the motors will spin forward.
int getLastTorqueValue(bool mc0)
Get the last torque percent value sent to a MC.
int getLastPedalValue(void)
Get the last pedal value that was internally used.
int32_t motorSpeed(int motor=-1)
Get the avg motorspeed.
void enableMotorBeating(bool enable)
Start MC heartbeat function, establishing a connection with the MCs.
void clearFaults(void)
Clear MC faults by sending a clear fault command.
void setup(void)
Initialize MC heartbeat function and clear faults, if any.