Controlling the LBB with Arduino

Started by Bonez34, September 13, 2015, 02:04:31 PM

Bonez34

So I'm working on a simple menu,  and was wondering.  Is it possible to control the LBB "maps" with another Arduino?  Seems like it would be pretty simple if enough pins are left on the LBB.

hakcenter

You could talk to it via ttl I  guess and setup some form of communication.

Most of the i/o is used up though, except the adcs.
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

Rx7man

Using a Mega board would give you more IO's... Perhaps over SPI you could share the data lines with the CAN controller and have a separate CS line
'94 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles

Bonez34

So it's not as simple as using a Mega and switching pins high/low to choose the maps?  Would you have to re-write the entire code to accomplish this?

I'm just asking if it's possible to eliminate the jumpers.

Rx7man

I think you could chose maps based on a pin state too.. I was thinking of doing it over digital comms though.. using pins is simpler for sure.

Somewhere in the program you'd probably poll that pin to see if it's changed.  You'd probably have what I call a "working copy" of the map which is what the program uses, and 2 static copies that contain the data for the long term.  As the pin changes HIGH, you'd copy from static map1 to the "working copy".. as it changes LOW, you'd copy the data of static map2 to the "working copy".. That would be pretty easy to implement.

If you have a spare ADC input, you could change gradually from one pin to the other
so if the ADC read 0, you take the data from static copy1, and if it's 1024, you take it from static copy2, and map the values between them...

So using some imaginary maps

int Map1[5]; //low performance?
int Map2[5]; //high performance?
int WorkingCopy[5]; //the map the rest of the program uses
int ADCvalue = analogRead(PerfPotPin); //get the ADC value from the 'performance' potentiometer

for (int i = 0; i<5; i++){
WorkingCopy(i) = map(ADCvalue, 0, 1024, Map1(i), Map2(i);
}








'94 dually,  67/67 HE351VE, NV5600, ~600hp
'93 ECLB 47RH, new toy truck, H pump project, 1000hp goal, 300K miles
93 XCLB auto, bone stock, 350K miles
93 XCLB 5spd, bone stock, 100K miles

Bonez34

I am not a coder.  That just gave me a headache.  lol  What about relays,  could I just replace the jumpers with relays or does the LBB need to reset after jumper changes?

hakcenter

If you didn't want to use the jumper configuration..  You don't have to. You could get 3 i/o's right there and ditch the jumpers and use various configurations of the i/o's to do what you want
TS2009 Deḇarim 8:2
"And you shall remember that יהוה your Elohim led you all the way these forty years in the wilderness, to humble you, prove you, to know what is in your heart, whether you guard His commands or not.

me78569

#7
I believe the last time I read through the lilbb code, the curve selection what in the setup section of the code, correct?  If that is the case you would need to "reset" the arduino to define a new curve.

Here is the code I use to allow a potentiometer to define a curve on the fly.


////////////////////////////////Watches for the pot position when pot switch is off to see what turbo curve is selected//////////////////////////////////////////
///////////////////////////////copying an array takes some time so I only check for this ever 900ms and I only copy the array if the last array doesn't match//
void Watchpotcrv() {
     
if (!eb_mode && !pot_mode) {
  if (PotentiometerValue > 960) { curvea = true; curvemode = 3; } else {curvea = false;}
  if (PotentiometerValue > 300 && PotentiometerValue < 960){  curveb = true; curvemode = 2; } else {curveb = false;}
  if (PotentiometerValue > 40 && PotentiometerValue < 300){ curvec = true; curvemode = 1; } else {curvec = false;}
  if (PotentiometerValue < 40){ curved = true; curvemode = 0; } else {curved = false;}
   
  if (curvemode != lastcurvemode){  //here is where I check to ensure that I only copy the array when needed, not every time
   
    if (curvea) {memcpy(turbo_curve,turbo_curve_1,sizeof(turbo_curve)); BoostMapMode = 'P';}
    if (curveb) {memcpy(turbo_curve,turbo_curve_2,sizeof(turbo_curve)); BoostMapMode = 'D';}
    if (curvec) {memcpy(turbo_curve,turbo_curve_3,sizeof(turbo_curve)); BoostMapMode = 'T';}
    if (curved) {memcpy(turbo_curve,turbo_curve_4,sizeof(turbo_curve)); BoostMapMode = 'M';}
    lastcurvemode = curvemode;  //if curve mode has changed this is where I set the last mode so I can check the next time.
    String MapMode = String(BoostMapMode);  //printing this only when I need to saves time.
    lcd.setCursor(19, 3);
    lcd.print(MapMode);
  }
}
}


You will have to edit the lilbb code, to take that out of the setup, but the above works well for me to switch curves on the fly.
2000 Dodge 2500 quad-cab 5.9 Cummins slt, homebuilt 47re revmax 3.5 messed with vb, Quad adr iquad, 4" tbe , pureflow 150 gph. he351ve in the works 100hp DFI inj