All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
smartmotor.h File Reference

A port of the smart motor library for ChibiOS/RT, header. More...

#include "ch.h"
#include "hal.h"
#include "vex.h"

Go to the source code of this file.

Data Structures

struct  smartMotor
 
struct  _smartController
 

Macros

#define kSmartMotorLibVersion   111
 
#define SMLIB_R_SYS   0.3
 
#define SMLIB_PWM_FREQ   1150
 
#define SMLIB_V_DIODE   0.75
 
#define SMLIB_I_FREE_393   0.2
 
#define SMLIB_I_STALL_393   4.8
 
#define SMLIB_RPM_FREE_393   110
 
#define SMLIB_R_393   (7.2/SMLIB_I_STALL_393)
 
#define SMLIB_L_393   0.000650
 
#define SMLIB_Ke_393   (7.2*(1-SMLIB_I_FREE_393/SMLIB_I_STALL_393)/SMLIB_RPM_FREE_393)
 
#define SMLIB_I_SAFE393   0.90
 
#define SMLIB_I_FREE_269   0.18
 
#define SMLIB_I_STALL_269   2.88
 
#define SMLIB_RPM_FREE_269   120
 
#define SMLIB_R_269   (7.2/SMLIB_I_STALL_269)
 
#define SMLIB_L_269   0.000650
 
#define SMLIB_Ke_269   (7.2*(1-SMLIB_I_FREE_269/SMLIB_I_STALL_269)/SMLIB_RPM_FREE_269)
 
#define SMLIB_I_SAFE269   0.75
 
#define SMLIB_I_SAFECORTEX   3.0
 
#define SMLIB_I_SAFEPE   3.0
 
#define SMLIB_TPR_269   240.448
 
#define SMLIB_TPR_393S   392
 
#define SMLIB_TPR_393T   627.2
 
#define SMLIB_TPR_QUAD   360.0
 
#define SMLIB_TPR_POT   6000.0
 
#define SMLIB_TEMP_AMBIENT   (( 72.0-32.0) * 5 / 9)
 
#define SMLIB_TEMP_TRIP   100.0
 
#define SMLIB_TEMP_HYST   10.0
 
#define SMLIB_TEMP_REF   25.0
 
#define SMLIB_I_HOLD_CORTEX   3.0
 
#define SMLIB_T_TRIP_CORTEX   1.7
 
#define SMLIB_K_TAU_CORTEX   0.5
 
#define SMLIB_TAU_CORTEX   (SMLIB_K_TAU_CORTEX * SMLIB_T_TRIP_CORTEX * 5.0 * 5.0)
 
#define SMLIB_C1_CORTEX   ( (SMLIB_TEMP_TRIP - SMLIB_TEMP_REF) / (SMLIB_I_HOLD_CORTEX * SMLIB_I_HOLD_CORTEX) )
 
#define SMLIB_C2_CORTEX   (1.0 / (SMLIB_TAU_CORTEX * 1000.0))
 
#define SMLIB_I_HOLD_393   1.0
 
#define SMLIB_T_TRIP_393   7.1
 
#define SMLIB_K_TAU_393   0.5
 
#define SMLIB_TAU_393   (SMLIB_K_TAU_393 * SMLIB_T_TRIP_393 * 5.0 * 5.0)
 
#define SMLIB_C1_393   ( (SMLIB_TEMP_TRIP - SMLIB_TEMP_REF) / (SMLIB_I_HOLD_393 * SMLIB_I_HOLD_393) )
 
#define SMLIB_C2_393   (1.0 / (SMLIB_TAU_393 * 1000.0))
 
#define SMLIB_I_HOLD_269   0.75
 
#define SMLIB_T_TRIP_269   2.0
 
#define SMLIB_K_TAU_269   0.5
 
#define SMLIB_TAU_269   (SMLIB_K_TAU_269 * SMLIB_T_TRIP_269 * 5.0 * 5.0)
 
