t vago's MPGuino workspace thread, continued
This code is now being maintained on GitHub at tvago1972/MPGuino. It is too large to be attached to this post any more, even with maximum compression.
In the course of modifying the original MPGuino 0.86 code to incorporate the fuel injection correction factor for Chrysler vehicles with returnless fuel systems, I've been fiddling with the code, doing this and that and the other thing. Since that other thread is really only meant for addressing that issue with Chrysler returnless fuel systems, it became increasingly apparent that a separate thread was needed to describe the other things I have done with the code. So, here it is. (All CPU workload figures assume a 20 MHz processor) UPDATE: After a period of several years, I have dusted off this project and have performed an almost complete refactoring of my code, quashing many bugs in the process (and doubtlessly introducing different ones). Code readability has been addressed, and more comments have been added. Known Issues (as of 18 March 2023):
Hardware Support added (as of 18 March 2023):
Implemented features undergoing testing (as of 18 March 2023):
Program Features built into the base MPGuino code (as of 18 March 2023):
Optional Compile-Tile Program Features added (as of 24 June 2023):
Technical Features added (as of 24 June 2023):
Technical 64-bit math specific features added (as of 24 June 2023):
Features in progress (as of 24 June 2023):
Features to be added (as of 18 March 2023):
This code is meant to be downloaded from GitHub, and compiled with the Arduino IDE. Currently using IDE 1.8.9. If you use the AVR command-line tools, use these settings for setting the programmable fuses to ensure that your MPGuino will work: Quote:
|
Quote:
|
Hi t vago as a lot of work to do.
Quote:
Indicating whether the condition of the battery and the alternator are in good condition. Thanks José Rodrigues |
Hey man - treid the 5-1-17 version for 250miles using the imperial define and it has a time bug. The MPH seem spot on, but it clocks up the miles significantly slower than the odo.
System clock is way out too and won't let me set it either so perhaps it's a related issue. E.g. it knows the miles part of MPH but is getting the Hour part wrong. |
Go back to around line 246 and change the clock frequency from 20 to 16.
|
Awesome - sorry probs could've worked that out as I'm using a nano as my arduino.
I still can't set the system time tho. |
Hi t vago
I've been updating and found that the new version does not allow you to change the number of injectors. In setting the number changes but then shows the previous number which is 6. Thanks José Rodrigues |
Quote:
Quote:
Quote:
|
Quote:
I try to remember to unplug it after the EEPROM write. |
Hi t vago
Thanks for the correction, now you can make the change. But in the settings when switching to the metric system, it does not change to Microsec/L. The previous version also had the problem, but when I informed it, I checked that I already had a new version, I thought the new version would correct the problem, but no. Thanks José Rodrigues |
Quote:
I am considering how to implement deep sleep mode, but you would lose the ability to wake up the MPGuino if you have 5-button analog switches or the Parallax switch assembly or buffered LCD. I might could work around buffered LCD, but analog/Parallax switch support is a show stopper. I will likely end up making deep sleep incompatible with analog/Parallax switches. That is, you can have either one or the other, but not both. Oh, and deep sleep would also be incompatible with the built-in clock display - the onboard clock would simply stop once MPGuino entered deep sleep. Quote:
Besides, the number is already autoconverted inside the code itself. It just isn't stored as a parameter. |
Hi t vago
When I speak in the metric system I am not referring to the imperial gallon, but to liters, which is the international norm "SI". The MPGuino used to do the conversion before and it was all in liters when switching to the metric system, now it does not, it changes all the others to liters less microseconds/L, I think how it worked before, because it avoids converting liters to US Gallon. Thanks José Rodrigues |
Quote:
I took out the storing of microseconds/liter, because this unit is not used on the MPGuino Wiki page. I did this because it would be confusing for people to list microseconds per US gallon, microsecond per liter, and microsecond per Imperial gallon. I decided that only one unit should ever be used, and since the MPGuino Wiki already uses only microseconds per US gallon, that is what I would also use. I do not understand why this should even be a problem, since MPGuino can now calculate this figure directly from injector size and the number of injectors. |
Hi t vago
Quote:
Thanks José Rodrigues |
Regarding deep sleep: like the positives, unaffected by the negatives.
|
Quote:
value = value * sqrt( (vehicle fuel pressure) / (injector test flow fuel pressure) ) value = 1 / value value = value * 3785 cc/gallon value = value * 60 sec/min value = value * 1000000 microseconds/sec Quote:
|
Hi t vago
Quote:
If I need to, how do I get it? Thanks José Rodrigues |
Quote:
The first is "P(Fuel)" and it can be in either psig *1000 or in Pa. The second is "P(Ref)" and it can also be in either psig *1000 or in Pa. In the code I have attached at the beginning of this thread, I have both of those values set to 43500 psig * 1000, so that square root portion will evaluate to 1. P(ref) should remain at 43500 psig * 1000, because that is the pressure that fuel injectors are normally flow-tested at, to get their flow ratings. P(Fuel) is the fuel pressure of your vehicle, and should be set accordingly. |
Hi t vago
It's great I had no idea it worked like that. One change that I believe takes some confusion is in InjSize mL/min which could have an InjFlow text and use cc/min which seems to be more common in the specs of the injectors, what do you think. Another question, the InjSize mL/min does not allow a decimal number in my case, the injector has a value of 191.8 cc/min, I have to put "192" correct. Quote:
Thanks José Rodrigues |
Worked over the timer scheduler a bit, toward the goal of enabling deep sleep mode. I estimate that I reduced the code's power consumption by anywhere between 20% and 40%, with a given configuration.
Quote:
Quote:
Quote:
I may have to increase the precision of this injSize parameter, such as making the units cc/min * 1000. Quote:
step 1: value is in cc/min step 2: value is in cc/min step 3: value is in min/cc step 4: value is in min/gal step 5: value is in sec/gal step 6: value is in microseconds/gal (value = value * 1000000 microseconds/sec) |
Hi t vago
Thanks for the help calculating, I created a file in excel to help in some calculations, if I can check if everything is working well thank you and can make some corrections if necessary. The file is here.https://mega.nz/#!hZEDnJpQ!hJ1LKufAT...xUxGz6fUnj2lO4 This last version of MPGuino I am not able to upload the code for the arduino, it starts but then it takes a lot of time and in the end it gives an error but does not specify what it is, maybe it is deep sleep before concluding, because it takes a lot of time for later give the error. Thanks José Rodrigues |
1 Attachment(s)
Quote:
Quote:
I have also included an alpha version of the latest code. I am not sure whether the LCD works, because I am trying to get the deep sleep code working and I need to move the LCD part of the code away from the ADC. I was using ADC for LCD delay generation, and now I am using timer0. |
Hi t vago
Quote:
This new version also has the same problem, the compilation is done without errors when it starts to send it is slow and does not send. This is the information it shows. Code:
Arduino: 1.8.0 (Windows 10), Placa:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)" José Rodrigues |
Quote:
I used one of these: Pololu USB AVR Programmer to reflash my Mega2560 with its bootloader. My Mega2560 is my primary test platform, followed by my TinkerKit! LCD module. I was finally able to test the LCD code, and it works... but it is incredibly slow. I am going to revert to using the ADC interrupt for the LCD timing. |
Hi t vago
There must be some problem with the code because if I use the version "20170107 - mpguino_1.94_tav.c" it works normally as you can see below, this error only happened in these last two versions. Code:
E:\arduino-1.8.0-windows\arduino-1.8.0\arduino-builder -dump-prefs -logger=machine -hardware E:\arduino-1.8.0-windows\arduino-1.8.0\hardware -tools E:\arduino-1.8.0-windows\arduino-1.8.0\tools-builder -tools E:\arduino-1.8.0-windows\arduino-1.8.0\hardware\tools\avr -built-in-libraries E:\arduino-1.8.0-windows\arduino-1.8.0\libraries -libraries C:\Users\josem\OneDrive\Documentos\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=0X2341_0X0042 -ide-version=10800 -build-path C:\Users\josem\AppData\Local\Temp\arduino_build_882241 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=E:\arduino-1.8.0-windows\arduino-1.8.0\hardware\tools\avr -prefs=runtime.tools.avrdude.path=E:\arduino-1.8.0-windows\arduino-1.8.0\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=E:\arduino-1.8.0-windows\arduino-1.8.0\hardware\tools\avr -verbose C:\Users\josem\Desktop\MPGuino.ino\MPGuino.ino.ino Thanks José Rodrigues |
Quote:
|
Hi t vago
Quote:
I use the portable version 1.8.0 of the arduino IDE, I already tested with the portable version 1.6.0 and it happens the same. https://www.arduino.cc/download_hand....0-windows.zip Thanks José Rodrigues |
Quote:
|
Quote:
I think there is something in the code that disables anything and does not premise communication between the Arduino IDE and the Arduino Mega. Thanks José Rodrigues |
Quote:
https://youtu.be/XLfNDOeNIw4 I can find nothing wrong. I used the most recent version of this code as of this post, and I used the 1.8.0 IDE to upload it to my AtMega 2560. The code, with the reversion to the fast LCD code, was also successfully tested on my TinkerKit! LCD module. I honestly can't think of any situation where the Arduino IDE could not upload a sketch it successfully compiled, because of something inside the compiled sketch itself. |
Hi t vago
This new version holds the error. Your procedure is the same as mine, the only differences are in the LCD selection and buttons your selection is different, one thing that is also different and may justify the problem is that I use the Arduino Mega without anything connected only with the USB cable, it is only speculation but what you have connected do not let the arduino fall asleep and allow to complete the recording. Because this problem only started after infusing deep sleep into the code I think that's the problem. Thanks José Rodrigues |
Hi,
I am Meelis, I have planned lately that I publish my GIT repository and/or maybe we can merge our codes. Seems that you are already taking features from my code and implementing them to your version. I dont mind, my plan was to suggest merging anyway :) I dont know how much you use my code, but at least you use some of features I added (referencing them "via Meelis11"). I can say that if you implement all features to your code, them maybe I can ditch mine and there is only one code :) Your code seem so low level so I am not sure that I can contribute (assembler and low level pure C) How many mpguino code "forks" are out there that can be downloaded? (different versions from different people) that are worth considering (not just custom features for persons own use) They should be added to wiki. Too bad that I cannot test your code right now, because I have run out all atmega328 chips at the moment, only one is in my car, my arduino is chipless :) I am checking your source code and reading what features you have implemented - feature list is really inspiring! Some questions: 1) are you using some kind of repository for version tracking? If not, then please start using GIT (github or bitbucket, I am using https://bitbucket.org) https://www.sitepoint.com/git-for-beginners/ 2) why are you keeping all sourcecode in one file? 3) How do you compile and upload code to mpguino? do I need to compile it using avr-gcc and use programmer and avrdude, or does copy-paste to arduino IDE and upload using arduino work? At least it seems to compile in arduino IDE, but gives one warning "WARNING: Category '' in library OneWire is not valid. Setting to 'Uncategorized'" Like I said, I cannot test uploading (no atmega chips) keep up good work! Meelis |
Quote:
I think I may have inadvertently solved the issue when I re-burned my AtMega2560's bootloader. I also think this problem is not limited to my version of the MPGuino code. Google: "mega2560 programming times out site:forum.arduino.cc" So I was wrong to assume that there wouldn't be anything within a successfully compiled sketch that would cause the programming to fail, simply because there was something within the sketch itself. The AtMega2560 appears to suffer from a bootloader bug that does exactly this. Trouble is, there's nothing in my code that is obviously the cause of the problem. For instance, many users report that if they include "!!!" within a string in their sketch, it will not load onto their AtMega2560. In my code, there is no "!!!" that gets compiled. There were "!!!"s in the source file, in the #error directives, but they do not get compiled into the code. Besides, those "!!!"s in the #error directives were in the 20170107 version, and you reported that it successfully uploaded. There is also another sequence of hex numbers that apparently causes programming to fail with this timeout error, but I am not able to find this sequence. Like I said, I re-programmed my AtMega2560's bootloader, and apparently, the new bootloader does not have this bug. I cannot duplicate this problem with my AtMega2560. |
Quote:
Quote:
The code itself is a bit complex, but I have also been trying to make it easier to understand with re-arranging data structures and with inserting these strange things into the code, that begin with a "// ". I think they're called "comments..." :D Quote:
Quote:
Quote:
I am trying to re-arrange the code so that it will be easy to split apart into modules. This is a long-term issue that I am keeping in the back of my mind. Quote:
Not sure what this OneWire error is - I've never seen it. I try not to use any Arduino-specific library functions. They are great for tinkering, but I would rather optimize for speed, and those Arduino libraries are not optimized for speed. Currently, I have a AtMega2560 test platform, a TinkerKit! LCD module test platform, and a JellyBeanDriver MPGuino test platform. I also have one of your MPGuinos, that I bought off another EcoModder.com member, but I have not yet started testing on it. Quote:
|
Hi t vago
Quote:
Thanks José Rodrigues |
Did some more work on the deep sleep function. I believe I have something that will work, and am going to test it tonight.
Considering re-writing the ADC routines to save even more power during idle mode, when MPGuino is patiently waiting for the next injector pulse or VSS pulse or button press. Right now, for those configurations which require ADC (mainly the 5-position Parallax switch or the 5 analog buttons or the Chrysler MAP sensor input), the ADC is pretty much sampling all the time. This won't affect those of you who do not use these things right now. However, in the future, it may affect those of you who want vehicle battery voltage readings or coolant temperature or other analog readings. |
Quote:
Thanks José Rodrigues |
Hi t vago
Good news, I was able to upload the new version without any problem like the one on the 7th, maybe because the sum of the day is also 7 LOL. http://i68.tinypic.com/ay7y11.jpg Thanks José Rodrigues |
Does this version also need full time power for Arduino?
In thinking to install this to motorcycle and battery cant handle long time load and it might be a problem? Sorry for asking but whole device is new to me and found it yesterday... And did you put the GIT repo up somewhere? |
Quote:
I think I will keep available both a "latest version" and a "version last known to upload successfully to the AtMega2560," at least until they finally figure out why the AtMega2560 occasionally fails to program. Quote:
Good news, though - I am finishing up the deep sleep addition to my code, and should release it here soon. This will drastically reduce power consumption when the MPGuino goes to sleep (after 2 minutes of no engine, no vehicle movement, and no button pressing). I do not currently use GIT, so there is no available repo. I post the latest version here on Ecomodder, and keep all of the previous versions on my network storage, and (for November 2016 and later) in a Gmail draft email as attachments. I've got versions dating from 2013 July 06. |
All times are GMT -4. The time now is 04:06 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com