Go Back   EcoModder Forum > EcoModding > Instrumentation > OpenGauge / MPGuino FE computer
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 11-18-2013, 03:45 PM   #261 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
Quote:
Originally Posted by t vago View Post
I got my TinyRTC module in the mail yesterday, and have made some changes to the code to begin supporting being able to use TWI. Both the serial and the LCD buffering code have been modified to use a simple Buffer class, and this class should prove useful for implementing TWI support. One welcome side benefit was that approximately 200 bytes of code space got freed up.

Also killed a few obscure bugs, and implemented the requested refinement in the blinking code. Now, the special little type characters in the main display will disappear for 0.5 seconds, then appear for 1.5 seconds. I can very easily make it so that they can appear for 3.5 seconds, then disappear for 0.5 seconds, if need be.

A-B testing code and coastdown testing code have not been worked on, I'm afraid. Life has been busy lately, so haven't been able to do much else with coding.
When will we be able to test these changes?

Quote:
If somebody (like me) is willing to go with the 5-button analog button code and hardware, that will make available the two required pins for the native hardware TWI communication interface.
Yes no doubt that this will be the best option for those who have few Pins available.

Quote:
The EEPROM and the clock share the SCL and SDA pins, but they are separate devices.
Ok

Thank you
José Rodrigues

  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 12-01-2013, 12:58 PM   #262 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
Intended to include a screen indicating the battery voltage, as it has in OBDuino, but do not know how can I include this code in MPGuino, would could give me some tips to do this, what are the points that should be taken into account.
Hope I'm not asking for much.

The code seems to be the only OBDuino this.
Code:
#define BatteryVoltageSensor

#ifdef BatteryVoltageSensor
  #define BatteryVoltagePin 14 // Battery voltage sensor, on analog 0
#endif

#define BATT_VOLTAGE  0xF9

"Batt Vlt", // 0xF9   Battery Voltage

#ifdef BatteryVoltageSensor
// Wiring:
// 12V ---- 30kOhm ---|--- 10kOhm ---- 0V(GND)
//                    |
//                    A0 (analog pin)
void get_batteryvoltage(char *retbuf)
{
  #define VoltageDevider 1955L // (30kOhm+10kOhm) / 10kOhm * 5V / 1023 * 100000
  
  long Voltage = analogRead(BatteryVoltagePin-14);
#ifdef DEBUGOutput
  Voltage = 535;
#endif
  Voltage = (Voltage * VoltageDevider) / 1000L; 
  
  char decs[16];
  long_to_dec_str(Voltage, decs, 2);
  sprintf_P(retbuf, PSTR("%s V"), decs);
}
#endif

#ifdef ELM
  else if(pid==BATT_VOLTAGE)
    elm_command(str, PSTR("ATRV\r"));
  else if(pid==CAN_STATUS)
    elm_command(str, PSTR("ATCS\r"));
#endif
#ifdef BatteryVoltageSensor
  else if(pid==BATT_VOLTAGE)
    get_batteryvoltage(str);
#endif

// Voltage sensor init
#ifdef BatteryVoltageSensor
  pinMode(BatteryVoltagePin, INPUT);
#endif
Thank you
José Rodrigues
  Reply With Quote
The Following User Says Thank You to josemapiro For This Useful Post:
t vago (12-02-2013)
Old 12-02-2013, 05:03 AM   #263 (permalink)
Scandinavian creature
 
Join Date: Jun 2012
Location: Finland
Posts: 146

Golf ball - '94 Volkswagen Golf III
90 day: 28.46 mpg (US)
Thanks: 4
Thanked 27 Times in 22 Posts
//Voltage reading (circuit = 12V---22k---VoltagePin---10k---GND )

#define voltagePin A1 // put this on definitions and change the pin to what you use

then this into sub-programs (where all other similar things are):

unsigned long batteryvoltage(void){
float vout = 0.0;
float vin = 0.0;
float R1 = 21550.0; // 22k
float R2 = 9095.0; // and 10k are just fine
int value = 0;
value = analogRead(voltagePin);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
return vin * 1000;
}

and add the voltage things to the menus the exact same way than everything else. The program name is "batteryvoltage" as you see.

This code is not mine, but i've used it successfully. It has 2% accuracy if you apply it unchanged, and 12V is after safety diode. Of course you can tweak it to your needs, whick is recommended.
__________________

Brrrmm
Now selling preassembled MPGuino's!
http://www.mthtek.net/mpguino/
  Reply With Quote
The Following 2 Users Say Thank You to Quezacotl For This Useful Post:
josemapiro (12-02-2013), t vago (12-02-2013)
Old 12-02-2013, 09:35 AM   #264 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,807

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 828
Thanked 708 Times in 456 Posts
I would not recommend the use of analogRead() or any other Arduino-specific library function. analogRead() in particular will interfere with the 1.86tav MPGuino legacy LCD output, as it turns off the analog free-wheeling interrupt that the LCD code requires in order to work.

I will add the vehicle battery read option to the list of features to be added.
  Reply With Quote
The Following User Says Thank You to t vago For This Useful Post:
josemapiro (12-02-2013)
Old 12-02-2013, 10:15 AM   #265 (permalink)
Scandinavian creature
 
Join Date: Jun 2012
Location: Finland
Posts: 146

Golf ball - '94 Volkswagen Golf III
90 day: 28.46 mpg (US)
Thanks: 4
Thanked 27 Times in 22 Posts
Yea it is best that author adds it. That was only a quick fix in case you were in long christmas vacancy
__________________

Brrrmm
Now selling preassembled MPGuino's!
http://www.mthtek.net/mpguino/
  Reply With Quote
