Skip to content

Commit

Permalink
Attempted Cleanup of ENABLE and REVERSE
Browse files Browse the repository at this point in the history
  • Loading branch information
jrickard committed Sep 17, 2014
1 parent 7c3ed3d commit e9bfdc2
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
31 changes: 15 additions & 16 deletions CodaMotorController.cpp
Expand Up @@ -4,8 +4,14 @@
* CAN Interface to the Coda flavored UQM Powerphase 100 inverter -
Handles sending of commands and reception of status frames to drive
the inverter and thus motor. Endianess is configurable in the firmware
inside the UQM inverter. This object module * uses little endian format
inside the UQM inverter but default is little endian. This object module * uses little endian format
- the least significant byte is the first in order with the MSB following.
**************NOTE***************
Ticks are critical for the UQM inverter. A tick value of 10000 in config.h is necessary as the inverter
expects a torque command within each 12 millisecond period. Failing to provide it is a bit subtle to catch
but quite dramatic. The motor will run at speed for about 5 to 7 minutes and then "cough" losing all torque and
then recovering. Five minutes later, this will repeat. Setting to a very fast value of 10000 seems to cure it NOW.
As the software grows and the load on the CPU increases, this could show up again.
*
Copyright (c) 2014 Jack Rickard
Expand Down Expand Up @@ -66,7 +72,7 @@ void CodaMotorController::setup()
// register ourselves as observer of all 0x20x can frames for UQM
CanHandler::getInstanceEV()->attach(this, 0x200, 0x7f0, false);

operationState=ENABLE;
operationState=ENABLE;
selectedGear=DRIVE;
running=true;
TickHandler::getInstance()->attach(this, CFG_TICK_INTERVAL_MOTOR_CONTROLLER_CODAUQM);
Expand Down Expand Up @@ -124,28 +130,21 @@ void CodaMotorController::handleCanFrame(CAN_FRAME *frame)
else {temperatureMotor = (StatorTemp-40)*10;}
Logger::debug("UQM 20E Inverter temp: %d Motor temp: %d", temperatureInverter,temperatureMotor);
break;


case 0x20F: //CAN Watchdog Status Message
Logger::debug("UQM 20F CAN Watchdog status error");
warning=true;
sendCmd2(); //If we get a Watchdog status, we need to respond with Watchdog reset
break;


}
}






void CodaMotorController::handleTick() {

MotorController::handleTick(); //kick the ball up to papa
sendCmd1(); //Send our torque command

sendCmd1(); //Send our lone torque command
}


Expand Down Expand Up @@ -211,15 +210,15 @@ void CodaMotorController::sendCmd1()
//Requested throttle is [-1000, 1000]
//Two byte torque request in 0.1NM Can be positive or negative

torqueCommand=32128; //Set our zero offset value
torqueRequested = ((throttleRequested * config->torqueMax) / 1000); //Calculate torque command
torqueCommand=32128; //Set our zero offset value -torque=0
torqueRequested = ((throttleRequested * config->torqueMax) / 1000); //Calculate torque request from throttle position x maximum torque
if(speedActual<config->speedMax){torqueCommand += torqueRequested;} //If actual rpm less than max rpm, add torque command to offset

output.data.bytes[3] = (torqueCommand & 0xFF00) >> 8;
else {torqueCommand+= torqueRequested/2;} //If at RPM limit, cut torque command in half.
output.data.bytes[3] = (torqueCommand & 0xFF00) >> 8; //Stow torque command in bytes 2 and 3.
output.data.bytes[2] = (torqueCommand & 0x00FF);
output.data.bytes[4] = genCodaCRC(output.data.bytes[1], output.data.bytes[2], output.data.bytes[3]);
output.data.bytes[4] = genCodaCRC(output.data.bytes[1], output.data.bytes[2], output.data.bytes[3]); //Calculate security byte

CanHandler::getInstanceEV()->sendFrame(output);
CanHandler::getInstanceEV()->sendFrame(output); //Mail it.
timestamp();

