Torque

Forums

Forums

Guest  

Show or hide header
Welcome Guest, posting in this forum require registration.




Torque » Torque OBD ECU Scanner » Torque Discussion / Ideas » Arduino internal variables

Pages: 1 2 [3]
Author Topic: Arduino internal variables
hugovw1976
Member
Posts: 19
Post Re: Arduino internal variables
on: April 23, 2017 (GMT)

Quote from 1kzte on April 22, 2017
Ok, so changed the HC-06 name to OBDII (also tried OBD2). I can see it on the head unit but still the same problem:
Shows up on the head unit as available device.
When I click on it, a screen pops up and says “Pair and connect”, “No Yes”.
I click on Yes, but nothing happens. No screen comes up to enter the pairing code.
I set the pairing code of the HC-06 to 0000. The head unit pairing code is also 0000. But there is no screen pop up to enter the code, and then the HC-06 never pairs, so Torque app never gets any sensor info.

Questions:
1. I have an HC-05. If I use it in master mode, will it cause a pop up screen to appear on the head unit to enter the pin?

2. Since I will want to connect my phone to the head unit, would it be better to connect the Arduino via USB, and use the Torque app via USB connection (I see the option of USB in the Torque settings). If so, what do I need to change in the code for it to communicate over USB? Can most head units connect to more than one Bluetooth device at a time?

3. Can I get a Bluetooth dongle that can communicate with SPP, and plug it into one of the USB ports of the headunit? Then I would still use the HC-05 or HC-06 to talk to the head unit?

Sorry, I’m new to this stuff, but really want to make this work to read boost and EGT on my old land cruiser!

Thanks for the suggestions so far, and look forward to some more!

Clear all paired phones (devices) on head unit restart and try again to pair with OBDII, for me take about 4 or 5 times. but once is paired for the first time the connection it’s automatic next time.

1kzte
Member
Posts: 12
Post Re: Arduino internal variables
on: April 25, 2017 (GMT)

The head unit manufacturer, Volsmart, claims that the units Bluetooth cannot communicate with Serial Port Profile (SPP). Does this mean I’m dead in the water trying to use an HC-05 or HC-06 with Arduino?

If so, how do I use the Torque app, connected to Arduino via USB. What do I need to change in the code, if I am not sending/receiving with RX/TX to Bluetooth board?

Thanks!

flywire
Member
Posts: 1
Post Re: Arduino internal variables
on: April 30, 2017 (GMT)

Would this run on the ESP8266 [see ESP8266 forum]? It runs wifi directly instead of bluetooth and is available as nice development boards.

1kzte
Member
Posts: 12
Post Re: Arduino internal variables
on: May 8, 2017 (GMT)

I know there is the option, within the Torque app, to select communication over wifi. Would there need to be any change to the arduino code, if I switch communication from bluetooth to wifi?

mroberte
Member
Posts: 1
Post Re: Arduino internal variables
on: June 4, 2017 (GMT)

Sorry for my ignorance in advance as I’m still learning Arduino, but I have purchased a Arduino Micro and HC-06 and have uploaded the Arduino code from https://torque-bhp.com/wiki/User_Arduino_code to the board.

I can connect the BT to my phone and Torque recognizes it.

My question now is I want to connect my Can HI/LO wires to the board. Do I connect the two wires to pins 8 and 9 directly? Or do I need a canbus shield too and then figure out how to write the extra code?

Thank you in advance!

puggy
Member
Posts: 3
Post Re: Arduino internal variables
on: July 17, 2017 (GMT)

@1989Marathon , @piemmm or others, when set up with an Arduino can Torque show data from Arduino sensors AT THE SAME TIME as ODB2 data from the car?

The video done by @1989Marathon at https://www.youtube.com/watch?v=5NpAFdCv7kA certainly suggests this is possible.

Edit: looking at the code by @1989Marathon it looks like he has hacked the ODB2 connector to feed the ECU data into the Arduino which in turn is then sent to Torque via Bluetooth.

Anyone have a link to suitable hardware for the ODB2 hack? Think I saw some recently.

smilliken
Member
Posts: 6
Post Re: Arduino internal variables
on: December 13, 2017 (GMT)

