SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
MotorControl.h File Reference

Motor Controller module. More...

#include "Canbus.h"
#include "Heartbeat.h"
#include "stdint.h"

Go to the source code of this file.

Namespaces

namespace  MC
 Methods used to more easily interface with RMS Motor controllers over CAN bus.
 

Macros

#define CONF_MAXIMUM_SWITCHING_SPEED   5
 The maximum speed value that the car can be moving before it switches between forwards and reverse.
 

Functions

void MC::setup (void)
 Initialize MC heartbeat function and clear faults, if any.
 
void MC::setupBuffers (void)
 Only initialize MC buffers, called by MC::setup.
 
void MC::clearFaults (void)
 Clear MC faults by sending a clear fault command.
 
void MC::enableMotorBeating (bool enable)
 Start MC heartbeat function, establishing a connection with the MCs.
 
void MC::sendTorque (uint32_t MC_ADD, int torque, bool direction, bool enableBit)
 Send a raw torque command to a MC.
 
void MC::setDirection (bool runForward)
 Set the direction of the motors.
 
bool MC::isForward (void)
 Get whether the motors will spin forward.
 
int MC::getLastTorqueValue (bool mc0)
 Get the last torque percent value sent to a MC.
 
int MC::getLastPedalValue (void)
 Get the last pedal value that was internally used.
 
int MC::getLastBrakeValue ()
 Get the last brake value that was internally used.
 
int MC::getLastSteerValue ()
 Get the last steer value that was internally used.
 
int32_t MC::motorSpeed (int motor=-1)
 Get the avg motorspeed.
 
void MC::setTorque (int pedal, int brake, int steer)
 Calculate and set the torque of both MCs.
 

Detailed Description

Motor Controller module.

Author
IR
Version
0.1
Date
2021-05-04

This module is a collection of functions that are used to ease the control of both Motor controllers over canbus.

The Motor controllers require a periodic message to be send when it is not being actively controlled, This is mainly controlled with MC::enableMotorBeating()

It is important to be aware of delays in code as if the Motors controllers do not receive a value in time, they will fault.

Faults can, however, be cleared by using MC::clearFaults()

See also
Faults.h for more info on viewing faults

Definition in file MotorControl.h.

Macro Definition Documentation

◆ CONF_MAXIMUM_SWITCHING_SPEED

#define CONF_MAXIMUM_SWITCHING_SPEED   5

The maximum speed value that the car can be moving before it switches between forwards and reverse.

Definition at line 39 of file MotorControl.h.