Skip to content

MarkusIppy/raspexi-viewer-linux

Repository files navigation

Raspexi is no longer maintained and has been replaced with its successor PowerTune

https://github.com/BastianGschrey/PowerTune

#__Raspexi__

_A'PEXi Power FC Interface for Raspberry Pi_

Summary

Digital Gauge Display for A'PEXi Power FC which runs on Raspberry Pi. Raspexi is capable of communicating with the Power FC to retrieve diagnostic information and display the information in the form of aesthetic guages and dashboards. Raspexi has been tested for Mazda Power FC's and is currently in beta testing for Nissan, Subaru and Toyota Power FC's.

The Gauges and Dashboards used in this software are adapted from MegaTunix by David J. Andruczyk
The A'PEXi Serial interface is adapted from FCLogger by Hitoshi Kashima

Installation

Pre-Requisite

Rasberry Pi with Raspbian OS. Tested versions:

  • 2016-05-10-raspbian-jessie works on PI 1 , PI 2 and PI 3
  • 2016-03-18-raspbian-jessie works on PI 1 , PI 2 and PI 3
  • 2015-11-21-raspbian-jessie works on PI 1 , PI 2 and PI 3
  • 2015-02-18-wheezy-raspbian
  • 2014-01-07-wheezy-raspbian
  • 2013-09-25-wheezy-raspbian
  • 2013-05-25-wheezy-raspbian

WIFI dongle for use with GoPro

Works on Raspberry Pi 1/2/3 (you can use built in WIFI for Pi3)

Tested Vehicles : Engine:

  • Mazda RX7 FD3S (13B-REW)
  • Mazda RX7 S5 Engine with AP Engineering ECU (13B)
  • Nissan Silvia S15 D-Jetro (SR20DET)
  • Nissan Skyline R33 GTS-T (RB25)
  • Nissan Skyline R34 GT-T (RB25)
  • Subaru Impreza WRX GF8 (EJ205G)

Install

Extract the archive raspexi-yyyymmdd.tar.gz to /home/pi:

$ cd /home/pi
$ tar xvzf raspexi-yyyymmdd.tar.gz

Configuration

There are a few configurable settings in raspexi.cfg:

[default]
port = /dev/ttyUSB0
baud = 57600,8,n,1
interval = 35
model = Mazda
vehicle_mass = 1300
gear_judge_nums = 120, 70, 45, 35, 26
speed_correction = 1.03
original_tyre = 195/55 R15
current_tyre = 225/65 R17
dash1 = Analogue_Dash_1280_720.xml
dash2 = Commander_1280_720.xml
dash3 = Digital_Dash_1280_720.xml
dash4 = Race_1280_720.xml
analog_eq1 = 1.4 * (AUX1 - AUX2) + 9.0
analog_eq2 = 0.5*AUX3+2.5
gopro_ip = 10.5.5.9
gopro_pass = Markus123
gopro_wifi_type = camera
camera_record = r
csvfile = /home/pi/raspexi/log/raspexi.csv
  • port ==> Serial port device name

  • baud ==> Serial port baud rate

  • interval ==> Data refresh interval

  • model ==> Mazda, Nissan, Subaru, Toyota

  • vehicle_mass ==> Mass of the vehicle in kilograms (required for Power datasource)

  • gear_judge_nums ==> Gear Judge numbers to estimate the current gear. In order 1st-4th, 1st-5th or 1st-6th, calculated from Rpm/Kph. (Can be calculated from a log file) (required for Gear datasource)

  • speed_correction ==> A simple multiplier for correction of the speedometer. For instance, can be calculated from a GPS comparison. (Takes precedence over tyre size calculation) (adjusts Speed datasource)

  • original_tyre, current_tyre ==> Original/Stock tyre size (speedo calibrated tyre size) and the current tyre size for speedometer correction. (adjusts Speed datasource)

  • dash1, dash2, dash3, dash4 ==> Dashboard XML file

  • analog_eq1, analog_eq2, analog_eq3, analog_eq4 ==> Analog equations for auxiliary input relations. (See section 'Analog Auxiliary Input Relationship Equations' for more details)

  • gopro_ip ==> Ip adress of your GoPro (seems to be always 10.5.5.9 )

  • gopro_pass ==> Your GoPRo WIFI password

  • gopro_wifi_type ==> camera, bacpac ( Camera is used for GoPro 3 and 3+ with build in WFIF , use bacpac for Hero 2 with WIFI backpack )

