Lil' Blackbox

Coding => v1.0 - v1.1 => Topic started by: me78569 on June 11, 2015, 09:38:57 AM

Title: HE351 code for me78569
Post by: me78569 on June 11, 2015, 09:38:57 AM
Alright, I have my code tabbed but this should reflect what I am working with.  I haven't had a chance to really narrow down the issue much, so don't spend too much time digging until I figure out the issue better.

Issue:  With the pot active I get a rapid cycling from 0 to desired position.  When the truck is sitting at 0 psi without the pot active it sits right at the commanded position.   I very well could have a wiring issue in the pot that is causing issues.

This afternoon I am going to connect the spare pots to the boost and drive sensors and test what happens when psi raises above 0 to verify that the issue is limited to the pot functions.  I will also test the EB code and verify that I am not having issues there also.

I will update the thread once I do some of the basic testing to verify the issue and try to narrow it down.


/*This code is to help get you started controlling your
HE351VE Variable Geometry Turbo. The whole program is
controlled through void loop(). This is where you can
add your own code or uncomment different sections of code
that I have put together. This is covered by the GNU License*/

#include <SPI.h>
#include <can.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// Defines for setting up the CAN Bus
#define mode NORMAL // define CAN mode
#define bitrate 250 // define CAN speed (bitrate)
MCP CAN1(10); //Create CAN Channel
//J1939 message; // Create message object to use J1939 message structure
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

// Pin Assignments on UNO
#define BoostPressurePin A0
#define ExhaustPressurePin A1
#define PotentiometerPin A2
#define ThrottlePositionPin A3
#define Switch 2
#define EBSwitch 12


#define NumEntries 14
// The first number is the boost sensor reading, and the second number is the desired vein position
// remember usable vien position range from 140-960
int BoostMap[NumEntries][2] = {{10,235},{11.5,244},{13,253},{14.5,280},
{16,308},{17.5,308},{19,363},{20.5,390},{22,418},{23.5,459},{25,500},{26.5,550},
{28,600},{29.5,650}};  //,{31,700},{32.5,750},{34,800},{35.5,850},{37,900},{38.5,950},{40,970}}; DPManage takes care of the veins after 30psi. 


  // Variables to read sensors
  int MaxExhaustPressure = 50; //Set desired max exhuast back pressure
  int ExPrsBuffer = 10; //set the point at which the system starts to manage IE: maxehaustpressure - exprsbuffer
  byte EBCalibrate = 2;
  int PotentiometerValue = 0;
  int ExhaustPressure = 0;
  int BoostPressure = 0;
  int ThrottlePosition = 0;
  boolean SwitchPosition = false;
  boolean EBSwitchPosition = false;
//  const int analogDelay = 1;

  // Value to Send Position
  int DesiredPosition = 0;

  // Variables to use within Code
  int JumpSize = 50;
  int MinVeinPos = 235;

  //Variables for LCD
  long LCDLastUpdate = 0;
  int Line1Last = 0;
  int LCDUpdateRate = 200;
 
// Exhaustpressure Average variables
  const int ExtnumReadings = 4;      // number of reads to do.
  int Extreadings[ExtnumReadings];      // the readings from the analog input
  int Extindex = 0;                  // the index of the current reading
  int Exttotal = 0;                  // the running total
  int Extaverage = 0;                // the average
 
  //  Boostpressure Average variables
  const int BstnumReadings = 4;      // number of reads to do.
  int Bstreadings[BstnumReadings];      // the readings from the analog input
  int Bstindex = 0;                  // the index of the current reading
  int Bsttotal = 0;                  // the running total
  int Bstaverage = 0;                // the average


///////////////////////will run once at startup//////////////////////////////////////////// 
  void setup()
{
  // Initialize Serial communications with computer to use serial monitor
  Serial.begin(115200);
  lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines and turn on backlight
  //Set CAN mode and speed
  CAN1.begin(mode, bitrate);

  // Setup Switch
  pinMode(Switch, INPUT_PULLUP); //configure switch to use internal pullup resistor
  pinMode(EBSwitch, INPUT_PULLUP); //configure EBswitch to use internal pullup resistor
  //Running exhaust average
    for (int ExtthisReading = 0; ExtthisReading < ExtnumReadings; ExtthisReading++)
    Extreadings[ExtthisReading] = 0;
  //Running Boost averag
    for (int BstthisReading = 0; BstthisReading < BstnumReadings; BstthisReading++)
    Bstreadings[BstthisReading] = 0;
   
//-------- Write characters on the display ----------------
// NOTE: Cursor Position: CHAR, LINE) start at 0 
  lcd.setCursor(2,0); //Start at character 4 on line 0
  lcd.print("Starting HE351VE");
  lcd.setCursor(5,1);
  lcd.print("Controller");
  lcd.setCursor(4,2);
  lcd.print("Will Display ");
  lcd.setCursor(0,3); 
  lcd.print("Boost,Drive,Position");
  delay(4000);
  lcd.clear();
  lcd.setCursor(4,0); //Start at character 4 on line 0
  lcd.print("Cycling Vein");
  lcd.setCursor(6,1);
  lcd.print("Position");
  lcd.setCursor(3,3);
  lcd.print("Wait To Start!");
  delay(2000);
  lcd.clear();
  SendTurboPosition (140);
  lcd.clear();
  lcd.setCursor(4,0); //Start at character 4 on line 0
  lcd.print("Cycling Vein");
  lcd.setCursor(6,1);
  lcd.print("Position");
  lcd.setCursor(3,3);
  lcd.print("Wait To Start!");
  delay(500);
  SendTurboPosition (140);
  lcd.clear();
  lcd.setCursor(4,0); //Start at character 4 on line 0
  lcd.print("Cycling Vein");
  lcd.setCursor(6,1);
  lcd.print("Position");
  lcd.setCursor(3,3);
  lcd.print("Wait To Start!");
  delay(500);
  SendTurboPosition (140);
  lcd.clear();
  lcd.setCursor(4,0); //Start at character 4 on line 0
  lcd.print("Cycling Vein");
  lcd.setCursor(6,1);
  lcd.print("Position");
  lcd.setCursor(3,3);
  lcd.print("Wait To Start!");
  delay(500);
  lcd.clear();
  lcd.setCursor(8,2);
  lcd.print("Done!");
  delay(1000);
  lcd.clear();

}


/////////////////// Main loops that chooses what to do.////////////////////////////////////////////
void loop()
  {
    // Read Sensors
    // Uncomment the Sensors that you have connected
    // There functions will need to be calibrated to the sensor.
    PotentiometerValue = ReadPotentiometer();
    ExhaustPressure = ReadExhaustPressure();   
    BoostPressure = ReadBoostPressure();   
    ThrottlePosition = ReadThrottlePosition();
    SwitchPosition = digitalRead(Switch);
    EBSwitchPosition = digitalRead(EBSwitch);


    {

    if ( SwitchPosition == HIGH && EBSwitchPosition == HIGH && BoostPressure >= 30)
      DPManage (); //set vein position based on boostmap
       
    else if (SwitchPosition != HIGH) // && ThrottlePosition < 30) //Disabled TPS input for testing
      PotManage ();  //vein position is pot value

    else if (EBSwitchPosition != HIGH && SwitchPosition == HIGH) // && ThrottlePosition < 1.5 )  //Disabled TPS input for testing
      EBManage (); //If below %1.5 then engage Exhaust brake and regulate the exhaust pressure.
               
    else DesiredPosition = BoostVeinPosCalc( BoostPressure );
    }

    // Set the Turbo Position
    SendTurboPosition( DesiredPosition );
    UpdateLCD();
    // Delay for Processor
    delay(2);
   
  }


////////////////////////////////Read Sensors//////////////////////////////////////////////
//Define the sensor type and range. (Namefromabove, 0v, 5v, 0v=minpos,5v=maxposition)

int ReadBoostPressure(){    //Works good but seems to be slower.
  Bsttotal = Bsttotal - Bstreadings[Bstindex]; // subtract the last reading:       
  Bstreadings[Bstindex] = analogRead(BoostPressurePin); // read from the sensor:
  Bsttotal= Bsttotal + Bstreadings[Bstindex];   // add the reading to the total:   
  Bstindex = Bstindex + 1;    // advance to the next position in the array:                 
  if (Bstindex >= BstnumReadings)    // if we're at the end of the array...         
    Bstindex = 0;    // ...wrap around to the beginning:                       
  Bstaverage = Bsttotal >> 2; // / BstnumReadings;    // calculate the average:     
  return map( Bstaverage, 83, 920, 0, 100); // Last two values are the psi range of the chosen sensor
  delay(1);        // delay in between reads for stability
}

int ReadExhaustPressure(){    //Works good but seems to be slower.
  Exttotal = Exttotal - Extreadings[Extindex]; // subtract the last reading:       
  Extreadings[Extindex] = analogRead(ExhaustPressurePin); // read from the sensor:
  Exttotal = Exttotal + Extreadings[Extindex];   // add the reading to the total:   
  Extindex = Extindex + 1;    // advance to the next position in the array:                 
  if (Extindex >= ExtnumReadings)    // if we're at the end of the array...         
    Extindex = 0;    // ...wrap around to the beginning:                       
  Extaverage = Exttotal >>2; // / ExtnumReadings;    // calculate the average:     
  return map( Extaverage, 83, 920, 0, 100); // Last two values are the psi range of the chosen sensor
  delay(1);        // delay in between reads for stability
}

int ReadThrottlePosition(){
int ThrottleVal = analogRead( ThrottlePositionPin );
return map ( ThrottleVal, 103, 920, 0, 100); // read the value from the sensor

}
int ReadPotentiometer(){
int PotVal = analogRead( PotentiometerPin );//(tmp + analogRead( PotentiometerPin )) / 2;
return map(PotVal, 0, 1023, 0, 970); // read the value from the sensor
}


////////////////////////////////////DP manage////////////////////////////////////////
//Manages DP to try and stay at or below 50psi drive while about 30psi boost.  veins will stay between 650 and 970 position
void DPManage (){

int Difference = (ExhaustPressure-MaxExhaustPressure); //set a buffer make sure max ex press doesn't get hit.

Difference = (Difference / EBCalibrate); // I used / rather than * as the * ended up applying too fast. the turbo was "snapping" open and closed
DesiredPosition += max(Difference, -10);//This way it doesn't close the veins to fast
DesiredPosition = constrain(DesiredPosition, 650, 970);
}


/////////////////////////////EB Manage////////////////////////////////////////
//Manages the apply of the EB
void EBManage(){

int Difference = (ExhaustPressure-MaxExhaustPressure); //set a buffer make sure max ex press doesn't get hit.

Difference = (Difference / EBCalibrate); // I used / rather than * as the * ended up applying too fast. the turbo was "snapping" open and closed
DesiredPosition += max(Difference, -10);//This way it doesn't close the veins to fast
DesiredPosition = constrain(DesiredPosition, 0,235);

}


//////////////////////////Pot Manage/////////////////////////////////////////////////
//Ensure Pot doesn't cause Drive pressure to go over the maxexhaustpressure **look at more

void PotManage (){
int Rate = 11; // added to make ManageRate grow as exhaust pressure rises to max and above.
int PotBuff = 10;   //amount to buffer the vein position before maxexhaust is reached when in pot mode
int ManageRate = ((ExhaustPressure - MaxExhaustPressure)+Rate);

if (ExhaustPressure < (MaxExhaustPressure-PotBuff))
   DesiredPosition = PotentiometerValue;
   
else if (ExhaustPressure >= (MaxExhaustPressure-PotBuff))
   DesiredPosition = (PotentiometerValue +(JumpSize * ManageRate));
   DesiredPosition = constrain(DesiredPosition, 0, 970);
}


///////////////////////////Vein Position send/////////////////////////////
// Function to calculate turbo vein position
  int BoostVeinPosCalc( int BoostPressureVal )
  {
    int VeinPosition = BoostMap[0][1];
    for(byte i=0;(BoostPressureVal > BoostMap[i][0]) && (i<NumEntries); i++)
    {
      VeinPosition = BoostMap[i][1];
    }

    return VeinPosition;
  }