Logger::debug("Torque command: %X %X ControlByte: %X LSB %X MSB: %X CRC: %X %d:%d:%d.%d",output.id, output.data.bytes[0],
Expand Down
12 changes: 6 additions & 6 deletions DmocMotorController.cpp
Expand Up @@ -95,13 +95,13 @@ void DmocMotorController::handleCanFrame(CAN_FRAME *frame) {
RotorTemp = frame->data.bytes[0];
invTemp = frame->data.bytes[1];
StatorTemp = frame->data.bytes[2];
temperatureInverter = invTemp * 10 -400;
temperatureInverter = (invTemp-40) *10;
//now pick highest of motor temps and report it
if (RotorTemp > StatorTemp) {
temperatureMotor = RotorTemp * 10 -400;
temperatureMotor = (RotorTemp-40) *10;
}
else {
temperatureMotor = StatorTemp * 10 -400;
temperatureMotor = (StatorTemp-40) *10;
}
activityCount++;
break;
Expand Down Expand Up @@ -253,11 +253,11 @@ void DmocMotorController::sendCmd2() {
if (selectedGear == DRIVE)
torqueRequested = (((long) throttleRequested * (long) config->torqueMax) / 1000L);
if (selectedGear == REVERSE)
torqueRequested = (((long) throttleRequested * (long) config->torqueMax) / 2000L);
torqueRequested = (((long) throttleRequested * (long) config->torqueMax) / 1000L);
}

if(speedActual<config->speedMax){torqueCommand+=torqueRequested;} //If actual rpm is less than max rpm, add torque to offset
// else torque is left set to zero.
if(speedActual < config->speedMax){torqueCommand+=torqueRequested;} //If actual rpm is less than max rpm, add torque to offset
else {torqueCommand += torqueRequested /2;} // else torque is halved
output.data.bytes[0] = (torqueCommand & 0xFF00) >> 8;
output.data.bytes[1] = (torqueCommand & 0x00FF);
output.data.bytes[2] = output.data.bytes[0];
Expand Down
4 changes: 2 additions & 2 deletions MotorController.cpp
Expand Up @@ -326,13 +326,13 @@ void MotorController:: checkReverseInput()
{
if((getDigital(reverseinput))||testreverseinput)
{
selectedGear=REVERSE;
setSelectedGear(REVERSE);
statusBitfield2 |=1 << 16; //set bit to turn on REVERSE annunciator
statusBitfield2 |=1 << reverseinput;//setbit to Turn on reverse input annunciator
}
else
{
selectedGear=DRIVE; //If it's off, lets set to DRIVE.
setSelectedGear(DRIVE); //If it's off, lets set to DRIVE.
statusBitfield2 &= ~(1 << 16); //clear bit to turn off REVERSE annunciator
statusBitfield2 &= ~(1 << reverseinput);//clear bit to turn off reverse input annunciator
}
Expand Down
18 changes: 9 additions & 9 deletions config.h
Expand Up @@ -35,8 +35,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#include <due_can.h>

#define CFG_BUILD_NUM 1050 //increment this every time a git commit is done.
#define CFG_VERSION "GEVCU alpha 2014-08-19"
#define CFG_BUILD_NUM 1051 //increment this every time a git commit is done.
#define CFG_VERSION "GEVCU 2014-09-16"


/*
Expand All @@ -57,16 +57,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* try to use the same numbers for several devices because then they will share
* the same timer (out of a limited number of 9 timers).
*/
#define CFG_TICK_INTERVAL_HEARTBEAT 2000000
#define CFG_TICK_INTERVAL_POT_THROTTLE 40000
#define CFG_TICK_INTERVAL_CAN_THROTTLE 40000
#define CFG_TICK_INTERVAL_MOTOR_CONTROLLER 40000
#define CFG_TICK_INTERVAL_HEARTBEAT 2000000
#define CFG_TICK_INTERVAL_POT_THROTTLE 40000
#define CFG_TICK_INTERVAL_CAN_THROTTLE 40000
#define CFG_TICK_INTERVAL_MOTOR_CONTROLLER 40000
#define CFG_TICK_INTERVAL_MOTOR_CONTROLLER_DMOC 40000
#define CFG_TICK_INTERVAL_MOTOR_CONTROLLER_CODAUQM 10000
#define CFG_TICK_INTERVAL_MOTOR_CONTROLLER_BRUSA 20000
#define CFG_TICK_INTERVAL_MEM_CACHE 40000
#define CFG_TICK_INTERVAL_BMS_THINK 500000
#define CFG_TICK_INTERVAL_WIFI 200000
#define CFG_TICK_INTERVAL_MEM_CACHE 40000
#define CFG_TICK_INTERVAL_BMS_THINK 500000
#define CFG_TICK_INTERVAL_WIFI 200000


/*
Expand Down
11 changes: 5 additions & 6 deletions website/src/gauges.js
Expand Up @@ -45,19 +45,18 @@ function generateGauges() {
width : 250,
height : 250,
glow : true,
units : 'Percent',
units : 'Raw',
title : "Throttle",
minValue : -60,
maxValue : 100,
majorTicks : ['-60','-40','-20','0','20','40','60','80','100'],
minValue : 0,
maxValue : 3000,
majorTicks : ['0','300','600','900','1200','1500','1800','2100','2400','2700','3000'],
minorTicks : 2,
strokeTicks : false,
valueFormat : { "int" : 3, "dec" : 1 },


highlights : [
{ from : -60, to : 0, color : 'rgba(255, 0, 0, .75)' },
{ from : 0, to : 100, color : 'rgba(0, 255, 0, .75)' }
{ from : 0, to : 3000, color : 'rgba(0, 255, 0, .75)' }
],

colors : {
Expand Down
Binary file modified website/website.img
Binary file not shown.

0 comments on commit e9bfdc2

Please sign in to comment.