Explanation about Fuelino software structure

This article explains the structure of Fuelino software. The software source code, which is available on GitHub at this link, is composed by many "cpp" and "h" C++ language files divided into sub-folders. In order to understand the software behavior, it is necessary to have a look at the "ino" file, which is the Arduino IDE sketch containing the "setup()" and "loop()" functions.

The source code below is copy-pasted from the latest software release available at the moment, Fuelino SW 1.00 beta 5. As shown below, the main sketch is composed by the following parts:

  • The "include" of header files of additional software modules (libraries).
  • Declaration of global variables used inside the Arduino sketch.
  • Declaration of "yield()" function, which is executed during SD card writing dead times (by "SDfat" library), or inside the main loop, during idle time.
  • setup() is executed before the main loop, and has the purpose of setting up: Serial communications, fuel injection management, EEPROM memory management, ADC acquisition manager, IMU manager (MPU-6050).

In the last part of the sketch, there is a loop() function which I would like to describe in detail. It does the following:

  1. Initializing the GPS (Ublox Neo 6M), only at first loop execution.
  2. Performing injector safety check, to make sure that the injector is not continuously commanded "open". In case the injector is not driven OFF at least one time inside a specific amount of time, the injector command is turned OFF.
  3. Engine steady state check evaluation, to understand when it is possible to perform a lambda sensor signal "screenshot", and when the engine has completed the cranking phase.
  4. IMU manager, to acquire data from MPU-6050.
  5. GPS manager, to send and acquire data from Ublox Neo 6M.
  6. Analog and digital signals acquisition, for data logging.
  7. Data logging into micro SD memory card
  8. Idling time

In the main folder of the project, there is a sub-folder called "src", which contains the following files and folders. Each folder corresponds to a software module (library). What each library does can be easily understood from the name of its folder.

  1. ADCmgr library. Manages analog inputs (A0 - A7) acquisition by using Atmel ATmega328p "ADC_vect" interrupts.
  2. COMMmgr library. It manages the communication using UART. There are 2 types of Serial communication. One is the hardware serial which connects Arduino to the PC (57600 baud), for service communication and calibration purposes. An other one is the software serial "SWseriale" port (9600 baud) which is managed using interrupts "INT0_vect" and "TIMER2_COMPA_vect".
  3. Display_Mgm library. Not used at the moment. Under development.
  4. EEPROMmgr library. It manages EEPROM memory reading and writing.
  5. GPSmgr library. It manages the communication, using SWseriale, with Ublox Neo 6M GPS module.
  6. INJmgr library. It manages the electronic fuel injection timing, using "PCINT2_vect" and Timer1 interrupts.
  7. MPU6050mgr library. It manages the measurements coming from MPU-6050, which is connected to the Atmega328p using I2C communication protocol.
  8. SDmgr librady. It manages the micro SD card writing, by using SPI communication protocol. Files handling is done by using the SDFat library, available on GitHub.

Fuelino SW Arduino IDE foldersThere is also a configuration file called "compile_options.h" (the file shown below), which contains the compiling options to enable/disable some parts of the source code, depending on the presence/absence of additional modules. You should check and correct the values of these flags, before compiling the software for your Fuelino: in case in your application some modules, such as GPS, Bluetooth, IMU, micro SD card, are not connected to Fuelino, you should set their flags to 0. This will help reducing Flash and RAM memory consumption. In particular, in case SD card is not connected to Fuelino, you should set its flag to zero, otherwise the program will keep trying to write data via SPI, locking the loop() iterations execution for some hundreds of milliseconds.

 

Author: Davide Cavaliere

I am an Italian Electrical Engineer graduated at Politecnico di Milano. My interests are motorcycles and cars, electronics, programming, Internet of Things, and Japanese culture.

2 thoughts on “Explanation about Fuelino software structure”

  1. Hello sir i'm very interested by your work. I would like to remplace membrane carburator in my big rc plane by efi. Do you think that possible with your system?

  2. Prima di tutto congratulazioni per il bellissimo lavoro. Ora, qual è la possibilità di utilizzare questa ECU con i motori Kart poiché non abbiamo adattato alcun supporto elettronico come in CG125?

Leave a Reply

Your email address will not be published. Required fields are marked *