// Function to Send the Calculated Position to the Turbo
void SendTurboPosition(int TurboPosition)
{
  int FinalPosition = map( TurboPosition, 0, 1023, 999, 0);
  byte lobyte = lowByte(FinalPosition);
  byte hibyte = highByte(FinalPosition);
  unsigned long ID = 0x0CFFC600; // Random Extended Message ID
  byte length = 8; // Data length
  byte data[] = { lobyte, hibyte, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // data message with an added counter
  CAN1.send ( ID, extID, length, data ); // Load message and send

}


///////////////////BarGraph////////////////////////////////////////////////////

void BarGraph(int Line, int oldBars, int Bars, int Value, String Name)
//Line, which line on the LCD are we changing.
//Bars, number of pixcels long the BaGraph is going to show
//oldBars, number of Bars that this Line had lastt time
//Value, what's the value we should print to the lcd
//Name, the Name we should call this Line

{
int GraphStartPoint = 11;//what cell does the graph start on on the lcd screen

if (oldBars != Bars){ // if nothing changed then skip this function
int oldBlocks = (oldBars / 5);
int blocks = (Bars / 5);
int singles = (Bars - (blocks * 5));
if(blocks > oldBlocks)
{
for(int x = oldBlocks; blocks > x; x++){
lcd.setCursor((x + GraphStartPoint), Line);
lcd.write(1023);
}}

else if(blocks < oldBlocks)
{
for(int x = oldBlocks; blocks <= x; x--){
lcd.setCursor((x + GraphStartPoint), Line);
lcd.print(" ");
//Serial.println(E1);
}}
if ((oldBars - oldBlocks) != singles) {//if the number of singles has changed display the new singles
  lcd.setCursor((blocks + GraphStartPoint),Line);
  lcd.write(singles);
}
}
  lcd.setCursor(GraphStartPoint - 4, Line);
String TurboPos = String(Value, DEC);
if(Value < 1000) TurboPos += " ";
  lcd.print(TurboPos);
  lcd.setCursor(0, Line);
  lcd.print(Name);
}


///////////////////////////////LCD/////////////////////////////////////////
void UpdateLCD(){

  if ((millis() - LCDLastUpdate) >= LCDUpdateRate){
    LCDLastUpdate = millis();
    int Line1Bars = map(DesiredPosition, 0, 1023, 0, 40);//map the value to a 0-50 value.
BarGraph(0, Line1Last, Line1Bars, DesiredPosition, "Turbo");
Line1Last = Line1Bars;
float DrivePressRatio = (ExhaustPressure / BoostPressure);
DrivePressRatio = constrain(DrivePressRatio, 0, 9.9);
String Boost = String("Boost " + String(BoostPressure, DEC) + ' ');
String Drive = String("Drive " + String(ExhaustPressure, DEC) + ' ');
String DtoBRatio = String("DtoB Ratio " + String(DrivePressRatio) + ":1");
       lcd.setCursor(0, 2);
       lcd.print(Boost);
       lcd.setCursor(10, 2);
       lcd.print(Drive);
       if (BoostPressure <= 0){
         lcd.setCursor(0, 3);
         lcd.print("DtoB Ratio 1.00:1");
       }
       else {
         lcd.setCursor(0, 3);
         lcd.print(DtoBRatio);
       }
       if (EBSwitchPosition != HIGH && SwitchPosition == HIGH)
       {
         lcd.setCursor(4, 1);
         lcd.print("!EB  Active!");
       }
       else if (SwitchPosition != HIGH && ThrottlePosition < 30)
       {
         lcd.setCursor(4, 1);
         lcd.print("!Pot Active!");
       }
       else {
         lcd.setCursor(4,1);
         lcd.print("            ");
       }
       

    }
}


Title: Re: HE351 code for me78569
Post by: me78569 on June 11, 2015, 09:39:06 AM



The code that benchtested well is below, but this code does not read the sensor multiple time and  average.  Also loading this code on the unit has the same issue as the above code. 

Something changed when I installed the turbo onto the truck......Just gotta figure out what that is  :-\


//HE351VE Variable Geometry Turbo. The whole program is
//controlled through void loop(). This is where you can
//add your own code or uncomment different sections of code
//that I have put together. This is covered by the GNU License*/

#include <SPI.h>
#include <can.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// Defines for setting up the CAN Bus
#define mode NORMAL // define CAN mode
#define bitrate 250 // define CAN speed (bitrate)
MCP CAN1(10); //Create CAN Channel
//J1939 message; // Create message object to use J1939 message structure
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

// Pin Assignments on UNO
#define BoostPressurePin A0
#define ExhaustPressurePin A1
#define PotentiometerPin A2
#define ThrottlePositionPin A3
#define Switch 2
#define EBSwitch 12


#define NumEntries 14
// The first number is the boost sensor reading, and the second number is the desired vein position
// remember usable vien position range from 140-960
int BoostMap[NumEntries][2] = {{10,235},{11.5,244},{13,253},{14.5,280},
{16,308},{17.5,308},{19,363},{20.5,390},{22,418},{23.5,459},{25,500},{26.5,550},
{28,600},{29.5,650}};  //,{31,700},{32.5,750},{34,800},{35.5,850},{37,900},{38.5,950},{40,970}}; DPManage takes care of the veins after 30psi. 


//for loop
  // Variables to read sensors
  int MaxExhaustPressure = 50; //Set desired max exhuast back pressure
  int ExPrsBuffer = 10; //set the point at which the system starts to manage
  byte EBCalibrate = 2;
  int PotentiometerValue = 0;
  int ExhaustPressure = 0;
  int BoostPressure = 0;
  int ThrottlePosition = 0;
  //int LCDupdatecount = 0;
  boolean SwitchPosition = false;
  boolean EBSwitchPosition = false;


  // Value to Send Position
  int DesiredPosition = 0;

  // Variables to use within Code
  int JumpSize = 50;
  int MinVeinPos = 235;

  //Variables for LCD
  long LCDLastUpdate = 0;
  int Line1Last = 0;
  int LCDUpdateRate = 200;

//will run once at startup 
  void setup()
{
  // Initialize Serial communications with computer to use serial monitor
  Serial.begin(115200);
  lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines and turn on backlight
  //Set CAN mode and speed
  CAN1.begin(mode, bitrate);

  // Setup Switch
  pinMode(Switch, INPUT_PULLUP); //configure switch to use internal pullup resistor
  pinMode(EBSwitch, INPUT_PULLUP); //configure EBswitch to use internal pullup resistor

//-------- Write characters on the display ----------------
// NOTE: Cursor Position: CHAR, LINE) start at 0 
  lcd.setCursor(2,0); //Start at character 4 on line 0
  lcd.print("Starting HE351VE");
  lcd.setCursor(5,1);
  lcd.print("Controller");
  lcd.setCursor(4,2);
  lcd.print("Will Display ");
  lcd.setCursor(0,3); 
  lcd.print("Boost,Drive,Position");
  delay(4000);
  lcd.clear();
  lcd.setCursor(4,0); //Start at character 4 on line 0
  lcd.print("Cycling Vein");
  lcd.setCursor(6,1);
  lcd.print("Position");
  lcd.setCursor(3,3);
  lcd.print("Wait To Start!");
  delay(2000);
  lcd.clear();
  SendTurboPosition (140);
  lcd.clear();
  lcd.setCursor(4,0); //Start at character 4 on line 0
  lcd.print("Cycling Vein");
  lcd.setCursor(6,1);
  lcd.print("Position");
  lcd.setCursor(3,3);
  lcd.print("Wait To Start!");
  delay(500);
  SendTurboPosition (140);
  lcd.clear();
  lcd.setCursor(4,0); //Start at character 4 on line 0
  lcd.print("Cycling Vein");
  lcd.setCursor(6,1);
  lcd.print("Position");
  lcd.setCursor(3,3);
  lcd.print("Wait To Start!");
  delay(500);
  SendTurboPosition (140);
  lcd.clear();
  lcd.setCursor(4,0); //Start at character 4 on line 0
  lcd.print("Cycling Vein");
  lcd.setCursor(6,1);
  lcd.print("Position");
  lcd.setCursor(3,3);
  lcd.print("Wait To Start!");
  delay(500);
  lcd.clear();
  lcd.setCursor(8,2);
  lcd.print("Done!");
  delay(1000);
  lcd.clear();

}

// Main loops that choices what to do.
void loop()
  {
    // Read Sensors
    // Uncomment the Sensors that you have connected
    // There functions will need to be calibrated to the sensor.
    PotentiometerValue = ReadPotentiometer();
    ExhaustPressure = ReadExhaustPressure();   
    BoostPressure = ReadBoostPressure();   
    ThrottlePosition = ReadThrottlePosition();
    SwitchPosition = digitalRead(Switch);
    EBSwitchPosition = digitalRead(EBSwitch);


    {

    if ( SwitchPosition == HIGH && EBSwitchPosition == HIGH && BoostPressure >= 30)
      DPManage (); //set vein position based on boostmap
       
    else if (SwitchPosition != HIGH) // && ThrottlePosition < 30) //Disabled TPS input for testing
      PotManage ();  //vein position is pot value

    else if (EBSwitchPosition != HIGH && SwitchPosition == HIGH) // && ThrottlePosition < 1.5 )  //Disabled TPS input for testing
      EBManage (); //If below %1.5 then engage Exhaust brake and regulate the exhaust pressure.
               
    else DesiredPosition = BoostVeinPosCalc( BoostPressure );
    }

    // Set the Turbo Position
    SendTurboPosition( DesiredPosition );

    // Delay for Processor
    delay(2);
  }

//Read Sensors
//Define the sensor type and range. (Namefromabove, 0v, 5v, 0v=minpos,5v=maxposition)
int ReadPotentiometer(){
int PotVal = analogRead( PotentiometerPin );
return map(PotVal, 0, 1023, 0, 960); // read the value from the sensor
}
int ReadBoostPressure(){
int BoostVal = analogRead( BoostPressurePin ); // read the value from the sensor
return map( BoostVal, 83, 920, 0, 100 ); // Last two values are the psi range of the choosen sensor
}

int ReadExhaustPressure(){
int ExhaustVal = analogRead( ExhaustPressurePin ); // read the value from the sensor
return map( ExhaustVal, 83, 920, 0, 100 ); // Last two values are the psi range of the choosen sensor
}


int ReadThrottlePosition(){
int ThrottleVal = analogRead( ThrottlePositionPin );
return map ( ThrottleVal, 103, 920, 0, 100); // read the value from the sensor

}

//Manages DP to try and stay at or below 50psi drive while about 30psi boost.  veins will stay between 650 and 970 position
void DPManage (){

int Difference = (ExhaustPressure-MaxExhaustPressure); //set a buffer make sure max ex press doesn't get hit.

Difference = (Difference / EBCalibrate); // I used / rather than * as the * ended up applying too fast. the turbo was "snapping" open and closed
DesiredPosition += max(Difference, -10);//This way it doesn't close the veins to fast
DesiredPosition = constrain(DesiredPosition, 650, 970);
}

//Manages the apply of the EB
void EBManage(){

int Difference = (ExhaustPressure-MaxExhaustPressure); //set a buffer make sure max ex press doesn't get hit.

Difference = (Difference / EBCalibrate); // I used / rather than * as the * ended up applying too fast. the turbo was "snapping" open and closed
DesiredPosition += max(Difference, -10);//This way it doesn't close the veins to fast
DesiredPosition = constrain(DesiredPosition, 0,235);

}

//Ensure Pot doesn't cause Drive pressure to go over the maxexhaustpressure **look at more

void PotManage (){
int Rate = 11; // added to make ManageRate grow as exhaust pressure rises to max and above.
int PotBuff = 10;   //amount to buffer the vein position before maxexhaust is reached when in pot mode
int ManageRate = ((ExhaustPressure - MaxExhaustPressure)+Rate);

if (ExhaustPressure < (MaxExhaustPressure-PotBuff))
   DesiredPosition = PotentiometerValue;
   
else if (ExhaustPressure >= (MaxExhaustPressure-PotBuff))
   DesiredPosition = (PotentiometerValue +(JumpSize * ManageRate));
   DesiredPosition = constrain(DesiredPosition, 0, 970);
}

// Function to calculate turbo vein position
  int BoostVeinPosCalc( int BoostPressureVal )
  {
    int VeinPosition = BoostMap[0][1];
    for(byte i=0;(BoostPressureVal > BoostMap[i][0]) && (i<NumEntries); i++)
    {
      VeinPosition = BoostMap[i][1];
    }

    return VeinPosition;
  }

// Function to Send the Calculated Position to the Turbo
void SendTurboPosition(int TurboPosition)
{
  int FinalPosition = map( TurboPosition, 0, 1023, 999, 0);
  byte lobyte = lowByte(FinalPosition);
  byte hibyte = highByte(FinalPosition);
  UpdateLCD();
  unsigned long ID = 0x0CFFC600; // Random Extended Message ID
  byte length = 8; // Data length
  byte data[] = { lobyte, hibyte, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // data message with an added counter

  CAN1.send ( ID, extID, length, data ); // Load message and send

}

//BarGraph//

void BarGraph(int Line, int oldBars, int Bars, int Value, String Name)
//Line, which line on the LCD are we changing.
//Bars, number of pixcels long the BaGraph is going to show
//oldBars, number of Bars that this Line had lastt time
//Value, what's the value we should print to the lcd
//Name, the Name we should call this Line

{
int GraphStartPoint = 11;//what cell does the graph start on on the lcd screen

if (oldBars != Bars){ // if nothing changed then skip this function
int oldBlocks = (oldBars / 5);
int blocks = (Bars / 5);
int singles = (Bars - (blocks * 5));
if(blocks > oldBlocks)
{
for(int x = oldBlocks; blocks > x; x++){
lcd.setCursor((x + GraphStartPoint), Line);
lcd.write(1023);
}}

else if(blocks < oldBlocks)
{
for(int x = oldBlocks; blocks <= x; x--){
lcd.setCursor((x + GraphStartPoint), Line);
lcd.print(" ");
//Serial.println(E1);
}}
if ((oldBars - oldBlocks) != singles) {//if the number of singles has changed display the new singles
  lcd.setCursor((blocks + GraphStartPoint),Line);
  lcd.write(singles);
}
}
  lcd.setCursor(GraphStartPoint - 4, Line);
String TurboPos = String(Value, DEC);
if(Value < 1000) TurboPos += " ";
  lcd.print(TurboPos);
  lcd.setCursor(0, Line);
  lcd.print(Name);
}
//LCD//
void UpdateLCD(){

  if ((millis() - LCDLastUpdate) >= LCDUpdateRate){
    LCDLastUpdate = millis();
    int Line1Bars = map(DesiredPosition, 0, 1023, 0, 40);//map the value to a 0-50 value.
BarGraph(0, Line1Last, Line1Bars, DesiredPosition, "Turbo");
Line1Last = Line1Bars;
//Serial.println(after-before);
float DrivePressRatio = ((ExhaustPressure*1.00) / (BoostPressure*1.00));
DrivePressRatio = constrain(DrivePressRatio, 0, 9.99);
String Boost = String("Boost " + String(BoostPressure, DEC) + ' ');
String Drive = String("Drive " + String(ExhaustPressure, DEC) + ' ');
String DtoBRatio = String("DtoB Ratio " + String(DrivePressRatio) + ":1");
       lcd.setCursor(0, 2);
       lcd.print(Boost);
       lcd.setCursor(10, 2);
       lcd.print(Drive);
       if (BoostPressure <= 0 ){
         lcd.setCursor(0, 3);
         lcd.print("DtoB Ratio 0.00:1");
       }
       else {
         lcd.setCursor(0, 3);
         lcd.print(DtoBRatio);
       }
       if (EBSwitchPosition != HIGH && SwitchPosition == HIGH && ThrottlePosition < 1)
       {
         lcd.setCursor(4, 1);
         lcd.print("!EB  Active!");
       }
       else if (SwitchPosition != HIGH && ThrottlePosition < 30)
       {
         lcd.setCursor(4, 1);
         lcd.print("!Pot Active!");
       }
       else {
         lcd.setCursor(4,1);
         lcd.print("            ");
       }
       

    }
}
Title: Re: HE351 code for me78569
Post by: hakcenter on June 11, 2015, 09:50:51 AM
Can you attach the ino's so I can toss them into my editor for more easier everything? :)
Title: Re: HE351 code for me78569
Post by: me78569 on June 11, 2015, 10:20:48 AM
Here you go. 

Like I said, don't dig too deep until I start to troublshoot more.  I would hate to waste a bunch of your time because I have a bad wire somewhere or something dumb like that.
Title: Re: HE351 code for me78569
Post by: hakcenter on June 11, 2015, 02:45:41 PM
I see some syntax problems and brackets because they are just brackets, and then a lack of bracketing... you want me to go through it a bit and clean it up?

BTW

//////////////////////////Pot Manage/////////////////////////////////////////////////
//Ensure Pot doesn't cause Drive pressure to go over the maxexhaustpressure **look at more

void PotManage() {
int Rate = 11; // added to make ManageRate grow as exhaust pressure rises to max and above.
int PotBuff = 10;   //amount to buffer the vein position before maxexhaust is reached when in pot mode
int ManageRate = ((ExhaustPressure - MaxExhaustPressure)+Rate);

      if (ExhaustPressure < (MaxExhaustPressure-PotBuff)) { DesiredPosition = PotentiometerValue; }
else if (ExhaustPressure >= (MaxExhaustPressure-PotBuff)) {
   DesiredPosition = (PotentiometerValue +(JumpSize * ManageRate));
   DesiredPosition = constrain(DesiredPosition, 0, 970);
}
}


Doesn't have a default value... so things can fall outside of that... yes desired position doesn't change.. but still

And I'm fixing the missing bracketing...
Title: Re: HE351 code for me78569
Post by: me78569 on June 11, 2015, 03:46:06 PM
haha yea I am sure there are syntax issues.  My coding skills haven't been dusted off in well over a decade.

Don't feel like you have to fix the issues, but I will be more than willing to learn from what you do.


My issue however is %100 wiring. 

Time to build a new harness with better quality wires. 
Title: Re: HE351 code for me78569
Post by: hakcenter on June 11, 2015, 04:16:06 PM
Ok, I'm going to add timers to your code, to really free up crap. And fix your syntax and spacing, its really difficult to read LOL  8)
Title: Re: HE351 code for me78569
Post by: me78569 on June 11, 2015, 04:33:09 PM
Well damn, Guess I need to send you some beer.

My code is kind of like my handwritting, I am about the only person that can read it....
Title: Re: HE351 code for me78569
Post by: hakcenter on June 11, 2015, 05:03:16 PM
Well now you and I should be able to read it, LOL

I added 2 timers, very similar to how I'm running code.. so make sure you add the Timer library from the libraries post, into your libraries so it will compile.

Might want to backup your current one.. even though it is posted.

LCDUpdate is ran every 200ms from the KeepTime timer,
Setting turbo position, is on its own 2ms timer, so regardless, it sends DesiredPosition to the turbo, so update DesiredPosition as required. (i've already updated your code in the areas so it should be fine)

Your ADCs roll over now, every 1ms from the KeepTime timer, an ADC is read, then next time around another, so the spacing between reads is 4ms, and I updated your rolling averages, to really roll the average, your total was never being reset, and it equaled itself, so very dangerous that way.

The position switches, are read every 100ms from the KeepTime timer. They could be put in faster ? I don't necessarily see the point, maybe 25ms at the fastest, adjust at your discretion.

And of course, all the If's have {}'s and Else's have {}'s, and they all line up to 2 spaces, etc...
Title: Re: HE351 code for me78569
Post by: Bdubb'z on June 11, 2015, 08:49:16 PM
umhum, very nice improvement indeed!  :o
Title: Re: HE351 code for me78569
Post by: me78569 on June 11, 2015, 09:01:51 PM
looking at it now. 

Thanks again.
Title: Re: HE351 code for me78569
Post by: me78569 on June 12, 2015, 07:25:10 AM
I really like what you did oddly it is VERY hard for me to read code like this haha.   I gotta relearn, but it gives me a good excuse to learn the timer stuff.  I was looking at it but it was lower on my list of things to do.

Title: Re: HE351 code for me78569
Post by: Bdubb'z on June 12, 2015, 08:31:45 AM
i really like the timed analog read setup....i'm gonna have to 'poll' like that as well.

in the function though i don't see a read twice.  is it not necessary with 'polling' like this?

i'm saying polling, but hac labed it roll over.

the tabbed code is growing on me.  normally you know the code so well its no big deal to scroll, but this may be a little quicker.   i do like seeing the whole thing though, guess i'm just used to it.
Title: Re: HE351 code for me78569
Post by: me78569 on June 12, 2015, 08:37:25 AM

////////////////////////////Keep Time/////////////////////////////////////////
void keep_time() {
  timer++;
  adc_roll_over++;
  // Read Sensors
  // Uncomment the Sensors that you have connected
  // There functions will need to be calibrated to the sensor.
  if (adc_roll_over == 0) { PotentiometerValue = ReadPotentiometer(); }
  if (adc_roll_over == 1) { ExhaustPressure = ReadExhaustPressure(); }   
  if (adc_roll_over == 2) { BoostPressure = ReadBoostPressure(); }
  if (adc_roll_over == 3) { ThrottlePosition = ReadThrottlePosition(); }
  if (adc_roll_over == 4) { adc_roll_over = 0; }
  if (timer % 100) {
    SwitchPosition = digitalRead(Switch);
    EBSwitchPosition = digitalRead(EBSwitch);
  }
  if (timer % 200) { UpdateLCD; }
  if (timer == 1000) { timer = 0; }
}


So reading through this am I on the right track? 

It will effectively run each of these one at a time ( per timer event) then reset adc_roll_over back to 0 and read pot. 

It will only read the switch positions if it has run through it and the timer is at %100?    I am assuming that if the main timer is set to 2ms then 1ms would be %50? 

I think what I am reading show that it resets the timer after 1 second or 1000ms?

Lcd update at %200 or 200 MS? 


My main question is how does the timer know that you are looking for 100ms = %100 ?

Quote from: Bdubb'z on June 12, 2015, 08:31:45 AM
in the function though i don't see a read twice.  is it not necessary with 'polling' like this?

I was wondering the same thing.  I added a double analog read on the TPS and pot


Last question, for now,  I am planning on reading tps from the apps.  Since the apps already has ground and 5v to it from the truck can I splice the return wire and just have that voltage input into the arduino?   Does the arduino care where the 5v supply is from? 

Title: Re: HE351 code for me78569
Post by: me78569 on June 12, 2015, 11:32:47 AM
Timer section had to be changed to this to make it work

////////////////////////////Keep Time/////////////////////////////////////////
void keep_time() {
  timer++;
  adc_roll_over++;
  // Read Sensors
  // Uncomment the Sensors that you have connected
  // There functions will need to be calibrated to the sensor.
  if (adc_roll_over == 1) { PotentiometerValue = ReadPotentiometer(); } //start at 1 vs 0
  if (adc_roll_over == 2) { ExhaustPressure = ReadExhaustPressure(); }   
  if (adc_roll_over == 3) { BoostPressure = ReadBoostPressure(); }
  if (adc_roll_over == 4) { ThrottlePosition = ReadThrottlePosition(); }
  if (adc_roll_over == 5) { adc_roll_over = 0; }
  if (timer % 100) {
    SwitchPosition = digitalRead(Switch);
    EBSwitchPosition = digitalRead(EBSwitch);
  }
  if (timer % 200) { UpdateLCD(); }
  if (timer == 1000) { timer = 0; }
}
Title: Re: HE351 code for me78569
Post by: Bdubb'z on June 12, 2015, 12:11:55 PM
yup you're on the right track.

your switches are read every 100 ms.  I do mine at 200, but what ever works best for you. 

your lcd is 200ms, you are correct. 

I see why 0 doesn't work. increment is at the top.  It needs to increment at the end, or you can leave it, but you need to keep writing/reseting it to zero for it to work. 
   
Title: Re: HE351 code for me78569
Post by: Rx7man on June 12, 2015, 12:40:56 PM
the % sign is MODULUS, so it's the remainder after doing integer division.. 10%2 = 0 (10/2 = 5 with no remainder), 10%3 = 1 (10/3 = 3 with 1 as a remainder)... perhaps that is what's confusing you?
Title: Re: HE351 code for me78569
Post by: Rx7man on June 12, 2015, 12:44:42 PM
Sorry, I had to look back in the code..

So
  if (timer % 200) { UpdateLCD; }

means if timer modulus 200 is not 0, update lcd... which means that if the timer fires every millisecond, the LCD will update every 200 milliseconds
Title: Re: HE351 code for me78569
Post by: Bdubb'z on June 12, 2015, 12:56:46 PM
Oh yeah, and the 5v ref from the truck.  You should be fine because you are 'bonded' with the truck ground.  If they isolate their 5v reference from the common ground then you would/could have issues with a 'floating' ground. 
Title: Re: HE351 code for me78569
Post by: me78569 on June 12, 2015, 02:24:02 PM
Got ya,

Thanks for the clarification on that.

When the count started at 0 vs 1 the lcd screen wouldn't show anything. like it reset to 0 then the count went to 1 before the lcd was updated.
Title: Re: HE351 code for me78569
Post by: hakcenter on June 12, 2015, 02:59:27 PM
Lulz ya, sorry simple typos

Keep Time runs at 1ms, look at the setup code. So % 100 = 100ms, etc. Anything non critical at computing time, can be put in there, cause it won't really add latency to the timer.

your code didn't have double reads, so i just glossed over it and didnt add them

I'll probably convert the common code to tabbing on the next update to 1.1
Title: Re: HE351 code for me78569
Post by: hakcenter on June 13, 2015, 04:36:37 PM
I am curious to hear how it is running, if any better without the pot now ?
Title: Re: HE351 code for me78569
Post by: Rx7man on June 13, 2015, 09:45:18 PM
I think you'll like the tabbed code once you get used to it.. though the order of the tabs ARE important if you have global variables... just to let you know.. I had to figure that one out myself
Title: Re: HE351 code for me78569
Post by: hakcenter on June 13, 2015, 10:57:28 PM
Yeah 1.1.0 is tabbed just so I can make more code look smaller lol
Title: Re: HE351 code for me78569
Post by: Rx7man on June 13, 2015, 11:33:34 PM
I was just at a buddy's wedding, turns out his step son is doing electromechanical engineering.. he's a young fellow, but I might be able to pick his brains a little on circuitry
Title: Re: HE351 code for me78569
Post by: me78569 on June 14, 2015, 12:26:02 PM
I am waiting on some parts before I can get it onto the road so I haven't run the turbo at all yet.  Just bench testing with pots to simulate boost/drive.
Title: Re: HE351 code for me78569
Post by: hakcenter on June 14, 2015, 02:25:38 PM
This was the only thing I had to buy to hook up to my intercooler piping, just clocked the compressor housing until it lined up and cut some of the elbow to fit.

2 75 3&quot; 3 Ply 45° Elbow Intake Turbo Intercooler Silicone Reducer Hose T Clamp | eBay  (http://www.ebay.com/itm/2-75-3-3-PLY-45-ELBOW-INTAKE-TURBO-INTERCOOLER-SILICONE-REDUCER-HOSE-T-CLAMP-/350894470317?hash=item51b2f0b4ad)

It isn't super rigid but it hasn't blown off either. Got t-bolts and a local shop for a couple bucks.
Title: Re: HE351 code for me78569
Post by: me78569 on June 15, 2015, 07:01:37 AM
yea I looked at doing that, but I felt that the charge tube would rub on the lower coolant hose.   

I figured for $80 it was worth the pipe.  knowing that you used a 45* reducer makes me wish I would have tried at least haha.
Title: Re: HE351 code for me78569
Post by: hakcenter on June 15, 2015, 08:17:09 AM
Ya it rubs, no big deal thou. Maybe some day pick up a hx35 or hx40 compressor housing and have it machined out.

Still wasn't an issue doing an oil filter change  8)
Title: Re: HE351 code for me78569
Post by: me78569 on June 15, 2015, 08:25:43 AM
I have a he300vg cover that ill sell you for cheap.  It needs to be machined out but I can't find anyone local to do it for me.   

Spec wise it is the same as a hx35 but it has the right vband style cover so it fits on the 351 without any mods.

Holset HE300VG ve VGT turbocharger Compressor Housing | eBay  (http://www.ebay.com/itm/221796237639?ssPageName=STRK:MESELX:IT&_trksid=p3984.m1586.l2649)

Theres my ebay ad, you can have it for $75 shipped if you want it.  Just trying to get my money back out of it.
Title: Re: HE351 code for me78569
Post by: Rx7man on June 15, 2015, 07:57:26 PM
I've seriously been considering cutting the elbow from the HX35 (it's 3") and welding it to the compressor housing of the 351... I hate having reducers, etc, and I have plenty of boots already... the other option I was thinking of is grinding the lip off and making a sleeve that goes over top of it, and epoxying it on.. as for the rest of the charge pipe, I have a couple spares, I'd cut and weld it  longer and with whatever bend I need in it.
Title: Re: HE351 code for me78569
Post by: me78569 on June 15, 2015, 08:27:19 PM
I agree I would have much rather had all oem, the stainless diesel product is really nice now that I have it installed. just requires one 2.75 to 3" boot.  everything else is oem. for $80 I am pretty happy, clears everything nicely.

(http://i879.photobucket.com/albums/ab360/me78569/he351ve%20turbo%20install/20150615_195717_zpskrlt2tif.jpg) (http://s879.photobucket.com/user/me78569/media/he351ve%20turbo%20install/20150615_195717_zpskrlt2tif.jpg.html)



Title: Re: HE351 code for me78569
Post by: Rx7man on June 15, 2015, 09:01:32 PM
I see you kept the non-vgt manifold.. I was lucky I got a manifold with the turbo, so I might as well use it I guess... I s'pose I could make an adapter too, but for my air filter setup I think I'd be better off with everything a little further back and lower... I just posted a pic of the downpipe adapter I made in my "my life, my coding" thread.. I'll work on the rest of it as time allows
Title: Re: HE351 code for me78569
Post by: Bdubb'z on June 15, 2015, 09:51:16 PM
Is that a brass adapter and fitting on the manifold for the back pressure??  If so I'd be careful with the egt's. 
Title: Re: HE351 code for me78569
Post by: Rx7man on June 15, 2015, 11:31:29 PM
brass should be fine.. I've had some brass fittings on my exhaust manifold for a long time and have not had any trouble with them.. When brazing (with brass) the steel needs to be CHERRY red, so that's up in the 1800F range... I think you'll have other problems before that :P 
Title: Re: HE351 code for me78569
Post by: me78569 on June 16, 2015, 08:35:58 AM
yea it is brass, I thought about that, and I am a little worried as depending on what it was cast out of it could have issues. 

However I got the "kit" from
ISSPRO Exhaust Back Pressure Installation Kit
(http://www.dieselpowerproducts.com/p-8213-isspro-exhaust-back-pressure-installation-kit.aspx) and it is an issopro kit marketed for this..... so I hope.



Since my truck is an auto I have the heat exchanger on the side of the block so I can't use a 4th gen manifold.  I wasn't willing to loose the heat exchanger so I went this route. 
Title: Re: HE351 code for me78569
Post by: me78569 on June 19, 2015, 07:51:09 AM
Well today was the first day with the new turbo.  Very different feeling compared to the old hx35. 

I THINK I need to open the veins up some across my boost map as it feels like I am driving the turbo pretty hard and it generates a good bit of heat with the veins set at 235 or about 9cm ( ithink gotta find that chart with the pos vs pos)

I can however do 65mph with the veins %100 open without smoke, and no boost or drive pressure, provided it is relatively flat.  EGTS are in the 800-950 range, but I don't think it is an issue since it really isn't fueling much at 0psi boost. EGT's seem to be more related to a lack in air compared to overfueling.  ( one in the same I suppose)  I need to drop my pot override to lower than %30 throttle.
Title: Re: HE351 code for me78569
Post by: Rx7man on June 19, 2015, 07:59:06 AM
/* Turbo Size (cm^2) vs Position
  *   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23   24  25
  *  960 918 876 835 793 751 709 667 625 584 542 500 458 416 375 333 291 249 207 165 124  82  40*/
sorry about the formatting

9cm is  half the size of a stock HX35,  I can't say anything more than that though.
Title: Re: HE351 code for me78569
Post by: hakcenter on June 19, 2015, 08:02:11 AM
Need to remove the whole inverting vane position. No reason for it. Match what Cummins did.
Title: Re: HE351 code for me78569
Post by: me78569 on June 19, 2015, 08:02:28 AM
beat me to it haha. 


thanks. 

I realyl should flip my vein position numbers to 960-40 vs 40-960,  low on the list.
Title: Re: HE351 code for me78569
Post by: me78569 on June 19, 2015, 10:00:51 AM
Alright the more pressing issue I have is how easy it is to bark the turbo. 

Thoughts on this? 
/////////////////////////////POS Manage////////////////////////////////////////
//Manages Boost map position in an effort to prevent Barking when letting off the throttle.
void POSManage() {
  if ( ((Thrreadings[2] + Thrreadings[3]) >>1) < (5+((Thrreadings[0] + Thrreadings[1]) >>1))) //Detect if throttle is lifted more than %5
    { DesiredPosition = BoostVeinPosCalc(Bstreadings[0]);}        // use the first boost reading in the array and keep the veins at that position
  else { DesiredPosition = BoostVeinPosCalc(BoostPressure);}
}


I created another array for TPS readings.  I am watching to see if I let of the throttle then if I am I am taking the oldest boost value in the array and using that for the vein position.  This should effectively delay the vein position movement when letting off throttle. 


Thoughts? 
Title: Re: HE351 code for me78569
Post by: Rx7man on June 19, 2015, 11:44:37 AM
How often are you reading the TPS?  if you're reading it very quick, you may need a larger array
Title: Re: HE351 code for me78569
Post by: hakcenter on June 19, 2015, 01:21:47 PM
Best way is to setup a vane position smoothing alog.

Look at my 1.1 code, and the set postion.

Since position runs every 2ms, I made it change position in increments of 2 every 2ms while within 10, then adjust by 10s if it's larger than 20.

You need to do something similar where positions to smaller sizes, take longer than going to larger sizes.

Using rpm helps here cause the shafts has inertia and doesn't immediately slow down,  then compute to a smaller size.
Title: Re: HE351 code for me78569
Post by: me78569 on June 19, 2015, 01:24:27 PM
The tps doesn't seem to be stable enough to do what I wanted originally.



Hak, that is what I am thinking I will work with what you have code wise and see what I come up with.   

I can drive it without to much issue at all, but I wouldn't wanna let someone else drive.  I would likely chew my fingers off with how nervous I would be.
Title: Re: HE351 code for me78569
Post by: hakcenter on June 19, 2015, 01:59:14 PM
Ya just go through my code. I'm pretty sure I update last rpm every 100ms or so. Calculating position every 50ms under 50k then 25ms to 100, then its every couple of ms or so up to speed.
Title: Re: HE351 code for me78569
Post by: me78569 on June 22, 2015, 07:26:19 AM
Well I have had the turbo in the truck for a few days. 

I have some EGT issues, and haze issues, but I am almost %100 sure that is due to the large cut I have in one of the boots coming off the intercooler. 

I am going to swing by a place tonight and get a new boot and get that fixed. 


However I have been able to put some 55-65 mph crusing miles on the truck.  I can say that I have 0 issues with leaving the veins %100 open and cruising egt's stay below 800 and I make no smoke. 

The code is set to jump out of the pot if I increase throttle above %25 I think, but it is rare I need that even here in the rockies.  I am able to accelerate from a stop light with the turbo open without any issues. 

I have put nearly 200 miles on the truck and I have used just over 1/4 of a tank.   some of which was going up a mountain pass and farting around with the skinny pedal.
Title: Re: HE351 code for me78569
Post by: Bdubb'z on June 22, 2015, 07:32:28 AM
Awesome!  Glad it's working out, fix the barking issue?

Title: Re: HE351 code for me78569
Post by: Rx7man on June 22, 2015, 07:50:55 AM
Yeah, a cut intercooler boot is going to do that for you.. happened to me too... did it rub on that fender lip?
Title: Re: HE351 code for me78569
Post by: me78569 on June 22, 2015, 08:01:05 AM
I haven't had a chance to work with the barking issue.  I was chasing some other more important issues, like forgetting to tighten down the compressor cover (ugh). 

I have a few small chances in the code to make it work like I was expecting then I will deal with the barking issues.  I VERY rarely put my foot into it so the barking isn't a huge issue.


The boot was just VERY old.  It was starting to tear from the fender and also around the clamp. 
Title: Re: HE351 code for me78569
Post by: me78569 on June 22, 2015, 10:39:04 AM
added 2 boost maps, for 3 total, select-able by the position of the pot when the pot switch is inactive.
#define NumEntries 14 // if using the entire boost map
// The first number is the boost sensor reading, and the second number is the desired vein position
// remember usable vien position range from 140-960
int BoostMap[NumEntries][2] = {{10,235},{11.5,250},{13,265},{14.5,280},
{16,295},{17.5,310},{19,325},{20.5,340},{22,355},{23.5,370},{25,385},{26.5,400},
{28,415},{29.5,430}};  //,{31,460},{32.5,475},{34,490},{35.5,505},{37,520},{38.5,535},{40,550}}; DPManage takes care of the veins after 30psi. 

#define NumEntrieshigh 14 // boost map for high performance
int BoostMaphigh[NumEntrieshigh][2] = {{5,135},{6,165},{13,195},{14.5,225},
{16,255},{17.5,285},{19,305},{20.5,320},{22,335},{23.5,350},{25,365},{26.5,380},
{28,400},{29.5,430}};

#define NumEntrieslow 3 // boost map for high mileage
int BoostMaplow[NumEntrieshigh][2] = {{10,335},{20,365},{30,430}};
/*
* Turbo Size (cm^2) vs Position
*  25  24  23  22  21  20  19  18  17  16  15  14
* 960 918 876 835 793 751 709 667 625 584 542 500
*  13  12  11  10  9   8   7   6   5   4    3
* 458 416 375 333 291 249 207 165 124  82  40
*/



/////////////////////////////POS Manage////////////////////////////////////////
//Manages Boost map position in an effort to prevent Barking when letting off the throttle.
void PosManage() {
  if ( PotentiometerValue < 25){ DesiredPosition = BoostVeinPosCalchigh(BoostPressure);}
  else if ( PotentiometerValue > 970){ DesiredPosition = BoostVeinPosCalclow(BoostPressure);}
  else { DesiredPosition = BoostVeinPosCalc(BoostPressure);}
}
Title: Re: HE351 code for me78569
Post by: me78569 on June 24, 2015, 07:21:10 AM
Well the starting position of inverted 235 is way to small for me.

300 works better. 

#define NumEntries 14 // if using the entire boost map
// The first number is the boost sensor reading, and the second number is the desired vein position
// remember usable vien position range from 140-960
int BoostMap[NumEntries][2] = {{10,235},{11.5,250},{13,265},{14.5,280},
{16,295},{17.5,310},{19,325},{20.5,340},{22,355},{23.5,370},{25,385},{26.5,400},
{28,415},{29.5,430}};  // DPManage takes care of the veins after 30psi. 

#define NumEntriesPerf 14 // boost map for high performance
int BoostMapPerf[NumEntriesPerf][2] = {{1,275},{3,285},{4,295},{9,305},{16,315},{17.5,325},{19,335},{20.5,345},{22,355},{23.5,365},{25,375},{26.5,385},
{28,400},{29.5,430}};

#define NumEntriesDD 14 // boost map for high performance
int BoostMapDD[NumEntriesDD][2] = {{10,300},{11.5,310},{13,320},{14.5,330},
{16,340},{17.5,350},{19,360},{20.5,370},{22,380},{23.5,390},{25,400},{26.5,410},
{28,420},{29.5,430}};

#define NumEntriesMpg 3 // boost map for high mileage
int BoostMapMpg[NumEntriesMpg][2] = {{10,400},{20,415},{29.5,430}};
Title: Re: HE351 code for me78569
Post by: me78569 on June 26, 2015, 07:52:49 AM
well the 7 x .009 injectors are on there way back to DFI to be checked out. 

I was talking with a CF member who has the same injectors and he took a couple videos.  the DFI's on his truck smoke about as much at %100 leaving a stop light as mine do at %30. 

Some of that has to do with altitude, but I am thinking something else is up.
Title: Re: HE351 code for me78569
Post by: Rx7man on June 26, 2015, 08:51:02 AM
that must be a lot of smoke.. Is the timing, etc the same? 
Title: Re: HE351 code for me78569
Post by: hakcenter on June 26, 2015, 04:05:13 PM
Did you install these at the same time with the turbo?
Title: Re: HE351 code for me78569
Post by: me78569 on June 29, 2015, 06:17:35 PM
Yep same time.  Timing is stock as I turned the quad off.  Fueling is off to.  A gut feeling something is up with the injwctors

I know some of it is due to the larger undivided housing but an idle snap test with no tuner on my truck produces way more smoke than the other guys with the same injectors at a 100% throttle take off.



I just got the umax10 and 9924 for sensing turbo speed so I will have to get that installed on my setup and give your code a try.

That thing was a pain to soldier. 
Title: Re: HE351 code for me78569
Post by: Rx7man on June 29, 2015, 10:40:59 PM
Maybe there's something wrong with your buddy's injectors or system?
Title: Re: HE351 code for me78569
Post by: me78569 on June 30, 2015, 09:01:14 AM
His truck runs like a champ.

The DFI injectors were supposed to be nearly stock when it comes to smoke output.   if you look at my videos you can see that isn't true haha. 

I am just waiting to hear from chris and I will go from there.  I was expecting some but a free rev shouldn't smoke like mine does without a tuner. 
Title: Re: HE351 code for me78569
Post by: hakcenter on June 30, 2015, 09:09:23 AM
Make sure to solder the max9924 in mode a2, for simplicity. Cout gets a 10k pullup. 100nF / 10nF for power decoupling isn't 100% necessary but if you have the space, I would add em.

Did you put it on a DIP10 conversion board ?
Title: Re: HE351 code for me78569
Post by: me78569 on June 30, 2015, 09:31:41 AM
Yep it is on a DIP10 board.

A2 mode is done by grounding Zero_en and intThrs according to what I am reading in the spec sheet? 

can I use the internal pullup on the arduino?  I am assuming the external pull up will work better for reading the pulses?
Title: Re: HE351 code for me78569
Post by: hakcenter on June 30, 2015, 01:23:37 PM
I went external on the things on my board, that I absolutely required to be pullups. That way no one can accidentally software wise, screw it up. A pullup is absolutely required, and I wouldn't waste a digital i/o on it, so just manual 10k it from the 5v rail.
Title: Re: HE351 code for me78569
Post by: Rx7man on June 30, 2015, 04:33:08 PM
Just some other thoughts.. are you using the right thickness sealing washers? I know incorrect injector protrusion into the chamber can lead to smoke
Title: Re: HE351 code for me78569
Post by: me78569 on June 30, 2015, 06:42:09 PM
I was using the copper washers provided by DFI. 

No double washers or anything like that.  Double and triple checked.
Title: Re: HE351 code for me78569
Post by: hakcenter on June 30, 2015, 08:59:38 PM
If it is of any help, my 5x012 SAC's I got from DFI smoke like a 007 smoke screen
Title: Re: HE351 code for me78569
Post by: me78569 on July 01, 2015, 07:38:31 AM
Humm not a good sign.


I ended up soldering on the 9924 backwards, ugh.  Too awhile to desolder it and get it turned the right way.
Title: Re: HE351 code for me78569
Post by: Rx7man on July 01, 2015, 01:27:06 PM
DOH!

I've put plenty of stuff in backward in my time... still never learn to check it enough times..  and things like forgetting to put the shrink tube over some wires BEFORE soldering them together?!
Title: Re: HE351 code for me78569
Post by: me78569 on July 01, 2015, 01:55:54 PM
haha that's why I have to solder everything twice.
Title: Re: HE351 code for me78569
Post by: me78569 on July 03, 2015, 01:02:16 PM
Couple of more question here. 

I have the 9924 in and soldered correctly this time. 

I know the VR has a + and - lead and the 9924 has a + and - input also.  I am assuming the VR sensor wires on turbo, Green and black, mean green + and black -?


Also I know you code as a min 4000 rpm shaft speed, but since my injectors are out and being tested by DFI I can't start the truck, so I am limited in RPM on the turbo to about 2000 rpm.  Will the vr sensor read that low on the turbo? 

I cannot for the life of me get the example for the freqmeasure library to read any values. 

I dunno if I fried the 9924 by having it backwards to start or what, but I get nothing.
Title: Re: HE351 code for me78569
Post by: Rx7man on July 03, 2015, 01:50:49 PM
I really doubt the polarity of the VR sensor is important.. it's an AC signal... I don't know if it give enough signal at that RPM to trigger the 9924, but I think the mode it's in says it's adaptive peak mode, which means when the signal is low it'll increase the gain
Title: Re: HE351 code for me78569
Post by: hakcenter on July 03, 2015, 06:43:58 PM
Do you have it exactly like the A2 model ?

2 10k resistors, with a filtering cap after them connecting + to - ? and the Cout 10k pullup ? Make sure the cap you use is non-polarity, ie ceramic.

The chip will not output crap, if it does not have the pullup on Cout.. I figured that one out after a day LOL. But it will count really low, Mine spins off to a couple hundred RPM.

Best thing to test, is just get a drill gun and put it on the input shaft and spin it while verifying, you should get it to atleast 1k.

Also make sure you wire Cout to pin8, for freqmeasure. You literally could just upload the LBB code to it at that point, and drop minimum rpm to 0 to check and see if its working.
Title: Re: HE351 code for me78569
Post by: me78569 on July 03, 2015, 07:37:48 PM
Yep a2 mode

Pull up on the Cout pin 8. 

Do I need to do anything with pin 4 on the chip? 

I am wondering if I fried the chip by having it reversed 5v through ground pin.

I have version 1.1 on it now trying to test and see if there is any output, but I get nothing with my dewalt spinning the turbo.   I might try and order a new 9924 and see if that fixes it.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 03, 2015, 09:31:53 PM
Make sure you set minimum_turbo_rpm to 0.

Pin 4 is bias, ground.

So I'll just set this for you.
1 vr+
2 vr-
3 NC
4 GND
5 GND

10 +5v
9 GND
8 NC
7 IO8 + 10k + 5v pullup
6 GND

Top left is 1, Top right is 10
Bottom left is 5, Bottom right is 6

Reversing it shouldn't of done anything it's a pretty robust chip.
Title: Re: HE351 code for me78569
Post by: me78569 on July 04, 2015, 08:34:30 AM
Thanks for the stupid proof directions haha.

I'll try some more.  Min speed set at 100 it goes to output enabled and does noting on 1.1, with 1.0-1.05 it will start running through the cycle but I never get a rpm reading. 

Time to break out the multimeter and start verifying wires.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 04, 2015, 11:03:21 AM
Since its on a DIP10 you can check for pin bridges, nothing should be 0ohm between any of the pins. If you diode check, i think 2 pins are like 1100ish

Also its really hard to solder that sob, no harm in pressing down firmly once you feel the pins are aligned well enough. Might want to check over the top of the pins to the DIP10 to verify connectivity as well.
Title: Re: HE351 code for me78569
Post by: Rx7man on July 04, 2015, 12:08:44 PM
Perhaps as a check you can write a new sketch using an interrupt on the pin to blink the onboard LED when it gets a signal?   Perhaps make it so it blinks once for every 10 revs

like

void PinISR(){
static int Count = 0;
static boolean Status = false;
Count++;
if (Count>=10){
Status = !Status;
digitalWrite(LEDpin, Status);
Count = 0;
}
}
Title: Re: HE351 code for me78569
Post by: Rx7man on July 04, 2015, 12:09:51 PM
You can also put a multimeter on the VR sensor pins on the AC setting, perhaps you can see if you're getting any voltage there
Title: Re: HE351 code for me78569
Post by: me78569 on July 05, 2015, 08:56:43 AM
Found the issue.


It seems that the canbus shield uses pin 8 for an led.  If I bend the pin 8 on the canbus shield so it can't make connection with the arduino then I started to get rpm readings.  It looks like I am getting some interferience though . I seeing rpm readings steady at 1260, then jump some and settle back down at 200 something. 

Do i need to twist that pair of wires?
Title: Re: HE351 code for me78569
Post by: hakcenter on July 05, 2015, 02:14:58 PM
Never twisted mine. You have the 10k cap 10k on the vr lines ?
Title: Re: HE351 code for me78569
Post by: me78569 on July 05, 2015, 02:31:01 PM
No cap yet
Title: Re: HE351 code for me78569
Post by: me78569 on July 06, 2015, 06:36:47 PM
WEll I am pretty sure I burned up the canbus shield.  After I installed the 9924 and did the pullup to pin 8 ( now I find out there is an led on pin 8 of the canbus).

This is the second can shield I have burned up since starting this project, both of them sparkfun shields.  I ordered a seeed can shield and have edited my code and your 1.1 code for the new can library they use. 

More fun to come I guess,.
Title: Re: HE351 code for me78569
Post by: Rx7man on July 06, 2015, 07:24:51 PM
not having much luck it would seem!?

On the other hand, you're getting 'experience' (it's what you get just after you need it)
Title: Re: HE351 code for me78569
Post by: me78569 on July 06, 2015, 07:31:09 PM
Seems like one thing after another haha.

Oh well work through it.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 06, 2015, 10:06:49 PM
Should just get my board... lol

if you know where the issue is thou, the mcp chips aren't that expensive to replace
Title: Re: HE351 code for me78569
Post by: me78569 on July 07, 2015, 07:27:37 AM
The seeed canshield was $11 shipped. 

I will be getting on of your boards after I pay for the wedding and now the additional $2900 for the surgery my future wife needs on the 16th. 


Ugh.
Title: Re: HE351 code for me78569
Post by: Rx7man on July 07, 2015, 02:29:26 PM
Just push the wedding and surgery back a couple months, she'll understand :P
Title: Re: HE351 code for me78569
Post by: hakcenter on July 07, 2015, 03:59:31 PM
Surgery oh noes
Title: Re: HE351 code for me78569
Post by: me78569 on July 08, 2015, 09:23:54 AM
haha yea I can see that convo now,


" hey hun, gonna have to push back removing your cysts and polyps from your baby making oven.  Daddy needs some more parts"

hahahah, any you guys got a spare room for me?  dog house wouldn't cut it.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 08, 2015, 10:11:47 AM
i got a cabana in the back, free rent no problem
Title: Re: HE351 code for me78569
Post by: me78569 on July 09, 2015, 10:23:18 AM
So rather than using the setup section to define what curve is selected I have done this.

////////////////////////////////Watches for the pot position when pot switch is off to see what turbo curve is selected//////////////////////////////////////////
   void Watchpotcrv() {
      if (!eb_mode && !pot_mode) {       
        if (PotentiometerValue > 970) {BoostMapMode = 'E';}
        if (PotentiometerValue > 20 && PotentiometerValue < 970){ BoostMapMode = 'D';}
        if (PotentiometerValue < 20){BoostMapMode = 'P';}
         
        if (LastBoostMapMode != BoostMapMode){
          if (BoostMapMode = 'E') {memcpy(turbo_curve,turbo_curve_1,sizeof(turbo_curve));}
          if (BoostMapMode = 'D') {memcpy(turbo_curve,turbo_curve_2,sizeof(turbo_curve));}
          if (BoostMapMode = 'P') {memcpy(turbo_curve,turbo_curve_3,sizeof(turbo_curve));}
          LastBoostMapMode = BoostMapMode;
        }
       }
      }


I know the memcpy function is slow, but I am assuming that by watching for a change in the inactive pot position and skipping the memcpy if the lastboostmapmode is the same as boostmapmode it should work right? 

I have it set in the timer section to only run this once every 900 millis or something like that. 

thoughts? 

Also in your lbb code I have a question about  "staging_enabled"   I can't find anywhere where you set it to true?  am I missing something? 
Title: Re: HE351 code for me78569
Post by: hakcenter on July 09, 2015, 11:08:45 AM
There is staging code in the calculate vane position, to skip the WOT top end section and just use ms timing / staging.

For people that may just have a drag only car and want a specific turbo response versus time.
Title: Re: HE351 code for me78569
Post by: me78569 on July 09, 2015, 11:18:00 AM
so you just manually set staging_enabled to true in the lbb common if you want that feature?
Title: Re: HE351 code for me78569
Post by: hakcenter on July 09, 2015, 07:17:34 PM
right.

its terrible for the street, just fyi, unless you always WOT and never let off lol

more proof of concept, especially in my early testing. To show how to do it, and how well it works.
Title: Re: HE351 code for me78569
Post by: me78569 on July 09, 2015, 08:05:02 PM
Haha don't think I have a need for it.

Title: Re: HE351 code for me78569
Post by: me78569 on July 10, 2015, 10:08:52 AM
Another question about what you are doing. 

The while(1) {   in the main loop?  Why are you doing a while(1) there?  doesn't that effectively just always do the code within {}?
Title: Re: HE351 code for me78569
Post by: hakcenter on July 10, 2015, 01:06:44 PM
Yes, but I like being in control of the actual loop. Also you can see there is variables for just the loop, that I didn't want to put into the main setup tab.
Title: Re: HE351 code for me78569
Post by: me78569 on July 13, 2015, 07:33:28 PM
Alright 9924 is in resistors and cap installed.  I'M now seeing turbo rpm.

I haven't road tested yet but so far so good.


New dfi injectors are in seem better, but haven't had it on the street yet.

I am gonna run Around with your code tomorrow , but I also have a hybrid my code your code I am gonna try.  Uses your vane position call and my eb brake and pot control and lcd screen.

Title: Re: HE351 code for me78569
Post by: hakcenter on July 14, 2015, 08:43:56 AM
yaaa
Title: Re: HE351 code for me78569
Post by: me78569 on July 14, 2015, 09:09:09 AM
Drove into work today 1/2 with you 1.1 code and half with my bastard code child ( haha)  both run the same, as expected, when using the vane calc, everything else is good on my side.  your code I don't have the wiring to do the position selection etc. 

Thoughts on how I am selecting the turbo curve based on the inactive pot reading? watchpot ()

Smoke cleanup is better it seems and the turbo control is better than with the boost maps.  No more barking so that is nice. 

I have attached my bastard code if you care to look.  I need to clean it up some.


Question I have for you is in the licenses for the code.  do I need to enter your header into each tab or at the beginning.  Also I need to indicate my changes from yours?  or does the header explain the changes well enough?

thanks again for your work man.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 14, 2015, 11:06:08 AM
Creative Commons - Attribution-NonCommercial-ShareAlike 4.0 International - CC BY-NC-SA 4.0  (http://creativecommons.org/licenses/by-nc-sa/4.0/)

Is the license its carried under, very simple, just cover my ass kind of stuff.

but for instance,


/////////////////////////////POS Manage////////////////////////////////////////
//Manages Boost map position in an effort to prevent Barking when letting off the throttle.
void PosManage() {
[...]

Everything in there is basically a copy of the lbb common code, what I would do in each tab where any of the common code was used, or you made a derivative work of.. just attribute.


/////////////////////////////POS Manage////////////////////////////////////////
/*
*  This work is licensed under the
*  Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
*  To view a copy of this license,
*  visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
*   
*  Sections of this code are based off of the LBB Common Code and may be derivative works or copy's of
*  Curtis R Hacker at www.lilbb.com and his RPM based HE351vgt Arduino shield.
*
*  POS Manage
*  Manages Boost map position in an effort to prevent Barking when letting off the throttle.
*/


It is really simple no problems, just cover your ass is the only reason I tossed a license in there.[/code]
Title: Re: HE351 code for me78569
Post by: me78569 on July 14, 2015, 03:01:36 PM
I am sure you have noticed this, but I have been watching what the turbo is doing from idle leaving a stop light.

Typically when driving you let of throttle and come to a stop, this would engage idle, which will bring the turbo veins to about 14 cm^2 ( or like 500 something) which is nice.  No reason to work the turbo hard at idle. 

Now the issue I see has to do from this point forward. When you start to leave a stoplight your program will decrease the vein position down to 5 or 6 cm^2, to help get the turbo shaft speed up.  Dodge/Cummins does this also.  They have an idle position then they jump down to the same 5 or 6 cm^2 and go from there. 

Issue is since there is code in place to keep the turbo from "jumping" ( which works really well) to a position it takes a good couple seconds for the turbo to go from the 14cm^2 down to the 5 or 6 cm^2 requested and get the shaft speed up. 

I feel like the turbo would feel much more perky and have a flatter torque curve is the jump to 5 or 6 cm^2 from idle was instant. 


Thoughts on this?  have you seen the same thing? 

I am thinking since I watch throttle position I could go around the "dejump" code if I see throttle input of 1-%10 ?  however I am sure you might have a better way to accomplish this.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 14, 2015, 04:58:09 PM
If rpm < first rpm stage jump out of smoothing
Title: Re: HE351 code for me78569
Post by: me78569 on July 14, 2015, 05:28:07 PM
duh,

haha good idea.  I never would have thought of that. 

thanks...again
Title: Re: HE351 code for me78569
Post by: me78569 on July 15, 2015, 09:22:10 AM
So I have done a bit of testing and changing of the code.  Since I know when I am at idle, watching throttle position, I don't have to qualify turbo rpms as = idle.  Rather than watching rpms to qualify idle by rpms I am doing this.

/////////////////////////////POS Manage////////////////////////////////////////
void PosManage() {

    if (turbo_rpm > minimum_turbo_rpm) {
      if (turbo_rpm <= curve_rpm[4]) {
        if (ThrottlePosition < 2){  // Idle Section
            Offidle = true;
            if(turbo_rpm <= idle_rpm) {
             vane_position = idle_position;
             idle_mode = true;
             idle_walkdown_mode = false;
        } else {
            if (turbo_rpm <= idle_walkdown_rpm) { idle_walkdown_mode = true; } else { idle_walkdown_mode = false; }
            if (idle_walkdown_mode) { vane_position = constrain((final_vane_position - 10),800, idle_position); }
            idle_mode = false;
          }
        }else {
          // -----
          // Curve section
               if (turbo_rpm <= curve_rpm[0]) { vane_position = map(turbo_rpm, idle_rpm, curve_rpm[0],(turbo_curve[0] + one_cm),turbo_curve[0]); } //(idle_position - one_cm), (turbo_curve[0] - two_cm)
          else if (turbo_rpm <= curve_rpm[1]) { vane_position = map(turbo_rpm, curve_rpm[0], curve_rpm[1], turbo_curve[0], turbo_curve[1]); Offidle = false; }
          else if (turbo_rpm <= curve_rpm[2]) { vane_position = turbo_curve[1]; }
          else if (turbo_rpm <= curve_rpm[3]) { vane_position = map(turbo_rpm, curve_rpm[2], curve_rpm[3], turbo_curve[1], turbo_curve[2]); }
          else { vane_position = map(turbo_rpm, curve_rpm[3], curve_rpm[4], turbo_curve[2], turbo_curve[3]); }
        }
      } else if (turbo_rpm < top_end_rpm) {
        vane_position = map(turbo_rpm, curve_rpm[4], top_end_rpm, turbo_curve[3], turbo_curve[4]);
      } else {
       
            if (turbo_rpm <= 126000) { vane_position = map(turbo_rpm, top_end_rpm, 126000, turbo_curve[4], 580); }
          else if (turbo_rpm <= 130000) { vane_position = map(turbo_rpm, 126000, 130000, 580, 400); }
          else { vane_position = map(turbo_rpm, 130000, 132000, 400, min_position); }
        }
        // Overrun protection
       if (turbo_rpm > 132000) { vane_position = 0; };   
      // Default Full Open Position if no RPM signal
  } else { vane_position = min_position; }
}


Now to keep the smoothing from running when going from idle state to accelerating ( from a stop light for example) I created the variable "Offidle", which I set to true when idle state is sensed ( less than 2% throttle).  then I set "Offidle" to false once turbo curve 2 is reached  I also took the idle_walkdown_rpm down to below curve_rpm[1] so if you come off the throttle for a second it won't jump right into walkdown mode.

void set_turbo_position() {
  // Keep vane position within constraints
  final_vane_position = vane_position;

    if(!startcycle) {      //disregards the smoothing function below when setup is running to allow for a full sweep of the vanes for cleaning.
     if(!eb_mode && !pot_mode) {  //disregards the smoothing if in EB mode or Pot mode.
      if(!Offidle);{
      constrain(vane_position, min_position, max_position);
      final_vane_position = vane_position;
      // Vane smoothing between large values
      if (turbo_rpm < top_end_rpm) {
        if (vane_position >= last_vane_position + 20 && last_vane_position < max_position - 10) {
          final_vane_position = last_vane_position + 10;
        } else if (vane_position <= last_vane_position - 20 && last_vane_position > min_position + 10) {
          final_vane_position = last_vane_position - 10;
        } else if (vane_position - 10 >= last_vane_position || vane_position + 10 <= last_vane_position) {
          if (vane_position > last_vane_position + 2 && last_vane_position < max_position - 2) {
            final_vane_position = last_vane_position + 2;
          } else if (vane_position < last_vane_position - 2 && last_vane_position > min_position + 2) {
            final_vane_position = last_vane_position - 2;
          }
        }
       }
      }
     }
    }
   
// Function to Send the Calculated Position to the Turbo
  last_vane_position = final_vane_position;
  byte lo_byte = lowByte(final_vane_position);
  byte hi_byte = highByte(final_vane_position);
  byte data[] = { lo_byte, hi_byte, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // data message with an added counter
  // data[2] = 0x02 for recalibrating gearbox
  // Load message and send
  CAN1.send(0x0CFFC600, extID, 8, data);

}



I am hoping that now rather than having start position be map(turbo_rpm, idle_rpm, curve_rpm[0], (idle_position - one_cm), (turbo_curve[0] - two_cm)); }
          }

It will jump from idle position to the start position when coming onto the throttle.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 15, 2015, 09:37:37 AM
Having a tps is great isn't it lol

Just make sure you don't run into a condition where you let off the throttle and the turbo is / was rolling hard or else you may bark it
Title: Re: HE351 code for me78569
Post by: me78569 on July 15, 2015, 09:46:06 AM
TPS is wonderful to have.  I gotta admit your rpm set idle worked really well though. 

I am somewhat worried about barking, but it shouldn't be bad as the smoothing is in effect at higher rpm ranges.  I do intend to work on that more though. 
Title: Re: HE351 code for me78569
Post by: hakcenter on July 15, 2015, 06:15:11 PM
Ya I spent an hour dialing that idle setup, pretty ingenious way to do it. Having a TPS input is the way to go thou.

You could trigger so much with just that.

RPM > 25k, TPS > 80% = perf.. etc


How's rpm control over boost / bp ? Pretty substantial difference in how smooth the power curve is ?
Title: Re: HE351 code for me78569
Post by: me78569 on July 15, 2015, 09:12:25 PM
Dunno yet.  I haven't run the Boost map code with the new injectors.  The Boost map wasn't really that "notchy" but I can tell the rpm mode is more versital.


I screwed up the top end stuff.  I spooled the turbo to quickly and got the rpms over the top limit and boost just dropped (as the code says it should).

I will have to retest tomorrow with the fix to what I screwed up haham
Title: Re: HE351 code for me78569
Post by: me78569 on July 17, 2015, 10:24:31 AM
Yet more questions. 

I see you are starting timers at the start of the main sections and finishing then calc the time spent; however I don't see them being used anywhere?

What are they for?
Title: Re: HE351 code for me78569
Post by: hakcenter on July 17, 2015, 12:45:36 PM
LBB Common Code (http://community.lilbb.com/coding/base-arduino-code/msg23/#msg23)

Quote from: hakcenter on April 16, 2015, 09:38:02 PM
[...]

const boolean millis_out = false; -- adds time per function into serial output

[...]

they are for debugging mostly, if you want to see how fast code is running in specific spots.
Title: Re: HE351 code for me78569
Post by: me78569 on July 17, 2015, 02:49:45 PM
figured that was the case.

Do anyone have a drive pressure gauge running your setup or am I the only one? 

I can't run the 860 start curve without sky high drive/boost ratio.  I am running 100 injectors and no tuner now, I was wondering how my experience compares to others?

I should do a video.
Title: Re: HE351 code for me78569
Post by: Bdubb'z on July 17, 2015, 04:13:56 PM
I run a modified curve 4 on my common rail, but definitely start at 860, it still blows a little smoke, but I'm also a manual trans.  Need it closed up after each shift.  Been towing heavy and light with mine for thousands and thousands of miles now, all over the western us.  Working good on my setup.  My worse case is around 2:1 down low there.   
Title: Re: HE351 code for me78569
Post by: me78569 on July 17, 2015, 05:42:30 PM
at what point down low so I need to start considering the ratio?  If I start at 860 I can easily build 7 psi of drive and 1-2 psi of boost. 

Does it really matter that the ratio is so high at very little boost? 

As soon as I switch positions over and start at 800 boost to drive stays closer to 2:1 then less as I start getting higher in the boot range.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 17, 2015, 08:36:47 PM
No offense but do you really care about any drive pressure under 30 psi, regardless of the boost pressure ? Drive pressure should be under 2:1 at 15~psi or so.

Shouldn't really matter at all unless you actually feel the position loading the motor on your butt dyno. Which is what I primarily use the cruise button for, when I'm tuning a curve. curve 4 should get the turbo up to speed and stay within 700s once its at 20k. If its under that you're not really driving probably just parking lot crap.
Title: Re: HE351 code for me78569
Post by: me78569 on July 17, 2015, 08:47:26 PM
That's what I was asking haha.  Figured that was the case, but I figure it is better to ask a dumb question than do something dumb.  I didn't know if there could be bearing issues by having so much pressure on one side.

I do however feel the motor loading with position starting under 7ish cm,

I am working to code my stuff to "snap" the turbo closed for a second like cummins/dodge does on take off.  I really like how it is working so far, but i need some more butt dyno time.  I am seeing a lot more overspooling conditions without WOT so I am thinking I am driving the turbo to hard.


Side note what did you use to qualify the overspeed rpm you have?  I am looking at some hx40 maps trying to figure out where I should be trying to have the turbo sit at.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 17, 2015, 10:00:50 PM
It's an hx40 wheel, so 130k is maximum. Obviously dudes have gone to 45psi on this turbo so it goes higher, but holset max is 130k

The lbb code goes to 0 @ 132k, it should walk from 130 to 132 to 0 though..  but the 132k is a catch all.

Now I've seen a truck that was obviously equipped with a he351ve.... stock at the metals warehouse I visit for cheap scraps... and his motor immediately loaded up to turbo whistle.. 900s imho, while barely touching the throttle.

The only real way to smooth out the transition to 20k is to raise the idle position, or lower the value. You should be able to idle in the 700s, it isn't loud. I would use it but it was too much of a pain to adjust the turbo to come back down to idle in that so I just left the code in a more module way.

Personally once my truck is back officially on the road, I'll be idling atleast in the 600s
Title: Re: HE351 code for me78569
Post by: Rx7man on July 18, 2015, 12:43:45 AM
I've been thinking about this, and I was going to make it so that it really doesn't spool at idle much, and if you do want it to spool at idle, just hit the jake switch which will then close it up and spool it... I was thinking of trying to maintain a constant drive pressure on it mapped to different RPM's.. eg 5 PSI at idle to 1250, then quickly ramp up to what you'd need to actually slow the vehicle down, like 40-60 psi
Title: Re: HE351 code for me78569
Post by: me78569 on July 19, 2015, 12:58:19 PM
Alright I have spent some time driving /testing and I think I have the "snap" upon take off working well.  this does require that a TPS sense wire is in place.

/*  This code is put in place to control an HE351ve turbo using Turbo RPM and other inputs.
*   
*  Sections of this code, including but not limited to the rpm based vane position calculations, Freq Measure, and
*  Timer setup are thanks to Curtis R Hacker at lilbb.com and his RPM based HE351vgt arduino shield.

*  This work is licensed under the
*  Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
*  To view a copy of this license,
*  visit [url=http://creativecommons.org/licenses/by-nc-sa/4.0/]Creative Commons &mdash; Attribution-NonCommercial-ShareAlike 4.0 International
&mdash; CC BY-NC-SA 4.0 [/url].
*/

/////////////////////////////POS Manage////////////////////////////////////////
void PosManage() {
      if (turbo_rpm <= curve_rpm[4]) {
        if (ThrottlePosition < 2) {  // Idle Section
            if(turbo_rpm <= idle_rpm) {
             vane_position = idle_position;
             idle_mode = true;
             idle_walkdown_mode = false;
          } else {
            if (turbo_rpm <= idle_walkdown_rpm) { idle_walkdown_mode = true; } else { idle_walkdown_mode = false; }
            if (idle_walkdown_mode) { vane_position = constrain((final_vane_position - 10),idle_position-two_cm, 800); }
            idle_mode = false;
          }
        }else {
          // -----
          // Curve section
               if (turbo_rpm <= curve_rpm[0]) { vane_position = map(turbo_rpm, idle_rpm , curve_rpm[0], 875, turbo_curve[0]);} //turbo_curve[0];}
          else if (turbo_rpm <= curve_rpm[1]) { vane_position = map(turbo_rpm, curve_rpm[0], curve_rpm[1], turbo_curve[0], turbo_curve[1]);}
          else if (turbo_rpm <= curve_rpm[2]) { vane_position = turbo_curve[1];}
          else if (turbo_rpm <= curve_rpm[3]) { vane_position = map(turbo_rpm, curve_rpm[2], curve_rpm[3], turbo_curve[1], turbo_curve[2]);}
          else { vane_position = map(turbo_rpm, curve_rpm[3], curve_rpm[4], turbo_curve[2], turbo_curve[3]);}
        }
      } else if (turbo_rpm < top_end_rpm) {
        vane_position = map(turbo_rpm, curve_rpm[4], top_end_rpm, turbo_curve[3], turbo_curve[4]);
      } else {
       
            if (turbo_rpm <= 126000) { vane_position = map(turbo_rpm, top_end_rpm, 126000, turbo_curve[4], 500);}
          else if (turbo_rpm <= 130000) { vane_position = map(turbo_rpm, 126000, 130000, 500, 300);}
          else { vane_position = map(turbo_rpm, 130000, 132000, 300, min_position);}
        }
        // Overrun protection
       if (turbo_rpm > 132000) { vane_position = 0;}   
}


The only other thing you will need is Offidle_position = (whatever you want it to snap to); in the variable setup.  I have mine set to 875 and it seems to work well. 

I have also adjusted the upper rpm section as I am still having issues with overspinning the turbo.  I will need to tinker with it more, but for the meantime it works pretty good.  The rpm based is starting to really shine compared to the boost map. 
Title: Re: HE351 code for me78569
Post by: me78569 on July 20, 2015, 09:41:20 PM
I am trying to tune the top end now.  I was running the top end positions from the 1.1 code, but if I held the throttle at %50 I would overspin the turbo faster than I can type overspin.   

Are you not having issues with that when you run 1.1?  I can't get it to hold over 25-30 psi without the vanes jumping to 0 due to overspin.

1.1 as you know is
else {
               if (performance_mode && turbo_rpm <= 125000) { vane_position = map(turbo_rpm, top_end_rpm, 125000, turbo_curve[4] + performance_position, 580); }
          else if (turbo_rpm <= 126000) { vane_position = map(turbo_rpm, top_end_rpm, 126000, turbo_curve[4], 580); }
          else if (turbo_rpm <= 130000) { vane_position = map(turbo_rpm, 126000, 130000, 580, 400); }
          else { vane_position = map(turbo_rpm, 130000, 132000, 400, min_position); }
        }


I am now matching what bduzz has for his topend, but I haven't tested yet.   

      } else if (turbo_rpm < top_end_rpm) {
        vane_position = map(turbo_rpm, curve_rpm[4], top_end_rpm, turbo_curve[3], turbo_curve[4]);
      } else {
{
               if (turbo_rpm <= 126000) { vane_position = map(turbo_rpm, top_end_rpm, 126000, turbo_curve[4], 300); }
          else if (turbo_rpm <= 130000) { vane_position = map(turbo_rpm, 126000, 130000, 300, 100); }
          else { vane_position = map(turbo_rpm, 130000, 132000, 100, min_position); }
        }



I really need to run my boostmap code with rpm display to see what shaft speed is in that code.  I was trying to hold the exhaustpressure at 50psi on the topend. :o little worried what I was doing haha.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 21, 2015, 01:14:13 AM
Well my clutch never held so it may be too steep at the tip top
Title: Re: HE351 code for me78569
Post by: me78569 on July 21, 2015, 07:16:47 AM
Even with the much more open top end I am overspeeding the turbo.  It's better, but still unable to do a WOT run without the vanes jumping open and boost falling off. 

Maybe I need to have the curve adjust with throttle input also.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 21, 2015, 09:41:15 AM
Does it ever come back down? You can over shoot it and it should walk back in and settle
Title: Re: HE351 code for me78569
Post by: me78569 on July 21, 2015, 10:15:58 AM
Yea if you hold it long enough, but it takes 5 seconds or so. 

It goes kinda like this example so take with grain of salt. 

WOT
1 sec 65000 rpm 20psi
2 sec 100000 rpm 30 psi
3 sec 130000 rpm 38 psi
4 sec 140000 rpm 12 psi
5 sec 120000 rpm 12 psi
6 sec 110000 rpm 13 psi
7 sec 100000 rpm 14psi
8 sec 110000 rpm 20 psi
9 sec 120000 rpm 25 psi
10 sec 130000 rpm 30 psi

then repeat pretty much

I am thinking turbo rpms are increasing too fast from 80,000-120000 and it can't adjust fast enough, also I think the turbo averaging section is delayed enough ( because of 64 reads, you wont see the average come up to actual for a bit due to how averages work) to make it so the vane position is too small for the actual rpm vs averaged rpm if that makes sense?

If I stay at %40-%50 the mid range power is incredible,  anything more and the truck becomes  a monster for a second then the vanes open up fully. 

pondering how to get it under control as I am still having issues with the 130000 position being at 100 haha

else {
          // -----
          // Curve section
               
               if (turbo_rpm <= curve_rpm[0]) { vane_position = constrain(map(turbo_rpm, idle_rpm , curve_rpm[0], Offidle_position, turbo_curve[0]), Offidle_position, turbo_curve[0]);} //turbo_curve[0];}
          else if (turbo_rpm <= curve_rpm[1]) { vane_position = map(turbo_rpm, curve_rpm[0], curve_rpm[1], turbo_curve[0], turbo_curve[1]);}
          else if (turbo_rpm <= curve_rpm[2]) { vane_position = turbo_curve[1];}
          else if (turbo_rpm <= curve_rpm[3]) { vane_position = map(turbo_rpm, curve_rpm[2], curve_rpm[3], turbo_curve[1], turbo_curve[2]);}
          else { vane_position = map(turbo_rpm, curve_rpm[3], curve_rpm[4], turbo_curve[2], turbo_curve[3]);}
        }
      } else if (turbo_rpm < top_end_rpm) {
        vane_position = map(turbo_rpm, curve_rpm[4], top_end_rpm, turbo_curve[3], turbo_curve[4]);
      } else {

               if (turbo_rpm <= 126000) { vane_position = map(turbo_rpm, top_end_rpm, 126000, turbo_curve[4], 200); }
          else if (turbo_rpm <= 130000) { vane_position = map(turbo_rpm, 126000, 130000, 200, 100); }
          else { vane_position = map(turbo_rpm, 130000, 132000, 100, min_position); }
        }
        // Overrun protection
       if (turbo_rpm > 145000) { vane_position = 0;}


Maybe increasing the turbo_curve[4] positions to a large position?  almost like the turbo is being slingshot from 80000 rpm to 140000 rpm right now
Title: Re: HE351 code for me78569
Post by: hakcenter on July 21, 2015, 11:39:14 AM
Well figure out where it is loading up all that inertia.

Set your under 126k to minimum size, and see if it over shoots it, if it does. You need to lower the band.

105 to 120, etc. then to 118, until it stops over shooting it, then retune the curve


if (performance_mode && turbo_rpm <= 120000) { vane_position = map(turbo_rpm, top_end_rpm, 120000, turbo_curve[4] + performance_position, 600); }
          else if (turbo_rpm <= 110000) { vane_position = map(turbo_rpm, top_end_rpm, 120000, turbo_curve[4], 600); }
          else if (turbo_rpm <= 115000) { vane_position = map(turbo_rpm, 120000, 128000, 600, 300); }
          else if (turbo_rpm <= 125000) { vane_position = map(turbo_rpm, 120000, 128000, 300, 200); }
          else { vane_position = map(turbo_rpm, 128000, 130000, 200, min_position); }
Title: Re: HE351 code for me78569
Post by: me78569 on July 21, 2015, 12:36:40 PM
already working that out.  Slowly.  I hate burning up this much fuel haha. 
Title: Re: HE351 code for me78569
Post by: Rx7man on July 21, 2015, 04:38:54 PM
I would do something like


int overspeedcompensation = map(turbineshaftspeed,140000,150000,0,900)
overspeedcompensation = constrain(overspeedcompensation,0,900)

vaneposition += overspeedcompensation


some of the logic may be reversed, but I think you get the idea.. if it's over 140,000, start opening the vanes to full open by 150,000... this should work pretty good, and it's only a couple lines of code
Title: Re: HE351 code for me78569
Post by: me78569 on July 21, 2015, 05:17:24 PM
that is a good idea. 

Interestingly the 6.7 logs that I have  show that the turbo never goes about 18cm on a WOT run.
The log shows this
Idle pos is 14cm
offidle pos snaps to 7cm
then increases on a curve from 7 cm to 14cm rather quickly then stays there for awhile
then jumps to 18cm for awhile
then back down to 14cm
and the EB apply hovers around 4cm


Point I am wondering about is why is it that a 6.7 cummins with 350-380hp never needs more than 18cm, whereas I need positions of %100 to keep turbo speed in check?

All my testing is done with 100hp injectors and 65hp worth of programmer help.
So butt dyno quality math gives me 235+100+65 = ~400 hp ( closer to 380 hp as we don't trust everything they say)

I am wondering if our freq readings are delayed enough (averaging 64 reads ends up causing latency vs real speed) that we are keeping the vanes too tight down low and "slingshoting" the turbo to 100k+ speeds then the freq catches up and jumps to a large position? 

Now the 64 reads should take less than 100ms for the read[63] to make it to read[0], but is that too slow to keep up with the vanes? 



Really just spit balling here. 


side note, I changed the top_end_rpm to 90000 and changed the top end curves to the below.  This has helped a TON.   I am still getting Overrun, but it is if I am really pushing and it corrects itself quickly.  If I wasn't bored and picky I would call it good and be happy, but I have free time to tune more.

if (turbo_rpm <= 126000) { vane_position = map(turbo_rpm, top_end_rpm, 126000, (turbo_curve[4] - TPS_range), (200 - TPS_range)); }
          else { vane_position = map(turbo_rpm, 126000, 132000, (200 - TPS_range), min_position);}




Question for the programmer master dude haha,  I know the freq readings averaged at 64 are VERY stable, but in your opinion how delayed would a spike in RPM be taking into account that a spike read as read[0] would take 32 more reads to become the middle position?  watching my screen I know that 100,000 to 130000 can happen within 1/4 second. 








Little update, I finally got around to inserting the freq measure into the boostmap code I have.  as I expected by 20-25psi of boost, the turbo shaft speed was climbing past 160,000 rpm :o  the rpm based code is without a doubt the way to go.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 21, 2015, 08:16:08 PM
LOL pretty dangerous boost code there bro.

You can cut the averaging out... which may need to happen post 100k...


      final_sum = 0;
      for (int i = 0; i < 64 ; i++) { final_sum += sum[i]; }
      turbo_rpm = FreqMeasure.countToFrequency(final_sum >> 6);
      turbo_rpm = (turbo_rpm << 6) - (turbo_rpm << 2);
      if (count > 63) { count = 0; }

to

      final_sum = 0;
      if (turbo_rpm < 100000) {
        for (int i = 0; i < 64 ; i++) { final_sum += sum[i]; }
        turbo_rpm = FreqMeasure.countToFrequency(final_sum >> 6);
        turbo_rpm = (turbo_rpm << 6) - (turbo_rpm << 2);
        if (count > 63) { count = 0; }
      } else {
        for (int i = 0; i < 8 ; i++) { final_sum += sum[i]; }
        turbo_rpm = FreqMeasure.countToFrequency(final_sum >> 3);
        turbo_rpm = (turbo_rpm << 6) - (turbo_rpm << 2);
        if (count > 7) { count = 0; }
      }



Also.. I would look to the timer...


  // Update vane_position every 10ms 100k+ / 25ms 60k - 100k / 100ms 0 - 60k
       if (timer % 10 == 0 && turbo_rpm > 100000) { update_vane_position = true; }
  else if (turbo_rpm > 60000 && timer % 25 == 0) { update_vane_position = true; }
  else if (timer % 50 == 0) { update_vane_position = true; }


Change %10 to... %4 to update position every 4ms.. which will make it react faster.. even 2ms if you want. wouldn't go faster than that thou.
Title: Re: HE351 code for me78569
Post by: me78569 on July 21, 2015, 08:54:58 PM
yea,  I thought that might be the case, which is why I moved off of it weeks ago haha.


Still bugging me that 6.7s only need 18cm to keep things in check.

If you can to enlighten me more,  The shaft of the turbo has 1 notch on it? 4 notches etc?  How does the code know what 1 revolution is?  Is that not how a vr sensor works?
Title: Re: HE351 code for me78569
Post by: hakcenter on July 21, 2015, 09:02:37 PM
from what I read and saw... its only 1 notch, so 1 count is 1 rev.

Seems about right cause it hits like a truck around 128k, whereas 115 was pretty fast.. but 128 was like weeeeeee

To be fair the 6.7 doesn't have an intro into 120k @ 12~cm, so there's more headroom for them to be safe, etc etc.
Title: Re: HE351 code for me78569
Post by: me78569 on July 21, 2015, 09:15:23 PM
Very true. 

I cut down your 64 reads to 32 and things seem to be calming down some in the "slinshot" from 100k to 130+  I absolutely want to retain the averaging function of rpms so this seems to be a good median, as 16 reads was all over compared to 64 and 32.

I have moved all positions up and will test more in the morning.   


It's a good free hobby at this point haha.


Edit: finally found a rebuild video of the he351ve.  The shaft clearly has one notch as expected.  haha
Title: Re: HE351 code for me78569
Post by: hakcenter on July 21, 2015, 09:57:34 PM
Well I have good news and not so good news.


Your overspin made me want to go ahead and push my new clutch setup. So far seems to be holding.. I probably should of greased the throwout bearing a bit more since I can feel it a bit in the pedal now as to opposed to first drive, oh well whatever.


The bad news is, yep overspinning now too haha. And pretty bad.

Here's my current stuff:

Loop

final_sum = 0;
      if (turbo_rpm < top_end_rpm) {
        for (int i = 0; i < 64 ; i++) { final_sum += sum[i]; }
        turbo_rpm = FreqMeasure.countToFrequency(final_sum >> 6);
        turbo_rpm = (turbo_rpm << 6) - (turbo_rpm << 2);
        if (count > 63) { count = 0; }
      } else {
        for (int i = 0; i < 4 ; i++) { final_sum += sum[i]; }
        turbo_rpm = FreqMeasure.countToFrequency(final_sum >> 2);
        turbo_rpm = (turbo_rpm << 6) - (turbo_rpm << 2);
        if (count > 3) { count = 0; }
      }


Timer1

if (turbo_rpm < top_end_rpm) {
    if (vane_position >= last_vane_position + 20 && last_vane_position < max_position - 10) {
      final_vane_position = last_vane_position + 10;
    } else if (vane_position <= last_vane_position - 20 && last_vane_position > min_position + 10) {
      final_vane_position = last_vane_position - 10;
    } else if (vane_position - 10 >= last_vane_position || vane_position + 10 <= last_vane_position) {
      if (vane_position > last_vane_position + 2 && last_vane_position < max_position - 2) {
        final_vane_position = last_vane_position + 2;
      } else if (vane_position < last_vane_position - 2 && last_vane_position > min_position + 2) {
        final_vane_position = last_vane_position - 2;
      }
    }
  } else {
    if (vane_position > last_vane_position + 10 || vane_position < last_vane_position - 5) {
      final_vane_position = vane_position;
    } else {
      final_vane_position = last_vane_position;
    }
  }

You want to remove the jitter, but let it get bigger faster than smaller.

Timer2

// Update vane_position every 10ms 100k+ / 25ms 60k - 100k / 100ms 0 - 60k
       if (timer % 4 == 0 && turbo_rpm > top_end_rpm) { update_vane_position = true; }
  else if (turbo_rpm > curve_rpm[4] && timer % 25 == 0) { update_vane_position = true; }
  else if (timer % 50 == 0) { update_vane_position = true; }


WOT Curve

} else {
               if (performance_mode && turbo_rpm <= 120000) { vane_position = map(turbo_rpm, top_end_rpm, 120000, turbo_curve[4] + performance_position, 480); }
          else if (turbo_rpm <= 120000) { vane_position = map(turbo_rpm, top_end_rpm, 120000, turbo_curve[4], 480); }
          else if (turbo_rpm <= 128000) { vane_position = map(turbo_rpm, 120000, 128000, 480, 140); }
          else { vane_position = map(turbo_rpm, 128000, 130000, 140, min_position); }
        }


And ya.. its a bit more managable now.

The really really bad news is, my truck can't keep traction now. LSD 355 gears on 265x75x16 BFG AT's (the baha winners). So I don't know what else to do but get bigger tires or dial my pump down.. which I probably should since I can't see the tail pipe at night over at Sears where I do all my WOT pulls.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 21, 2015, 10:35:20 PM
I'll come up with a more ingenious way to keep rpms around 128k.. just going to take more thought now

I did go through the cummins log to notice that basically position 506 to 372, with no incrementing at all. 0xfa 0x01 to 0x74 0x01

I imagine I'll probably end up writing stepping, instead of mapping up to that point.. seems like a good idea... lol

This'll be the next thing I try..


if (performance_mode && turbo_rpm <= 120000) { vane_position = map(turbo_rpm, top_end_rpm, 120000, turbo_curve[4] + performance_position, 480); }
          else if (turbo_rpm <= 120000) { vane_position = map(turbo_rpm, top_end_rpm, 120000, turbo_curve[4], 480); }
          else if (turbo_rpm <= 122000) { vane_position = 400; }
          else if (turbo_rpm <= 124000) { vane_position = 320; }
          else if (turbo_rpm <= 126000) { vane_position = 240; }
          else if (turbo_rpm <= 128000) { vane_position = 160; }
          //else if (turbo_rpm <= 128000) { vane_position = map(turbo_rpm, 120000, 128000, 480, 140); }
          else { vane_position = map(turbo_rpm, 128000, 130000, 160, min_position); }


And if it works pretty well I may go back to 64 averages, 10ms updates, no jitter removal, etc etc
Title: Re: HE351 code for me78569
Post by: me78569 on July 21, 2015, 10:54:13 PM
The more you hash it out the better it gets.  I'll test your changes in the am
Title: Re: HE351 code for me78569
Post by: me78569 on July 22, 2015, 08:17:51 AM
well I might have figured out part of my issues.   When I set the averaging to 4 rather than 32 or 64 I am seeing random rpm reads of %30-%40 higher or lower than the rest of the group.  Seems as I drive the worse it gets then it clears up and comes back. 

I am wondering if I am getting interference on the turbo speed wires.  I am going to twist them and wrap in tinfoil tonight and see if that helps.

Idle rpms of 12k I see jumps to 5k and up to 20k,  at 50k I see 30k to 70k, and above 100k I see 80k to 170k very odd.
Title: Re: HE351 code for me78569
Post by: Rx7man on July 22, 2015, 01:27:54 PM
The sensor wires *should* be pretty resistant to interference as they operate on a differential voltage... The interference you get on 1 of the wires you'll also get on the other (since they run together), and the chip is designed to exclude common voltages between them.. but it can't hurt anything.
Title: Re: HE351 code for me78569
Post by: me78569 on July 22, 2015, 01:29:12 PM
From CF post

P2580 Turbo Speed Sensor Circuit Low

Turbo speed is used to throw a MIL and the ecm will try and estimate turbo speed.

I don't think the 6.7 tuning uses shaft speed to directly tune the turbo curves, rather it uses shaft speed to ensure the turbo stays within it's bounds.

It might explain that jump from 14 position to 18 directly in the canbus logs. Seems that maybe the turbo was reaching the limit on a long pull at 14cm^2 and shaft speed hit the limit, so the vanes snapped to 18cm.

This in theory would allow the turbo to keep making maximum boost, while reducing the speed some.


Quote from: Rx7man on July 22, 2015, 01:27:54 PM
The sensor wires *should* be pretty resistant to interference as they operate on a differential voltage... The interference you get on 1 of the wires you'll also get on the other (since they run together), and the chip is designed to exclude common voltages between them.. but it can't hurt anything.

Any theories on why I am seeing a HUGE jump in RPMS?    Only think I know is the wires from the sensor on the turbo are twisted. figure there might be a reason for it? haha.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 22, 2015, 01:50:25 PM
Delays could change output.

What is the exact code you're using for 4 intervals? Are you not running it the way i am?
Title: Re: HE351 code for me78569
Post by: me78569 on July 22, 2015, 02:22:15 PM
void loop() {

  // Freq Measure
  unsigned long sum[4];
  unsigned long final_sum;
  byte count = 0;
 
  // loop
  while(1) {
    t1.update();
    t2.update();
   
    // Freq Measure
    if (FreqMeasure.available()) {
      // average several reading together
      sum[count] = FreqMeasure.read();
      count++;
      // turbo_rpm = Freq(sum / count) * 60
      final_sum = 0;
      for (int i = 0; i < 4 ; i++) { final_sum += sum[i]; }
      turbo_rpm = FreqMeasure.countToFrequency(final_sum >> 2);
      turbo_rpm = (turbo_rpm << 6) - (turbo_rpm << 2);
      if (count > 3) { count = 0; }
    }
  }
}


32 is the lowest number of reads that has steady reads. 

think possibly I am running too many things in my keeptime that is causing a delay in the freqcount?

I will comment out stuff and see I guess haha.



I really like how the rpm mapping works on the low end, but the more I think about it I think the turbo speed up high should set a position rather than map like you said.  I also think TPS should be taken into consideration and increase or decrease that position from there. 
Title: Re: HE351 code for me78569
Post by: hakcenter on July 22, 2015, 02:38:03 PM
Imho the first thing in your code i would take out is the lcd. And see how it fairs
Title: Re: HE351 code for me78569
Post by: Rx7man on July 22, 2015, 03:23:35 PM
There's gotta be a reason for it.. but be darned if I know what it is :P  some help I am eh?
Title: Re: HE351 code for me78569
Post by: Rx7man on July 22, 2015, 03:34:14 PM
Oh, here's ONE possibility.. freqmeasure isn't catching all the pulses... I wrote my own code for it, and with some rough testing it seemed to work well..

So you have a global variable

int TSScounts;

And you have an interrupt enabled pin and routine

void Setup(){
.
.
.
  /* Here's the interrupts on various boards
  Board         int.0 int.1 int.2 int.3 int.4 int.5
  Uno, Ethernet 2 3
  Mega2560 2 3 21 20 19 18
  Leonardo 3 2 0 1 7
  */
  attachInterrupt(1, TSSpinISR, FALLING);
}



And whenever you want the RPM updated, call this sub to update the global variable (TSStimeout is a global variable too, but could be localized if you want...


void CalculateTSS() {
  static unsigned long LastMicros = micros();
  unsigned long Now = micros();
  unsigned long Timespan = Now - LastMicros;
  unsigned int NewRPM = 60000000 / Timespan * TSScounts;
  int counts = TSScounts;
  if (Timespan > TSStimeout) { // a second has elapsed without accumulating enough counts, thus the turbine is stopped
    // Serial.println("Reset RPM to 0");
    TSS.Reset(); //one of the rare times you access the storage directly
    LastMicros = Now;
  }
  else  if (counts > TSSminCounts) {//only update value if we have enough counts to do something with.. rather increase the timespan (by waiting until the next go round) to get a closer approximation
    TSScounts = 0;
    LastMicros = Now;
    TSS.UpdateValue(NewRPM);
  }
}



//And finally the very simple ISR
void TSSpinISR() {
  TSScounts++;
}


Title: Re: HE351 code for me78569
Post by: hakcenter on July 22, 2015, 04:56:02 PM
FreqMeasure falls on an interrupt pin and 64bit blah blah blah roll over blah blah blah

It's accurate and fast on pin 8.

However fast the code can come around and measure will drastically affect the average.

If one time you got to count for 100ms then next time counted for 150ms, there's going to be variation.
Title: Re: HE351 code for me78569
Post by: me78569 on July 22, 2015, 05:02:44 PM
yep,

I am looking elsewhere at this point. 

I am more concerned about the overspin and tuning the top end as I can user averaging of 32 reads to gt good rpms results.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 22, 2015, 05:15:41 PM
If you have any libraries that disable interrupts that can royally ruin FreqMeasure as well
Title: Re: HE351 code for me78569
Post by: Rx7man on July 22, 2015, 05:36:04 PM
that's a very good point!
Title: Re: HE351 code for me78569
Post by: hakcenter on July 22, 2015, 07:29:21 PM
Well... I went back to stock 1.1 code minus the top end.


  // Update vane_position every 10ms 100k+ / 25ms 60k - 100k / 100ms 0 - 60k
       if (timer % 10 == 0 && turbo_rpm > top_end_rpm) { update_vane_position = true; }
  else if (turbo_rpm > curve_rpm[4] && timer % 25 == 0) { update_vane_position = true; }
  else if (timer % 50 == 0) { update_vane_position = true; }



  // Vane smoothing between large values
  if (turbo_rpm < top_end_rpm) {
    if (vane_position >= last_vane_position + 20 && last_vane_position < max_position - 10) {
      final_vane_position = last_vane_position + 10;
    } else if (vane_position <= last_vane_position - 20 && last_vane_position > min_position + 10) {
      final_vane_position = last_vane_position - 10;
    } else if (vane_position - 10 >= last_vane_position || vane_position + 10 <= last_vane_position) {
      if (vane_position > last_vane_position + 2 && last_vane_position < max_position - 2) {
        final_vane_position = last_vane_position + 2;
      } else if (vane_position < last_vane_position - 2 && last_vane_position > min_position + 2) {
        final_vane_position = last_vane_position - 2;
      }
    }
  }
  // Update last_vane_position



      for (int i = 0; i < 64 ; i++) { final_sum += sum[i]; }
      turbo_rpm = FreqMeasure.countToFrequency(final_sum >> 6);
      turbo_rpm = (turbo_rpm << 6) - (turbo_rpm << 2);
      if (count > 63) { count = 0; }



} else {
               if (performance_mode && turbo_rpm <= 120000) { vane_position = map(turbo_rpm, top_end_rpm, 120000, turbo_curve[4] + performance_position, 580); }
          else if (turbo_rpm <= 120000) { vane_position = map(turbo_rpm, top_end_rpm, 120000, turbo_curve[4], 580); }
          else if (turbo_rpm <= 122000) { vane_position = 500; }
          else if (turbo_rpm <= 124000) { vane_position = 440; }
          else if (turbo_rpm <= 126000) { vane_position = 340; }
          else if (turbo_rpm <= 128000) { vane_position = 220; }
          else { vane_position = map(turbo_rpm, 128000, 130000, 220, min_position); }
        }


Working great on my truck! Infact I had to move the last position 1cm, tuned it in half cm increments. Comes in pretty hard, slightly slows down, gets stuck for a long time, rolls into mapping to 0 then comes slightly back!

Truck is still a rocket as well... really enjoying it, obviously the idle walkdown needs more work I found instances where it popped out of it... so I'll have to figure something out.
Title: Re: HE351 code for me78569
Post by: me78569 on July 22, 2015, 08:57:51 PM
I am going to attempt that top end tomorrow.  Looking forward to it.
Title: Re: HE351 code for me78569
Post by: me78569 on July 23, 2015, 07:27:17 AM
Much better,  I need to adjust my curve a bit, but it tried pretty hard to stay right at 130000
Title: Re: HE351 code for me78569
Post by: me78569 on July 23, 2015, 08:13:50 AM
And the two other libraries that I am using are

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

Looking through them now to see any funny business about disable interrupts
Title: Re: HE351 code for me78569
Post by: Rx7man on July 23, 2015, 11:48:18 AM
I don't know much about the Wire library, but perhaps the I2C library uses an interrupt of higher priority, and if it does a lot of stuff in there it might delay yours... Just another of my thoughts :P
Title: Re: HE351 code for me78569
Post by: me78569 on July 23, 2015, 12:10:43 PM
I see other people using freqmeasure using the i2c library together. 


The more I read the more I am thinking the lcd update is causing the hiccup in the freqmeasure. 
Title: Re: HE351 code for me78569
Post by: hakcenter on July 23, 2015, 02:00:34 PM
Look for isr anywhere in the library. If it exists... Look up  isr_noblock and add it the other interrupts not the freqmeasure one
Title: Re: HE351 code for me78569
Post by: Rx7man on July 23, 2015, 02:32:41 PM
I'd guess it as well.. can you temporarily disable it and see if it fixes it?
Title: Re: HE351 code for me78569
Post by: me78569 on July 23, 2015, 03:01:27 PM
lcd update process takes 71 ms to run.  I am gonna to trim it down some and likely run it every 500 millis. 

So that runs every 300 millis. currently.  Tested without the lcd and added output to serial,  the readings are more accurate, but I am still able to blow through the 150000 range using the 1.1 code plus the new top end still.

So what I did is map the over 105000 rpm (top_end_rpm, 130000, curve[4]-TPS_range, 200-TPS_range)

Went for a drive and shaft speed will spike to 135,000-140,000 but then settles down around 125ish-130ish pretty nicely.

Next I am going to try taking the top end rpms down 90000 and mapping to 120,000 rather than 130000 and see if I can't get it to spike to 135 and settle at 12x,000.   
Title: Re: HE351 code for me78569
Post by: hakcenter on July 23, 2015, 05:14:24 PM
What happens if you just run the lbb 1.1 with my changes?

Might need to make the analog reads unblock
Title: Re: HE351 code for me78569
Post by: me78569 on July 23, 2015, 06:59:56 PM
1.1 with your changes and I blow through to 150k then it jumps wide open and all boost is lost. 

I am seeing no "isr" in either the wire.h or liquidcrystal.h

My top end seems to be managing the vanes up there now.  I see a spike (assuming while the system catches up) then it comes back down and hovers between 115000-125000 pretty nice. 

Title: Re: HE351 code for me78569
Post by: me78569 on July 23, 2015, 10:53:12 PM
Alright I think I have a good way to control the top end stuff.   I will do the code in the am.

Rather than assigning positions to different shaft speeds to try and slow the rise In rpms, why don't we assign a desired top end rpm.  Very basic code on phone so it's dirty

If (turbo _ rpm > topend){
If (turbo _ rpm <desired_rpm){
Map (movement, turbo rpm, desired rpm, 10, 1);
Vane_position += conrstain (movement, topendpos, 18cm );}
Else if (turbo_rpm>desiredrpm){ map (movement,desiredrpm,overspeedrpm,1,10);
Vane_positio -=constrain  (movement, 18cm, 25cm);}
}





Thoughts?  Dunno if I can sleep until I write this up.  It would automatically increase or decrease vane potion trying to get turbo rpm at the desired position.  This should work regardless of fueling or throttle input.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 23, 2015, 11:16:23 PM
RPM hunting is nearly impossible without delays since its nearly impossible to foresee shaft changes until after the fact.

Put it in cruise mode and watch how responsive that is. If you try to break out, you can for awhile. I wrote a bit like that, for awhile but eventually abandoned it completely.

All I can suggest, like how I tuned my top end curve. Is try to make it step into the final area rather abruptly. If from 120 to 122 isn't even there, you need to make it substantially larger.

You could take out the 120 to 122 step and go from 120 to 124, etc..



Lastly, do you have a schematic for your layout ? Are you doing any power filtering at all on the 5v rail ?
Is your 9924 vr+ / vr- 10k then ceramic 1nF (0.001uF / 1000pF) cap across ? 10k pullup on the 5v rail for Cout ?
Title: Re: HE351 code for me78569
Post by: me78569 on July 23, 2015, 11:18:33 PM
Yep couldn't sleep.

Little  tired so this may not be right, but I think it is in the right direction. 
else if (turbo_rpm < lit_rpm) {
        vane_position = map(turbo_rpm, curve_rpm[4], lit_rpm, turbo_curve[3] - TPS_range, turbo_curve[4] - TPS_range);
      } else{
        if(turbo_rpm < Target_Rpm){
          POSMovement = map(Movement, turbo_rpm, Target_Rpm, 10, 1);
          vane_position += POSMovement;
          constrain(vane_position, turbo_curve[4] - TPS_range,333 - TPS_range);}
        else {
          POSMovement = map(Movement, Target_Rpm, turbo_rpm, 1, 10);
          vane_position -= POSMovement;
          constrain(vane_position, 500 - TPS_range, min_position);}

        }


        // Overrun protection
      if (turbo_rpm > 140000){
        if (!curvea) {vane_position = min_position;} //{overrun = true;} else{overrun = false;}
      }
    }


Same principle that I use in my EB function.




Quote from: hakcenter on July 23, 2015, 11:16:23 PM
Lastly, do you have a schematic for your layout ? Are you doing any power filtering at all on the 5v rail ?
Is your 9924 vr+ / vr- 10k then ceramic 1nF (0.001uF / 1000pF) cap across ? 10k pullup on the 5v rail for Cout ?


I have the 10k external pullups and the ceramic 1nf from your parts list.  I also have the external 5v pull on cout.

the 9924 is setup the exact same way yours is.
Title: Re: HE351 code for me78569
Post by: Rx7man on July 24, 2015, 08:02:32 AM
If you used a PID feedback loop you could avoid the overshoots... If every time you updated the turbine RPM you saved the last value before updating it, and multiplied it by some amount, you could know if the RPM is increasing or decreasing

so something like

if RPM>120000
  compensation = (RPM-oldRPM) * factor
  vaneposition += compensation
end if

where the factor is some constant for how aggressive you want it to open the vanes based on how fast the RPM is increasing
in my version (yet to be tested of course) I have PID loops on nearly every variable if I choose to use them
Title: Re: HE351 code for me78569
Post by: me78569 on July 24, 2015, 08:35:06 AM
My brain is in server admin mode right now so forgive me if I miss something?

Wouldn't the above need to be * by a factor of .00025 to be small enough to make the vane position movement be 1/2 cm? 




BTW guys I am only editing / thinking / going on with this to see if I can make things better.   The code the hakcenter wrote with the set position at rpm works pretty good once I change the curves and positions. 

I just get bored and see if anything make anything better.   don't feel like think is an huge deal, I am more so just tinkering and bouncing ideas.
Title: Re: HE351 code for me78569
Post by: Rx7man on July 24, 2015, 09:09:56 AM
it really depends on how fast you're updating the RPM.. if you're updating it ever 10 millis, there isn't going to be much difference between the old and new RPM values, requiring a bigger factor.. You could get rid of that by (RPM-oldRPM)/updateinterval, which would give the  RPM/s^2... then you have a better mental picture of how fast it's accelerating... if it's accelerating at 40,000 RPM/s, you know it's going to overshoot and you'll need to open the vanes more and quickly, if it's accelerating at 5,000 RPM/s, you may not really need to do anything.  If you have a large factor you can probably start opening the vanes a little later
Title: Re: HE351 code for me78569
Post by: hakcenter on July 24, 2015, 09:21:37 AM
Quote from: Rx7man on July 24, 2015, 08:02:32 AM
If you used a PID feedback loop you could avoid the overshoots... If every time you updated the turbine RPM you saved the last value before updating it, and multiplied it by some amount, you could know if the RPM is increasing or decreasing

so something like

if RPM>120000
  compensation = (RPM-oldRPM) * factor
  vaneposition += compensation
end if

where the factor is some constant for how aggressive you want it to open the vanes based on how fast the RPM is increasing
in my version (yet to be tested of course) I have PID loops on nearly every variable if I choose to use them

old rpm is in Timer1, just unused.

The big problem is the turbo as variable acceleration rates.100rpm / 200rpm @ various other rpm increments, don't respond the same way.

Say

110k, + 100rpm != 118k + 100rpm

And it looks like, in most of our thinking, that we should somehow be able to transistion rotor speed on a slope and it should just work. That is far from the case thou. While it may look like its what we should do. I think a moving average non-linear slope is most likely the way to do.

When I get to it, I'll make more stuff and a more consistent easier to edit, way of doing things. I'm thinking of taking the last 10ms speeds, at 1ms intervals, and making a judgement call on position. Using seconds, is going to be way too slow.


Me where are you getting your power for the Arduino ? And are you doing any capacitor filtering ?
Title: Re: HE351 code for me78569
Post by: me78569 on July 24, 2015, 09:28:50 AM
updating at 10 millis now

I am curious as to how fast the turbo can build speed.  100 per second?


At 120000 rpm the turbo is rotating 2 times per millis.  if I am reading once every 10 millis 20 revs per read is steady speed.


Haha no filtering on power that I know of, to slick for me.  Running the 14v through a converter to 5v ( I think maybe 7v)
Title: Re: HE351 code for me78569
Post by: hakcenter on July 24, 2015, 09:45:13 AM
Get a 0.1uF and 1uF cap, and toss them over the 5v arduino rail, you should be able to just use the female headers.


So ya, 2rpms @ 120k, since my truck is stable... I'll probably toss a variable in and start computing.. and see if this would be the next logical step.

Variable changes

// Turbo
const int minimum_turbo_rpm = 4000;
byte stage = 1;
unsigned long turbo_rpm = 0;
unsigned long last_turbo_rpm[10] = { 0,0,0,0,0,0,0,0,0,0 };
double turbo_accel = 0.0;

// Timer2 Variables
unsigned int timer = 0;
byte last_turbo_timer = 0;
byte stage_timer = 0;
boolean stage_down = false;
boolean update_vane_position = false;


Timer2

void keep_time() {
  time_start2 = millis();
  timer++;
  if (staging_enabled) {
    // Keeps turbo staging in time
    stage_timer++;
    if (stage_timer > 200) { stage_timer = 200; }
    if (timer % 2 == 0 && turbo_rpm > 100000) { update_vane_position = true; }
  }
  // Update vane_position every 10ms 100k+ / 25ms 60k - 100k / 100ms 0 - 60k
       if (timer % 10 == 0 && turbo_rpm > top_end_rpm) { update_vane_position = true; }
  else if (turbo_rpm > curve_rpm[4] && timer % 25 == 0) { update_vane_position = true; }
  else if (timer % 50 == 0) { update_vane_position = true; }
  // Update last_turbo_rpm
  last_turbo_rpm[last_turbo_timer] = turbo_rpm;
  last_turbo_timer++;
  if (last_turbo_timer > 9) { last_turbo_timer = 0; }
  // Update turbo_accel before calculating vane_position
  if (update_vane_position) {
    turbo_accel = 0.0;
    for (int i = 0 ; i < 10 ; i++) { turbo_accel += last_turbo_rpm[i]; }
    turbo_accel = (turbo_accel / 10) / 6000.0;
    turbo_accel = turbo_accel - (turbo_rpm / 6000.0);
  }
  // Modes
  if (timer % 100 == 0) { calculate_modes(); }
  // Calculate vane_position
  if (update_vane_position) { update_vane_position = false; calculate_vane_position(); }
  if (serial_out) {
    if (turbo_rpm < top_end_rpm && timer % 100 == 0) { serial_output(); }
    if (turbo_rpm > top_end_rpm && timer % 10 == 0) { serial_output(); }
  }
  if (timer == 1000) { timer = 0; }
  time_finished2 = millis();
  time_elapsed2 = time_finished2 - time_start2;
}


Serial Output changes

    output += extra + turbo_rpm + " | ";
    output += "Accel : ";
    if (turbo_accel >= 0) { output += " "; }
    output += turbo_accel;
    Serial.print(output);
    output = " | Mode : " + current_mode_array[current_mode];
    Serial.println(output);


I'll post a log later.. unfortunately bitwise can't be used in decimal math.. so sucks, whatever
Title: Re: HE351 code for me78569
Post by: hakcenter on July 24, 2015, 12:08:10 PM
After a bit more work, I got this log... going to need to update accel units as time updates change... since over 105k its 10ms vs 25 vs 50ms depending on shaft speed.

Log is in UTF8, so use notepad++ if you don't have a nix* machine

WOT section

CPOS : 756 | APOS : 756 | RPM :  39000 | Accel :  0.00 | Mode : Normal
CPOS : 753 | APOS : 755 | RPM :  40620 | Accel :  0.14 | Mode : Normal
CPOS : 751 | APOS : 752 | RPM :  41220 | Accel :  0.08 | Mode : Normal
CPOS : 749 | APOS : 750 | RPM :  42420 | Accel :  0.09 | Mode : Normal
CPOS : 746 | APOS : 748 | RPM :  43920 | Accel :  0.16 | Mode : Normal
CPOS : 743 | APOS : 746 | RPM :  45060 | Accel :  0.18 | Mode : Normal
CPOS : 742 | APOS : 743 | RPM :  45780 | Accel :  0.09 | Mode : Normal
CPOS : 739 | APOS : 740 | RPM :  47100 | Accel :  0.11 | Mode : Normal
CPOS : 735 | APOS : 737 | RPM :  48720 | Accel :  0.16 | Mode : Normal
CPOS : 731 | APOS : 733 | RPM :  50940 | Accel :  0.19 | Mode : Normal
CPOS : 725 | APOS : 728 | RPM :  53400 | Accel :  0.20 | Mode : Normal
CPOS : 719 | APOS : 723 | RPM :  56280 | Accel :  0.26 | Mode : Normal
CPOS : 713 | APOS : 716 | RPM :  59040 | Accel :  0.23 | Mode : Normal
CPOS : 706 | APOS : 710 | RPM :  62460 | Accel :  0.31 | Mode : Normal
CPOS : 699 | APOS : 700 | RPM :  66300 | Accel :  0.16 | Mode : Normal
CPOS : 695 | APOS : 696 | RPM :  70320 | Accel :  0.16 | Mode : Normal
CPOS : 691 | APOS : 692 | RPM :  74820 | Accel :  0.20 | Mode : Normal
CPOS : 686 | APOS : 687 | RPM :  79500 | Accel :  0.22 | Mode : Normal
CPOS : 681 | APOS : 682 | RPM :  84540 | Accel :  0.23 | Mode : Normal
CPOS : 675 | APOS : 676 | RPM :  90600 | Accel :  0.24 | Mode : Normal
CPOS : 669 | APOS : 670 | RPM :  96960 | Accel :  0.27 | Mode : Normal
CPOS : 662 | APOS : 663 | RPM : 103860 | Accel :  0.28 | Mode : Normal
CPOS : 658 | APOS : 662 | RPM : 105480 | Accel :  0.27 | Mode : Normal
CPOS : 654 | APOS : 656 | RPM : 106260 | Accel :  0.06 | Mode : Normal
CPOS : 650 | APOS : 654 | RPM : 106980 | Accel :  0.12 | Mode : Normal
CPOS : 645 | APOS : 650 | RPM : 107880 | Accel :  0.15 | Mode : Normal
CPOS : 640 | APOS : 645 | RPM : 108900 | Accel :  0.17 | Mode : Normal
CPOS : 635 | APOS : 640 | RPM : 109740 | Accel :  0.14 | Mode : Normal
CPOS : 631 | APOS : 633 | RPM : 110580 | Accel :  0.07 | Mode : Normal
CPOS : 626 | APOS : 631 | RPM : 111480 | Accel :  0.15 | Mode : Normal
CPOS : 622 | APOS : 626 | RPM : 112140 | Accel :  0.11 | Mode : Normal
CPOS : 618 | APOS : 622 | RPM : 112980 | Accel :  0.14 | Mode : Normal
CPOS : 613 | APOS : 618 | RPM : 113880 | Accel :  0.15 | Mode : Normal
CPOS : 610 | APOS : 611 | RPM : 114480 | Accel :  0.04 | Mode : Normal
CPOS : 606 | APOS : 610 | RPM : 115260 | Accel :  0.13 | Mode : Normal
CPOS : 602 | APOS : 606 | RPM : 115980 | Accel :  0.12 | Mode : Normal
CPOS : 598 | APOS : 602 | RPM : 116640 | Accel :  0.11 | Mode : Normal
CPOS : 595 | APOS : 598 | RPM : 117300 | Accel :  0.11 | Mode : Normal
CPOS : 592 | APOS : 593 | RPM : 117900 | Accel :  0.03 | Mode : Normal
CPOS : 588 | APOS : 592 | RPM : 118500 | Accel :  0.10 | Mode : Normal
CPOS : 585 | APOS : 588 | RPM : 119220 | Accel :  0.12 | Mode : Normal
CPOS : 582 | APOS : 585 | RPM : 119700 | Accel :  0.08 | Mode : Normal
CPOS : 500 | APOS : 582 | RPM : 120300 | Accel :  0.10 | Mode : Normal
CPOS : 500 | APOS : 500 | RPM : 120780 | Accel :  0.03 | Mode : Normal
CPOS : 500 | APOS : 500 | RPM : 121320 | Accel :  0.09 | Mode : Normal
CPOS : 500 | APOS : 500 | RPM : 121740 | Accel :  0.07 | Mode : Normal
CPOS : 440 | APOS : 500 | RPM : 122280 | Accel :  0.09 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 122640 | Accel :  0.06 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 122820 | Accel :  0.00 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 122940 | Accel :  0.02 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123180 | Accel :  0.04 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123240 | Accel :  0.01 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123300 | Accel :  0.01 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123180 | Accel :  0.02 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123240 | Accel :  0.01 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123240 | Accel :  0.00 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123240 | Accel :  0.00 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123360 | Accel :  0.02 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123480 | Accel :  0.01 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123840 | Accel :  0.06 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123840 | Accel :  0.00 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123780 | Accel : -0.01 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123780 | Accel :  0.00 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123900 | Accel :  0.02 | Mode : Normal
CPOS : 340 | APOS : 440 | RPM : 124020 | Accel :  0.02 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124260 | Accel :  0.04 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124380 | Accel :  0.02 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124500 | Accel :  0.02 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124440 | Accel : -0.02 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124440 | Accel :  0.00 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124380 | Accel : -0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124200 | Accel : -0.03 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124260 | Accel :  0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124080 | Accel : -0.03 | Mode : Normal
CPOS : 440 | APOS : 340 | RPM : 123960 | Accel : -0.02 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123900 | Accel : -0.01 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123900 | Accel :  0.00 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123780 | Accel : -0.02 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123960 | Accel :  0.01 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 123960 | Accel :  0.00 | Mode : Normal
CPOS : 340 | APOS : 440 | RPM : 124140 | Accel :  0.03 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124200 | Accel :  0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124440 | Accel :  0.04 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124500 | Accel :  0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124500 | Accel :  0.00 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124680 | Accel :  0.03 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124620 | Accel : -0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124620 | Accel :  0.00 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124680 | Accel :  0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124680 | Accel :  0.00 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124800 | Accel :  0.02 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124800 | Accel :  0.00 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124740 | Accel : -0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124680 | Accel : -0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124620 | Accel : -0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124740 | Accel :  0.02 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124740 | Accel :  0.00 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124800 | Accel :  0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124680 | Accel : -0.05 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124860 | Accel :  0.03 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125040 | Accel :  0.03 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125100 | Accel :  0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125040 | Accel : -0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125220 | Accel :  0.03 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125160 | Accel : -0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125280 | Accel :  0.02 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125340 | Accel :  0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125340 | Accel :  0.00 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125460 | Accel : -0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125460 | Accel :  0.00 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125400 | Accel : -0.01 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 125100 | Accel : -0.05 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124800 | Accel : -0.05 | Mode : Normal
CPOS : 340 | APOS : 340 | RPM : 124260 | Accel : -0.02 | Mode : Normal
CPOS : 440 | APOS : 340 | RPM : 123420 | Accel : -0.14 | Mode : Normal
CPOS : 440 | APOS : 440 | RPM : 122220 | Accel : -0.20 | Mode : Normal
CPOS : 500 | APOS : 440 | RPM : 120960 | Accel : -0.21 | Mode : Normal
CPOS : 584 | APOS : 500 | RPM : 119280 | Accel : -0.28 | Mode : Normal
CPOS : 592 | APOS : 588 | RPM : 117840 | Accel : -0.14 | Mode : Normal
CPOS : 604 | APOS : 592 | RPM : 115680 | Accel : -0.36 | Mode : Normal
CPOS : 612 | APOS : 604 | RPM : 114120 | Accel : -0.26 | Mode : Normal
CPOS : 621 | APOS : 612 | RPM : 112380 | Accel : -0.29 | Mode : Normal
CPOS : 629 | APOS : 621 | RPM : 110880 | Accel : -0.25 | Mode : Normal
CPOS : 636 | APOS : 633 | RPM : 109560 | Accel : -0.09 | Mode : Normal
CPOS : 643 | APOS : 636 | RPM : 108360 | Accel : -0.20 | Mode : Normal
CPOS : 649 | APOS : 643 | RPM : 107220 | Accel : -0.19 | Mode : Normal
CPOS : 655 | APOS : 649 | RPM : 106020 | Accel : -0.20 | Mode : Normal
CPOS : 660 | APOS : 655 | RPM : 105120 | Accel : -0.15 | Mode : Normal
CPOS : 663 | APOS : 661 | RPM : 102780 | Accel : -0.31 | Mode : Normal
Title: Re: HE351 code for me78569
Post by: hakcenter on July 24, 2015, 12:47:18 PM
I won't be driving until much later today... so here's the rendition that I'll run later

Variable changes

// Turbo
const int minimum_turbo_rpm = 4000;
byte stage = 1;
unsigned long turbo_rpm = 0;
unsigned long last_turbo_rpm = 0;
double turbo_accel = 0.0;
double accel_factor = 0.0;


Serial Output

void serial_output() {
  if (turbo_rpm > minimum_turbo_rpm) {
    String output = "";
    String extra = "";
    byte current_mode = 2;
    if (idle_mode) { current_mode = 0; }
    if (idle_walkdown_mode) { current_mode = 1; }
    if (cruise_mode) { current_mode = 5; }
    if (performance_mode) { current_mode = 6; }
    if (brake_mode) { current_mode = 4; }
    if (spare_mode) { current_mode = 3; }
    // Addes extra spaces infront of position to keep things aligned
    if (vane_position < 10) { extra = "  "; } else if (vane_position < 100) { extra = " "; }
    output += "CPOS : " + extra + vane_position + " | ";
    extra = "";
    if (final_vane_position < 10) { extra = "  "; } else if (final_vane_position < 100) { extra = " "; }
    output += "APOS : " + extra + final_vane_position + " | RPM : ";
    extra = "";
    // Addes extra spaces infront of turbo_rpm to keep things aligned
    if (turbo_rpm < 1000) { extra = "   "; } else if (turbo_rpm < 10000) { extra = "  "; } else if (turbo_rpm < 100000) { extra = " "; }
    output += extra + turbo_rpm + " | ";
    output += "Accel : ";
    if (turbo_accel >= 0) { output += " "; }
    output += turbo_accel;
    Serial.print(output);
    output = " | Mode : " + current_mode_array[current_mode];
    Serial.println(output);
  }
  if (millis_out) {
    Serial.print(time_elapsed1);
    Serial.print(" ms |loop()");
    Serial.print(" || " );
    Serial.print(time_elapsed2);
    Serial.print(" ms |keep_time()");
    Serial.print(" || " );
    Serial.print(time_elapsed3);
    Serial.print(" ms |calculate_vane_position()");
    Serial.print(" || " );
    Serial.print(time_elapsed4);
    Serial.println(" ms |set_turbo_position()");
  }
}


Timer2

void keep_time() {
  time_start2 = millis();
  timer++;
  if (staging_enabled) {
    // Keeps turbo staging in time
    stage_timer++;
    if (stage_timer > 200) { stage_timer = 200; }
    if (timer % 2 == 0 && turbo_rpm > 100000) { update_vane_position = true; }
  }
  // Update vane_position every 10ms 100k+ / 25ms 60k - 100k / 50ms 0 - 60k
       if (timer % 10 == 0 && turbo_rpm > top_end_rpm) { update_vane_position = true; accel_factor = 10.0;}
  else if (turbo_rpm > curve_rpm[4] && timer % 25 == 0) { update_vane_position = true; accel_factor = 25.0; }
  else if (timer % 50 == 0) { update_vane_position = true; accel_factor = 50.0;}
  // Update turbo_accel before calculating vane_position
  if (update_vane_position) {
    turbo_accel = (turbo_rpm / (60000.0 / accel_factor)) - (last_turbo_rpm / (60000.0 / accel_factor));
    last_turbo_rpm = turbo_rpm;
  }
  // Modes
  if (timer % 100 == 0) { calculate_modes(); }
  // Calculate vane_position
  if (update_vane_position) { update_vane_position = false; calculate_vane_position(); }
  if (serial_out) {
    if (turbo_rpm < top_end_rpm && timer % 100 == 0) { serial_output(); }
    if (turbo_rpm > top_end_rpm && timer % 10 == 0) { serial_output(); }
  }
  if (timer == 1000) { timer = 0; }
  time_finished2 = millis();
  time_elapsed2 = time_finished2 - time_start2;
}


Should be about right. Probably multiply by 1000, get a bit more resolution on the decimal places and get it into RPs acceleration.


BTW if you couldn't tell from the accel log, I've fixed idle_walkdown :D, and it jumps out of idle to curve[0] when its off idle accel.
Title: Re: HE351 code for me78569
Post by: me78569 on July 24, 2015, 02:58:35 PM
Do I have to wait until version 1.2 to see how you accomplished the offidle jump?  I am VERY curious.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 24, 2015, 04:06:47 PM
I'm going to figure out a way to do bitwise and move the decimal at the end or something. Maybe do 2x + 8x then, use the front minus 8 bitshift as the front of the decimal and the back only the first byte...  It'll come to me after i finish some yard work
Title: Re: HE351 code for me78569
Post by: me78569 on July 24, 2015, 05:30:59 PM
No hurry haha. 


So using my pot control  I decided to do some testing.  I left the pot at a specified position then went and drove like a crazy man.

Final pos of 14 for injector only makes it hard to overspeed.  16 for can bus fueling addition and 18 for wiretap fueling.


So I guess I know where I need to end up haha.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 24, 2015, 05:48:43 PM
?? confused ??
Title: Re: HE351 code for me78569
Post by: me78569 on July 24, 2015, 08:11:03 PM
Sorry,


I have a Potentionmeter in the cab that I can set the vane position manually.  I dunno why I didn't do this earlier, but I went out and set the vanes manually.

I started without a tuner at all, just my 100hp injectors

At position 12cm^2 I was unable to get the turbo rpm to go over 130,000


With my tuner set to 65hp+ over stock I can run at 14cm^2 and not get over 130,000

With my tuner set to "kill" 180hp over stock I set it at 18cm and I was unable to get over 130,000


I want to have 3 curves , Tow, DD, and Perf that will follow the above tuner settings.  so now that I know what my upper limit has to be I can adjust the curve below 100,000 to keep it from slingshotting past 130k.


just gotta figure out how to slow down the shaft acceleration haha. 

Looking forward to trying what you come out with.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 24, 2015, 09:38:02 PM
Ya I'll keep thinking, I may have to just give up on 100% accuracy and go with like a 51/256 or something.. to find out if its even faster I'll have to setup millis.. which I've been doing haha..

Work on one thing, get an idea for another... decided to time serial output, and there was room to speed it up...

Simulated RPM...

CPOS : 666 | APOS : 667 | RPM :  99217 | Accel :  0.27 | Mode : Normal
1400uS
CPOS : 664 | APOS : 664 | RPM : 101731 | Accel :  0.27 | Mode : Normal
1420uS
CPOS : 600 | APOS : 662 | RPM :   4344 | Accel : -82.71 | Mode : Normal
1392uS
CPOS : 600 | APOS : 600 | RPM :   6904 | Accel :  1.09 | Mode : Idle
1360uS
CPOS : 600 | APOS : 600 | RPM :   9472 | Accel :  1.09 | Mode : Idle

versus

CPOS : 666 | APOS : 667 | RPM :  99261 | Accel :  0.27 | Mode : Normal
1124uS
CPOS : 664 | APOS : 664 | RPM : 101775 | Accel :  0.26 | Mode : Normal
1152uS
CPOS : 600 | APOS : 662 | RPM :   4399 | Accel : -82.7 | Mode : Normal
1116uS
CPOS : 600 | APOS : 600 | RPM :   6967 | Accel :  1.09 | Mode : Idle
1084uS
CPOS : 600 | APOS : 600 | RPM :   9515 | Accel :  1.09 | Mode : Idle


0.2ms faster not bad... lol

Then you ask, how did you make adding Strings together faster... lolol



  if (update_vane_position) {
    turbo_accel = ((turbo_rpm / 60000.0) - (last_turbo_rpm / 60000.0)) * accel_factor;
    last_turbo_rpm = turbo_rpm;
  }


Bout as fast as it can get, 80-84uS. throwing big bitshifts isn't helping when its not twice as fast.. so I'd rather have better resolution.
Title: Re: HE351 code for me78569
Post by: Rx7man on July 25, 2015, 01:39:58 PM

if (update_vane_position) {
    turbo_accel = ((turbo_rpm / 60000.0) - (last_turbo_rpm / 60000.0)) * accel_factor;
    last_turbo_rpm = turbo_rpm;
  }


You can get that faster by refactoring

if (update_vane_position) {
    turbo_accel = (turbo_rpm  - last_turbo_rpm) / 60000.0 * accel_factor;  // <---refactored.. one less division
    last_turbo_rpm = turbo_rpm;
  }
Title: Re: HE351 code for me78569
Post by: hakcenter on July 25, 2015, 02:28:58 PM
yep thanks. wasted so much time in bitwise math >.>
Title: Re: HE351 code for me78569
Post by: Rx7man on July 25, 2015, 04:04:07 PM
Just remember to get the low-hanging fruit first :)
Title: Re: HE351 code for me78569
Post by: hakcenter on July 25, 2015, 04:39:31 PM
It's tough when you spend so much time in thought of how to save a couple nanoseconds! lolol

Did quite well on the serial output. Decided to go for the whole re-write and happy I did, results are workagering ^_~
Title: Re: HE351 code for me78569
Post by: Rx7man on July 26, 2015, 12:52:25 AM
On my code I haven't bothered trying to make it fast yet.. I'm keeping it readable, lots of divisions and multiplications could be refactored, but until it drives, I'd like to make it make sense to me after I haven't looked at the code for a month or two.. It's amazing how fast you forget how something worked!  I have dozens of old projects that I don't think I could figure out if I had to look at them again... or at the least it would take a lot of thinking to get into it. 
Title: Re: HE351 code for me78569
Post by: hakcenter on July 26, 2015, 03:25:07 PM
ya I'm almost to the point of releasing 1.1.1, I want to figure out a use for the acceleration variable.. might use it to tune the top end over multiple pulls or something /shrug
Title: Re: HE351 code for me78569
Post by: me78569 on July 28, 2015, 10:11:54 AM
while I am curiously waiting for 1.1.1 I have been tuning / testing with VERY nice results. 

I have moved the curve some to

// Turbo Curves & Factors
const byte two_cm = 80;
const byte one_cm = 40;
const byte half_cm = 20;
const unsigned int idle_rpm = 12000;
const unsigned int idle_walkdown_rpm = 22000; 
const unsigned long lit_rpm = 105000;  //RPM where turbo is considered to be making full boost
const unsigned long BarkRpm = 75000;  // If rpm is over this rpm process runs to keep turbo from barking when letting off throttle
const unsigned long Target_Rpm_Low = 120000;  //Lower rpm range where you want to hold RPMS at top end
const unsigned long Target_Rpm_High= 128000;  //upper rpm range where you want to hold RPMS at top end
const unsigned int curve_rpm[5] = { 17000, 20000, 26000, 37000, 65000 };
unsigned int turbo_curve[5] = { 0,0,0,0,0 };
const unsigned int turbo_curve_1[5] = { 770,730,710,600,416 };  //Perf curve larger vane position due to more fuel can + tap fuel. Curve is choosen by inactive pot position watchpot();
const unsigned int turbo_curve_2[5] = { 800,760,720,625,500 };  //DD curve with can fueling only mid curve
const unsigned int turbo_curve_3[5] = { 830,790,730,650,550 };  //Tow curve for timing only no extra fueling


Then I have changed the PosCalc to

/*  This code is put in place to control an HE351ve turbo using Turbo RPM and other inputs.
*   
*  Sections of this code, including but not limited to the rpm based vane position calculations, Freq Measure, and
*  Timer setup are thanks to Curtis R Hacker at lilbb.com and his RPM based HE351vgt arduino shield.

*  This work is licensed under the
*  Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
*  To view a copy of this license,
*  visit [url=http://creativecommons.org/licenses/by-nc-sa/4.0/]Creative Commons &mdash; Attribution-NonCommercial-ShareAlike 4.0 International
&mdash; CC BY-NC-SA 4.0 [/url].
*/

/////////////////////////////POS Manage////////////////////////////////////////
void PosManage() {
      if (turbo_rpm <= curve_rpm[4]) {
        if (ThrottlePosition < 3) {  // Idle Section
          if (turbo_rpm > BarkRpm) {AntiBark = true; vane_position = min_position;} else {AntiBark = false;}
            if(turbo_rpm <= idle_rpm) {
             vane_position = idle_position;
             idle_walkdown_mode = false;
          } else {
            if (turbo_rpm <= idle_walkdown_rpm) { idle_walkdown_mode = true;} else { idle_walkdown_mode = false; }
            if (idle_walkdown_mode) { vane_position = constrain((final_vane_position - 10),idle_position-two_cm, 800); }
                       
          }
        }else {  AntiBark = false;
          // -----
          // Curve section
               
               if (turbo_rpm <= curve_rpm[0]) { vane_position = constrain(map(turbo_rpm, idle_rpm , curve_rpm[0], Offidle_position, turbo_curve[0]), Offidle_position, turbo_curve[0]);} //turbo_curve[0];}
          else if (turbo_rpm <= curve_rpm[1]) { vane_position = map(turbo_rpm, curve_rpm[0], curve_rpm[1], turbo_curve[0], turbo_curve[1]);}
          else if (turbo_rpm <= curve_rpm[2]) { vane_position = turbo_curve[1];}
          else if (turbo_rpm <= curve_rpm[3]) { vane_position = map(turbo_rpm, curve_rpm[2], curve_rpm[3], turbo_curve[1], turbo_curve[2]);}
          else { vane_position = map(turbo_rpm, curve_rpm[3], curve_rpm[4], turbo_curve[2], turbo_curve[3]);} //+ TPS_range was put into place to open the vane more if throttle input was higher
        }
      } else if (turbo_rpm < lit_rpm) { AntiBark = false;
          vane_position = map(turbo_rpm, curve_rpm[4], lit_rpm, turbo_curve[3], turbo_curve[4] - TPS_range);}
       else{
        AntiBark = false;
        if (curvea){
            if(turbo_rpm < Target_Rpm_Low){
            vane_position = map(turbo_rpm, lit_rpm, Target_Rpm_Low, turbo_curve[4] - TPS_range, 233 - TPS_range);   
            Stable_Pos = vane_position;
            }
             else if (turbo_rpm > Target_Rpm_Low && turbo_rpm < Target_Rpm_High){
              vane_position = Stable_Pos;}         
             
             else if (turbo_rpm > Target_Rpm_High){
              vane_position -= constrain(map(Movement, Target_Rpm_High, turbo_rpm, 1, 10),1,10);
              constrain(vane_position, min_position, 233 - TPS_range);
          }  Stable_Pos = vane_position; //else { vane_position = 333;}
       }
        if (curveb){
            if(turbo_rpm < Target_Rpm_Low){
            vane_position = map(turbo_rpm, lit_rpm, Target_Rpm_Low, turbo_curve[4] - TPS_range, 333 - TPS_range);   
            Stable_Pos = vane_position;
            }
             else if (turbo_rpm > Target_Rpm_Low && turbo_rpm < Target_Rpm_High){
              vane_position = Stable_Pos;}       
             else if (turbo_rpm > Target_Rpm_High){
              vane_position -= constrain(map(Movement, Target_Rpm_High, turbo_rpm, 1, 10),1,10);
              constrain(vane_position, min_position, 333 - TPS_range);
          }  Stable_Pos = vane_position;  //else { vane_position = 416;}
        }
        if (curvec){
            if(turbo_rpm < Target_Rpm_Low){
            vane_position = map(turbo_rpm, lit_rpm, Target_Rpm_Low, turbo_curve[4] - TPS_range, 416 - TPS_range);   
            Stable_Pos = vane_position;
            }
             else if (turbo_rpm > Target_Rpm_Low && turbo_rpm < Target_Rpm_High){
              vane_position = Stable_Pos;}       
             else if (turbo_rpm > Target_Rpm_High){
              vane_position -= constrain(map(Movement, Target_Rpm_High, turbo_rpm, 1, 10),1,10);
              constrain(vane_position, min_position, 416 - TPS_range);
          }  Stable_Pos = vane_position; //else { vane_position = 500;}
        }

        // Overrun protection
      if (over_run > 145000){
        if (!curvea) {vane_position -= half_cm;} //{overrun = true;} else{overrun = false;}
         
      //if (overrun) {vane_position = min_position;}
    }
   }


Big things to note are the AntiBark function if tps is below 3% and turbo rpm is above barkrpm.  This works VERY well to keep barking from happening.  I have not had one bark since putting it into place. 

Next big thing is the upper end control, snippet from above
        if (curvea){
            if(turbo_rpm < Target_Rpm_Low){
            vane_position = map(turbo_rpm, lit_rpm, Target_Rpm_Low, turbo_curve[4] - TPS_range, 233 - TPS_range);   
            Stable_Pos = vane_position;
            }
             else if (turbo_rpm > Target_Rpm_Low && turbo_rpm < Target_Rpm_High){
              vane_position = Stable_Pos;}         
             
             else if (turbo_rpm > Target_Rpm_High){
              vane_position -= constrain(map(Movement, Target_Rpm_High, turbo_rpm, 1, 10),1,10);
              constrain(vane_position, min_position, 233 - TPS_range);
          }  Stable_Pos = vane_position; //else { vane_position = 333;}
       }


I change the the end position based upon which curve I have selected, inactive pot position <20 or 20<>970 or >970,  if I am running the perf curve I set the end position to 233 - tps_range. 

Note that there is a range of turbo shaft speeds on the top end that I don't adjust vane position, between Target_Rpm_Low 120,000 and Target_Rpm_High 128,000.

the thought is I adjust the tuner fueling based on what curve. 

anyways this upper end curve does a VERY good job of keeping the turbo RPMS between 120k and 127k.  RPMS will spike to 140 for a split second then walk down nicely and hold.

As I tested before the positions that I can run on each curves without overspeeding at 16cm for injector only fueling, 18cm for canbus plus injectors, and 20cm for tuner set to "kill" and injectors.  So that is why I set the positon where I did for the top end.

 
Title: Re: HE351 code for me78569
Post by: hakcenter on July 28, 2015, 02:37:23 PM
Yeah bark is bad, I'll probably enable the smoothing function while acceleration is negative over top end
Title: Re: HE351 code for me78569
Post by: Bdubb'z on July 28, 2015, 03:03:42 PM
Yeah mine will bark with a 12000 pound trailer under hard acceleration between 5th and 6th shift.  Seems to only do it on that shift.  Was focusing on driving and didn't have laptop connected so I don't know where that is as far as rpm goes, but only with that decent load on it will it bark.  Did it a few times so I would slowly let off the throttle, then grab the shift.   
Title: Re: HE351 code for me78569
Post by: me78569 on July 28, 2015, 03:14:55 PM
Hakcenter,

The hard part in regards to barking is a lot of the time when you lift there isn't anytime code wise to do anything before the bark happens.  The best way I can accomplish it is to watch for TPS going below %3 and if rpms are greater than 65,0000 ( or whatever) jump right to min position without smoothing. 

In my Vein adjust section I am skipping if (AntiBark)

Anything else I did, smoothing wise, couldn't keep up.  IE: once the arduino knows that barking might be happening it is too late. 

On my way home today I worked to try and get it to bark, WOT throttle lifts at 130,000 rpm and it will bark half of the time still.  I am guessing that when I lifted didn't line up with the start of the Position_calc code and the code barked before the code could get back to the top.I dunno really how much better you could make it because I don't think the arduino / Shaft speed can catch the issue in time and adjust.  The averaging read of the shaft speed takes too long to see a drop in rpms.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 28, 2015, 06:19:09 PM
Quote from: me78569 on July 28, 2015, 03:14:55 PM
Hakcenter,

The hard part in regards to barking is a lot of the time when you lift there isn't anytime code wise to do anything before the bark happens.  The best way I can accomplish it is to watch for TPS going below %3 and if rpms are greater than 65,0000 ( or whatever) jump right to min position without smoothing. 

In my Vein adjust section I am skipping if (AntiBark)

Anything else I did, smoothing wise, couldn't keep up.  IE: once the arduino knows that barking might be happening it is too late. 

On my way home today I worked to try and get it to bark, WOT throttle lifts at 130,000 rpm and it will bark half of the time still.  I am guessing that when I lifted didn't line up with the start of the Position_calc code and the code barked before the code could get back to the top.I dunno really how much better you could make it because I don't think the arduino / Shaft speed can catch the issue in time and adjust.  The averaging read of the shaft speed takes too long to see a drop in rpms.

Well not trying to be rude, but that's an oxymoron statement there at the end. Because the only way to bark it, is to go from large size to small size on. Which means the rpm code is causing the problem, otherwise the turbo wouldn't try to get smaller.

I'll give the truck a few runs when I get time, and monitor the accel variable to see if it will be a viable solution for more than just anti compressor surge.

What I'll try to do is get it to happen and hit the cruise button immediately, so I have a marker in the log of where it occured and try to figure out what is actually happening.

Best guess is the rotor is decelerating at a very fast rate, faster than acceleration. Then a large vane size change two or more cm counters the shaft deceleration for a moment and that's when the compressor surges.

Easiest way then is to make a deceleration curve, or take more time getting to the smaller vane position. I'm leaning towards number two as a simpler approach to the problem.
Title: Re: HE351 code for me78569
Post by: me78569 on July 28, 2015, 06:34:55 PM
Not taking it as rude, but learning and talking about my experience on the turbo, haha not a typical large forum members here.  Truthfully I am not even sure what statement you are referring to?  Maybe there is something else up, but from my testing if I waited for the turbo shaft speed to fall before doing into "antibark" it would still bark.

Barking is when pressure on the intake side are greater than on the exhaust side correct?  so in theory, again unless I miss something, can also happen if you remove all exhaust from the turbine side( let off the throttle quick, and leave vanes at the same position can it not? 
Title: Re: HE351 code for me78569
Post by: hakcenter on July 28, 2015, 06:42:52 PM
Surging is when the rotor changes directions momentarily.

You can surge off the map, you can surge low throttle. It really can't be boost related on the our diesels cause we don't have throttle bodies, all the boost goes right out into the exhaust as well.

So the only way to change rotor direction is to cause a exhaust pressure spike that is so violent it surges the compressor from deceleration to acceleration.

Kapok6 has quite a bit of experience with surging on throttle, his older turbo setup, had anti-surge ports, switch to a turbo without the surge ports, and actually surged during acceleration.. crazy thing. Switched to surge cover and it disappeared.


My big thing is that if you check the canbus log from that guy with the 6.7, he goes directly from WOT to brake, and no problem. 505 directly to 940 no stepping. And no problem.


Msg ID=0x0cffc600 len=8 data=0xf9 01 01 ff ff ff ff ff total count=0
Msg ID=0x0cf00f51 len=8 data=0x63 00 b6 f3 75 80 7f 60 total count=0
Msg ID=0x0cf00f51 len=8 data=0x63 00 b6 f3 75 80 7f 60 total count=0
Msg ID=0x18ffc502 len=8 data=0x01 f9 01 6a 00 f9 01 76 total count=0
Msg ID=0x0cf00f51 len=8 data=0x63 00 c4 f3 75 80 7f 60 total count=0
Msg ID=0x18f00a00 len=8 data=0xff ff 2e 11 ff ff ff ff total count=0
Msg ID=0x0cffc600 len=8 data=0xac 03 01 ff ff ff ff ff total count=0


So figure that one out. We either have way more energy in our exhaust, or doing something wrong.
Title: Re: HE351 code for me78569
Post by: me78569 on July 28, 2015, 07:15:15 PM
Interesting.

Thanks don't be afraid to correct me haha.

I am no expert.
Title: Re: HE351 code for me78569
Post by: hakcenter on July 28, 2015, 08:36:17 PM
if you happen on any logs with compressor surge please post them that'll help.

My only concern is it may not show up as decelerating before the surge happens.. that's my only real concern, since the shaft speed sensor doesn't care which way the rotor is spinning, to count. It could count faster if it oscillates both directions or it could not count at all and fall into the else of no freq to count...
Title: Re: HE351 code for me78569
Post by: me78569 on July 28, 2015, 08:40:45 PM
What are typical boost levels on a stock 6.7 25-30psi?  suppose that more than likely they never spin the turbo beyond 80k-100k? 

I can't for the life of me fine a compressor map, dumb holset, to see what shaft speed 25 some psi is. 

I would love to know how they tune it. 

I will try and log some here.
Title: Re: HE351 code for me78569
Post by: hakcenter on August 06, 2015, 08:33:55 AM
The real question is, does it crush ?
Title: Re: HE351 code for me78569
Post by: Rx7man on August 06, 2015, 09:02:37 AM
surge is NOT when the compressor changes direction, it's when the airflow changes direction! its essentially cavitation, when the airflow isn't sufficient to keep it's momentum against the pressure
surge will causes changes in the compressor speed, but no where even close to enough to cause it to turn backward
Title: Re: HE351 code for me78569
Post by: me78569 on August 06, 2015, 08:48:12 PM
https://www.youtube.com/watch?v=w4lnVx2BAYk
Title: Re: HE351 code for me78569
Post by: hakcenter on August 10, 2015, 08:22:02 PM
Any logs with the acceleration variable and barking?
Title: Re: HE351 code for me78569
Post by: me78569 on August 11, 2015, 02:06:35 PM
Ive been way to busy with wedding stuff to mess with stuff over the last week.  gonna be a bit until I can jump back into this at this point. 

Good news is it is running great.  haha
Title: Re: HE351 code for me78569
Post by: me78569 on August 25, 2015, 12:13:36 PM
Little update when I have a second to post it.


Things are working very well. I am not yet using the accl var yet.  I have however extended the vane based beyond turbo speed.

I am taking TPS into consideration, along with boost to shrink or expand the housing in low boost high throttle or high boot high throttle etc.



Here is the vane position code.  The TPS_range is what I am using to adjust from the base curve.

else {  AntiBark = false;
          // -----
          // Curve section
               
               if (turbo_rpm <= curve_rpm[0]) { vane_position = constrain(map(turbo_rpm, idle_rpm , curve_rpm[0], Offidle_position, turbo_curve[0]), Offidle_position, turbo_curve[0]);} // This will snap the vanes from idle position to starting position whne tps sense.
          else if (turbo_rpm <= curve_rpm[1]) { vane_position = map(turbo_rpm, curve_rpm[0], curve_rpm[1], turbo_curve[0], turbo_curve[1]);}  //this is the high end mapping of the turbo.
          else if (turbo_rpm <= curve_rpm[2]) { vane_position = turbo_curve[1];}  //this is the high end mapping of the turbo.
          else if (turbo_rpm <= curve_rpm[3]) { vane_position = map(turbo_rpm, curve_rpm[2], curve_rpm[3], turbo_curve[1], turbo_curve[2]- TPS_range);}  //this is the high end mapping of the turbo.
          else { vane_position = map(turbo_rpm, curve_rpm[3], curve_rpm[4], turbo_curve[2]- TPS_range, turbo_curve[3]- TPS_range);}  //this is the high end mapping of the turbo.
        }
      } else if (turbo_rpm < lit_rpm) { AntiBark = false;
          vane_position = map(turbo_rpm, curve_rpm[4], lit_rpm, turbo_curve[3]- TPS_range, turbo_curve[4] - TPS_range);}//- TPS_range was put into place to open the vane more if throttle input was higher while boost is low

/////////////////This is the top end controls.  The turbo really does increase rpms VERY quickly the trick to to find the sweet spot where rpms stay steady at wot.       
////////////////
       else{
        AntiBark = false;
        if (curvea){  //end pos of 18cm starts 12 cm
                 if (turbo_rpm <= 120000) { vane_position = 540 - TPS_range;}  // the 6.7 logs we have show the turbo jumping to positions when at WOT rather than stepping.
            else if (turbo_rpm <= 128000) { vane_position = 456 - TPS_range;}  // this will jump to a higher position at given rpms on the top end to slow the turbo down.
            else { vane_position = 373 - TPS_range; }  //it will jump a good bit to slow the turbo down if above 130000
        }                                              // according to holset the turbo is balanced to 130,000 rpm. 
        if (curveb){  //End pos of 16cm start 11cm
                 if (turbo_rpm <= 120000) { vane_position = 624 - TPS_range;}
            else if (turbo_rpm <= 128000) { vane_position = 540 - TPS_range;}
            else { vane_position = 456 - TPS_range; }  //16cm
        }
        if (curvec){  //End pos of 14cm 456 start 10cm
                 if (turbo_rpm <= 120000) { vane_position = 685 - TPS_range;}
            else if (turbo_rpm <= 128000) { vane_position = 624 - TPS_range;}
            else { vane_position = 540 - TPS_range; }   //14cm
        }

        // Overrun protection
      if (turbo_rpm > 140000){  // 140,000 rpms is where I get worried about shaft speed. 
        if (!curvea) {vane_position -= one_cm;}
        //this will creep the vane position more open each code cycle if turbo rpms are above 135,000 if not in curvea ( perf mode defined by "F_watchpot" tab)
         
     }
   }



TPS_range is calc'd here

// TPS_range calc process

  if (timer % 200) {
     if (ThrottlePosition <= 25) {TPS_low = true;} else {TPS_low = false;}
     if (ThrottlePosition <= 45 && ThrottlePosition > 25) {TPS_midlow = true;} else {TPS_midlow = false;} //{TPS_range = 0;}// watches throttle input to increase vane position.  Vane position mapping is based on low throttle input.
     if (ThrottlePosition <= 70 && ThrottlePosition > 45) {TPS_mid = true;} else {TPS_mid = false;} //{TPS_range = 20;}
     if (ThrottlePosition > 70)  {TPS_high = true;} else {TPS_high = false;} //{TPS_range = 40;}

     if (TPS_low) {TPS_range = 0;} //supports low throttle cruise. if under %25 don't change vanes
     if (TPS_midlow){
      if ( BoostPressure < 5) {TPS_range = -40;} //it will try and spool the turbo if tps is 25><45 - numbers decrease vane size
      else if ( BoostPressure < 10) {TPS_range = -20;}
      else {TPS_range = 0;}
     }
     if (TPS_mid){
      if (BoostPressure < 10) {TPS_range =  -20;}
      else if (BoostPressure < 20) {TPS_range = 0;}
      else {TPS_range = 20;}
     }
     if (TPS_high){
      if (BoostPressure < 20) {TPS_range = 0;}
      else if (BoostPressure < 30) {TPS_range = 20;}
      else {TPS_range = 40;}
     }
  }



This really helps smoke levels when going from low throttle cruising to high throttle to pass.  cruising turbo speeds tend to be sub 45,000 rpm.  I am happy with mpgs at this point in the curves, but I was having issues with smoke whenever I would stab the throttle. 

with the TPS_ range code as soon as you go over %25 throttle it will jump the housing smaller by one cm is under 5 psi.
Title: Re: HE351 code for me78569
Post by: me78569 on November 09, 2015, 07:11:34 AM
So I have a curious issue that has been going on for awhile now, off and on, Seems that turbo shaft speeds below 60k read perfect, but as soon as I top 70k the shaft speeds jump by 30% every 3rd or 5th read?  Somedays are worse than  other, but today seemed pretty bad. 

I can disable the writting to my lcd screen and watch it happening in the serial output so I don't think it is the lcd writing delay.  I can also load your code, and see the same issue, so I don't think it is a code issue.

Any thoughts on why I would have this issue?  bad sensor on the turbo?
Title: Re: HE351 code for me78569
Post by: Rx7man on November 09, 2015, 08:22:29 AM
I'm not sure, Hard to know if it's a hardware or software issue...  a scope on it would help.. since it's jumping UP, I have a hard time imagining a sensor issue.. more likely a software thing...
Title: Re: HE351 code for me78569
Post by: me78569 on November 09, 2015, 08:28:01 AM
I would imagine that if I had the issue so would other tho if it was software. 

Also since it is worse on some days than others leads me away from code. Working in a software company it is rare to see a dynamic issue like this that is code related.  Much more often hardware is the issue.

It's a strange issue Maybe I should twist the wires and see if the issue gets better.
Title: Re: HE351 code for me78569
Post by: Rx7man on November 09, 2015, 10:20:47 AM
I would think it's more likely it would MISS count pulses at high speed than get extra ones!...

if weather plays a role it certainly pretty much eliminates software...

Perhaps a bad cap somewhere?
Title: Re: HE351 code for me78569
Post by: me78569 on November 09, 2015, 01:26:51 PM
Could be. 

I need to spend some time digging I guess. 
Title: Re: HE351 code for me78569
Post by: Rx7man on November 09, 2015, 02:43:03 PM
Once I get my 'version' of the software tested, I might be of more help... I don't plan on using freqmeasure at all.
Title: Re: HE351 code for me78569
Post by: hakcenter on November 09, 2015, 02:45:51 PM
Check your shield for cold solder joints. If nothing I would start with the ceramic cap first, replace it. Then the 2 resistors, before digging into the power circuit on the max chip.

You don't need to twist the wires! It has a cap :)
At worst you can swap the pins, but I doubt it will do anything.
Title: Re: HE351 code for me78569
Post by: me78569 on November 09, 2015, 04:10:58 PM
Remember way back when I started I got the 9924 put in backwards.  I wonder if that if what caused it. 

I am no electrical engineer so I will take your word that it having a cap prevent any issues needing to twist the cable :)

I will look deeper, however on my way home, it read fine....
Title: Re: HE351 code for me78569
Post by: hakcenter on November 09, 2015, 05:37:22 PM
the VR sensor wires are coupled via the capacitor any interference bleed over would make it count less not more, at least that's what I get by looking at it.

I would just go through your shield, and re-solder all your joints.

If it still does it after re-soldering, I would replace the ceramic capacitor. Then check your alternator for AC current. Then check your arduino power supplies, then maybe / maybe replace the max.
Title: Re: HE351 code for me78569
Post by: me78569 on November 10, 2015, 09:40:26 AM
Cool thanks,

Again it was fine this morning.  I am needing to check the alternator so I will start there haha. 

Thanks!
Title: Re: HE351 code for me78569
Post by: me78569 on November 10, 2015, 03:47:31 PM
Alright,

another thought I have been having is that I would really like to start reading the canbus data from the truck.  things like RPM, APPS and so forth would be VERY handy when it comes to controlling the turbo, mostly rpm, but rather than run a bunch of wires under the hood I might as well use what is there.

Am I off base in thinking that I could use the uno to read canbus data and send canbus to the turbo at the same time with the same canbus shield?  or would I run into issues trying to send a canbus message to the turbo over the same can network that ecm is running on? 

Thoughts on this?  I have example code to get this going, but I am no buff in terms of how the canbus network works.   I am worried that the canbus network protocol for the turbo won't work with the old canbus j1939 that the rest of the truck uses.
Title: Re: HE351 code for me78569
Post by: Rx7man on November 11, 2015, 02:17:59 AM
I think it should be possible.. CAN can have several slave devices, as long as they have unique ID's.. only the unit with the correct ID will respond to the command, so it should work... I don't  have that luxury I don't think.. my truck is OBD1 (1994)
Title: Re: HE351 code for me78569
Post by: me78569 on November 11, 2015, 06:35:28 AM
Issue I am thinking is that the turbo more than likely uses a different can protocol to talk than my truck does.  More I think about it the more I think I will need another can bus shield.
Title: Re: HE351 code for me78569
Post by: Rx7man on November 11, 2015, 07:08:15 AM
One way to find out!!
Title: Re: HE351 code for me78569
Post by: me78569 on November 13, 2015, 09:06:02 AM
http://freematics.com/store/index.php?route=product/product&product_id=30

$39 shipped to port OBD data into the arduino via serial.  Gonna open up a whole new world in terms of tuning the turbo.  I have always felt that engine RPM is HUGE when it comes to tuning the turbo.  pretty excited to get this in and working on it.

This will open up a pin on the arduino as I won't need to read TPS VIA voltage input on the pin.

Title: Re: HE351 code for me78569
Post by: Rx7man on November 13, 2015, 04:21:06 PM
I just hacked my wiring harness and used an arduino for an oscilloscope (I ran 4 channels at 500 samples per second.. and I think I can do better)  I think it's Gray/light blue, and it outputs a 5v square wave, but with a very short pulse... I'm sending that to an interrrupt enabled pin to do the counting... I'll be able to tell you how it works tomorrow I think.

I do think that if I had the option of using OBD2 (perhaps OBD1 would have enough info?) I could save myself some CPU cycles and have access to more info... I have to make do with what I have.

I totally agree though, engine RPM is essential for turbo tuning!
Title: Re: HE351 code for me78569
Post by: me78569 on November 13, 2015, 05:14:02 PM
I do have to say with the current tune I am at

7000' altitude

33 psi boost, 35-40 psi drive
1295 EGT
max rpms 145,000

10psi by 1400 rpm, I am sure I could generate more, but I don't like to lug the motor that much.

I think I can drop some shaft speed, but keep boost up if I was to be able to read engine RPM. 

So overall pretty happy, there is some more to be gained, but overall it spools like nuts and pulls nicely, egt's and smoke is VERY low.  I can take off smoke free at 25% then hammer it after rpms come up above 1600, and be %100 smoke free.
Title: Re: HE351 code for me78569
Post by: hakcenter on November 13, 2015, 07:50:39 PM
love to see obd working, that'd be pretty nice.

I wonder if the TPS plug is in the manual truck harness. Anyone got a pic of location for a 2nd gen, and what it looks like ?
Title: Re: HE351 code for me78569
Post by: Rx7man on November 13, 2015, 08:09:33 PM
3 prong metripack flat, wire color for the TPS is Orange/bark blue (looks black)... you should have one since yours is auto anyhow... just tap into it (and sensor ground (black/green?)) and bring it to a analog input.. just sensing the TPS alone (even without RPM) would make a world of difference... I don't see it on my truck, but it's a standard
Title: Re: HE351 code for me78569
Post by: me78569 on November 13, 2015, 08:43:50 PM
Yea tps is huge for getting things working well.

Rpms will be even bwtter.
Title: Re: HE351 code for me78569
Post by: hakcenter on November 13, 2015, 09:18:29 PM
My truck is a 5spd bruh :D hopefully eventually a 6spd.

Just wondering if the harness is in there, I'll look in the engine bay tomorrow. Have to get in there and fix my broken HID ballast again. Things always blow the 400v cap every 6mo or so. No idea why.
Title: Re: HE351 code for me78569
Post by: Rx7man on November 13, 2015, 10:58:01 PM
weren't you working on an auto tranny in your basement? 

I'll steer my buddy away from the HID's in that case.. he works on his truck enough.

Title: Re: HE351 code for me78569
Post by: me78569 on November 20, 2015, 04:55:47 PM
Added a warmup mode to my code. 

void WarmupManage() {
   if (IAT == 12 || IAT == 13 ||IAT == 14){
      if ( EngineRPM > 1000) {
      constrain(vane_position, 918, 960);
      vane_position += .05;
      if (vane_position > 940) {vane_position = 800;}
    }
    else{vane_position = last_vane_position - 10;}
   }
   
    else if (IAT == 22 || IAT == 23 || IAT == 24){
      vane_position = 960;
     }
    else {vane_position = 1000;}
   // }
  }



I am also working on getting my code ready for the obd reader that is on it's way.  I am gonna pipe in TPS, ECT, IAT ( hopefully don't know if that is j1939 or j1979), engine RPM.

I trying to work on a good way to adjust the turbo map in regards to RPM mainly. 

right now I am mapping engine RPM from (0, 3200, 0, 80) so I can use the 0-80 to adjust the vanes larger as engine speed increases. 
int ReadEngineRPM(){
if (obd.read(PID_RPM, EngineRPM));
  return map(EngineRPM, 0, 3200, 0, 80);                    // read the value from the sensor I am mapping the rpms to give a reasonable vane adjustment without having to divide later.
}


then adjusting the position


        if (turbo_rpm > curve_rpm[3]) {vane_position -= TPS_range;}
        if (turbo_rpm > curve_rpm[4]) {vane_position -= RPM;}


TPS_range is used in the same manner it used to be, I might need to adjust it some as it was put in place to try and predict engine rpms and open the vanes.
Title: Re: HE351 code for me78569
Post by: Rx7man on November 20, 2015, 05:59:00 PM
I think the OBD inputs are going to greatly help drivability and responsiveness... doing only an hour of tuning on my truck I'm already pretty happy with the way it runs,.. I gotta track down that exhaust leak though, my engine brake pressure SUCKS, and no doubt spooling is affected by it too.

My code for a 2d map may not be working too great on a low memory device.. it requires about 120 bytes... depends on the other bells and whistles you got going on.  My sketch would still theoretically fit on an Uno, but as I tested it the serial port starts getting gibbled up.  My map is a map of "byte", so I had to do some scaling.. I have 2 maps, one gives me my 'base position', so it's 1/10th of the turbo position, and the other is desired pressure.. the two maps share the array for the axis labels.  The instance of the map class has a function called "Interpolate" (taking RPM and TPS as arguments), which gets a smoothed interpolation of the values between the discrete points... it returns a floating point number
Title: Re: HE351 code for me78569
Post by: Rx7man on November 20, 2015, 06:02:09 PM
The truck sounds AWESOME when I'm warming it up with the engine brake on!.. at initial startup, the oil is pretty thick right now, so it takes a while for the turbine to get going, and then you hear it come on slowly and steadily.. When I was warming it up after playing darts last week there were some girls out in the parking lot commenting about it sounding like it was going to take off.. They weren't my type unfortunately
Title: Re: HE351 code for me78569
Post by: me78569 on November 20, 2015, 06:23:23 PM
haha,

You should see my truck is 3 cylinder high idle with the EB on haha.

I can go from 20*f coolant to 160*F in <5 minutes.  egt's sit at about 1000* and it smokes and smokes and smokes and thumps and thumps.  sounds and looks like an old WWII v12 fighter starting.

I am really quite happy with mine at this point, but it can always be better.  Even at 7000' altitude I now struggle to make it smoke when the tuner is off.  Even with the tuner set to max it cleans up quick.

Anyways looking forward to reading through your stuff. 
Title: Re: HE351 code for me78569
Post by: Rx7man on November 20, 2015, 11:23:37 PM
Mine only stumbles badly when it's under 0F.. the engine brake sure does help it warm up quicker though, especially if you fast idle it to about 1200-1400 RPM,.. but the governor setup on mine makes it so it *really* doesn't want to be there.. it's either 1000 or 1500 when it's cold and no in between.  the 24 valve trucks were always a little easier to warm up than the 12V's were.. they are just miserable.. when it's -10F out, I can plug it in for an hour, warm it up for 10 minutes at low idle, and it still take about 8-10 miles (half way to town) before I get any heat.. I can idle it for a half hour and if I'm lucky I might get a little defrost action.
Title: Re: HE351 code for me78569
Post by: me78569 on November 22, 2015, 01:35:42 PM
I think I am going to remove the turbo mapping functions and do more a step for each turbo rpm range. 

I can use the rpm variable to take it's place and I think it will work better and have less "slingshot" action.
Title: Re: HE351 code for me78569
Post by: Rx7man on November 23, 2015, 10:32:18 AM
Did you get my PM?

So far I haven't had any problems in my code with overboost... except when I had the logic backward (doh) and I momentarily wrapped the 35PSI boost gauge in my truck.. I don't see how the logic was backward because I studied and studied it but in real life it was still backward.. I created a class of variable that keeps track of the history, thus making it easy to determine the slope of any given parameter... in this case I use Intake manifold pressure (MAP), I start to open the vanes based on slope alone at about 20PSI, and start limiting based on actual pressure as well at about 25 PSI, this makes it come up to 20PSI fast, but starts a little bit of opening action if it's really spiking.  Again my code isn't the prettiest, but it seems to be working nicely
Title: Re: HE351 code for me78569
Post by: me78569 on November 23, 2015, 11:01:31 AM
I did, I haven't read through it yet though, is there supposed to be a .ino in the pm's?  I only see your libraries.


Oddly enough I don't have any overboost issues, strictly overspeed.  I am thinking that I am getting invalid speed readings above 100k haha.  I see 30psi at ~130,000, but I have to drive rpms up around 160,000 ( arrording to the arduino) to see 35psi. 

The map doesn't really support that.  I am hoping that with the OBD I am trim out some fat.    I am not sure where my delay in the rpm read is though,  I see the same result regardless of what code I use.  gotta be in the board install someplace. 

RPMS are VERY steady 0-60k then jumps to 70-90k VERY quick and then more stable 100,000-130,000


I did test for AC noise on the alternator and I was sitting at .01 / .02 volts

Still haven't looked at the solder joints, I have been too lazy to pull the controller out haha
Title: Re: HE351 code for me78569
Post by: Rx7man on November 24, 2015, 08:20:12 AM
The .ino is going to be all wrong.. in the .c file I gave an example of how to use it though
Title: Re: HE351 code for me78569
Post by: me78569 on November 24, 2015, 11:06:55 AM
reading through it now.  thanks!
Title: Re: HE351 code for me78569
Post by: Rx7man on November 25, 2015, 09:28:11 AM
Hope it's of some use to you... Included is the "mapf" function that is a floating point version of the map() function.. I use it a lot
Title: Re: HE351 code for me78569
Post by: me78569 on November 25, 2015, 10:10:31 AM
Yep,  We will see what I gain from it, always good to see another way.


I think I am going to ditch the multi curve tuning of the turbo, rather I think I am going to make a "fueling Offset" that is defined by the Potentionmeter position .  The base curve will be adjusted to effectively create useable curve for your fueling. 
Title: Re: HE351 code for me78569
Post by: Rx7man on November 25, 2015, 03:24:34 PM
I currently have it set so that it looks at the 'base map' which is of TPS vs RPM for a raw turbo position (I call it the "position map"), and a second map, also of TPS vs RPM but in boost PSI (I call it the "boost map", and the potentiometer on the dash adjusts how much to pay attention to the boost map... so far I've found it behaves better when I completely ignore the boost map, and just set the position.

Of course after all that I still have a 'maximum boost' setting that starts to open the vanes by about 30-50 position units for every PSI over the maximum..., and an overspeed compensation that  limits based on acceleration only from 130-135,000, and by both acceleration AND speed above 135,000 RPM..
Title: Re: HE351 code for me78569
Post by: me78569 on November 25, 2015, 04:06:12 PM
Got ya, 

What are your stable(ish) shaft speeds are you seeing at 30psi? 35 psi?

Vane vane position do you typically run at the 30/35 psi mark?
Title: Re: HE351 code for me78569
Post by: Rx7man on November 26, 2015, 01:09:58 AM
I don't have the sensor working at this time.. I'm keeping my boost under 30 PSI until I get it sorted.

I'll pay attention to my vane position next time I go for a drive.. it's been slick roads out here so I haven't been able to get on it much.. last trip to town I was in 4x4 and was breaking all 4 tires loose in 4th at 50mph, and it felt like doing at in 5th and 65 mph was a serious possibility, and I don't feel like smashing this thing up.. I got waaaay too much into it now to make it what I want.
Title: Re: HE351 code for me78569
Post by: me78569 on November 26, 2015, 07:58:20 AM
understand that. 

Since we don't really have a turbo map that is worth a damn, I am curious what others are seeing to verify my readings. 

I see guys all the time running 40psi / 45psi according to what I am seeing that should put shaft speeds 140,000-155,000 so I was curious.
Title: Re: HE351 code for me78569
Post by: hakcenter on November 26, 2015, 09:32:18 AM
FWIF I get 40psi @ 130k
Title: Re: HE351 code for me78569
Post by: Rx7man on November 26, 2015, 09:53:41 AM
Good to know :)
Title: Re: HE351 code for me78569
Post by: me78569 on November 26, 2015, 08:47:12 PM
What vane position for that?
Title: Re: HE351 code for me78569
Post by: hakcenter on November 26, 2015, 10:30:05 PM
For what? I'm confused.

You guys are way too into this lol.
Title: Re: HE351 code for me78569
Post by: me78569 on November 27, 2015, 06:23:07 AM
What vane position do you typically see as your stable wot position.

Does it require 18cm to hold 40 psi at 130 k?

20? 16? Haha just curious
Title: Re: HE351 code for me78569
Post by: hakcenter on November 27, 2015, 08:10:05 AM
Depends on what gear I'm in. Usually in the 200s

I use accel to dampen its acceleration rate, since in the lower gears it'll sky rocket.
Title: Re: HE351 code for me78569
Post by: me78569 on November 27, 2015, 10:31:39 AM
So it spikes to 130,000 then jumps from the 400 to 200 (ish) position and is able to hold boost? 

I loose way to much drive pressure to sustain boost if I do that. 
Title: Re: HE351 code for me78569
Post by: hakcenter on November 27, 2015, 11:25:44 AM
The basemap is not far from my personal map.

My top end is slightly more extreme but yes I step it down
Title: Re: HE351 code for me78569
Post by: me78569 on November 28, 2015, 12:53:46 PM
I got the OBD in, 

And ugh.

It doesn't like to connect to the truck, sometimes it does, others it doesn't.  Then when it does the obd read is slow enough to make the turbo cycle lol. 

Too cold out there for me to dig too much, but my code worked on the first try lol. 
Title: Re: HE351 code for me78569
Post by: Rx7man on November 28, 2015, 09:19:03 PM
Well that kinda sucks... it's pretty cold out here too.. -16C or 5F.. sure don't like doing anything without gloves on!
Title: Re: HE351 code for me78569
Post by: me78569 on November 29, 2015, 12:02:37 AM
Yea I need to spend some time working through the example code and see if I can get it to read.
Title: Re: HE351 code for me78569
Post by: me78569 on November 29, 2015, 08:46:13 PM
Well I think I hit the wall.  While the obd reader does support the right buadrate it doesn't support j1939, ugh. 

I figured since it was built on the eml327 adapter that it would work for what I need since my cheapo eml 327 works fine.

Time to open up my eml327 and see if it has previsions on the board for serial tx/rx
Title: Re: HE351 code for me78569
Post by: hakcenter on November 29, 2015, 09:22:50 PM
I'm confused. Does it use too many pins? You can't read can bus on and obd at the and time with multiple shields?
Title: Re: HE351 code for me78569
Post by: me78569 on November 30, 2015, 10:19:57 AM
the obd reader I bought that was built around arduino with a library etc does support the j1939 protocol for whatever reason ( I think the reader isn't speced for the right pins on the obd.

I am now just working through AT commands to read the obd data that is in serial form from my cheapo eml327.  I should be able to read the data directly using the Arduino without the obd library that the other reader uses.

hopefully since the em327 can read the PID's I want I can sniff it out of the data stream.
Title: Re: HE351 code for me78569
Post by: me78569 on December 01, 2015, 01:03:09 PM
so I have been working through getting the OBD serial stuff coded. 

I am finding that there needs to be a delay between the serial.print and serial.read This could really throw a wrench in things.

Thoughts on doing something like
 
if(timer % 100) { serial.print("010c");

if timer % 200) { serial.readstring();}



or


adc_roll_over++;
// There functions will need to be calibrated to the sensor.
  if (adc_roll_over == 1) { serial.print("010c"); }
  if (adc_roll_over == 2) { engineRpm = serial.readstring(); }   Plus some math to convert from hex to decimal
  if (adc_roll_over == 3) { adc_roll_over = 0; }


or something similar to space the serial send and read?  I am assuming that since I am not using the serial section of your code that the serial message should sit in the buffer? 
Title: Re: HE351 code for me78569
Post by: hakcenter on December 01, 2015, 01:17:52 PM
Well yeah there needs to be a delay because it takes time to process your request.

Alternate with a switching boolean
Title: Re: HE351 code for me78569
Post by: me78569 on December 01, 2015, 05:04:14 PM
Well I am not sure the truck can talk fast enough to work for what I need.

I am sending and receiving serial data via the elm327, but it is SLOW.    not sure where to go from here, I need a break from it for a bit lol. 
Title: Re: HE351 code for me78569
Post by: hakcenter on December 01, 2015, 07:53:39 PM
Data rate should be around what 30-40hz ? Should be fast enough for basic sampling.
Title: Re: HE351 code for me78569
Post by: me78569 on December 01, 2015, 08:25:23 PM
38400 is supported,

My loop was taking 175ms to complete.   I am rewriting now without any 3rd party library and strictly serial commands.  I am gonna try again tomorrow and see what I can do with it.   I think if it is going to work I need to work through how much of a delay there is between the serial send and when the request comes back from the PCM.  If I can do other stuff in the code then go back and read the serial buffer it might work.   
Title: Re: HE351 code for me78569
Post by: me78569 on December 02, 2015, 07:01:47 PM
Alright I think I am gonna be able to make it work.   I am now not using any outside libraries to talk to the OBD.  I struggled most of the day because I forgot to use Serial.println(); instead of Serial.print();  The ELM327 wasn't reading the serial string due to the missing "\r" after the serial print. 
'
Now I need to figure out the rest.  I know all the commands I need to send via serial, but I am struggling with how to read a hex return and translate that to an usable int.  Biggest issue I have is I am not sure how to read the full return. 

If I send the command ("010c") for rpm request I am expecting to see something like "00 00" if engine off or 0 rpm. or any series of hex to signal the rpm

Back to reading and the endless google pit.
Title: Re: HE351 code for me78569
Post by: hakcenter on December 03, 2015, 08:49:02 AM
I'm going to crudely reply.

if 2 bytes back

int value = 0;
if (Serial.available() > 1) {
    value = 0;
    value = (int) strtol(Serial.read(), 0, 16);
    value += (int) strtol(Serial.read(), 0, 16);
}
if (Serial.available() > 0) {
    value = 0;
    value = (int) strtol(Serial.read(), 0, 16);
}


No idea if you're receiving /r/n etc so you may want to catch those and discard.
Title: Re: HE351 code for me78569
Post by: me78569 on December 03, 2015, 10:20:41 AM
That's pretty similar to what I wrote, THANKS!!!! Your's , as normal, is less complicated than mine haha.  I felt like a blind man haha.   

I am unsure on the \r\n also.  I know when I talk to the elm327 via my laptop using terminal I don't get a \r or \n but I am unsure if the terminal program filters that.

question for you,  The hex sent by the computer is in form 00 00  I am guessing that 00 00 is considered 2 bytes? each one in it self is consider a byte correct?  So you need to combine both bytes into a string then convert to make it an usable integer? hence the need for the if statement >1 or >0? 

I just want to make sure I am not misunderstanding this whole thing.   
Title: Re: HE351 code for me78569
Post by: Rx7man on December 03, 2015, 11:15:08 AM
00 00 can mean anything.. typically, if you're speaking HEX, you prefix it with '0x' to make it evident.. it takes 2 characters to display one byte in hex, so 0x00, 0x00 is indeed 2 bytes.

Isn't there something in the Arduino where you can specify "high byte" and "Low byte"? don't know if it takes hex, but might be worth checking out
Title: Re: HE351 code for me78569
Post by: me78569 on December 03, 2015, 12:12:26 PM
I will look.  This is a whole new world for me so I think I do about 1 line of code for 5 hours reading haha. 
Title: Re: HE351 code for me78569
Post by: hakcenter on December 03, 2015, 08:09:08 PM
The response back from the eml37 for rpm, could range from 0 to greater than 255, so you would want to catch both.

You might get 0x03, then sometime later get 0x01 0xff or something. I put that crude reply so it would make more sense written out, you totally don't have to do it that way, just put it in a for loop.

And 00 00, is 2 bytes. But if the ECU does not give you 00 0F, but 0F instead, you would want to catch the 1 byte reply.
Title: Re: HE351 code for me78569
Post by: me78569 on December 07, 2015, 09:00:15 AM
Thanks!

So I have been struggling to figure out why my shaft speed stopped working all the sudden.  Finally found that the 5v on my shield was no longer producing 5v, after I replaced the 9924 with a spare I had, redid all the wires and ohm'd out all the wires. 

Well now I can't read shaft speeds under 40,000, just reads 1000, or 2000, then you hit 40,000-50,000 and it reads great.  Very stable and more jumping etc lol.    seems that I changed from having bad reads above 80,000 to having no reads below.

So who know, gonna have to go back and review all the stuff I have,.
Title: Re: HE351 code for me78569
Post by: hakcenter on December 07, 2015, 01:26:57 PM
Weird
Title: Re: HE351 code for me78569
Post by: me78569 on December 07, 2015, 07:36:30 PM
REdid all the grounds / 5v resistors on the 9924. 

It is almost like when a hall sensor goes back and it won't read unless there is a lot of movement.  I am almost wondering if the turbo speed sensor is bad. 

I need to verify one other thing tomorrow before I go looking for a new shaft speed sensor. 
Title: Re: HE351 code for me78569
Post by: 65fpvmustang on December 07, 2015, 08:39:30 PM
my turbo speed sensor slowly stop working switched to spare same thing. worked ok at high shaft speed but dead blow 40k. seamed to get better when engine was warm. changed motor oil and it came back. haven't had a problem in 6 months or more i think it was a build up of zddp additive. i run a lm1815 circuit feeding to mega squirt.
it was driving me nuts a changed the lm1815 circuit.  I could take the sensor out and hold it next to alt fan and it would read great. put it back in turbo crappy signal again. good luck i know how frustrating it can be.
Title: Re: HE351 code for me78569
Post by: me78569 on December 07, 2015, 08:51:40 PM
I am overdue for an oil change.  I had that thought too.

I'll do that tomorrow I guess...
Title: Re: HE351 code for me78569
Post by: me78569 on December 08, 2015, 04:50:49 PM
oil change done, same issue.  ( oh well needed to be done anyways)

Anyways issue was that the butt connector I used to connect the VSS harness ( soldiered first, but wires busted) were not working.  I resoldiered the wires in the harness and bam issue fixed.   Not sure why that matters, but oh well.
Title: Re: HE351 code for me78569
Post by: me78569 on December 14, 2015, 04:02:23 PM
finally got my shaft speed issue fixed.  Ordered a new sensor, same issue.....ugh

I found that the solder joint was causing too much resistance in the wires causing it not to read.  I cut out the wire and recrimped the ends in the plug end and blam issue fixed.
Title: Re: HE351 code for me78569
Post by: hakcenter on December 14, 2015, 07:13:44 PM
Noice
Title: Re: HE351 code for me78569
Post by: me78569 on December 14, 2015, 08:49:48 PM
Also my top end jump issues are fixed.  I am now seeing stable shaft speeds above 80,000.  I am also struggling to push speeds above 120,000 in my current code.  Very excited to tune some more now.

Title: Re: HE351 code for me78569
Post by: me78569 on January 03, 2016, 06:53:39 PM
Made a holiday trip to my moms house up in north minnesota, AKA sea level.  I cannot say how much I hate living at 7000' in altitude. 

with my 100 injectors and my quadzilla turned up my truck is all but smoke free at 450 hp worth of fuel at sea level, at home my truck smokes like a train.

I could EASILY pass emissions with the fuel turned up if I didn't live at 7000'


I did notice that my boost and drive sensors were reading high at idle, due to more atmospheric pressure.  I have added some to my code to adjust the boost and drive values by comparing idle state boost to recorded boost, IE: at idle boost should read 0 so if it is reading more or less I can adjust.

Here is the timer trigger
if (timer % 800){ //checks for idle state to run the barcalc section, which corrects the boost and drive sensor for altitude changes.
    if (ThrottlePosition = 0){
      barcount ++;
      if (barcount = 10){
        baroffset();
      }
    }
    else { barcount = 0;}
  }


Pretty much if TPS is 0 for 10 times through the timer section it will run baroffset();

void baroffset (){                                         // compares idle state boost to 0 psi so altitude isn't causing miss readings.
  barcount = 0;
  barcalcb = 0 - BoostPressure;
  barcalcd = 0 - ExhaustPressure;

}


Then  I adjust my boost and drive reads.

  if (adc_roll_over == 1) { BoostPressure = ReadBoostPressure() + barcalcb; }
  if (adc_roll_over == 2) { ExhaustPressure = ReadExhaustPressure() + barcalcd; } 


Title: Re: HE351 code for me78569
Post by: Rx7man on January 04, 2016, 06:13:37 PM
Altitude compensation is tricky... Depending on the sensor (absolute, sealed gauge, or vented gauge) will change how you go about it...

Honestly, I think you should be keeping the boost control logic using an absolute pressure reference (uncompensated for altitude), but compensate it for 'display' purposes...
At the end of the day, you want a certain *absolute* manifold pressure to burn a certain amount of fuel, and that doesn't change with altitude, but your boost gauge will read differently... At sea level, you probably need to run 30 PSI boost (44.7psi absolute ... 30PSI +14.7).. while at 7000 feet you would need the same absolute pressure (44.7), but your boost to get it would change because of lower atmospheric pressure.. Lets say there's a 4 PSI change from 0 to 7000 ft (wild guess).. Now you'd need 34 PSI of gauge boost to get the same 44.7 PSI absolute pressure (34+ 10.7).  Since your sensor is changing it's reading depending on your elevation, I'd go out on a limb and say it's either a "sealed gauge" or "absolute" style, either are fine... the "vented gauge" types will read the same as your in-cab gauge, the other two will change with elevation.

I'd consider not changing the boost level for elevation!
Title: Re: HE351 code for me78569
Post by: me78569 on January 05, 2016, 07:19:19 AM
Thanks for the insight,

My boost readings don't really do much in the tune.  It will adjust the vanes somewhat at lower boost and high tps input to help spool but other than that it isn't really considered significantly. 

I was thinking of just editing the display, but I am a little bored and I figured I might as well try and adjust it fully haha.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 05, 2016, 10:13:47 AM
Have fun with it.. I am having lots of fun, trying to find things that work, learning from what doesn't.. sometimes things defy what you think is logical, and then you gotta figure out why.

Without a dedicated atmospheric pressure sensor, it'll be really hard to accurately do any compensation.. My truck typically makes about 1-2PSI boost at idle, so I pretty much can't use that sensor for squat.. I'd have to have a MAP sensor before the turbo, and with that I could calibrate the other one when the engine is idling, and display air filter restriction any other time... I do have a spare MAP sensor.. perhaps I'll do that for shits and giggles.
Title: Re: HE351 code for me78569
Post by: hakcenter on January 05, 2016, 10:37:14 AM
What sensors are you guys using, and do you account for the dead zone variations ?

Without accurately measuring the true scale of the sensor, you won't have a true representation of the pressure. Most sensors that are absolute throw away the first bar of pressure considered to us vacuum, then when you're at the first bar you'll be at 0psi ie unity with the atmosphere.

http://www.nxp.com/files/sensors/doc/data_sheet/MPX4250A.pdf

I've done a lot of extensive programming for map sensors into a car software and it is not a lot of fun.

However check out the pdf, the dead zone on the sensor is 0v to 0.2v then it should be on scale up to 4.9v so anything over 4.9 is a throw away. Of course assuming you use the manufacturer specs for setting up the schematic, decoupling capacitors etc.. you can see the scale sweep on page 4.

If the sensors you use are vented / relative, you shouldn't have to account for atmosphere vs absolute sensors, but the scale really won't change just the output of your setup based on altitude.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 05, 2016, 03:28:55 PM
I have been considering the deadzone.. my sensors are .5V-4.5V for 0-100 psi respectively.. so that works out to a raw ADC value of 103 to 920 for 0-100 psi... the way I do it is I have a 'map' function that uses floating point math..
so my code looks a little like this

float Pressure = mapf(analogread(MAPpin), 103,920,0,100);

Speaking of sensors.. my honeywell EGP sensor packed it in already.. I have no idea why... it couldn't get hot or get hot gases the way it was mounted (3 ft of coiled brake tubing to the manifold)... I'm going to have to talk to them about it.
My sensor is a 'sealed gauge' type, all stainless.. which is why I'm baffled as to why it failed... If it really comes down to it, I'm going to see if I can't use an oil pressure sender for it if I keep having problems.


Title: Re: HE351 code for me78569
Post by: hakcenter on January 05, 2016, 05:52:59 PM
too hot ?
Title: Re: HE351 code for me78569
Post by: Rx7man on January 05, 2016, 06:26:37 PM
was mounted on the firewall by the stock ECU.. it's bloody winter dammit... it couldn't get that hot under any circumstance
Title: Re: HE351 code for me78569
Post by: me78569 on January 05, 2016, 09:18:19 PM
My sensor are working great.

I used the ones the guy on cf speed way back when for his code.  Think they are $46 each. .5-4.5v for 0-100 psi.  I am reading pressure in the same way.

I need to finish my work with the obd stuff so I can just read baromelet values from the ecm.
Title: Re: HE351 code for me78569
Post by: Bdubb'z on January 06, 2016, 05:56:07 AM
No problems with my sensors either.  I use this http://jgsturbo.com/dppt.html (http://jgsturbo.com/dppt.html) after my stainless coil of brake line then the exh pressure sensor threads into this.  I also have the mechanical gauge off of this unit as well. Easily drained and cleaned and keeps the sensor safe.  I use this sensor and map it just like Rx7man. It's psig as well.  http://www.auberins.com/index.php?main_page=product_info&cPath=5_23&products_id=271 (http://www.auberins.com/index.php?main_page=product_info&cPath=5_23&products_id=271)
Title: Re: HE351 code for me78569
Post by: me78569 on January 06, 2016, 06:09:29 AM
Yep that's the sensor I am using.
Title: Re: HE351 code for me78569
Post by: Bdubb'z on January 06, 2016, 06:14:30 AM
Oh yeah, if anyone is looking for a psia boost reference, I use this.  I also live at 7000' and travel all over the west and don't seem to have an elevation adjustment issue, or sensor reading issue.  http://www.auberins.com/index.php?main_page=product_info&products_id=150 (http://www.auberins.com/index.php?main_page=product_info&products_id=150) 

Also, WAY back to numbers for the turbo, I seem to run 30-35 psi boost at ~119-123k rpm and around 1250* egt with ~ 40-45 psi bp.  That's about 600 on the actuator position, if it opens more I drop boost and egts skyrocket.  Can't seem to get over that for whatever reason.  I've changed all my boost boots and clamps too, probably need to do a boost leak test next summer.

I like where you're going with the OBDII, I bought this https://www.sparkfun.com/products/9555 (https://www.sparkfun.com/products/9555) a while ago to also tap in for engine RPM, just haven't had the time to implement or play with it.  I need to quit my job so I can get all my projects done!!
Title: Re: HE351 code for me78569
Post by: hakcenter on January 06, 2016, 10:24:25 AM
I would totally boost leak that, seems really odd. What's your altitude though ?
Title: Re: HE351 code for me78569
Post by: me78569 on January 06, 2016, 10:45:49 AM
Quote from: hakcenter on January 06, 2016, 10:24:25 AM
I would totally boost leak that, seems really odd. What's your altitude though ?

Quote from: Bdubb'z on January 06, 2016, 06:14:30 AM
I also live at 7000' and travel all over the west

I notice the same thing at altitude, sea level not so much.  Much open beyond 16-18cm makes boost fall off the face of the earth, unless I say into the pedal then it will climb again. 

I can make 35psi all day long but not 40.  did boost leak test and found none.  However if you take the 40psi people see at seal level and minus the 3-4 psi lost due to being at 7000'  it is pretty close.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 06, 2016, 11:00:40 AM
Remember too that turbo compressors don't care about the actual boost, but the pressure RATIO!

so 30 PSI at sea level is roughly 3:1 pressure ratio (30+14.7)/14.7)
30 PSI at 7000 feet (lets say 11 PSI atmospheric) is (30+11)/11 = 3.72... a TOTALLY different pressure ratio for the same boost.

So what does a pressure ratio of 3.72 work out to at sea level?  (3.72*14.7)-14.7 = 40 PSI
So (if 7000 ft = 11 psi) you can see the turbo has to work a whole lot harder to get the same boost pressure.. and that's still not producing the air density it would at sea level (you'd need another 3.7 psi for that (14.7-11).

Clogged air filters are in effect the same as high altitude by reducing the pressure on the intake side of the turbo
Title: Re: HE351 code for me78569
Post by: Rx7man on January 06, 2016, 11:09:08 AM
Wow.. I'm surprised at how good my guess was

   Altitude above Sea Level and Air Pressure
(http://www.engineeringtoolbox.com/air-altitude-pressure-d_462.html)

7000 feet is 11.3 PSI... so my calculations should give you a pretty good idea.

As for your truck smoking like heck at that elevation, it makes sense... To get the same density of air into the engine at 7000 feet compared to 30 PSI boost at sea level you'd need to run 43 PSI!.. just about a whole point of pressure ratio more!
Thankfully the likely colder temps will mitigate that at least a bit
Title: Re: HE351 code for me78569
Post by: me78569 on January 06, 2016, 11:55:25 AM
Exactly.

Thanks for doing the math I was lazy and just guessing haha.
Title: Re: HE351 code for me78569
Post by: Bdubb'z on January 06, 2016, 12:04:47 PM
Yup!  Thanks, guess I wont worry about why I'm not getting 40+ boost out of this sucker!  It must be working pretty good because I've held about 38-39 psi with a gvw of about 24000 over a 10000' pass.  At that weight I'm way out of the throttle to keep egts under 1500*.....but still passing cars.  6inarow make 'em go!
Title: Re: HE351 code for me78569
Post by: me78569 on January 06, 2016, 12:25:56 PM
Understand your pain man.   Biggest PITA for me is emissions.   Even in California they don't do rolling loaded snap tests  >:(

I could honestly Pass emissions the tuner turned up if I was at sea level.  Keep in mind I have ~450 hp worth of fuel

Here in CO Springs we are allowed %30 opacity in 3 test.

1. snap test idle
2. 45 mph snap
3. 55 mph snap.

That was a 0 - %40 throttle take off and a %20 - WOT roll at ~2000' altitude

Dfi 7 x .009 injectors he351ve 2nd gen cummins - YouTube (http://www.youtube.com/watch?v=3m3sPPji2gs)


Here is a my house

~%20 - WOT

He 351 100% - YouTube (http://www.youtube.com/watch?v=-OVcouWEi8g)


Even with the tuner turned off, Just my 100 hp injectors, I won't pass emissions unless I borrow a smarty tuner and enable the 1/2 power mode.    Even then I still have %5 Opacity in the above tests.   I struggle to understand why CO Springs has more harsh emissions standards than California even though we are subject to much much thinner air.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 06, 2016, 01:29:15 PM
Since I installed this turbo my EGT's went WAY down, and I'm wondering if it's something to do with my pyro placement that changed.. I can pull pretty darned hard and not go over 1100, I even removed the fuel plate completely and still hardly get over 1200.  Truck doesn't smoke much unless I really tromp on  it at about 1400 RPM without building some boost first.. I think if I put an AFC controller on it I can make it pretty much smoke-free.

I can't watch the videos from here, but will try to remember next week... How much smoke is 30%?  I'd figure 5% would be pretty much invisible though.

For passing smog  tests, try a much more aggressive boost curve to build more boost earlier, in addition  to defueling.
Title: Re: HE351 code for me78569
Post by: me78569 on January 06, 2016, 02:39:53 PM
I have no idea what %30 looks like.  That's what I really wish I knew.

Actually the truck smokes worse down low if I have an agressive curve.  Power is better, but smoke is worse.

I struggle to get egts over 1200*f
Title: Re: HE351 code for me78569
Post by: me78569 on January 07, 2016, 10:11:56 PM
Pretty Graph time.

My quadzilla app has been updated to do data logging.  short run to prove it works, > %30 throttle up to ~30 mph.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 07, 2016, 11:04:08 PM
You're right.. it is pretty... nicer than what mine are
Title: Re: HE351 code for me78569
Post by: me78569 on January 08, 2016, 07:42:08 AM
I finally get the logging working and it start snowing haha.  Can't use the skinny pedal.  Oh well.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 08, 2016, 09:05:13 AM
4 wheel drifts at 60 mph are fun though!
Title: Re: HE351 code for me78569
Post by: me78569 on January 08, 2016, 10:14:47 AM
haha yes they are, but people frown upon that.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 08, 2016, 11:34:13 AM
hahah, yes.. Pedestrians, cops, and passengers especially
Title: Re: HE351 code for me78569
Post by: me78569 on January 11, 2016, 07:39:20 AM
well I did get a chance to do a 3rd gear pull.  I pretty much flooded the turbo with fuel, but oh well...had I rolled into the throttle it would have built boost much better. 

Impressive thing to note from this graph is the EGT's.  Everything turned up my max temp in 3rd was 1200*f
Title: Re: HE351 code for me78569
Post by: 65fpvmustang on January 12, 2016, 06:43:27 PM
me78569 look familiar.
Yes it's your old HE300 housing.
Ended up getting a 58mm wheel for a hx40 and milling the housing to match.
Then the map width enhancement slot was off so I made one that is adjustable.
I have alot of time in that housing but look forward to testing it out.
Title: Re: HE351 code for me78569
Post by: me78569 on January 12, 2016, 07:42:35 PM
wonderful to hear!

I actually seen a 300ve on ebay the other day and thought about the housing haha.  small world.


Nice to see you could mill the housing.  and pics of the process? 
Title: Re: HE351 code for me78569
Post by: Rx7man on January 12, 2016, 08:53:41 PM
Only went to 58mm?  looks like nice work.. While we're on the topic.. how are you balancing it?   As I was saying earlier that BD won't put a bigger wheel on a 351, I do have the tools that I think I could recut the housing for the wheel, but balancing would be a problem
Title: Re: HE351 code for me78569
Post by: hakcenter on January 12, 2016, 09:09:24 PM
AFAIK everything is neutral balanced ?
Title: Re: HE351 code for me78569
Post by: 65fpvmustang on January 12, 2016, 09:40:51 PM
it's actually a smaller housing and wheel where it got interesting is on the exducer.
Smaller dia. but taller blades so the housing had to be cut back for clearance. Inducer stayed 58mm but the length is different so the mwe groove ended where the comp wheel started. https://www.youtube.com/watch?v=jRrLdXGi2YQ (https://www.youtube.com/watch?v=jRrLdXGi2YQ)
Title: Re: HE351 code for me78569
Post by: Rx7man on January 12, 2016, 09:41:42 PM
That is possible, but with the sensitivity of these things I don't know if that's enough.

Wish I could watch the vid from here
Title: Re: HE351 code for me78569
Post by: 65fpvmustang on January 12, 2016, 09:46:05 PM
So re cut mwe and made a threaded collar to make it adjustable. copping bullzie
http://www.bullseyepower.com/blog/World-s-First-Tunable-Race-Cover/62#.VpXjwlmID-V (http://www.bullseyepower.com/blog/World-s-First-Tunable-Race-Cover/62#.VpXjwlmID-V)
Title: Re: HE351 code for me78569
Post by: Rx7man on January 12, 2016, 09:59:03 PM
Their stuff sure looks nice!  how does the MWE width affect it?  From my understanding the hot air it recirculates creates a boundary layer and reduces surge at high P/R's and low flows...  I haven't seen anything describing it much more than that.  On my truck I manage about 20PSI at 1500 RPM before i'm bordering the surge line
Title: Re: HE351 code for me78569
Post by: 65fpvmustang on January 12, 2016, 10:08:23 PM
Do have a balancer at work but needs to be setup. my understanding is the parts are balanced separately.
This all just to get more boost power below 4k rpm. The 60mm he351 really flows alot more then i want.
enough to make 600hp I only want 400hp
Title: Re: HE351 code for me78569
Post by: 65fpvmustang on January 12, 2016, 10:17:32 PM
The mwe slot can actually add flow and reduce surge but at a cost. At higher flows the exducer can actually suck more then the inducer can feed theslot adds flow here but recirculates air near surge. widening the map in both directions but efficiency is lost.
I surge at 14 psi boost at 3k would like to run closer to 20
Title: Re: HE351 code for me78569
Post by: Rx7man on January 12, 2016, 10:31:32 PM
hmmm.. interesting...

I really want my buddy to put a 351 on my old 3rd gen Rx7.. he's in the 500 hp area now with a T66-1 that comes online quite nicely around 3500 RPM.. it idles at 1800, and I think with the 351 he could get a couple PSI just off idle and get a really nicely driveable car.. it would also quiet it down at idle a little
Title: Re: HE351 code for me78569
Post by: 65fpvmustang on January 12, 2016, 10:53:52 PM
saw a video of one on a 13b 12 psi boost blipping throttle in neutral.
i have mine setup so closed creates no ebp in cruise but cost me spool below 3000 rpm.
I get no boost blipping throttle all the way to 7k rpm.
On a 13b i would expect 20 psi at 3k running ebp 3psi over boost. Really just depends on surge line.
i get 5psi at 2500 with 7 psi ebp
Title: Re: HE351 code for me78569
Post by: Rx7man on January 13, 2016, 12:04:38 AM
I have my truck set up like your car... at cruise it opens up.. 70mph (4.10 gears), 2500 RPM, about 4 PSI boost and excellent mileage.  I implemented a tps rate adjustment that closes it up and holds it close for a while if you mash the throttle, it helps responsiveness when shifting gears by preventing it from going into a 'cruise' mode. 
Title: Re: HE351 code for me78569
Post by: me78569 on January 18, 2016, 08:19:29 PM
did a run with the quad turned off, so just my 100 hp injectors.
(http://forum.mopar1973man.com/storage/attachments/monthly_2016_01/Capture.PNG.7321cdb268b33a7b03444164d9bca91f.PNG)

max temp of 900*f and nearly smokeless.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 18, 2016, 11:03:57 PM
Looks ok, but from a graph you really can't tell what it's like to drive.

I did some heavy hauling over the weekend, and found EGT's with this turbo take a long time to come up, and then they stay up... I have a compressor outlet temp gauge, and I found it directly linked to that.. So the compressor gets hot and heat soaks, and it takes a long time to warm up or cool down.. For short pulls you'll never see it get hot, but pull a mile long hill at 60mph and 6 ton behind the truck, and your EGT's will be 1300F.. I wasn't able to get above 1000F with no fuel plate without a load, when I was hauling that all changed
Title: Re: HE351 code for me78569
Post by: me78569 on January 19, 2016, 07:24:34 AM
Honestly 1300*f with 6 tons and pulling a grade at 60 mph is pretty impressive.

I know that towing a 2 horse trailer up the pass, 3rd gear 45 mph, my egt's don't climb above 1100 with the quad turned off.  I am sure if I downshifted and tried to pull in OD it would climb to 1400-1500. 

It drives nice.  No smoke and no need to watch the gauge so far. 
Title: Re: HE351 code for me78569
Post by: Rx7man on January 19, 2016, 08:57:23 AM
I think the cam and head work I did help a lot with that. 

coming home last night (windy, hilly dirt road.. nearly logging road) again with 6 ton behind the truck, and the new version of my program, I was pretty impressed at the boost I was getting down low.. I was going up some hills in 4th, going down to 1300RPM, and rolling back onto it, my AFC starts fuelling at 15PSI, and that was no job to get.. usually 20 PSI @ 1400, 25 @ 1500, 30@1700,.. I do find I need more boost at peak torque, I'm going to go to 35 PSI.. I didn't have the overboost sensitivity very high, and turbo didn't seem to mind the 40 PSI I hit a few times, and it did help with EGT's.  Peak turbine speed was 117,000 RPM
Title: Re: HE351 code for me78569
Post by: me78569 on January 19, 2016, 09:33:43 AM
Holset says 4.5 PR is fine so I can hit 40psi and have a pr of 4.52 at 7000'.  So long as I am below 125,000 rpm I don't even worry about it.   (11.34+40)/11.34 = 4.52  I have yet to see 40 psi, but I hover around 36-38 psi so I feel like I am at a good spot. 

The vgt can handle the 5.9 pretty easy.  I can see why the 6.7 has drive pressure issues, but I honestly run near to 1:1 above 25 psi.  I am not driving the turbo as hard as I could, but I like how the truck drives.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 19, 2016, 10:43:55 AM
If only we had REAL compressor maps for holsets.. it's their BIG downfall.  I wonder how the maps look with the 64 and 67mm wheels?  I put a compressor inlet MAP sensor to detect air filter restrictions, etc as well as a barometric pressure sensor.. They won't be permanent, but it's kinda neat to see what's going on.
Title: Re: HE351 code for me78569
Post by: me78569 on January 19, 2016, 10:47:36 AM
I really wish we had one too. 

I a just going off what holset says is true for a super hx40 ( I think) but the site said 4.5 pr and then there are a couple of maps that match the 130,000 rpm number. 

I would assume it is somewhat efficient up around 45 psi, but again without a map, who knows. 
Title: Re: HE351 code for me78569
Post by: Rx7man on January 19, 2016, 01:47:35 PM
Peak efficiency is probably around 30-35 PSI, depending of course on airflow, but it can handle more.
Title: Re: HE351 code for me78569
Post by: hakcenter on January 19, 2016, 05:06:47 PM
It is a super hx40 wheel, so use that map
Title: Re: HE351 code for me78569
Post by: me78569 on January 19, 2016, 05:26:38 PM
Haha do you have that map? Verified? 

I have seen a couple that might be a hx40.....
Title: Re: HE351 code for me78569
Post by: Rx7man on January 19, 2016, 06:50:23 PM
I found 3 types of maps for an hx40.. B8584,  and B8579, and B8574.. Redline seems to be between 117000 and 127000 RPM
Title: Re: HE351 code for me78569
Post by: me78569 on January 19, 2016, 08:49:19 PM
From what I remember, I couldn't find a map with 130,000 rpm and a pr of up to 4.5

Holset Super 40 and Pro 52 Upgrades (http://www.myholsetturbo.com/upgrades.html)

Super 40 Holset Turbo Application Notes (http://www.myholsetturbo.com/40appnotes.html)
Title: Re: HE351 code for me78569
Post by: Rx7man on January 19, 2016, 09:50:22 PM
I also wish they had a full command list for the VGT actuator.. I think there's some stuff hidden in there I might take advantage of..   Perhaps a method of mapping the raw temperature to real temperature?  I'm already happy I deciphered the stuff it sends back.. Perhaps you could set the CAN bus timeout too
Title: Re: HE351 code for me78569
Post by: hakcenter on January 20, 2016, 08:51:27 AM
To find an actual dyno'd compressor map graph is going to probably be impossible.

The HE351VE uses a 7 blade compressor wheel, the same exact part number used in the Super 40hx. It flows roughly 69lbs/min

This is about the best we'll get: It is an 83/75 S300ish map that is very comparable, AFAIK they used the same compressor in it.
(http://i289.photobucket.com/albums/ll214/WatsonFab/HX40%20vs%20BW/S300SX83-7560mmcompmap.jpg)
Title: Re: HE351 code for me78569
Post by: hakcenter on January 20, 2016, 08:54:38 AM
To find an actual dyno'd compressor map graph is going to probably be impossible.

The HE351VE uses a 7 blade compressor wheel, the same exact part number used in the Super 40hx. It flows roughly 69lbs/min

This is about the best we'll get: It is an 83/75 S300ish map that is very comparable, AFAIK they used the same compressor in it.
(http://i289.photobucket.com/albums/ll214/WatsonFab/HX40%20vs%20BW/S300SX83-7560mmcompmap.jpg)
Title: Re: HE351 code for me78569
Post by: hakcenter on January 20, 2016, 08:57:06 AM
To find an actual dyno'd compressor map graph is going to probably be impossible.

The HE351VE uses a 7 blade compressor wheel, the same exact part number used in the Super 40hx. It flows roughly 69lbs/min

This is about the best we'll get: It is an 83/75 S300ish map that is very comparable, AFAIK they used the same compressor in it.
(http://i289.photobucket.com/albums/ll214/WatsonFab/HX40%20vs%20BW/S300SX83-7560mmcompmap.jpg)
Title: Re: HE351 code for me78569
Post by: Rx7man on January 20, 2016, 12:55:06 PM
I want to figure out the relationship between efficiency and compressor temperature rise and superimpose it on the map, in an attempt to find out the optimal boost.

Thanks for the map
Title: Re: HE351 code for me78569
Post by: hakcenter on January 20, 2016, 06:40:03 PM
Without airflow you still won't know where you are on the map though.
Title: Re: HE351 code for me78569
Post by: Rx7man on January 20, 2016, 07:25:27 PM
If you know your turbine RPM and PR you should be able to figure it out.. and you should be able to get pretty close by knowing engine RPM, VE and temp as well
Title: Re: HE351 code for me78569
Post by: hakcenter on January 20, 2016, 11:32:20 PM
You'll know what line you're on but not where in airflow without either AFR with injection duty cycle, or a MAF, or VE with AFR.

No offense but this information is pretty much useless anyways. There's no way I'm putting a MAF upfront just to know where I'm at on the compressor map. It's not surging and its spinning 125k, what else is there to really know.

All I'm interested in knowing is if it reaches at least 125k, I know I can get over 60lbs/min out of it. Which I don't need to know while its running, only needed to know that before I mounted it on my exhaust and started boosting. :)

People be all like, omg its a hair drier at those speeds, blah blah. 78% to 68% efficiency at the outer edge, I would have to disagree. At those airflow rates I would be worried about intercooler size etc. But again info to know before its on the vehicle, don't really care once its there. /shrug
Title: Re: HE351 code for me78569
Post by: me78569 on March 14, 2016, 09:20:50 PM
Spent some more time tuning.  The curve is adjusted down some.  Added a perf mode for idle position only, smoke is down and general DD driving is nice, little high strung for my liking, but it is easy to adjust the curve with the incab pot.

3rd gear %50 pull 15psi at 1500 rpm, hard to load the engine enough to put low rpm boost.  I am sure there is 5-10 psi more to gain at that RPM, but I don't like doing pulls that low often. 
(http://i879.photobucket.com/albums/ab360/me78569/Capture_zpsw2qo4jvj.png) (http://s879.photobucket.com/user/me78569/media/Capture_zpsw2qo4jvj.png.html)

I need to spend some more time on the boost / drive readings to make them work right at various altitudes, but low on the list of thing sot do in life.
Title: Re: HE351 code for me78569
Post by: Rx7man on March 15, 2016, 10:18:00 AM
You can build pretty much unlimited boost at any RPM if you can load it hard enough and care to wait for it.. I don't like doing it as a routine either, but I had to try it.. got 40+ PSI @ 1400..  it's pretty brutal on the drivetrain.
Title: Re: HE351 code for me78569
Post by: me78569 on March 15, 2016, 11:26:23 AM
Agree'd

There is a point that you ask yourself " do I really want 30 psi at 1400 rpm?"  I am trying to get the feel of the truck nice. 

I never spend time below 1500, so why should I worry what my PSI is at down there haha?   I don't care to load the truck that hard that low in the rpms.  much rather work in the range that the cummins is good at making power in.
Title: Re: HE351 code for me78569
Post by: hakcenter on March 15, 2016, 12:28:13 PM
I like 10psi off idle, LOL
Title: Re: HE351 code for me78569
Post by: me78569 on March 15, 2016, 12:56:05 PM
Greedy,  the tire companies are gonna love you hahahaha
Title: Re: HE351 code for me78569
Post by: Rx7man on March 15, 2016, 01:42:47 PM
I live on a windy dirt road, I DO spend a lot of time actually driving in the 1000-1400 range, but it's not under a whole lot of load.. a boost of 3-8 PSI is plenty.

If I had an auto tranny in it and it was a drag truck.. well.. that might be a different story!.. Would be fun launching with 40 PSI
Title: Re: HE351 code for me78569
Post by: me78569 on March 24, 2016, 01:23:09 PM
Added a warmup mode.   Not sure I like the trigger method yet.

for the first 2000 cycles of the code the turbo will shift from EB position to 800 position at idle state, then after 2000 cycles to 20000 cycles it will hold eb position at idle.  After that it goes back to the default 700 or 880 position for idle  depending on the inactive pot position. 

Not sure if I will like the first 20000 cycles method of triggering warmup, time will tell.

if (timer % 900) {
    if (StartCount < 20000){  //this section will walk the turbo to EB position for warmup if startup count is less than 20000 or ~ 8-10 minutes
       idle_position += 1; //walk turbo up in position by 1 every time the cycle runs
       idle_position = constrain(idle_position,700,1000); //keeps turbo position in a valid range
       if ( StartCount < 2000){ //walks the turbo to fully closed then back to open and back when first starting.
        if (idle_position > 999){
          idle_position = 800;
        }
       }
       StartCount++; // each time it runs startcount increases by 1 to disable the function after 2000 times

    }else{
    if (PotentiometerValue < 5) { perf_mode = true;} else {perf_mode = false;}
    if (perf_mode) { idle_position = 880;}
    else {idle_position = 700;}

    }

  }
 


Time it takes to reach op temp is easily cut in half when I use the EB.  Turbo timer also will keep the truck running in keyless mode as EGT's stay around 700*f when eb is applied at idle.
Title: Re: HE351 code for me78569
Post by: Rx7man on March 24, 2016, 02:59:16 PM
I'm working on a similar thing.. though I'm not going all the way to EB mode... Currently it's only working to kick out the turbo after idling for 10-20 seconds or so, which keeps it spooled, but will save a little fuel in stop and go traffic... I'm going to make it not kick out when it's under a certain temperature to help warm up.
Title: Re: HE351 code for me78569
Post by: hakcenter on March 24, 2016, 03:39:54 PM
Yeah once I get coolant running through mine I can map out temps.

I've got can messages integrated in my latest code. Works great just need to map out stuff.
Title: Re: HE351 code for me78569
Post by: me78569 on March 24, 2016, 06:45:39 PM
Are you able to read coolant temp Via the turbo??? 

Please say yes.


?Edit:
I completely forgot about that.  I am looking through code rx7 pretty cool.  Wonder if my setup can read it fast enough to do anything worth while


Rx7man,  are you mapping the values yet?   I should be able to map it pretty easy by comparing it to my coolant temp readout. 
Title: Re: HE351 code for me78569
Post by: Rx7man on March 24, 2016, 09:37:44 PM
I think you can read a temp close enough to determine if you should be in warmup mode or not, it's sensitive around lower temps but seems to be stagnant in the operating temp range.. I've had other stuff to do than fiddle with that for now.
Title: Re: HE351 code for me78569
Post by: me78569 on March 25, 2016, 07:19:32 AM
I am gonna run a couple of tests to see if my so so readings match up warm up cycle to warm up cycle -40 offset in C seems likely.
Title: Re: HE351 code for me78569
Post by: Rx7man on March 25, 2016, 08:04:47 AM
That's what I thought at first as well, but in my testing it didn't seem to pan out that way..
Title: Re: HE351 code for me78569
Post by: me78569 on March 25, 2016, 10:06:59 AM
It's hard to know because of a couple of things.

Board temp vs true coolant temp
heater core pre turbo
turbine heat

I think as long as a "warmup temp" is predictable. IE at 140 coolant the turbo temp is typically 50 C then I don't care.

So far this code is working VERY well.  I didn't bother trying to map the value from the turbo, as long as it is the same warmup cycle to warm up cycle I don't care. 

if (timer % 700)   {
    if (VgtRawTemp < 80){  //this section will walk the turbo to EB position for warmup if startup count is less than 600 or ~ 8 minutes
       idle_position += 1; //walk turbo up in position by 5 every time the cycle runs
       idle_position = constrain(idle_position,700,1000); //keeps turbo position in a valid range
       if (VgtRawTemp < 50){ //walks the turbo to fully closed then back to open and back when first starting.
        if (idle_position > 999){
          idle_position = 800;
        }
       }
    }else{
    if (PotentiometerValue < 5) { perf_mode = true;} else {perf_mode = false;}
    if (perf_mode) { idle_position = 880;}
    else {idle_position = 700;}

    }

  }
Title: Re: HE351 code for me78569
Post by: me78569 on March 25, 2016, 01:04:40 PM
So is there a better way to calc a diffence between two variable then

if ((VarA/VarB)>1){}

I would like to take the commanded position and compare it to the respond from turbo to it to look for anything more than a x% difference.

I suppose I could just do error = VarA - VarB then do a if (error > 2 || error < -2)
Title: Re: HE351 code for me78569
Post by: me78569 on March 25, 2016, 02:13:00 PM
Added a warning to my screen to tell me if the command position and real position are different. 
Huge thanks to rx7guy for the canbus read code. 
Title: Re: HE351 code for me78569
Post by: Rx7man on March 25, 2016, 02:53:56 PM
whenever you try to quickly change the vane position you'll get large differences in values.. you'll also get increasing error with increasing backpressure.
You can also just read the motor command speed which SHOULD be proportional to the difference between the two.. I think 0 maps to -128, 128 = 0, and 255 = +127 or something similar.. I haven't tested to see how far off it has to be to put it to 'full speed'..  and it may have an internal PID feedback loop as well.. would take a lot of fiddling to get to the bottom of it, and it's hard to do while it's in the truck.
During my bench testing, I noticed if I command it from full open to full closed several times in quick succession it will go into a "slow" mode to reduce motor wear and heat, then come back to full speed if it's given a little rest... It's something like if it moves more than 4000 position units in 2 seconds, which really would never happen in normal driving.
Title: Re: HE351 code for me78569
Post by: me78569 on March 25, 2016, 03:31:55 PM
What I ended up doing is putting a count into place that would happen each time a variance was found between the two. 

If that count was off for more than 10 reads in a row it would flag a warning on the screen.  my turbo seems to keep up, I can up the count from 1 time to 3 and the warning goes away. 

This should keep the warning from happening due to the turbo responding slowly. 
Title: Re: HE351 code for me78569
Post by: Rx7man on March 26, 2016, 01:55:30 AM
in your code
error = VarA - VarB then do a if (error > 2 || error < -2)

if the sign of the error isn't relevant, I find readability improves if you take the absolute value, and then only have to do one test on it.. and the more conditions you check the error against the more of a difference it makes

error = abs(VarA-VarB);
if (error >= errorthreshold1){
  do something
}
if (error >= errorthreshold2){
  do something else
}


Gotta ask though.. what is this warning doing? Is there a reason for concern here?
Title: Re: HE351 code for me78569
Post by: hakcenter on March 26, 2016, 05:51:45 AM
Probably just looking for sticking vane positions, I'm going to do the same thing except not toss an error lol.

Just add a * to the output page once vane position falls out of spec for 2 reads.
Title: Re: HE351 code for me78569
Post by: Rx7man on March 26, 2016, 08:38:55 AM
Thankfully the importance of this is minor compared to Ford/Garrett models
Title: Re: HE351 code for me78569
Post by: me78569 on March 26, 2016, 10:36:27 AM
Just doing because I can.  I was curious how fast the vanes match the position. Requested,  figuredo I might as well put a warning in place since most of the code was already there.
Title: Re: HE351 code for me78569
Post by: me78569 on May 23, 2016, 10:19:32 AM
Alright,

Well the time has come to setup to the arduino mega.  I have one coming, should be here tomorrow.  Hopefully he changes go smooth, not sure how I am going to "move" the pins for the canbus yet, but I will figure it out.


Then I found $5 ( just because it is a boring post)


I need to start watching Engine RPM and I am going to add in a APPS buffer that can slow down throttle input to help pass emissions. 
Title: Re: HE351 code for me78569
Post by: Bdubb'z on May 23, 2016, 10:56:26 AM
Nice, excited to see how it turns out.

I'll be the stupid one here, what's $5 post? 
Title: Re: HE351 code for me78569
Post by: me78569 on May 23, 2016, 12:42:20 PM
that's how you end a stupid story " and then I found $5" 
Title: Re: HE351 code for me78569
Post by: Bdubb'z on May 23, 2016, 02:51:38 PM
   mmmmmmm...... free money ......... :-X
Title: Re: HE351 code for me78569
Post by: me78569 on May 23, 2016, 07:07:15 PM
exactly haha.
Title: Re: HE351 code for me78569
Post by: me78569 on May 25, 2016, 07:21:49 AM
Well the Mega is install and everything is working except my lcd screen.  I gotta take a look and see what the pin changes are for that.


I am really considering creating a shield for the mega that allows you nice right hand connectors for sensor output, kinda like the lilbb, but with more plugs. 



Question I have for you guys is, Since the vgt is using 250 kb couldn't I use the same can channel to talk to the truck pcm also?   The truck uses 250 also. 
Title: Re: HE351 code for me78569
Post by: hakcenter on May 25, 2016, 08:39:04 PM
I think you can talk to both ?
Title: Re: HE351 code for me78569
Post by: me78569 on May 26, 2016, 07:14:51 AM
I think so too,  I am reviewing some example code from sparkfun that deals with talking to the ecm.  I am gonna throw it on the old unit I have with a spare canbus shield and see if I can't get it to talk.   Then I will try to move it into my turbo controller and go from there.
Title: Re: HE351 code for me78569
Post by: Rx7man on May 27, 2016, 01:41:44 PM
Should be able to talk to both if the addresses are different (they ought to be)
Title: Re: HE351 code for me78569
Post by: me78569 on May 30, 2016, 08:54:09 PM
I am pretty sure they are,  I have a obdlink reader coming that will allow me to do some canbus sniffing on the computer using tera term rather than having to work through the arduino.  This will speed up the process a good bit since I am unsure what protocol is used for what on my truck.  There are 3 different canbus type networks haha.

have some mountain pass towing time this weekend.  Turbo continued to work great.  3rd gear 2300 rpm %50-%60 TPS held shaft speeds right at 110,000 rpm at 15-20 psi without any trouble.   I really had to push it to see over 120,000 rpm.  Just took it and kept asking for more.  I am sure I could have held higher boost, but I have no need to pull up the pass at 65 mph haha. 
Title: Re: HE351 code for me78569
Post by: Rx7man on June 01, 2016, 12:02:41 AM
You have no NEED to go up the pass at 65, but it's FUN!  I can't wait to put the 6 speed and 3.55's in my truck so I can do 85 up the passes.. Might have some fun with some fords too :P
Title: Re: HE351 code for me78569
Post by: me78569 on June 01, 2016, 08:28:03 AM
I am in no hurry, most of the passes around my area you would be dead if you tried to pull them at 85.  It is scary to see some of the rigs flying up the pass when you know there is a legitimate 20 mph corner just a mile up the road.

Oh well, I just chug a long at 55 happy as can be.
Title: Re: HE351 code for me78569
Post by: Bdubb'z on June 02, 2016, 03:19:44 PM
Quote...  I can't wait to put the 6 speed and 3.55's in my truck so I can do 85 up the passes.. Might have some fun with some fords too :P

Do you have 4.10's now?  I just swapped from 3.73's to 3.42's in my AAM axles, and have the nv5600.  The 5600 doesn't have as deep an overdrive as the 4500.  At 65mph and 285/17's I was right about 2000 rpm.  All the freeway speed limits around here are 70, then out of town is 80.  I just pulled the 10000' pass home last night at 85 and like 2200 rpm.....aaahhhhhh
Title: Re: HE351 code for me78569
Post by: me78569 on June 02, 2016, 09:16:24 PM
3.55's here
Title: Re: HE351 code for me78569
Post by: Rx7man on June 03, 2016, 01:17:37 AM
bdubs, yes, I have 4.10's.. slow as molasses in january, and with the power I have now you don't need the extra gearing.. All duallies in the 2nd gens were 4.10's and all 2500's were 3.55's AFAIK.. perhaps there were some custom orders?
If I put the 6 speed into it without gearing changes I'd be doing nothing but shifting
Title: Re: HE351 code for me78569
Post by: Bdubb'z on June 03, 2016, 09:05:34 AM
You still will be shifting all the time  :D   I still skip a few every once and a while.  Its nice though, I don't miss the big step on the 4500.  Less shifting for you on those windy dirt roads probably. 
Title: Re: HE351 code for me78569
Post by: Rx7man on June 03, 2016, 10:35:10 AM
I think I'll be going between 4th and 5th on the 6 speed on the dirt roads... truck doesn't mind 1200 RPM puttering.. I figured it that I'll basically have the same gears, and one extra.. Truck ought to do 110mph if I ask it to, right now it's out of revs at 85, which sucks for passing
Title: Re: HE351 code for me78569
Post by: hakcenter on June 04, 2016, 11:22:09 AM
gear vendors
Title: Re: HE351 code for me78569
Post by: Rx7man on June 04, 2016, 01:36:34 PM
I would love a gearvendors overdrive, but the price of them is prohibitive!... I can buy a 6 speed for that
Title: Re: HE351 code for me78569
Post by: hakcenter on June 04, 2016, 03:00:29 PM
You can't buy a 12spd for that though
Title: Re: HE351 code for me78569
Post by: Rx7man on June 04, 2016, 10:51:52 PM
Don't need a 12 speed either.. As it happens, I do have a big ass rearend from a 5 ton with a split axle, paid $600 for the whole truck, I guess there might be a way to stuff that under my truck :P
Title: Re: HE351 code for me78569
Post by: me78569 on June 06, 2016, 07:32:13 AM
only if you can write a class for it and control it via the arduino hahaha
Title: Re: HE351 code for me78569
Post by: hakcenter on June 07, 2016, 09:27:17 AM
Pretty sure the foots switch could be controlled by the arduino...
Title: Re: HE351 code for me78569
Post by: me78569 on September 05, 2016, 05:02:42 PM
Rx man gave an update so I figured I would too.

Things are working way to well to touch anything haha.  My truck is about perfect for my needs.  0 smoke ( thanks to the quadzilla tuning I was able to create) , great power, great spool...cake and eat it too. 
Title: Re: HE351 code for me78569
Post by: Rx7man on September 05, 2016, 09:13:20 PM
Good to hear..  I never achieve perfection.. I add features, then find they complicate things too much so tear them out, rinse, repeat.. though I will say my truck is nicely driveable as it stands
Title: Re: HE351 code for me78569
Post by: me78569 on October 18, 2016, 11:12:11 AM
So how would you go about programming cruise state qualification?

My thoughts are

-average TPS reads every 20 cycles of the time-keep section and watch for  high % jump in tps maybe?   

Any one think of a better way to qualify if you are at cruise?
Title: Re: HE351 code for me78569
Post by: Rx7man on October 18, 2016, 09:45:23 PM
You can look at TPS as well as RPM.. at cruise both should be relatively steady..
What is the end game of figuring out you're at cruise?
Title: Re: HE351 code for me78569
Post by: me78569 on September 29, 2017, 05:57:01 PM
Well I got some 7 x .012's in the truck, up from my 7 x .009's.  Didn't have to change anything in the code.  Props to hakcenter for the RPM logic it works well.

Video of a cruise to WOT throttle snap
https://youtu.be/KxPmJmKarb4
Title: Re: HE351 code for me78569
Post by: hakcenter on September 29, 2017, 06:54:14 PM
Nice, I don't know if you know.. but your dash is like cracked...
Title: Re: HE351 code for me78569
Post by: Rx7man on September 30, 2017, 09:02:05 AM
Good job!  I would guess these are VCO injectors?
Title: Re: HE351 code for me78569
Post by: me78569 on September 30, 2017, 11:36:22 AM
Quote from: hakcenter on September 29, 2017, 06:54:14 PM
Nice, I don't know if you know.. but your dash is like cracked...


What dash? 


7 x .012's vcos set at 330 bar rather than 310 bar.  Using my Quadzilla tuner to pull duration down to 68% of stock at 0psi and walk up from there.  small timing adjustments in the tune as well, but not near as much as I thought.
Title: Re: HE351 code for me78569
Post by: Rx7man on September 30, 2017, 12:35:08 PM
If I do new injectors at some point i'll probably go to VCO's.. the SAC's I have are just too dirty..
Title: Re: HE351 code for me78569
Post by: hakcenter on October 01, 2017, 05:21:34 PM
Have to agree, sure the SAC's flow more but they just seem too dirty
Title: Re: HE351 code for me78569
Post by: me78569 on October 01, 2017, 08:16:08 PM
OEM choose them for a reason.  I have MORE than enough power now, Gaining 15 hp with SAC's I could care less about. 

More videos.  this one is a passing situtation, or at least emulation

Took it to 30 mph, in 3rd, locked the TC and did a pull to show lugging the motor transitioning into boost coming up and passing.


https://www.youtube.com/watch?v=9pmmdpOaeNs

data log
(https://mopar1973man.com/storage/attachments/monthly_2017_10/59d14332953a7_3rdgearpull.PNG.cbcf5771fc4f57a3dcd13400653ea3f9.PNG)


Title: Re: HE351 code for me78569
Post by: Rx7man on October 04, 2017, 10:54:29 AM
Looks like the VCO nozzles may be getting fast tracked.. see my thread for info
Title: Re: HE351 code for me78569
Post by: me78569 on October 30, 2017, 08:52:28 AM
Well I moved my 65000 rpm to 105000 vane position up by ~1 cm.   this has solved my barking issue and keeps my DP from going north of 50 psi on top.  I am pretty dang happy right now.

DP to B ratio is 1.42 on my "race curve"