#define SMLIB_C1_269   ( (SMLIB_TEMP_TRIP - SMLIB_TEMP_REF) / (SMLIB_I_HOLD_269 * SMLIB_I_HOLD_269) )
 
#define SMLIB_C2_269   (1.0 / (SMLIB_TAU_269 * 1000.0))
 
#define SMLIB_C1_3WIRE   SMLIB_C1_269
 
#define SMLIB_C2_3WIRE   SMLIB_C2_269
 
#define SMLIB_LEDON   0
 
#define SMLIB_LEDOFF   1
 
#define SMLIB_MOTOR_MAX_CMD   127
 
#define SMLIB_MOTOR_MIN_CMD   (-127)
 
#define SMLIB_MOTOR_DEFAULT_SLEW_RATE   10
 
#define SMLIB_MOTOR_FAST_SLEW_RATE   256
 
#define SMLIB_MOTOR_DEADBAND   10
 
#define SMLIB_MOTOR_MAX_CMD_UNDEFINED   255
 
#define SMLIB_TOTAL_NUM_CONTROL_BANKS   3
 
#define SMLIB_TOTAL_NUM_BANK_MOTORS   5
 
#define SMLIB_CORTEX_PORT_0   0
 
#define SMLIB_CORTEX_PORT_1   1
 
#define SMLIB_PWREXP_PORT_0   2
 
#define _SmartMotorGetPtr(index)   ((smartMotor *)&sMotors[ index ])
 
#define _SmartMotorControllerGetPtr(index)   ((smartController *)&sPorts[ index ])
 
#define SmartMotorsAddPowerExtender(p0,...)   _SmartMotorsAddPowerExtender( p0, ##__VA_ARGS__, -1, -1, -1 )
 
#define SmartMotorGetCurrent(index,...)   _SmartMotorGetCurrent( index, ##__VA_ARGS__, 0 )
 
#define SmartMotorSetLimitCurent(index,...)   _SmartMotorSetLimitCurent( index, ##__VA_ARGS__, 1.0 )
 
#define SmartMotorSetRpmSensor(index, port, ticks_per_rev,...)   _SmartMotorSetRpmSensor( index, port, ticks_per_rev, ##__VA_ARGS__, FALSE )
 
#define SetMotor(index, value,...)   _SetMotor( index, value, ##__VA_ARGS__, FALSE )
 

Typedefs

typedef struct _smartController smartController
 

Functions

void SmartMotorsInit (void)
 Initialize the smartMotor library. More...
 
void SmartMotorLinkMotors (tVexMotor master, tVexMotor slave)
 Link two motors. More...
 
void SmartMotorsSetEncoderGearing (tVexMotor index, float ratio)
 Set the encoder gearing. More...
 
void _SmartMotorsAddPowerExtender (int p0, int p1, int p2, int p3,...)
 Add a power extender to the system. More...
 
float SmartMotorGetSpeed (tVexMotor index)
 Get Motor speed. More...
 
float _SmartMotorGetCurrent (tVexMotor index, int s,...)
 Get Motor current. More...
 
float SmartMotorGetTemperature (tVexMotor index)
 Get Motor temperature. More...
 
int SmartMotorGetLimitCmd (tVexMotor index)
 Get Motor command limit. More...
 
float SmartMotorGetControllerCurrent (short index)
 Get Controller current. More...
 
float SmartMotorGetControllerTemperature (short index)
 Get Controller temperature. More...
 
void SmartMotorPtcMonitorEnable (void)
 Enable current limit by monitoring the PTC temperatures. More...
 
void SmartMotorPtcMonitorDisable (void)
 Disable current limit by monitoring the PTC temperatures. More...
 
void SmartMotorCurrentMonitorEnable (void)
 Enable current limit by using a preset threshold. More...
 
void SmartMotorCurrentMonitorDisable (void)
 Disable current limit by using a preset threshold. More...
 
void _SmartMotorSetLimitCurent (tVexMotor index, float current,...)
 Set Motor current limit. More...
 
