Author Topic: VemsDisplay with Raspberry or Arduino  (Read 7643 times)

Offline Matus

  • Jr. Member
  • **
  • Posts: 72
  • BHP: 0
VemsDisplay with Raspberry or Arduino
« on: October 13, 2015, 10:04:18 am »
Hi,

I would like to use VemsDisplay as major instrument cluster for my racing car. I would like to build in to dash so need remote power on/off. Wired connection with ECU is preferred

Display unit http://www.ebay.com/itm/10-1-10-inch-TFT-LCD-Display-w-HDMI-VGA-Video-Driver-Board-for-Raspberry-Pi/301581161486?_trksid=p2047675.c100005.m1851&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D33747%26meid%3D3a423f702c8644968e75e41d757b01d6%26pid%3D100005%26rk%3D3%26rkt%3D6%26mehot%3Dpp%26sd%3D262050803732

Did anybody try it already ?



Offline gunni

  • Hero Member
  • *****
  • Posts: 1492
  • BHP: 37
Re: VemsDisplay with Raspberry or Arduino
« Reply #1 on: October 13, 2015, 12:50:48 pm »
Why not a Android tablet?

Offline Kamuto

  • Hero Member
  • *****
  • Posts: 814
  • BHP: 19
Re: VemsDisplay with Raspberry or Arduino
« Reply #2 on: October 13, 2015, 01:11:20 pm »
Why not a Android tablet?
Because we need it bit more complicated :D
Vems installer in Lithuania
valdas.sunokas@gmail.com

Offline Matus

  • Jr. Member
  • **
  • Posts: 72
  • BHP: 0
Re: VemsDisplay with Raspberry or Arduino
« Reply #3 on: October 14, 2015, 10:04:41 am »
Because tablet is stand alone and can't be operated by car electronic. I want to mount it/build in to dash so no touch control, no access to power button, long boot, lot of disrupting stuff inside  etc...

Offline Mads Lund

  • Jr. Member
  • **
  • Posts: 61
  • BHP: 4
    • VEMS member
Re: VemsDisplay with Raspberry or Arduino
« Reply #4 on: October 19, 2015, 01:45:09 pm »
Hi Matus

I've done a similar thing with help from Per Boddum.

We have the Vems protocol adapted to a Netduino so the netduino can be used to several things. I mainly uses it to drive my A/F display, but it have all the parameters from Vems so can do everything you can think of.

In short, You send an "A" on the TX port, and your Vems will return a string with all data, the trick is to decode the data string, code below.

Below code will request data from VEMS and store it in a set of parameters in your arduino, you then can use for what ever purpose. For my project did I only need the A/F ratio, to make a PWM outpput for my gauge.




static void ReadVEMS() //read parameters from VEMS
        {
            port.Write(System.Text.Encoding.UTF8.GetBytes("A"), 0, 1); //send "A" on Com1 TX
            Thread.Sleep(80);
            if (ReadBytes(ref bytes) > 35) //read RX if exceed 35 bytes
            {
                MsDatabase.Decode(ref bytes); //update MSdatabase
            }
        }


namespace TVR_PC
{
   public class MsDatabase
   {
      const bool AfrDisplay = false;
      const bool Celcius = true;
      
      public struct VemsDataStruc
      {
         public Byte Seconds;
         public Byte squirtBitflag;
         public Byte engineBitflag;
         public Byte Baro;
         public UInt16 Map;
         public Byte Mat;
         public Byte Clt;
         public Byte Tps;
         public Byte Battery;
         public Byte Ego1;
         public Byte egoCorrection;
         public Byte airCorrection;
         public Byte warmupEnrich;
         public UInt16 rpm;
         public UInt16 pulseWidth1;
         public Byte baroCorrection;
         public Byte gammaEnrich;
         public Byte veCurr1;
         public Byte dwell;
         public Byte advance;
         public Byte idleDC;
         // ikke protokol relateret flags
         public bool ready;
         public bool crank;
         public bool startWarmup;
         public bool warmup;
         public bool accel;
         public bool decel;

      }

      public static VemsDataStruc VemsData;

      MsDatabase()
      {
      }