*camera_record ==> r (mapped keypoard button to stop and start recording )

  • csvfile ==> CSV log output file

Note: If the 'csvfile' location is set to the /tmp directory then it will be removed by the system on (re)start

Note: The 'model' setting is in testing and has only been confirmed for Mazda (March/2015)

How To Run

You can run this release with the following command:

$ cd /home/pi/raspexi
$ sudo ./run.sh

Gauge Datasources

The following Descriptions are for information which the Power FC will return for a given model. The Datasource Name can be used in the dashboard XML files to define what information a particular gauge will display:

Note: The current version is in testing for support for vehicles other than Mazda (March/2015)

Description Datasource Name Mazda Nissan Subaru Toyota
NEW ! GoPro recording status (0/1) Rec ✓* ✓*
NEW ! Vehicle power (kW) Power ✓* ✓*
NEW ! Acceleration (+100km/h)(s) Accel ✓* ✓* ✓*
NEW ! Acceleration (G) GForce ✓* ✓* ✓*
NEW ! Force exerted (N) ForceN ✓* ✓* ✓*
NEW ! Current gear number (#) Gear ✓* ✓* ✓*
NEW ! Primary injector duty cycle (%) PrimaryInjD ✓* ✓* ✓*
NEW ! 0-100km/h Timer (Sec) AccelTimer ✓* ✓* ✓* ✓*
Engine Speed (rpm) RPM ✓* ✓*
Absolute Intake Pressure (Kg/cm2) Intakepress ✓*
Pressure Sensor Voltage (mv) PressureV ✓*
Engine Load (N) EngLoad ✓*
Mass Flow Sensor #1 (mv) MAF1V ✓*
Mass Flow Sensor #2 (mv) MAF2V ✓* ✓*
Throttle Sensor Voltage (mv) ThrottleV ✓* ✓*
Throttle Sensor #2 Voltage(mv) ThrottleV_2 ✓*
Primary Injector Pulse Width (mSec) Primaryinp ✓* ✓*
Fuel correction Fuelc ✓* ✓*
Leading Ignition Angle (deg) Leadingign ✓* ✓*
Trailing Ignition Angle (deg) Trailingign ✓* ✓*
Fuel Temperature (deg.C) Fueltemp
Metering Oil Pump Duty (%) Moilp
Boost Duty (TP.%) Boosttp
Boost Duty (Wg,%) Boostwg
Boost Pressure (PSI) BoostPres ✓* ✓* ✓*
Boost Duty (%) BoostDuty ✓* ✓* ✓*
Water Temperature (deg. C) Watertemp ✓* ✓*
Intake Air Temperature (deg C) Intaketemp ✓* ✓* ✓*
Knocking Level Knock ✓* ✓*
Battery Voltage (V) BatteryV ✓* ✓*
Vehicle Speed (Km/h) Speed ✓* ✓*
ISCV duty (%) Iscvduty ✓*
Mass Air Flow sensor activity ratio (%) MAFactivity ✓*
O2 Sensor Voltage (mv) O2volt ✓* ✓* ✓*
O2 Sensor #2 Voltage (mV) O2volt_2 ✓* ✓*
Secondary Injector Pulse Width (mSec) Secinjpulse
Suction In Air Temperature (mV) SuctionAirTemp ✓*
Analog Auxiliary Input #1 AUX1
Analog Auxiliary Input #2 AUX2
Analog Auxiliary Input #3 AUX3
Analog Auxiliary Input #4 AUX4
Analog Auxiliary Input #5 AUX5
Analog Auxiliary Input #6 AUX6
Analog Auxiliary Input #7 AUX7
Analog Auxiliary Input #8 AUX8
Result of Analog Equation #1 Analog1
Result of Analog Equation #2 Analog2
Result of Analog Equation #3 Analog3
Result of Analog Equation #4 Analog4
* Implemented but untested

Analog Auxiliary Input Relationship Equations

It may not be convenient to view AUX1, AUX2, etc, in a gauge as is. Therefore we have implemented a simple linear equation parser for the raspexi.cfg file. The linear equations can be represented in the form 'y=m*x+b'. Here, the result 'y' is stored in either Analog1, Analog2, Analog3 or Analog4 depending on the definition in raspexi.cfg, 'm' is a multiplier, 'x' is an auxiliary input (AUX1, AUX2, etc) and 'b' is an adder.

Two examples are as follows:

  • For 'y' = Analog1, 'm' = 1.4, 'x' = AUX1 - AUX2 and 'b' = 9.0. The resulting line in raspexi.cfg could be analog_eq1 = 1.4 * (AUX1 - AUX2) + 9.0.

  • For 'y' = Analog2, 'm' = 0.5, 'x' = AUX3 and 'b' = 2.5. The resulting line in raspexi.cfg could be analog_eq2 = 0.5*AUX3+2.5.

Note: The multiplication, subtraction and addition cannot be changed and spaces in the equation are ignored.

Custom Gauges and Dashboards

You can create your very own custom gauges and dashboards using MegaTunix which you can download compiled here or the source here.

To create your own Gauges you can use the MtxGaugeDesigner.
To create your own Dashboards (which can include custom gauges) you can use the MtxDashDesigner.

Once you have saved the custom Gauges and Dashboards in the XML file format you will need to make sure that the XML field element <datasource> contains the appropriate 'Datasource Name' from the table above for each <gauge> in the dashboard XML file.

Development

  1. Download or clone the original forked MegaTunix source code using:
$ git clone https://github.com/MarkusIppy/MegaTunix
  1. Run the following to download MegaTunix and install its dependencies (it may take a while to download and install these (>10mins)):

    $ cd ~/
    $ sudo apt-get install pkg-config libcurl4-openssl-dev libtool libtool-bin intltool libgtkgl2.0-dev libgtkglext1-dev g++ gcc flex bison glade libglade2-dev make git-core gdb automake1.9
    $ git clone https://github.com/MarkusIppy/MegaTunix MegaTunix
    

    A good step by step installation guide for MegaTunix can be found here. (See README.md in MegaTunix for more detail)

  2. Download or clone Raspexi source code with:

$ cd ~/MegaTunix
$ sudo git clone https://github.com/MarkusIppy/raspexi-viewer-linux raspexi
  1. Add the exact line raspexi/Makefile to MegaTunix AutoConf configuration file (configure.ac) or apply the following patch (only needed if you use the original megatunix source instead of our fork )
diff --git a/configure.ac b/configure.ac
index e868b1b..9bec24f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,6 +311,7 @@ MegaTunix32_dbg.iss
 MegaTunix64_dbg.iss
 Doxyfile
 WIN_NOTES.txt
 raspexi/Makefile
 ])
 AC_OUTPUT
  1. This step is only needed if you whish to install MegaTunix to use the gauge and dash designer on older rasbian distros . Edit the file MegaTunix/src/main.c and comment out line 80 -86 by adding "//" in front of each line. This disables the OpenGl error messages when launching MegaTunix
  /* Check if OpenGL is supported. */                                         
  if (gdk_gl_query() == FALSE) {
      g_print("OpenGL not supported\n");
      return 0;
  }
  else
      gl_ability = TRUE;
  1. Execute autogen.sh to generate build configuration.
