Jump to content
  • Welcome To Mopar1973Man.Com LLC

    We are a privately owned support forum for the Dodge Ram Cummins Diesels. All information is free to read for everyone. To interact or ask questions you must have a subscription plan to enable all other features beyond reading. Please go over to the Subscription Page and pick out a plan that fits you best. At any time you wish to cancel the subscription please go back over to the Subscription Page and hit the Cancel button and your subscription will be stopped. All subscriptions are auto-renewing. 

He351ve stand alone Arduino controller code for 2nd Gen Cummins


Recommended Posts

not that I am aware of.  since we know everything we need to know about controlling the turbo via canbus there isn't much point in my mind.  Using Can controlled signals you can increase the vein position one position at a time for the whole 0-1000 range.  

 

Open to new ideas if you have them though.

Link to comment
Share on other sites

I agree, however the he351ve is to large for my application. The he341ve is better but the few I can find/have only accept a PWM signal as far as I know. Im thinking about integrating the PWM sheild with your project (which is great by the way!) unless someone has a better idea.

Link to comment
Share on other sites

whats your application?  

 

 

I THINK steed runs a he341 on his toyota with his controller.

 

Edit, No he actually used the compressor from a 341 on a 351 and made a hybrid.  

 

the 341 is a 24v system also.  I would do what he did.

Link to comment
Share on other sites

4bt - in a landcruiser.

 

I've talked to steed a few times on this project, but I dont think he ever got around to testing the 341 actuator. His hybrid method is expensive unless your lucky to find a used newer 341 and there still expensive. My 341 is older off of the f-650 and wont work as a hybrid, but it is 12 volts. Im going to buy a cheap adjustable PWM and see if I can get it to function.

Link to comment
Share on other sites

Cowboy or others

 

 

I am having some issues with the code now that I have the map sensors connected.  

 

