SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
MC Namespace Reference

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

Functions

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

Detailed Description

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

Function Documentation

◆ enableMotorBeating()

void MC::enableMotorBeating ( bool  enable)

Start MC heartbeat function, establishing a connection with the MCs.

Parameters
enable

◆ getLastBrakeValue()

int MC::getLastBrakeValue ( )

Get the last brake value that was internally used.

Returns
int the last brake value that was internally used

◆ getLastPedalValue()

int MC::getLastPedalValue ( void  )

Get the last pedal value that was internally used.

Returns
int the last pedal value that was internally used

◆ getLastSteerValue()

int MC::getLastSteerValue ( )

Get the last steer value that was internally used.

Returns
int the last steer value that was internally used

◆ getLastTorqueValue()

int MC::getLastTorqueValue ( bool  mc0)

Get the last torque percent value sent to a MC.

Parameters
mc0return the value for MC0, otherwise MC1
Returns
int the last torque percent value that was sent

◆ isForward()

bool MC::isForward ( void  )

Get whether the motors will spin forward.

Returns
true The motors will spin forward
false The motors will spin in reverse

◆ motorSpeed()

int32_t MC::motorSpeed ( int  motor = -1)

Get the avg motorspeed.

Parameters
motor0 or 1 for either motor or nothing for
Returns
int32_t

◆ sendTorque()

void MC::sendTorque ( uint32_t  MC_ADD,
int  torque,
bool  direction,
bool  enableBit 
)

Send a raw torque command to a MC.

Note
enableMotorBeating must have been set to false before calling this function
Parameters
MC_ADDThe specific motor controller address
torqueThe torque to set the motor at
directiondirection of the motor
enableBitwhether the motor should be enabled

◆ setDirection()

void MC::setDirection ( bool  runForward)

Set the direction of the motors.

Parameters
runForwardwhether the motors should spin forwards

◆ setTorque()

void MC::setTorque ( int  pedal,
int  brake,
int  steer 
)

Calculate and set the torque of both MCs.

Note
enableMotorBeating must have been set to false before calling this function
Parameters
pedalThe raw value of the pedal
brakeThe raw value of the brake
steerThe raw value of the steering wheel