$ sudo ./autogen.sh CPPFLAGS="-UDATA_DIR -DDATA_DIR=\\\"./\\\""

Command line option CPPFLAGS="-UDATA_DIR -DDATA_DIR=\\\"./\\\"" is need to override data directory (ex. /Dashboards, /Gauges, ...) of MegaTunix to working directory.

If you would like to install MegaTunix so that you can create your own dashboards and gauges on the Raspberry Pi then run sudo make install and sudo ldconfig.

  1. Build Raspexi
$ cd ~/MegaTunix/raspexi
$ sudo chmod +x compile.sh
$ sudo ./compile.sh
  1. Install associated fonts from Raspexi's GaugeFonts directory
$ cd ~/MegaTunix/raspexi
$ sudo chmod +x install_fonts.sh
$ sudo ./install_fonts.sh
  1. To build a binary package for deployment:
$ sudo ./package.sh

The binary package raspexi-yyyymmdd.tar.gz will then be created.

  1. To use GoPro use one of the methods below to establish a Adhoc WIFI between GoPro and Raspberry Pi

There are various ways of configuring your WIFI : You can configure simply via GUI, CLI or WICD CURSES

  1. Automatically start raspexi at boot without starting X Desktop (only works on linx distros which uses systemd eg Jessie)

First make shure your pi is set to boot to Console (you can set this in raspberry pi configuration)

