Controlling the LBB with Arduino

  • 7 Replies
  • 625 Views
*

Offline Bonez34

  • Member
  • **
  • 22
    • 300ZX
Controlling the LBB with Arduino
« on: September 13, 2015, 02:04:31 PM »
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.

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 679
    • 1998 12v Ram
Re: Controlling the LBB with Arduino
« Reply #1 on: September 13, 2015, 02:09:06 PM »
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.
AMP 2 Corinthians 8:21
For we take thought beforehand and aim to be honest and absolutely above suspicion, not only in the sight of the Lord but also in the sight of men.


*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 988
  • Jack of all trades
    • '94 Dodge dually
Re: Controlling the LBB with Arduino
« Reply #2 on: September 13, 2015, 02:14:54 PM »
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 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Bonez34

  • Member
  • **
  • 22
    • 300ZX
Re: Controlling the LBB with Arduino
« Reply #3 on: September 13, 2015, 02:49:05 PM »
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.

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 988
  • Jack of all trades
    • '94 Dodge dually
Re: Controlling the LBB with Arduino
« Reply #4 on: September 13, 2015, 06:12:27 PM »
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
Code: [Select]
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 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Bonez34

  • Member
  • **
  • 22
    • 300ZX
Re: Controlling the LBB with Arduino
« Reply #5 on: September 14, 2015, 03:11:11 PM »
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?

*

Offline hakcenter

  • developer
  • Hero Member
  • *****
  • 679
    • 1998 12v Ram
Re: Controlling the LBB with Arduino
« Reply #6 on: September 14, 2015, 03:28:22 PM »
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
AMP 2 Corinthians 8:21
For we take thought beforehand and aim to be honest and absolutely above suspicion, not only in the sight of the Lord but also in the sight of men.


*

Offline me78569

  • Sr. Member
  • ****
  • 274
Re: Controlling the LBB with Arduino
« Reply #7 on: September 15, 2015, 12:26:22 PM »
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.

Code: [Select]
////////////////////////////////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