Car tuning DLP emulation

Just want to hang out with other Makers and chat about stuff? This is the place to do it.
Post Reply
ledsarecool
Posts: 18
Joined: Tue Aug 04, 2015 5:45 pm

Car tuning DLP emulation

Post by ledsarecool » Wed Sep 09, 2015 4:02 am

Hello.

I'm having a bit of trouble with car tuning software that uses a DLP-08 Analog/Digital Emulator to send real time data to Nistune via USB.
Director of Nistune has given us a code to use on a Arduino as a DLP-08 Emulator to do the same job.
Thing now I have trouble with is trying to add 3 DS18b20 sensors on there own pin.
First 3 Channels/Pins are used.

I have these addresses to use from an example I found online that uses DallasTemperature.h library but I have no idea where or how to use them in the DLP Emulation sketch and a lot of examples seem to use a function to call all the sensors on one bus.
I was told ( I just read the Arduino AD input and put it over Serial ).
If someone could help me out it would be most appreciated!
Sorry I'm not a hardcore programmer so I don't understand this sketch so I'm really stuck.

Code: Select all

 DeviceAddress tempa = { 0x28, 0xE1, 0x53, 0xD7, 0x06, 0x00, 0x00, 0x8D };//DS18S20 temperature senor MAC address
 DeviceAddress tempb = { 0x28, 0xB3, 0x18, 0x2F, 0x06, 0x00, 0x00, 0x39 };//DS18S20 temperature senor MAC address
 DeviceAddress tempc  ={ 0x28, 0x1B, 0x75, 0xC4, 0x06, 0x00, 0x00, 0xE4 }; //DS18S20 temperature senor MAC address

Code: Select all

/* Arduino One - DLP emulation */

const int DLP_CMD_DIGITAL_IN_CH1 = 0x41;
const int DLP_CMD_DIGITAL_IN_CH2 = 0x53;    
const int DLP_CMD_DIGITAL_IN_CH3 = 0x44;    
const int DLP_CMD_DIGITAL_IN_CH4 = 0x46;    
const int DLP_CMD_DIGITAL_IN_CH5 = 0x47;    
const int DLP_CMD_DIGITAL_IN_CH6 = 0x4E;    
const int DLP_CMD_DIGITAL_IN_CH7 = 0x4A;    
const int DLP_CMD_DIGITAL_IN_CH8 = 0x4B;

const int DLP_CMD_ANALOG_IN_CH1 = 0x5A;
const int DLP_CMD_ANALOG_IN_CH2 = 0x58;
const int DLP_CMD_ANALOG_IN_CH3 = 0x43;
const int DLP_CMD_ANALOG_IN_CH4 = 0x56;
const int DLP_CMD_ANALOG_IN_CH5 = 0x42;
const int DLP_CMD_ANALOG_IN_CH6 = 0x4E;
const int DLP_CMD_ANALOG_IN_CH7 = 0x4D;
const int DLP_CMD_ANALOG_IN_CH8 = 0x2C;

const int DLP_CMD_TEMPERATURE_IN_CH1 = 0x39;
const int DLP_CMD_TEMPERATURE_IN_CH2 = 0x30;
const int DLP_CMD_TEMPERATURE_IN_CH3 = 0x2D;
const int DLP_CMD_TEMPERATURE_IN_CH4 = 0x3D;
const int DLP_CMD_TEMPERATURE_IN_CH5 = 0x4F;
const int DLP_CMD_TEMPERATURE_IN_CH6 = 0x50;
const int DLP_CMD_TEMPERATURE_IN_CH7 = 0x5B;
const int DLP_CMD_TEMPERATURE_IN_CH8 = 0x5D;

const int DLP_SETUP_FARENHEIT = 0x4C; // not used
const int DLP_SETUP_CELCIUS = 0x3B; // not used
const int DLP_SETUP_ASCII = 0x60;
const int DLP_SETUP_BINARY = 0x5C;

const int DLP_CMD_PING = 0x27;
const int DLP_RESP_PING = 0x51;

const int SET_MODE_ASCII = 0;
const int SET_MODE_BINARY = 1;

const float AD_MULTIPLIER = 5.0/1024.0;

void setup() {
  Serial.begin(115200);
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(A2,INPUT);
  pinMode(A3,INPUT);
  pinMode(A4,INPUT);
  pinMode(A5,INPUT);
}

int rxByte = 0;
int currMode = SET_MODE_ASCII;
int sensorValue = 0;

void loop() 
{
  if (Serial.available() > 0)
  {
     rxByte = Serial.read();
     int sendADVal = false;
     int sendTempVal = false;
     
     switch (rxByte)
     {
       case DLP_SETUP_ASCII:
         currMode = SET_MODE_ASCII;
         break;
       case DLP_SETUP_BINARY:
         currMode = SET_MODE_BINARY;
         break;
       case DLP_SETUP_FARENHEIT:
         break; // not used
       case DLP_SETUP_CELCIUS:
         break; // not used
       case DLP_CMD_PING:
         // ping response
         Serial.write(DLP_RESP_PING);
         break;
       case DLP_CMD_ANALOG_IN_CH1:
         sensorValue = analogRead(A0);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH2:
         sensorValue = analogRead(A1);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH3:
         sensorValue = analogRead(A2);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH4:
         sensorValue = analogRead(A3);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH5:
         sensorValue = analogRead(A4);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH6:
         sensorValue = analogRead(A5);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH7:
       case DLP_CMD_ANALOG_IN_CH8:
         sensorValue = 0; // not available
         sendADVal = true;
         break;
       case DLP_CMD_TEMPERATURE_IN_CH1:
       case DLP_CMD_TEMPERATURE_IN_CH2:
       case DLP_CMD_TEMPERATURE_IN_CH3:
       case DLP_CMD_TEMPERATURE_IN_CH4:       
       case DLP_CMD_TEMPERATURE_IN_CH5:       
       case DLP_CMD_TEMPERATURE_IN_CH6:       
       case DLP_CMD_TEMPERATURE_IN_CH7:       
       case DLP_CMD_TEMPERATURE_IN_CH8:       
         sensorValue = 0; // not available
         sendTempVal = true;       
         break;       
       default:
         break;
     }
     
     if (sendADVal || sendTempVal)
     {
        if (currMode == SET_MODE_BINARY)
        {
           Serial.write((char)(sensorValue >> 8));
           Serial.write((char)(sensorValue));
        }
        else
        {
           Serial.print((float)sensorValue * AD_MULTIPLIER,2);
           Serial.println("V");
        }
     }
  }
}

ledsarecool
Posts: 18
Joined: Tue Aug 04, 2015 5:45 pm

Re: Car tuning DLP emulation

Post by ledsarecool » Mon Sep 14, 2015 2:25 pm

No one??

Post Reply