Old 12-02-2013, 10:20 AM   #266 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,807

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 828
Thanked 708 Times in 456 Posts
Quote:
Originally Posted by Quezacotl View Post
Yea it is best that author adds it. That was only a quick fix in case you were in long christmas vacancy
Heh - I wish!

No, I've just been extremely busy this past month. Lots of other things to catch my attention.
  Reply With Quote
Old 12-02-2013, 02:52 PM   #267 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
Quote:
Originally Posted by t vago View Post
I will add the vehicle battery read option to the list of features to be added.
Thanks for implementing the battery voltage, a supplement would show the battery condition, perhaps an indication of the battery voltage with the car off and with the car running, that way you could see if it was charging or not correctly.
But I'd like also to begin to understand a little more code, so you do not have to be asking for new things.

Thank you
José Rodrigues
  Reply With Quote
The Following User Says Thank You to josemapiro For This Useful Post:
t vago (12-11-2013)
Old 12-07-2013, 01:08 PM   #268 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
If it is not asking too much, is that I could explain the points which I must add the code to for eg: a menu to show text on the first line and the second line an outcome one more symbol.
The result can be any of those already in the code, what I want is to understand the process.

Thank you
José Rodrigues
  Reply With Quote
The Following User Says Thank You to josemapiro For This Useful Post:
t vago (12-11-2013)
Old 12-10-2013, 10:54 PM   #269 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,807

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 828
Thanked 708 Times in 456 Posts
Quote:
Originally Posted by josemapiro View Post
If it is not asking too much, is that I could explain the points which I must add the code to for eg: a menu to show text on the first line and the second line an outcome one more symbol.
The result can be any of those already in the code, what I want is to understand the process.
Ooo... you just asked for a novel. Sorry about that.

In order to make the code as compact as possible and add all of the features I've added, it was necessary to make some complexity for each display level.

The code defines several display levels:
Level 1 - Standard 4-variable display
Level 2 - Big FE display
Level 3 - CPU Utilization
Level 4 - FE vs Time graphs
Level 5 - FE vs Speed graphs
Level 6 - Time To Empty big number displays
Level 7 - System Clock
Level 8 - System Clock Editor
Level 9 - Settings Selector Menu
Level 10 - Setting Editor
Level 11 - Trip Load/Save/View Select Menu
Level 12 - Trip Viewer
Level 13 - Level 1 Display Editor
Level 14 - A/B Trip Viewer (not yet implemented)
Level 15 - A/B Trip Trigger (not yet implemented)
Level 16 - Coastdown Tool (not yet implemented)
Level 17 - EEPROM Viewer

Of course, these levels are controlled by the various #defines placed at the beginning of the code. Some levels are also grouped together. These levels, and their groupings, are controlled by several arrays.

The first array (screenCursorSize) contains the maximum number of options that each level may have, and is directly related to left/right button cursor movement functionality. For instance, Level 1 contains either 7, 8, 9, or 10 - depending on whether or not idle/EOC tracking is enabled, analog scanning is enabled, or whether Chrysler MAP correction is enabled. This is directly related to how many different 4-variable screens Level 1 is allowed to display.

The second array (screenCursor) contains the cursor position for a given level.

The third array (menuBaseLevelPosition) contains information about the base level, for a given level group. Levels 1 through 7 are grouped together, for instance. This is used by the level up/down code, which directly corresponds to a future implementation of cursor up/down code for 5-button configurations of MPGuino.

The fourth array (menuBaseLevelLength) contains information about the # of levels in a group. This is also used by the level up/down code.

The fifth array (buttonPressAdrList) contains information related to any special keypresses associated with a given level. It contains value pairs, which correspond to keypresses and their associated function index. Note that left-button and right-button definitions do not go here - they are rather handled directly within the main loop itself.

The sixth array (screenCursorUpdate) contains function indexes related to left-button/right button cursor updates. Each time the cursor is moved left or right, this array is accessed, and the corresponding function is called for the current level.

The seventh array (menuDisplayFuncs) contains function indexes related to main loop update refreshes. Every time the main loop refreshes, once every 1/2 second, this array is accessed, and the corresponding function is called for the current level. This array is also accessed immediately after the cursor update function is called.

The eighth array (funcPointers) contains a pointer list of all functions that are referenced by the keypress array, the cursor update array, and the display refresh array. This array is referenced by function index values in buttonPressAdrList, screenCursorUpdate, and menuDisplayFuncs.

The most recent version of the code has been attached to the first post in this thread. In the future, this is where the most recent version will be located.

Last edited by t vago; 12-10-2013 at 11:06 PM..
  Reply With Quote
The Following 4 Users Say Thank You to t vago For This Useful Post:
AndrzejM (12-11-2013), Ardent (12-11-2013), ECONORAM (03-17-2014), josemapiro (12-11-2013)
Old 12-11-2013, 02:24 PM   #270 (permalink)
EcoModding Apprentice
 
Join Date: Dec 2012
Location: Portugal
Posts: 197
Thanks: 93
Thanked 70 Times in 64 Posts
Quote:
Originally Posted by t vago View Post
Ooo... you just asked for a novel. Sorry about that.
Really it is a novel, my idea was a bit kind of copy and past just to understand the logic that you use in your code, not all this work we had.
I plan to include a LDR to read the light and pop up a warning indication to turn the car lights when the car start moving, because many times I drive with the light off, which is not good. I also intend to include an audible warning together with an indication.
Another addition I intend to do is a menu with the voltages coming from the O2 sensor and the ECU receives, for use with a HHO system.

Quote:
The most recent version of the code has been attached to the first post in this thread. In the future, this is where the most recent version will be located.
Sounds good so it is easier to find, instead of having to navigate enters the pages.

Thank you
José Rodrigues

  Reply With Quote
Reply  Post New Thread






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