      static public void Decode(ref byte[] aBuf)
      {
         VemsData.Seconds = aBuf[0];
         VemsData.squirtBitflag = aBuf[1];
         VemsData.engineBitflag = aBuf[2];
         VemsData.Baro = aBuf[3];
         VemsData.Map = aBuf[4];
         VemsData.Map = (UInt16)(VemsData.Map << 8);
         VemsData.Map |= aBuf[5] ;
         VemsData.Mat = aBuf[6];
         VemsData.Clt = aBuf[7];
         VemsData.Tps = aBuf[8];
         VemsData.Battery = aBuf[9];
         VemsData.Ego1 = aBuf[10];
         VemsData.egoCorrection = aBuf[11];
         VemsData.airCorrection = aBuf[12];
         VemsData.warmupEnrich = aBuf[13];
         VemsData.rpm = aBuf[14];
            VemsData.rpm = (UInt16)(VemsData.rpm << 8);
            VemsData.rpm |= aBuf[15];
            VemsData.pulseWidth1 = aBuf[16];
         VemsData.baroCorrection = aBuf[18];
         VemsData.gammaEnrich = aBuf[19];
         VemsData.veCurr1 = aBuf[20];
         VemsData.dwell = aBuf[21];
         VemsData.advance = aBuf[22];
         VemsData.idleDC = aBuf[23];

         // mask flags
         VemsData.ready = (VemsData.engineBitflag & 0x01) == 0x01;
         VemsData.crank = (VemsData.engineBitflag & 0x02) == 0x02;
         VemsData.startWarmup = (VemsData.engineBitflag & 0x04) == 0x04;
         VemsData.warmup = (VemsData.engineBitflag & 0x08) == 0x08;
         VemsData.accel = (VemsData.engineBitflag & 0x10) == 0x10;
         VemsData.decel = (VemsData.engineBitflag & 0x20) == 0x20;
      }

      static public double Egoafr(double egoread)
      {
            double v1 = 14.7 * ((egoread > 211) ? ((egoread + 47.5) / 16 / 14.7) : (egoread + 306) / 470);
            return v1;
      }

      static public double Temperature(double aValue)
      {
         double v1 =  (aValue - 100);
         return v1;
      }

      static public double FuelConsumption(int rpm, double pulseWidth, double roadSpeed)
      {
         /*
         int nCylinders = 8;
         int ccMin = 250;
         double lagtime = 0.1;
         Byte divider = 2; // alternating=1
         */
         int nCylinders = 6;
         int ccMin = 250;
         double lagtime = 0.1;
         int divider = 1;

         double kml;
         double l_100km;
         double lphr;
         double ccPhr;
         double ccPerMin;
         double pulseWidthInMinute;

         pulseWidthInMinute = (pulseWidth - lagtime) / 60000.0;
         ccPerMin   = rpm * (nCylinders / (divider * 2.0)) * pulseWidthInMinute * ccMin;
         ccPhr   = ccPerMin * 60.0;
         lphr = ccPhr / 1000.0;
         l_100km = (lphr * 100.0) / roadSpeed;
         kml = 100.0 / l_100km;

         return l_100km;
      }

      

   }
}


Offline jrussell

  • VEMS USA
  • Administrator
  • Full Member
  • *****
  • Posts: 224
  • BHP: 15
    • VEMS USA
Re: VemsDisplay with Raspberry or Arduino
« Reply #5 on: October 20, 2015, 07:01:32 pm »
There are apps/settings to make an android tablet boot upon power applied to the microUSB, and it can start VemsDisplay automatically. The only downside I've seen is the long boot time if you don't drive the car for a week or two and the tablet does a complete shutdown instead of sleep.

The only reason I can think of to use a Pi (longer boot time than an android tablet waking from sleep), is if you need i/o for something.
VEMS USA - Located in beautiful Burlington, Vermont
1988 RX7 Turbo

Offline Matus

  • Jr. Member
  • **
  • Posts: 72
  • BHP: 0
Re: VemsDisplay with Raspberry or Arduino
« Reply #6 on: October 22, 2015, 04:45:17 pm »
Mads Lund    thanks for sharing of valuable data.

Current situation is that I have ECU on table pinned just for RS232, Power and Grounds.
After consideration of all visible complications vs eventual benefits I decide to try tablet by few reasons.

1. I realize that maximum size of display/device that will fit in to E46 Dash is around 5 Inch.

2. It is track day/competition car which means that I can turn it on once in the morning and let it run whole day, so no matter how long it will boot.  (I am not using stock ignition switch with key so can operate +30 +15 and ignition separately )

3. Price argument >>  I have found Lenovo TAB 2 A7-10F with price 79 euro  on our market including VAT.


To do : 

Use/study “There are apps/settings to make an android tablet boot upon power applied to the microUSB, and it can start VemsDisplay automatically.” As I was thinking about how to operate power button on the tablet when it is inside the dash. But this will solve it and gives me better options for mount.
Thanks Jrussell, I hoped that there will be this option.

I googled a little bit and found also test application “AutoStart” that is working well, just auto lock need to be turned off in device settings.
I didn’t found yet  how to control power on/ power off by USB power but it seems to be just matter of time.


Order Bluetooth module for my ECU .
Physical mount of tablet to the dash (I have Fiber Glass dash) 7inch fitment will be tricky.