Has anyone tried to use the Arduino 101 which has the built in BT?

1kzte
Member
Posts: 12
Post Re: Arduino internal variables
on: January 9, 2018 (GMT)

I finally got the RC-05 to connect to my Volsmart head unit. All is working nice now.

Another question – does anyone know if it is possible to have the RC-05 bluetooth send the same info to two different devices? In otherwords, could I have it send sensor info to torque running on my head unit and to an android tablet at the same time?

Pronchai9
Member
Posts: 1
Post Re: Arduino internal variables
on: March 5, 2018 (GMT)

    Quote from 1989Marathon on August 12, 2016

    #include avr/pgmspace.h
    #include SoftwareSerial.h
    #include String.h
    
    // ******INPUTS******
          int MAPsensor = A0;                      //inputpin for the MAP sensor
          int TPSsensor = A1;                      //input pin for the TPS sensor
          int AFRsensor = A2;                      //input pin for the AFR sensor
          int RPMsensor = 21;                      //input pin for the RPM sensor. Pin 21 is tied to interrupt#2
          int Temps = 0;                           //input pin for the temperature sensor(s)
          
    // ******OUTPUTS******
          int Injector = 2;                        //injector connected to digital pin 2
    
    // ******VARIABLE DECLARATION******
          volatile bool Running = 0;               //is the motor running or not
          volatile int FireInjector = 0;           //set when the injector should be fired
          volatile float RPMcount;                 //number of triggers on the RPM sensor
    
          volatile float RPMValue = 2453;          //calculated RPM from interrupt #2. Declared volatile so it is loaded from RAM
          float OldRPMValue = 0;                   //keep track of what the previous rpm value was, for time rollover purposes
          float MAPsensorValue = 0;                //value coming from the MAP sensor
          float TPSsensorValue = 0;                //value coming from the TPS sensor
          float AFRsensorValue = 0;                //value coming from the AFR sensor
          float RPMpercent = 0;                    //percent of 8000rpm
          float MAPsensorpercent = 0;              //percent output from the MAP sensor
          float TPSsensorpercent = 0;              //percent output from the TPS sensor
          float AFRsensorpercent = 0;              //percent output from the AFR sensor
          float MaxPulsewidth = 0;                 //maximum anount of time for injector to be ON
          float InjectorONtime = 0;                //amount of time the injectors are commanded ON (msec)
          float Toothcount = 1;                    //number of triggers per one flywheel revolution
          float InjectorOndelay = 1.5;             //how long it takes the injector to open(msec)
          float InjectorOffdelay = 0.5;            //how long it takes the injector to close(msec)
          float CrankingPulsewidth =60.0;          //how long to fire the injector during starting(msec)
          float AFR = 0;                           //actual AFR reading from AFR display   
          float CubicInches = 30;
          float SCFM = 0;                          //Standard Cubic Feet Per Minute Air Flow
          float AFRRAW = 0;
          float TimePerCycle = (60/RPMValue)*2;
          float VolumetricEfficiency = 0.5;        //Volumetric Eficiency of the motor
          float RequiredCFMAir = 0;                //Requird CFM of Air = SCFM * VolumetricEfficiency
          float LbsAirMin = 0;                     //Pounds of Air Flow per Minute
          float LbsFuelMin = 0;                    //Pounds of Fuel Required per Minute
          float LbsAirCycle = 0;                   //Pounds of Air Flow per cycle
          float LbsFuelCycle = 0;                  //Pounds of Fuel Required per cycle
          float InjectorFlowRate = 51;             //Pounds per Hours rating of the injector
          int AFRdiff = 0;                         //voltage difference from target
          int MAPLookup = 0;                       //which array element to use for MAP range
          int TPSLookup = 0;                       //which array element to use for TPS range
          int dTPSLookup = 0;
          int RPMLookup = 0;                       //which array element to use for RPM range
          int IATLookup = 0;                       //which array element to use for IAT range
          int x = 0;
          float TPSMapvalue = 0;                   //the value returned from the TPS fuel map
          float MAPMapvalue = 0;                   //the value returned from the MAP fuel map
          float AFRtarget = 14;                    //the value returned from the TPS fuel map
          float LastTPS = 0;
          float dTPSpercent = 0;
          float dTPS = 0;
          bool InjectionComplete = 1;
          unsigned long timeold;                   //the last time RPM was calculated
          const String ATE = "ATE";                //Echo off/on
          const String ATI = "ATI";                //Version id
          const String ATZ = "ATZ";                //Reset
          const String ATS = "ATS";                //Set protocol X
          const String ATH = "ATH";                //Headers off / on
          const String ATL = "ATL";                //Linefeeds off/on
          const String ATM = "ATM";                //Memory off/on
          const String GETDEFINITIONS = "GETDEFINITIONS"; //Get sensor definitions
          const String GETCONFIGURATION = "GETCONFIGURATION"; //Get config of app (hide car sensors, devices sensors, etc)
          const String GETSENSORS = "G";           //Get sensor values, one shot.
          const String SETSENSOR = "S";            //Set a sensor value
          const String PROMPT = ">";
          const String CANBUS = "6";               //canbus 500k 11 bit protocol id for elm.
          const String ATDPN = "ATDPN";
          const String ATDESC = "AT@1";
          const String ATAT = "ATAT";
          const String LF = "\n";
          const String VERSION = "Torque Protocol Interface v0.0.1"; //Don't change this - it's used by Torque so it knows what interface it is connected to
          const String VERSION_DESC = "Torque For Android Protocol Interface";
          const String OK = "OK";
          const String ANALOG = "a";
          const String DIGITAL = "d";
          const String IS_INPUT = "i";
          const String IS_OUTPUT = "o";
          String fromTorque = "";
          int test=75;
    
    /**
     * Array of sensors we will advertise to Torque so it can automatically import them. Using strings
     * Stucture is:
     *  
     *  Arduino Pin, Arduino pin type, Input/Ouput, Default value(if output), ShortName, Long name, units, minimum value, maximum value
     *  
     *  Caveats:  Don't use a '>' in any of the names, 
     *            Update 'sensorsSize' with the number of elements.
     *            Analog outputs are PWM on digital pins.
     *  
     */
    const int SENSORSSIZE = 9 * 8; // each line is 9 attributes, and we have 8 lines.
    const String sensors[SENSORSSIZE] = {
                        "1",  ANALOG, IS_INPUT,  "0",  "Test1",  "Potentiometer1",  "Pot1",  "0",  "100",
                        "2",  ANALOG, IS_INPUT,  "0",  "MAP",    "Potentiometer2",  "MAP",   "0",  "100",
                        "3",  ANALOG, IS_INPUT,  "0",  "TPS",    "Potentiometer3",  "TPS",   "0",  "100",
                        "4",  ANALOG, IS_INPUT,  "0",  "RPM",    "Potentiometer4",  "RPM",   "0",  "100",
                        "5",  ANALOG, IS_INPUT,  "0",  "AFR",    "Potentiometer5",  "AFR",   "0",  "100",
                        "6",  ANALOG, IS_INPUT,  "0",  "MAP%",   "Potentiometer6",  "MAP%",  "0",  "100",
                        "7",  ANALOG, IS_INPUT,  "0",  "TPS%",   "Potentiometer7",  "TPS%",  "0",  "100",
                        "8",  ANALOG, IS_INPUT,  "0",  "AFR%",   "Potentiometer8",  "AFR%",  "0",  "100"
                       }; 
    /**
     * Configuration directives for the app to hide various things. Comma separated. Remove to enable visibility in Torque
     *  - handy if your project isn't car related or you want to make sensor selections relatively easy.
     *  
     *  Supported types:
     *    NO_CAR_SENSORS  - hide any car related sensors
     *    NO_DEVICE_SENSORS - hide any device (phone) sensors
     *    
     */
    const String CONFIGURATION = "NO_CAR_SENSORS,NO_DEVICE_SENSORS"; 
    
    // Setup bluetooth module on pins 10 and 11 on Arduino Mega 2560(you can't use these digial pins in the sensor list or it'll break comms)
    SoftwareSerial mySerial(10,11); // Most other boards can use pins 2 and 3
    
    //*************Correction Tables********************
    
    const float VETable [20][20] PROGMEM ={ 
    /*                   5% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  10% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  15% */  {0.43,  0.43,  0.43,  0.43,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  20% */  {0.43,  0.43,  0.43,  0.40,  0.40,  0.40,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  25% */  {0.45,  0.45,  0.40,  0.40,  0.40,  0.45,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  30% */  {0.50,  0.50,  0.40,  0.40,  0.45,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  35% */  {0.50,  0.50,  0.40,  0.45,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  40% */  {0.50,  0.50,  0.45,  0.45,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  45% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*       TPS        50% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*    Throttle      55% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*    Position      60% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  65% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  70% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  75% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  80% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  85% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  90% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                  95% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  
    /*                 100% */  {0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50,  0.50},  };
    //                          ===========================================================================================================================================
    //                             4      8      1      1      2      2      2      3      3      4      4      4      5      5      6      6      6      7      7      8
    //                             0      0      2      6      0      4      8      2      6      0      4      8      2      6      0      4      8      2      6      0
    //                             0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
    //                                           0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
                                                                                                        /* RPM */
    
    
    const float dTPSTable [20][20] PROGMEM ={ 
    /*                   5% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  10% */  {1.0,  1.0,  20.0,  20.0,  20.0,  20.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  15% */  {1.0,  1.0,  20.0,  20.0,  20.0,  20.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  20% */  {1.0,  1.0,  20.0,  20.0,  20.0,  20.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  25% */  {1.0,  1.0,  20.0,  20.0,  20.0,  20.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  30% */  {1.0,  1.0,  20.0,  20.0,  20.0,  20.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  35% */  {1.0,  1.0,  20.0,  20.0,  20.0,  20.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  40% */  {1.0,  1.0,  20.0,  20.0,  20.0,  20.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*      dTPS        45% */  {1.0,  1.0,  20.0,  20.0,  20.0,  20.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*      Delta       50% */  {1.0,  1.0,  20.0,  20.0,  20.0,  20.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*     Throttle     55% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*     Position     60% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  65% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  70% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  75% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  80% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  85% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  90% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                  95% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},
    /*                 100% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,},  };
    //                          ========================================================================================================================
    //                             4     8     1     1     2     2     2     3     3     4     4     4     5     5     6     6     6     7     7     8
    //                             0     0     2     6     0     4     8     2     6     0     4     8     2     6     0     4     8     2     6     0
    //                             0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
    //                                         0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
                                                                                              /* RPM */
    
    
    const float MAPTable [20][20] PROGMEM ={ 
    /*                   5% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  10% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  15% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  20% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  25% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  30% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  35% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  40% */  {1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  45% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*       MAP        50% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*     Percent      55% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*     Feedback     60% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  65% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  70% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  75% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  80% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  85% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  90% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                  95% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},
    /*                 100% */  {1.0,  1.0,  8.0,  7.0,  6.0,  5.0,  4.0,  3.0,  2.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},  };
    //                          ========================================================================================================================
    //                             4     8     1     1     2     2     2     3     3     4     4     4     5     5     6     6     6     7     7     8
    //                             0     0     2     6     0     4     8     2     6     0     4     8     2     6     0     4     8     2     6     0
    //                             0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
    //                                         0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0
                                                                                              /* RPM */
    
    
    
    const float AFRTable [20][20] PROGMEM ={ 
    /*                   5% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  10% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  15% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  20% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  25% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  30% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  35% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  40% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  45% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*       MAP        50% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*     Percent      55% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*     Feedback     60% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  65% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  70% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  75% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  80% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  85% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  90% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                  95% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},
    /*                 100% */  {14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,  14.0,},  };
    //                          =============================================================================================================================================
    //                              4      8      1      1      2      2      2      3      3      4      4      4      5      5      6      6      6      7      7      8
    //                              0      0      2      6      0      4      8      2      6      0      4      8      2      6      0      4      8      2      6      0
    //                              0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
    //                                            0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0      0
                                                                                                         /* RPM */
    
    
    const float IATTable [20] PROGMEM ={0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2,  0.2};
    //                                 ========================================================================================================================
    //                                   50°   60°   70°   80°   90°  100°  110°  120°  130°  140°  150°  160°  170°  180°  190°  200°  210°  220°  230°  240°
                                                                                              /* IAT */
    
    
    // ******SETUP - RUNS ONE TIME ON POWERUP******
    void setup() {
          Serial.begin(115200);
          pinMode(RPMsensor, INPUT);
          pinMode(Temps, INPUT);
          pinMode(Injector, OUTPUT);
          attachInterrupt(2, RPMTRIGGER, RISING);             //call interrupt #2 when the tach input goes high
    
        // Init the pins 
        initSensors();
        Serial.begin(9600);    // the GPRS baud rate 
        delay(600);
        mySerial.begin(9600); 
                 }
    
    // ******MAIN PROGRAM LOOP - RUNS CONTINUOUSLY******
    void loop() {
    
    //This is used for testing the Torque App  
      if (test > 100){
        test = 0;
        delay(1000);}
       
      delay(50); 
        if (test  0) {
            fromTorque.toUpperCase();
            processCommand(fromTorque);
            fromTorque = "";
         } else if (c != ' ' && c != '\n' && c !='\r') {
            // Ignore spaces.
            fromTorque += c; 
         }
      }
                
    //read the value from the sensors:
          MAPsensorValue = analogRead(MAPsensor);
          TPSsensorValue = analogRead(TPSsensor);
          AFRsensorValue = analogRead(AFRsensor);
          
          MAPsensorpercent = (MAPsensorValue/1023)*100;       // percent output from the MAP sensor
          TPSsensorpercent = ((TPSsensorValue/1023)*100);     // percent output from the TPS sensor
          AFRsensorpercent = (AFRsensorValue/1023)*100;       // percent output from the AFR sensor
    
          AFRRAW = map(AFRsensorValue, 0, 1023, 735, 2239);   // actual AFR reading from AFR display
          AFR = AFRRAW/100;
          RPMpercent = (RPMValue/8000)*100;                   // percent of 8000rpm. A number that can't be reached.
          MaxPulsewidth = ((((60/RPMValue)*2)*1000)*0.85);    // maximum allowable pulse width(msec)
    
          SCFM = (CubicInches * RPMValue) / 3456;             //Standard Calculation for Engine CFM
          RequiredCFMAir = SCFM * VolumetricEfficiency;       //Corrected Calculation for Engine CFM x VE
          LbsAirMin = RequiredCFMAir * 0.0765;                //Pounds of Air Required per Minute
          LbsFuelMin = LbsAirMin / AFRtarget ;                //Pounds of Fuel Required per Minute
          LbsFuelCycle = (LbsFuelMin * (60 / RPMValue) * 2);  //Pounds of Fuel Required per cycle
     
    //Acceleration Enrichment
       if (TPSsensorpercent > LastTPS)
         dTPSpercent = (TPSsensorpercent - LastTPS);
          if (InjectionComplete == 1){
            x = x + 1;
            if (x >= 1000){
              x = 0;
            LastTPS = TPSsensorpercent;
            InjectionComplete = 0;}}
    
    //This determines which TABLE value to use for dTPS        
         dTPSLookup = (int)(dTPSpercent / 5);
          if (dTPSLookup > 19)
            dTPSLookup = 19;
            
    //This determines which TABLE value to use for RPM
          RPMLookup = (int)(RPMpercent / 5);
          if (RPMLookup > 19)
            RPMLookup = 19;
            
    //This determines which TABLE value to use for TPS
          TPSLookup = (int)(TPSsensorpercent / 5);
          if (TPSLookup > 19)
            TPSLookup = 19;
            
    //This determines which TABLE value to use for MAP
          MAPLookup = (int)(MAPsensorpercent / 5);
          if (MAPLookup > 19)
            MAPLookup = 19;
            
    //calculate the injector ON time
    //sense the % throttle position because it is what the drivers wants to see happen.
    //calculate % injector time based on that
    //lookup in VEtable for correction for current VE range at current RPM
    //lookup in MAPtable for correction for current MAP range at current RPM
    //then adjust for AFRsensorValue - TBD
    //multiply by MaxPulsewidth to get a percentage of MaxPulsewidth
    //limit InjectorONtime to MaxPulsewidth
    //factor in the InjectorOndelay and InjectorOffdelay
    
    //the arrays are stored in FLASH memory
          VolumetricEfficiency = pgm_read_float(&VETable[TPSLookup][RPMLookup]);
          TPSMapvalue = pgm_read_float(&VETable[TPSLookup][RPMLookup]);
          MAPMapvalue = pgm_read_float(&MAPTable[MAPLookup][RPMLookup]);
          AFRtarget = pgm_read_float(&AFRTable[MAPLookup][RPMLookup]);
          dTPS = pgm_read_float(&dTPSTable[dTPSLookup][RPMLookup]);
    
          InjectorONtime = (LbsFuelMin / (InjectorFlowRate / 60)) * (((60/RPMValue)*2)*1000);     //Injector ON Time
            InjectorONtime = InjectorONtime * MAPMapvalue;                                        //calculate correction for MAP vs RPM
              InjectorONtime = InjectorONtime * dTPS;                                             //calculate correction for dTPS vs RPM
                if (InjectorONtime > MaxPulsewidth)
                  InjectorONtime = MaxPulsewidth;                                                 //limit the InjectorONtime to MaxPulsewidth
    
    //is the engine running or being started?
         if (RPMValue > 50)
           (Running = 1); 
         else 
           (Running = 0); 
             
    //this is for when the engine is cranking during start         
          if (RPMValue < 550)
            (InjectorONtime = CrankingPulsewidth);
            if (RPMValue < 50) 
              (InjectorONtime = 0);
    
          if (Running == 1) {
            if (FireInjector >= 1){
              if (InjectorONtime > 0) {
                digitalWrite(Injector, HIGH);
                  if (InjectorONtime < 15) {  
                   delayMicroseconds(InjectorONtime * 1000); }
                  else {
                    delay(InjectorONtime); 
                                       }
            FireInjector = 0;
            InjectionComplete = 1;  }
                            }
          }
    // wait to finish injection period   
          digitalWrite(Injector, LOW);
         }
    
    //Parse the commands sent from Torque
    void processCommand(String command) {
     
       // Debug - see what torque is sending on your serial monitor
       Serial.println(command);
     
       // Simple command processing from the app to the arduino..
       if (command.equals(ATZ)) {
           initSensors(); // reset the pins
           mySerial.print(VERSION);
           mySerial.print(LF); 
           mySerial.print(OK);
       } else if (command.startsWith(ATE)) {
           mySerial.print(OK); 
       } else if(command.startsWith(ATI)) {
           mySerial.print(VERSION);
           mySerial.print(LF);
           mySerial.print(OK);
       } else if (command.startsWith(ATDESC)) {
           mySerial.print(VERSION_DESC); 
           mySerial.print(LF);
           mySerial.print(OK);
       } else if (command.startsWith(ATL)) {
           mySerial.print(OK);
       } else if (command.startsWith(ATAT)) {
           mySerial.print(OK);
       } else if (command.startsWith(ATH)) {
           mySerial.print(OK);
       } else if (command.startsWith(ATM)) {
           mySerial.print(OK);
       } else if (command.startsWith(ATS)) {
           // Set protocol
           mySerial.print(OK);
       } else if (command.startsWith(ATDPN)) {
           mySerial.print(CANBUS);
       } else if (command.startsWith(GETDEFINITIONS)) {
           showSensorDefinitions();
       } else if (command.startsWith(GETSENSORS)) {
           getSensorValues();
       } else if (command.startsWith(GETCONFIGURATION)) {
           getConfiguration();
       } else if (command.startsWith(SETSENSOR)) {
           setSensorValue(command);
       }
     
       mySerial.print(LF); 
       mySerial.print(PROMPT);
    }
    
    //List all the sensors to the app
    void showSensorDefinitions() {
       int id = 0;
       for (int i = 0; i < SENSORSSIZE/9; i++) {
          for (int j = 0; j < 9; j++) {
             id = (i*9)+j;
             mySerial.print(sensors[id]);
     
             if (id+1 < SENSORSSIZE) {
                mySerial.print(',');
             }
          }
          mySerial.print(LF);
       }
    }
     
    //Dump sensor information for input sensors.
    //Format to Torque is id:type:value
    void getSensorValues() {
       for (int i = 0; i < SENSORSSIZE/9; i++) {
          int group = i * 9;
          int id = sensors[group].toInt();
          String type = sensors[group+1];
          boolean isOutput = sensors[group+2].equals(IS_OUTPUT);
      Serial.println(SENSORSSIZE);
      Serial.println(group);
      Serial.println(id);
          if (!isOutput) {
            if (id == 1){
             mySerial.print(id);
             mySerial.print(":");
             mySerial.print(type);
             mySerial.print(":");
             if (type.equals(ANALOG)) {
               mySerial.print(test);}
             else if (type.equals(DIGITAL)) {
               mySerial.print(digitalRead(id));}
          }
       }
    
          if (!isOutput) {
            if (id == 2){
             mySerial.print(id);
             mySerial.print(":");
             mySerial.print(type);
             mySerial.print(":");
             if (type.equals(ANALOG)) { 
               mySerial.print((MAPsensorValue));}
             else if (type.equals(DIGITAL)) {
               mySerial.print(digitalRead(id));}
          }
       }
    
          if (!isOutput) {
            if (id == 3){ 
             mySerial.print(id);
             mySerial.print(":");
             mySerial.print(type);
             mySerial.print(":");
             if (type.equals(ANALOG)){
               mySerial.print(TPSsensorValue);}
             else if (type.equals(DIGITAL)) {
               mySerial.print(digitalRead(id));}
          }
       }
       
          if (!isOutput) {
            if (id == 4){ 
             mySerial.print(id);
             mySerial.print(":");
             mySerial.print(type);
             mySerial.print(":");
             if (type.equals(ANALOG)){
               mySerial.print(RPMValue);}
             else if (type.equals(DIGITAL)) {
               mySerial.print(digitalRead(id));}
          }
       }
    
          if (!isOutput) {
            if (id == 5){ 
             mySerial.print(id);
             mySerial.print(":");
             mySerial.print(type);
             mySerial.print(":");
             if (type.equals(ANALOG)){
               mySerial.print(AFR);}
             else if (type.equals(DIGITAL)) {
               mySerial.print(digitalRead(id));}
          }
      }
    
          if (!isOutput) {
            if (id == 6){ 
             mySerial.print(id);
             mySerial.print(":");
             mySerial.print(type);
             mySerial.print(":");
             if (type.equals(ANALOG)){
               mySerial.print(MAPsensorpercent);}
             else if (type.equals(DIGITAL)) {
               mySerial.print(digitalRead(id));}
          }
      }
      
          if (!isOutput) {
            if (id == 7){ 
             mySerial.print(id);
             mySerial.print(":");
             mySerial.print(type);
             mySerial.print(":");
             if (type.equals(ANALOG)){
               mySerial.print(TPSsensorpercent);}
             else if (type.equals(DIGITAL)) {
               mySerial.print(digitalRead(id));}
          }
      }
      
          if (!isOutput) {
            if (id == 8){ 
             mySerial.print(id);
             mySerial.print(":");
             mySerial.print(type);
             mySerial.print(":");
             if (type.equals(ANALOG)){
               mySerial.print(AFRsensorpercent);}
             else if (type.equals(DIGITAL)) {
               mySerial.print(digitalRead(id));}
          }
      }
      
                mySerial.print('\n');
       }
    }
    
    //Sets a sensors value
    void setSensorValue(String command) {
      int index = command.indexOf(":");
      int id = command.substring(1,index).toInt();
      int value = command.substring(index+1, command.length()).toInt();
      
      for (int i = 0; i < SENSORSSIZE/9; i++) {
         int group = i * 9;
         int sid = sensors[group].toInt();
         boolean isOutput = sensors[group+2].equals(IS_OUTPUT);
         if (isOutput) {
           if (sid == id) {
              String type = sensors[group+1];
              if (type.equals(ANALOG)) {
                analogWrite(sid, constrain(value,0,255));
              } else if (type.equals(DIGITAL)) {
                digitalWrite(sid, value > 0 ? HIGH: LOW);
              }
              break;
           }
        }
      }
    }
     
    //Init the sensor definitions (input/output, default output states, etc)
    void initSensors() {
       for (int i = 0; i < SENSORSSIZE/9; i++) {
          int group = i * 9;
          int id = sensors[group].toInt();
          String type = sensors[group+1];
          boolean isOutput = sensors[group+2].equals(IS_OUTPUT);
          int defaultValue = sensors[group+3].toInt();
     
          if (isOutput) {
             if (type.equals(ANALOG)) {
                 pinMode(id, OUTPUT);
                 analogWrite(id, constrain(defaultValue, 0, 255));
    
             } else if (type.equals(DIGITAL)) {
                 pinMode(id, OUTPUT);
                 digitalWrite(id, defaultValue > 0 ? HIGH : LOW);
             }
          }
       }
    }
     
    void getConfiguration() {
      mySerial.print(CONFIGURATION);
    }
         
    // ******INTERRUPT #2 - GETS CALLED WHEN RPM SENSOR IS TRIGGERED******
    void RPMTRIGGER() {
          RPMcount = RPMcount + 1;              //Increment RPMcount every time the sensor triggers. Return the new value
          FireInjector = FireInjector + 1;      //set when the injector should be fired(every other cycle)
          if (RPMcount >= Toothcount) {
            if ((micros() - timeold) < 0) {
              RPMValue = OldRPMValue; }         //this handles the rollover of the microsecond clock
            else {
              RPMValue = (60000000/(micros() - timeold)*RPMcount)/Toothcount; }
              
          timeold = micros();                   //store the time that the RPM sensor was triggered
          RPMcount = 0;                         //reset the RPMcount to zero
          OldRPMValue = RPMValue;
                                      }
                      }
    
    hamed-pc
    Member
    Posts: 19
    Post Re: Arduino internal variables
    on: June 20, 2018 (GMT)

    Hi
    Please tell me how to connect arduino to k line ecu pin , ?
    I need schematic and witch pin of arduino to k line ? How to pullup arduino pin to 12 v ?
    Please hellp me i want to connect arduino to ecu k line

    Can i use L9637 for connect to K Line this pic ?

    or Can i use Vag409.1 Cable connect to arduino and k line this pic ?

    Thank you

    hamed-pc
    Member
    Posts: 19
    Post Re: Arduino internal variables
    on: June 22, 2018 (GMT)

    nobody help me ?

    pfi
    Member
    Posts: 3
    Post Re: Arduino internal variables
    on: February 7, 2020 (GMT)

    Anyone got a Raspberry Pi code for this ?

    Norway

    Supra
    Member
    Posts: 1
    Post Re: Arduino internal variables
    on: May 2, 2020 (GMT)

    Hello,

    I have a problem…
    I successfully enhaced my program with the provided sample code. succesfully connect with Torque to my arduino Due, and see my data on android.
    But the example suggest, i can send data back to arduino from Torque:
    “4”,DIGITAL,IS_OUTPUT,”0″,”Dout1″,”Digital Out 1″,”bit”,”0″, “1”

    I set three parameter based this (one analog and two digital), and make a sample code:

    “11”, ANALOG, IS_OUTPUT, “1”, “T-SEL”, “!Turbo Control: select”, “Number”,”0″, “5”,
    “12”, DIGITAL,IS_OUTPUT, “0”, “T-“, “!Turbo Control: +”, “Number”,”0″, “1”,
    “13”, DIGITAL,IS_OUTPUT, “0”, “T+”, “!Turbo Control: -“, “Number”,”0″, “1”

    I see these IDs in the Torque, but cannot able to setup diplay, wich able to send data back.

    This directon is working and tested? How i setup the reverse data flow?

    Plan B is another android application with another BT adapter for modify arduino parameters – but this is extremely difficult.

    Thanks for any help/suggestion! (sorry for my english :-()

    rockmr2
    Member
    Posts: 1
    Post Re: Arduino internal variables
    on: April 3, 2023 (GMT)

    @1989Marathon Is the IAT Table, voltage or resistance?

    TIA

    Pages: 1 2 [3]
    WP-Forum by: Fredrik Fahlstad, Version: 2.4
    Page loaded in: 0.055 seconds.

      Follow me on twitter