Now we need to get get the pi to boot with a blank screen instead of all the messages. change console=tty1 to console=tty3 to redirect all the text to a different console change loglevel to 3 and hide the raspberry logo by adding logo.nologo last but not least add the option -quiet .

$ sudo nano /boot/cmdline.txt

Here a example of my cmdline.txt

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty3 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes loglevel=3 rootwait logo.nologo -quiet 

Now we install Matchbox ( window manager ),unclutter to hide the mouse pointer and x11 xserver-utils

$ sudo apt-get install matchbox
$ sudo apt-get install x11-xserver-utils
$ sudo apt-get install unclutter

Create a file called startraspexi

$ sudo nano /home/pi/startraspexi

Insert the following text into startraspexi

#!/bin/sh
xset -dpms     # disable DPMS (Energy Star) features.
xset s off       # disable screen saver
xset s noblank # don't blank the video device
unclutter -root -idle 0.1 &
matchbox-window-manager &
/home/pi/raspexi/run.sh

Make startraspexi executable

sudo chmod +x /home/pi/startraspexi

Create a sercive to launch the startraspexi script at boot

$ sudo nano /etc/systemd/system/raspexi.service

Insert the following text into raspexi.service

[Unit]

Description=Raspexi

[Service]

Type=simple

ExecStart=/usr/bin/xinit /home/pi/startraspexi

[Install]

WantedBy=multi-user.target

Test if the script works:

$ sudo systemctl start /etc/systemd/system/raspexi.service

If Raspexi is launching , quit it by pressing 'q' on the keyboard:

Now enable the script

$ sudo systemctl enable /etc/systemd/system/raspexi.service

Reboot your pi and you should see Raspexi starting at boot

$ sudo reboot

12.Launch a custom video at boot with OMXPlayer (only works on linx distros which uses systemd eg Jessie)

$ sudo nano /etc/systemd/system/bootsplash.service

Copy the following content into the file and save it ( this example assumes you have a video called "Raspexi.mp4" in the folder: "/home/pi/" :

[Unit]
Description=BootSplash
DefaultDependencies=no
After=local-fs.target
Before=basic.target

[Service]
Type=simple
ExecStart=/usr/bin/omxplayer -b /home/pi/Raspexi.mp4

[Install]
WantedBy=getty.target

Test if the script works:

$ sudo systemctl start /etc/systemd/system/bootsplash.service

If the video is playing , then enable the script:

$ sudo systemctl enable /etc/systemd/system/bootsplash.service

Reboot your pi and you should see your video at boot

$ sudo reboot

History

Version Revision Date (d/m/y) Notes
TBA TBA TBA
  • Added GoPro 2,3 and 3+ support (Suryian)
  • Added Primary injector duty cycle & 0-100km/h Timer datasources (JacobD)
  • Fixed issue where some dashboards had faint pixels/outlines around gauges (JacobD)
  • Minimised issue where screen would flash white when toggling between dashboards (JacobD)
  • Added gauges & dashboards
v1.3 R7 10/04/2015
  • Added Vehicle Acceleration, Acceleration in G-force, Force exerted in Newtons & Current gear number datasources (JacobD)
  • Added speed correction - calculated from a simple multiplier or from tyre sizes from the config file (JacobD)
v1.2 R6 15/03/2015
  • Added support for Nissan, Subaru and Toyota (by JacobD)
  • Added CSV log file error handling (JacobD)
  • Added XML dashboard file incorrect 'datasource' error handling (JacobD)
  • Added linear equations to define the auxiliary relationships from the config file (JacobD)
  • Added Instantaneous vehicle power datasource for power gauges (JacobD)
v1.1 R5 07/07/2014
  • Implementation of auxiliary inputs AUX1-AUX8 (SonicRaT)
v1.0 R4 07/05/2014
  • Revising and refactoring for public release (Markus Ippy)
v0.3 R3 18/04/2014
  • Implement multiple dash board (up to 4), can be switch by key 1/2/3/4
  • Full screen on start
  • Data save to CSV file
v0.2 R2 05/04/2014
  • Implement PowerFC RS-232 protocol (based on fclogger.py)
  • Add configuration file (raspexi.cfg)
  • Fix issue Gauges data location
v0.1 R1 31/03/2014
  • Initial release