void SmartMotorSetFreeRpm (tVexMotor index, short max_rpm)
 Set Motor maximum rpm. More...
 
void SmartMotorSetSlewRate (tVexMotor index, int slew_rate)
 Set Motor slew rate. More...
 
void SmartMotorRun (void)
 Start the smart motor monitoring. More...
 
void SmartMotorStop (void)
 Stop smart motor tasks. More...
 
void SmartMotorSetControllerStatusLed (int index, tVexDigitalPin port)
 Set Controller status LED. More...
 
void SmartMotorSetPowerExpanderStatusPort (tVexAnalogPin port)
 Set power expander status port. More...
 
void SmartMotorDebugStatus (void)
 Dump controller and motor status to the debug stream. More...
 
void _SmartMotorSetRpmSensor (tVexMotor index, tVexAnalogPin port, float ticks_per_rev, bool_t revesed,...)
 Assign (non encoder) sensor for rpm measurement. More...
 
void _SetMotor (int index, int value, bool_t immediate,...)
 Set motor to value. More...
 
smartMotorSmartMotorGetPtr (tVexMotor index)
 Get pointer to smartMotor structure - not used locally. More...
 
smartControllerSmartMotorControllerGetPtr (short index)
 Get pointer to smartController structure - not used locally. More...
 
void SmartMotorSpeed (smartMotor *m, int deltaTime)
 calculate speed in rpm for the motor More...
 
void SmartMotorSimulateSpeed (smartMotor *m)
 calculate a simulated speed in rpm for a motor More...
 
float SmartMotorCurrent (smartMotor *m, float v_battery)
 Estimate smart motor current. More...
 
float SmartMotorControllerCurrent (smartController *s)
 Calculate the current for a controller bank. More...
 
int SmartMotorSafeCommand (smartMotor *m, float v_battery)
 Calculate safe current command. More...
 
float SmartMotorTemperature (smartMotor *m, int deltaTime)
 Calculate the PTC temperature for a motor. More...
 
float SmartMotorControllerTemperature (smartController *s, int deltaTime)
 Calculate the PTC temperature for a controller bank. More...
 
void SmartMotorMonitorPtc (smartMotor *m, float v_battery)
 Monitor Motor PTC temperature. More...
 
void SmartMotorControllerMonitorPtc (smartController *s, float v_battery)
 Monitor controller bank PTC temperature. More...
 
void SmartMotorMonitorCurrent (smartMotor *m, float v_battery)
 Monitor Motor Current. More...
 
void SmartMotorControllerSetLed (smartController *s)
 Set the current monitor LED on or off. More...
 
msg_t SmartMotorTask (void *arg)
 The smart motor task. More...
 
msg_t SmartMotorSlewRateTask (void *arg)
 The motor slew rate task. More...
 

Detailed Description

A port of the smart motor library for ChibiOS/RT, header.

Macro Definition Documentation

