Giter Site home page Giter Site logo

ecusim's Introduction

ECUSim

  • This is a ecu simulator for OBDII scantool like ELM327.
  • This sketch can respond OBDII CAN message with using MCP2515 CAN controller board.

Demonstration

Demo

Dependency

Hardwares need to run the sketch

  • Arduino Uno or its compatilble boards.
  • MCP2515 CAN controller board.
  • Connection Arduino <-> MCP2515 board
    • This sketch does not use interrupt. No need to connect INT and D2 pin.

Wiring

Install

  • Before the install, please modify the argument of CAN.begin(CAN_250KBPS, MCP_8MHZ) in CANMessageHandle.ino, follwoing CAN speed and the frequency of XTAL of MCP2515 board.
  • And please installcoryjfowler/MCP_CAN_lib MCP2515 library and altelch/iso-tp ISO-TP library.
    • Get zip file of repository and install on Arduino IDE.
  • After setting the parameter above, compile ECUSim.ino and flash to arduino board.

GUI fronend

  • GUI frontend is available on sugiuraii/ECUSimGUI.
  • You can control PID sensor value by GUI fronted, by using the program above.

Features

  • Sends value back on PID request of service 0x01
  • Control PID sensor values by serial port (using PC GUI program)
  • Responds ECU ID
  • Responds 6PIDS request by single message (J1939)

Control PID sensor values via serial port

After the CAN initialization (Serial message by "CAN BUS Shield init ok!"), the arduino board wait PID sensor value update message on seial port. The update serial scommand consists with 10 character and LF(\n).

  • The first 2 characters select (hexadecimal) PID.
  • The following 8 characters set the sensor value of PID.
    • Plesase fill 8 character regardless of the number of value bytes. See the example below.

Example

  • Set PID 0x04(= Calculated engine load) to 60.0% (153 in decimal, 0x99 in hexadecimal)
    • -> Send "0499000000\n" via serial port (latter 3 bytes are ignored.)
  • Set PID 0x0C(= Engine speed rpm) to 5745rpm (22980 in decimal, 0x59C4 in hexadecimal)
    • -> Send "0C59C40000\n" via serial port (latter 2 bytes are ignored.)
  • Note that PIDs of "Supported PID" (such as 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0 and 0xE0) are automatically calculated on compling the sketch. You don't have to set by serial port command.

Enable/disable debug message

You can enable/disable error or debug message on ECUSim.h.

constexpr bool PIDSET_DEBUG = false;
constexpr bool PIDSET_ERROR = true;
constexpr bool CANMSG_DEBUG = false;
constexpr bool CANMSG_ERROR = true;
constexpr bool CANMSG_FATAL = true;

Supported PID's

See PIDMap_Definition.h

Enable/disable PID

Edit constexpr unsigned char _PID_BYTE_LENGTH[256] in PIDMap_Definition.h. This array stores the data byte length of each PIDs. By setting byte length to zero, you can disable PID.

constexpr unsigned char _PID_BYTE_LENGTH[256] =
    {
        0, // PID:0x00 (refer PIDAvailableFlagMap in PROGMEM)
        4, // PID:0x01
        2, // PID:0x02
        2, // PID:0x03 // <- Set PID data byte length to enable PID, set zero to disable PID.
        1, // PID:0x04
        1, // PID:0x05
        1, // PID:0x06

Sources

License

MIT License

ecusim's People

Contributors

sugiuraii avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.