int ReadExhaustPressure(){
int ExhaustVal = analogRead( ExhaustPressurePin ); // read the value from the sensor
return map( ExhaustVal, 103, 920, 0, 100);
 
int ReadBoostPressure(){
int ExhaustVal = analogRead( BoostPressurePin ); // read the value from the sensor
return map( ExhaustVal, 103, 920, 0, 100);
 
Now I know map function doesn't constrain, but if I set it to above my boost/exhaust reads -12psi with the sensor plugged in at atmophere.  The specs on the sensor is 0 psi at .5v and 100 at 4.5v  
 
Now I am guessing this means the arduino is reading 0v from the sensor correct?
 
 
No looking at the code I started with It was 
 
int ReadBoostPressure(){
int ExhaustVal = analogRead( BoostPressurePin ); // read the value from the sensor
return(ExhaustVal);

 

This reads the sensor at 0psi.  

 

Now I am assuming I need to map the sensor values????? right???  

Link to comment
Share on other sites

This is what I'm currently running, and it's working great, and I'm guessing we've got the same $20 pressure transducer.  Once thing you'll want to do is be prepared for negative pressures.  I posted a couple options earlier in this thread.

int PressureRead(byte AnalogPin) {
  int AverageNum = 3;
  int Val = 0;


  for (int i = 0; i < AverageNum; i++) {
    Val += analogRead(AnalogPin);
  }
  Val = constrain((Val / AverageNum), 103, 925);
  return map(Val, 103, 920, 0, 1000 );//0-1000 so I have 0.1 precision.
}

I would make sure the sensor is wired correctly, and is receiving good voltage.

Link to comment
Share on other sites

Weirdly tho the sensor ,ss207, is only spec'd for 0-100psi

 

Just very confused by the sensor is returning -12psi haha.  I suppose the thing that makes the most sense is I am not getting power to the sensor and thus no reading back?

Link to comment
Share on other sites

Well

 

 

I have gotten the arduino mounted in the cab with the sensors installed.  Turbo is still on my bench waiting for the t3 to he351ve adapter.  

 

 I am going to have to make some changes to the lcd display and only update the display every half second or so to try and keep the values readable.  

Link to comment
Share on other sites

Alright first post is updated with current code.  

 

 

LCD refresh rate has been increased from 200 to 400 ( assuming millis)  constrans have also been added to keep the boost and driver readings positive.  

 

 

Thinking about adding a MAX value to the drive and boost to show the max hit, but I am unsure if that is needed. I suppose it would be nice so I might mess with it some.

Link to comment
Share on other sites

Well after a few days of driving with the sensors connected I can say that the boost sensor reads VERY steady, however the drive pressure bounces a lot. 

 

 

I am not sure if this is due to wiring, sensor, or maybe a leak in the exhaust copper line.

Link to comment
Share on other sites

My Boost sensor was very steady as well when I had it Tee'd into where the wastegate hooks in by the AFC, because there is an orifice right there working as a snubber.  I than moved it to the head for reasons, and now it is very spiky.  So I'm going to put my own snubber in the line.  In both cases, the sensors actual locations didn't move, and had the same 1.5' of 1/4" hose going to it.  So maybe your DP spikes is just normal engine operation.

Link to comment
Share on other sites

I am thinking that might be the case.  

 

 

Not sure if some sort of needle valve will help, or not.   My concern is that the spikes in the drive pressure will cause the turbo to jump alot once boost goes over 30psi ( where the program is set to manage veins by drive not boost)

 

Guess I could try and filter out readings that outside of the typical 2:1 ratio.  since drive pressure can never been less than boost and should be no more than double boost, I should be able to contain the reading?  

Can I use a variable to constran the drive reading, rather than the typical 0-1023?  

 
int ReadBoostPressure(){
int BoostVal = analogRead( BoostPressurePin );
BoostVal = constrain(BoostVal, 83, 920); // 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 BtoDlimit = (BoostPressurePin * 3);
int ExhaustVal = analogRead( ExhaustPressurePin ); // read the value from the sensor
if (SwitchPosition != HIGH && ThrottlePosition < 30){  //If I am using the pot I want to see drive
ExhaustVal = constrain(ExhaustVal, 83, 920);
return map( ExhaustVal, 83, 920, 0, 100); // Last two values are the psi range of the choosen senso
  } 
else{
ExhaustVal = constrain(ExhaustVal, BoostPressurePin, BtoDlimit);
return map( ExhaustVal, 83, 920, 0, 100);
  }
}
 

Thoughts?

Link to comment
Share on other sites

After hak guy dude helped me on CF I am now reading the exhaust sensor 5 times and averaging.

//Read Sensors
//Define the sensor type and range. (Namefromabove, 0v, 5v, 0v=minpos,5v=maxposition)
int ReadPotentiometer(){
int tmp = analogRead( PotentiometerPin );
delay(analogDelay);
int PotVal = (tmp + analogRead( PotentiometerPin )) / 2;
return map(PotVal, 0, 1023, 0, 970); // read the value from the sensor
}

int ReadBoostPressure(){
int tmp = analogRead( BoostPressurePin );
delay(analogDelay);
int BoostVal = (tmp + analogRead( BoostPressurePin )) / 2;
BoostVal = constrain(BoostVal, 83, 920);        // 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 tmp = analogRead( ExhaustPressurePin );
tmp = constrain(tmp, BoostPressurePin, 920);
delay(analogDelay);
int tmp1 = analogRead( ExhaustPressurePin );
tmp1 = constrain(tmp1, BoostPressurePin, 920);
delay(analogDelay);
int tmp2 = analogRead( ExhaustPressurePin );
tmp2 = constrain(tmp2, BoostPressurePin, 920);
delay(analogDelay);
int tmp3 = analogRead( ExhaustPressurePin );
tmp3 = constrain(tmp3, BoostPressurePin, 920);
delay(analogDelay);
int tmp4 = analogRead( ExhaustPressurePin );
tmp4 = constrain(tmp3, BoostPressurePin, 920);
int ExhaustVal = ((tmp + tmp1 + tmp2 + tmp3 + tmp4) / 5) + 1;
return map( ExhaustVal, 83, 920, 0, 100); // Last two values are the psi range of the chosen sensor
}




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

}
Link to comment
Share on other sites

Looks good.  I forgot to mention that I am averaging 3 reads.  What do you have "analogDelay" set to?

 

Here's something that should work the same, but may be a little cleaner.  I used to not care about how clean my code was, but after leaving a project for a couple months, and then trying to get back in.  Having a cleaner code makes figuring out what you were trying to do so much easier.  

//Read Sensors
//Define the sensor type and range. (Namefromabove, 0v, 5v, 0v=minpos,5v=maxposition)
int ReadPotentiometer(){
int tmp = analogRead( PotentiometerPin );
delay(analogDelay);
int PotVal = (tmp + analogRead( PotentiometerPin )) / 2;
return map(PotVal, 0, 1023, 0, 970); // read the value from the sensor
}
 
int ReadBoostPressure(){
int tmp = analogRead( BoostPressurePin );
delay(analogDelay);
int BoostVal = (tmp + analogRead( BoostPressurePin )) / 2;
BoostVal = constrain(BoostVal, 83, 920);        // 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 tmp = constrain(analogRead( ExhaustPressurePin ), 83, 920);
delay(analogDelay);
tmp += constrain(analogRead( ExhaustPressurePin ), 83, 920);
delay(analogDelay);
tmp += constrain(analogRead( ExhaustPressurePin ), 83, 920);
delay(analogDelay);
tmp += constrain(analogRead( ExhaustPressurePin ), 83, 920);
delay(analogDelay);
tmp += constrain(analogRead( ExhaustPressurePin ), 83, 920);
delay(analogDelay);

return map(tmp / 5, 83, 920, 0, 100); // Last two values are the psi range of the chosen sensor
}
 
int ReadThrottlePosition(){
int tmp = analogRead( ThrottlePositionPin );
delay(analogDelay);
int ThrottleVal = (tmp + analogRead( ThrottlePositionPin )) / 2;
return map ( ThrottleVal, 103, 920, 0, 100); // read the value from the sensor
 
}

Because I have a couple sensor hookups, and do a lot of repetitive stuff with them.  I used a lot of "for loops", it makes things simple and clean, but it won't run as fast as the above code.  But that is an option in your interested.

int ReadExhaustPressure(){
int AverageNum = 5;
int tmp = 0;

for(int x = 0; x < AverageNum; x++){
tmp += constrain(analogRead( ExhaustPressurePin ), 83, 920);
delay(analogDelay);
}
return map(tmp/AverageNum, 83, 920, 0, 100); // Last two values are the psi range of the chosen sensor
}
Link to comment
Share on other sites

I am using 1ms as my analog delay.

 

 

I am going to define a boostreference variable and have that = to boost constrain( 83, 920)  yada yada yada.   So then I can reference the boostrefrence as the lower constrant to the averaging of the analog read.  

 

 

driving around it works pretty dang good, couple of stray readings but not bad at all.  I am a bit worried about the dpmanage function that will adjust vein position after 30 psi of boost.  I dunno if the drive pressure will be stable enough to rely on.

 

int ReadExhaustPressure(){
int BoostReference = constrain((BoostPressure + 5), 83, 920);
int tmp = analogRead( ExhaustPressurePin );
tmp = constrain(tmp, BoostReference, 920);
delay(analogDelay);
int tmp1 = analogRead( ExhaustPressurePin );
tmp1 = constrain(tmp1, BoostReference, 920);
delay(analogDelay);
int tmp2 = analogRead( ExhaustPressurePin );
tmp2 = constrain(tmp2, BoostReference, 920);
delay(analogDelay);
int tmp3 = analogRead( ExhaustPressurePin );
tmp3 = constrain(tmp3, BoostReference, 920);
delay(analogDelay);
int tmp4 = analogRead( ExhaustPressurePin );
tmp4 = constrain(tmp3, BoostReference, 920);
int ExhaustVal = ((tmp + tmp1 + tmp2 + tmp3 + tmp4) / 5);
return map( ExhaustVal, 83, 920, 0, 100); // Last two values are the psi range of the chosen sensor
}

Is there any perk to using the tmp += vs assigning multiple variables?  It is easier for me to read like I did it haha, My coding mind isn't that creative.

 

 

I do have a question in regards to the constrain function,  been trying to read up on it but I cannot find an answer.  

 

So I know constrain makes the variable at hand stay between a and b.  However if a reading lower than a comes in does the code disregard it or simply assign it to a?

 

IE if I have 

 

tmp1 = constrain(tmp1, 83, 920);  and a value for tmp1 of 40 is read does it just bump that 40 value to 83 or does it disregard it?

Link to comment
Share on other sites

My sloppy attempt at creating an array and using it to average the exhaust reading.  i'll test this in the am.  It should work a little better.....I think haha.  

int ReadExhaustPressure(){
  const int numReadings = 5;      // number of reads to do.
  int readings[numReadings];      // the readings from the analog input
  int index = 0;                  // the index of the current reading
  int total = 0;                  // the running total
  int average = 0;                // the average
  int BoostReference = constrain((BoostPressure + 1), 83, 920);
  
    for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;
  
  total= total - readings[index];    
  readings[index] = analogRead(constrain(ExhaustPressurePin, BoostReference, (BoostReference *3))); // read from the sensor:  Constrains Value to between boost 
                                                                                                    //value and boost value times 3 D:B should never be more than 3:1
  total = total + readings[index];       // add the reading to the total:  
  index = index + 1;                    // advance to the next position in the array:

  
  if (index >= numReadings)     // if we're at the end of the array... 
    index = 0;                  // ...wrap around to the beginning:         

  // calculate the average:
  average = total / numReadings;         
  delay(1);    
return map( average, 83, 920, 0, 100); // Last two values are the psi range of the chosen sensor
}
Link to comment
Share on other sites

×
×
  • Create New...