#define kSmartMotorLibVersion   111
#define SMLIB_R_SYS   0.3
#define SMLIB_PWM_FREQ   1150
#define SMLIB_V_DIODE   0.75
#define SMLIB_I_FREE_393   0.2
#define SMLIB_I_STALL_393   4.8
#define SMLIB_RPM_FREE_393   110
#define SMLIB_R_393   (7.2/SMLIB_I_STALL_393)
#define SMLIB_L_393   0.000650
#define SMLIB_Ke_393   (7.2*(1-SMLIB_I_FREE_393/SMLIB_I_STALL_393)/SMLIB_RPM_FREE_393)
#define SMLIB_I_SAFE393   0.90
#define SMLIB_I_FREE_269   0.18
#define SMLIB_I_STALL_269   2.88
#define SMLIB_RPM_FREE_269   120
#define SMLIB_R_269   (7.2/SMLIB_I_STALL_269)
#define SMLIB_L_269   0.000650
#define SMLIB_Ke_269   (7.2*(1-SMLIB_I_FREE_269/SMLIB_I_STALL_269)/SMLIB_RPM_FREE_269)
#define SMLIB_I_SAFE269   0.75
#define SMLIB_I_SAFECORTEX   3.0
#define SMLIB_I_SAFEPE   3.0
#define SMLIB_TPR_269   240.448
#define SMLIB_TPR_393S   392
#define SMLIB_TPR_393T   627.2
#define SMLIB_TPR_QUAD   360.0
#define SMLIB_TPR_POT   6000.0
#define SMLIB_TEMP_AMBIENT   (( 72.0-32.0) * 5 / 9)
#define SMLIB_TEMP_TRIP   100.0
#define SMLIB_TEMP_HYST   10.0
#define SMLIB_TEMP_REF   25.0
#define SMLIB_I_HOLD_CORTEX   3.0
#define SMLIB_T_TRIP_CORTEX   1.7
#define SMLIB_K_TAU_CORTEX   0.5
#define SMLIB_TAU_CORTEX   (SMLIB_K_TAU_CORTEX * SMLIB_T_TRIP_CORTEX * 5.0 * 5.0)
#define SMLIB_C1_CORTEX   ( (SMLIB_TEMP_TRIP - SMLIB_TEMP_REF) / (SMLIB_I_HOLD_CORTEX * SMLIB_I_HOLD_CORTEX) )
#define SMLIB_C2_CORTEX   (1.0 / (SMLIB_TAU_CORTEX * 1000.0))
#define SMLIB_I_HOLD_393   1.0
#define SMLIB_T_TRIP_393   7.1
#define SMLIB_K_TAU_393   0.5
#define SMLIB_TAU_393   (SMLIB_K_TAU_393 * SMLIB_T_TRIP_393 * 5.0 * 5.0)
#define SMLIB_C1_393   ( (SMLIB_TEMP_TRIP - SMLIB_TEMP_REF) / (SMLIB_I_HOLD_393 * SMLIB_I_HOLD_393) )
#define SMLIB_C2_393   (1.0 / (SMLIB_TAU_393 * 1000.0))
#define SMLIB_I_HOLD_269   0.75
#define SMLIB_T_TRIP_269   2.0
#define SMLIB_K_TAU_269   0.5
#define SMLIB_TAU_269   (SMLIB_K_TAU_269 * SMLIB_T_TRIP_269 * 5.0 * 5.0)
#define SMLIB_C1_269   ( (SMLIB_TEMP_TRIP - SMLIB_TEMP_REF) / (SMLIB_I_HOLD_269 * SMLIB_I_HOLD_269) )
#define SMLIB_C2_269   (1.0 / (SMLIB_TAU_269 * 1000.0))
#define SMLIB_C1_3WIRE   SMLIB_C1_269
#define SMLIB_C2_3WIRE   SMLIB_C2_269
#define SMLIB_LEDON   0
#define SMLIB_LEDOFF   1
#define SMLIB_MOTOR_MAX_CMD   127
#define SMLIB_MOTOR_MIN_CMD   (-127)
#define SMLIB_MOTOR_DEFAULT_SLEW_RATE   10
#define SMLIB_MOTOR_FAST_SLEW_RATE   256
#define SMLIB_MOTOR_DEADBAND   10
#define SMLIB_MOTOR_MAX_CMD_UNDEFINED   255
#define SMLIB_TOTAL_NUM_CONTROL_BANKS   3
#define SMLIB_TOTAL_NUM_BANK_MOTORS   5
#define SMLIB_CORTEX_PORT_0   0
#define SMLIB_CORTEX_PORT_1   1
#define SMLIB_PWREXP_PORT_0   2
#define _SmartMotorGetPtr (   index)    ((smartMotor *)&sMotors[ index ])
#define _SmartMotorControllerGetPtr (   index)    ((smartController *)&sPorts[ index ])
#define SmartMotorsAddPowerExtender (   p0,
  ... 
)    _SmartMotorsAddPowerExtender( p0, ##__VA_ARGS__, -1, -1, -1 )
#define SmartMotorGetCurrent (   index,
  ... 
)    _SmartMotorGetCurrent( index, ##__VA_ARGS__, 0 )
#define SmartMotorSetLimitCurent (   index,
  ... 
)    _SmartMotorSetLimitCurent( index, ##__VA_ARGS__, 1.0 )
#define SmartMotorSetRpmSensor (   index,
  port,
  ticks_per_rev,
  ... 
)    _SmartMotorSetRpmSensor( index, port, ticks_per_rev, ##__VA_ARGS__, FALSE )
#define SetMotor (   index,
  value,
  ... 
)    _SetMotor( index, value, ##__VA_ARGS__, FALSE )
Examples:
clawbot.c.

Typedef Documentation

Function Documentation

void SmartMotorsInit ( void  )

Initialize the smartMotor library.

Initialize the smart motor library - This function must be called once when the program starts. Motors are automatically detected and assigned to the cortex banls, if a power expander is used then it should be added by using the SmartMotorsAddPowerExtender function after calling SmartMotorsInit

void SmartMotorLinkMotors ( tVexMotor  master,
tVexMotor  slave 
)

Link two motors.

Parameters
[in]masterThe master motor (usually with an encoder)
[in]slaveThe slave motor (usually un-encoded)

This lets us use encoder counts from one motor for another motor.

void SmartMotorsSetEncoderGearing ( tVexMotor  index,
float  ratio 
)

Set the encoder gearing.

Parameters
[in]indexThe motor index
[in]ratioThe gear ratio

If using a quad encoder then it may not be directly connected to the motor. This function allows a change of gearing by changing the ticks per rpm. Only call this function once per motor after calling init

ratio is encoder revs/motor revs

void _SmartMotorsAddPowerExtender ( int  p0,
int  p1,
int  p2,
int  p3,
  ... 
)

Add a power extender to the system.

Parameters
[in]p0The first power expander motor port
[in]p1The second power expander motor port
[in]p2The third power expander motor port
[in]p3The fourth power expander motor port

This function reassigns up to four motors to a power expander rather than ports on the cortex.

There is a macro SmartMotorsAddPowerExtender for ROBOTC compatibility

// the motor on port4 is assigned to the power expander
// three motors are assigned to the power expander
SmartMotorsAddPowerExtender( ArmMotorA, ArmMotorB, ArmMotorC );
float SmartMotorGetSpeed ( tVexMotor  index)

Get Motor speed.

Parameters
[in]indexThe motor index
Returns
The motor speed as rpm
float _SmartMotorGetCurrent ( tVexMotor  index,
int  s,
  ... 
)

Get Motor current.

Parameters
[in]indexThe motor index
[in]sSet as 1 for signed current otherwise absolute is returned
Returns
The motor current in amps
float SmartMotorGetTemperature ( tVexMotor  index)

Get Motor temperature.

Parameters
[in]indexThe motor index
Returns
The motor temperature in deg C
int SmartMotorGetLimitCmd ( tVexMotor  index)

Get Motor command limit.

Parameters
[in]indexThe motor index
Returns
The motor maximum command value
float SmartMotorGetControllerCurrent ( short  index)

Get Controller current.

Parameters
[in]indexThe motor controller index (0, 1 or 2)
Returns
The motor controller current in amps
float SmartMotorGetControllerTemperature ( short  index)

Get Controller temperature.

Parameters
[in]indexThe motor controller index (0, 1 or 2)
Returns
The motor controller temperature in deg C
void SmartMotorPtcMonitorEnable ( void  )

Enable current limit by monitoring the PTC temperatures.

void SmartMotorPtcMonitorDisable ( void  )

Disable current limit by monitoring the PTC temperatures.

void SmartMotorCurrentMonitorEnable ( void  )

Enable current limit by using a preset threshold.

void SmartMotorCurrentMonitorDisable ( void  )

Disable current limit by using a preset threshold.

void _SmartMotorSetLimitCurent ( tVexMotor  index,
float  current,
  ... 
)

Set Motor current limit.

Parameters
[in]indexThe motor index
[in]currentThe maximum motor current
Note
Do not use this function directly, instead use the macro SmartMotorSetLimitCurent which allows a default value for current of 1.0A
void SmartMotorSetFreeRpm ( tVexMotor  index,
short  max_rpm 
)

Set Motor maximum rpm.

Parameters
[in]indexThe motor index
[in]max_rpmThe maximum motor rpm
void SmartMotorSetSlewRate ( tVexMotor  index,
int  slew_rate 
)

Set Motor slew rate.

Parameters
[in]indexThe motor index
[in]slew_rateThe maximum motor slew_rate
void SmartMotorRun ( void  )

Start the smart motor monitoring.

After initialization the smart motor tasks need to be started

void SmartMotorStop ( void  )

Stop smart motor tasks.

void SmartMotorSetControllerStatusLed ( int  index,
tVexDigitalPin  port 
)

Set Controller status LED.

Parameters
[in]indexThe motor controller index (0, 1 or 2)
[in]portThe digital port that the led is connected to

This function allows an led to be assigned to a controller bank that is illuminated when any motor on that bank trips the ptc or exceeds the preset current limit

void SmartMotorSetPowerExpanderStatusPort ( tVexAnalogPin  port)

Set power expander status port.

Parameters
[in]portThe analog port for status from the power expander

This allows the battery voltage of the power expander to be monitored. Monitoring occurs after the ptc in the power expander so can be used to cut power to those motors if necessary.

void SmartMotorDebugStatus ( void  )

Dump controller and motor status to the debug stream.

void _SmartMotorSetRpmSensor ( tVexMotor  index,
tVexAnalogPin  port,
float  ticks_per_rev,
bool_t  reversed,
  ... 
)

Assign (non encoder) sensor for rpm measurement.

Parameters
[in]indexThe motor index
[in]portThe sensor port
[in]ticks_per_revticks per rovolution for this sensor
[in]reversedA bool indicating motor direction is reversed

This function can be used to assign any sensor to a motor for calculating rpm, the most likely situation would be a potentiometer. The parameter ticks_per_rev is the sensor change for one revolution of the motor, for example, a potentiometer with 1:1 gearing has about 6000 ticks_per_rev, if the gearing was 7:1 then this would be reduced to about 857. Set reversed to true if the potentiometer value decreases with positive motor command values.

void _SetMotor ( int  index,
int  value,
bool_t  immediate,
  ... 
)

Set motor to value.

Parameters
[in]indexThe motor index
[in]valueThe motor control value (speed)
[in]immediateIf TRUE then bypass the slew rate control

Set a new control value for the motor. This is the only call that should be used to change motor speed. Using vexMotorSet will completely bugger up the code - do not use it

The naming of this function is inconsistent with the rest of the library to allow backwards compatibility with team 8888's existing library

smartMotor* SmartMotorGetPtr ( tVexMotor  index)

Get pointer to smartMotor structure - not used locally.

Parameters
[in]indexThe motor index
smartController* SmartMotorControllerGetPtr ( short  index)

Get pointer to smartController structure - not used locally.

Parameters
[in]indexThe motor index
void SmartMotorSpeed ( smartMotor m,
int  deltaTime 
)

calculate speed in rpm for the motor

Parameters
[in]mPointer to smartMotor structure
[in]deltaTimeThe time in mS from the last call to this function
Warning
Internal smartMotorLibrary function, do not call, ref only
void SmartMotorSimulateSpeed ( smartMotor m)

calculate a simulated speed in rpm for a motor

Parameters
[in]mPointer to smartMotor structure
Warning
Internal smartMotorLibrary function, do not call, ref only
Note
We needed to do something for motors which do not have encoders and are also not coupled to another motor and able to share its encoder
float SmartMotorCurrent ( smartMotor m,
float  v_battery 
)

Estimate smart motor current.

Parameters
[in]mPointer to smartMotor structure
[in]v_batteryThe battery voltage in volts
Returns
The calculated current
Warning
Internal smartMotorLibrary function, do not call, ref only

Estimate current in Vex motor using vamfun's algorithm.
subroutine written by Vamfun...Mentor Vex 1508, 599.
7.13.2012 vamfu.nosp@m.n@ya.nosp@m.hoo.c.nosp@m.om... blog info http://vamfun.wordpress.com

Modified by James Pearman 7.28.2012.
Modified by James Pearman 10.1.2012 - more generalized code.

If cmd is positive then rpm must also be positive for this to work.

float SmartMotorControllerCurrent ( smartController s)

Calculate the current for a controller bank.

Parameters
[in]sA pointer to a smartController structure
Returns
The calculated current
Warning
Internal smartMotorLibrary function, do not call, ref only
int SmartMotorSafeCommand ( smartMotor m,
float  v_battery 
)

Calculate safe current command.

Parameters
[in]mPointer to smartMotor structure
[in]v_batteryThe battery voltage in volts
Returns
The calculated command value
Warning
Internal smartMotorLibrary function, do not call, ref only

Calculate a command for the motor which will result in a target current based on motor speed.

target_current should be set prior to calling the function and must be POSITIVE.

If command direction and rpm are not of the same polarity then this function tends to fallover due to back emf being of opposite direction to the drive direction. In this situation we have no choice but to let current go higher as the motor is changing directions and will in effect stall as it does through zero.

float SmartMotorTemperature ( smartMotor m,
int  deltaTime 
)

Calculate the PTC temperature for a motor.

Parameters
[in]mPointer to smartMotor structure
[in]deltaTimeThe time in mS from the last call to this function
Returns
The calculated ptc temperature
Warning
Internal smartMotorLibrary function, do not call, ref only
Note
math by vamfun
float SmartMotorControllerTemperature ( smartController s,
int  deltaTime 
)

Calculate the PTC temperature for a controller bank.

Parameters
[in]sPointer to smartController structure
[in]deltaTimeThe time in mS from the last call to this function
Returns
The calculated ptc temperature
Warning
Internal smartMotorLibrary function, do not call, ref only
Note
math by vamfun
void SmartMotorMonitorPtc ( smartMotor m,
float  v_battery 
)

Monitor Motor PTC temperature.

Parameters
[in]mPointer to smartMotor structure
[in]v_batteryThe battery voltage in volts
Warning
Internal smartMotorLibrary function, do not call, ref only

If the temperature is above the set point then calculate a command that will result in a safe current

void SmartMotorControllerMonitorPtc ( smartController s,
float  v_battery 
)

Monitor controller bank PTC temperature.

Parameters
[in]sPointer to smartController structure
[in]v_batteryThe battery voltage in volts
Warning
Internal smartMotorLibrary function, do not call, ref only

If the temperature is above the set point then calculate a commands for each motor that will result in a safe current.

void SmartMotorMonitorCurrent ( smartMotor m,
float  v_battery 
)

Monitor Motor Current.

Parameters
[in]mPointer to smartMotor structure
[in]v_batteryThe battery voltage in volts
Warning
Internal smartMotorLibrary function, do not call, ref only
void SmartMotorControllerSetLed ( smartController s)

Set the current monitor LED on or off.

Parameters
[in]sPointer to smartController structure
Warning
Internal smartMotorLibrary function, do not call, ref only

Turn on status LED if either controller ptc is tripped or any connected motors are tripped. LED is only turned on in this function as it may be shared between more then one controller. The LED is briefly turned off each loop around the calling task but only remains off for a very short period which is inperceptable.

msg_t SmartMotorTask ( void *  arg)

The smart motor task.

Parameters
[in]argpointer to user data (not used)
Note
Running a little different in this version, instead of a 100mS delay and then calculations on each motor we do one motor each iteration
msg_t SmartMotorSlewRateTask ( void *  arg)

The motor slew rate task.

Parameters
[in]argpointer to user data (not used)

Task - compares the requested speed of each motor to the actual speed and increments or decrements to reduce the difference as necessary