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

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 08-04-2015, 01:58 PM   #401 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,808

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 831
Thanked 709 Times in 457 Posts
Quote:
Originally Posted by amnonholland View Post
A warm thanks from Canberra, Australia to all those who have contributed to the mpguino project and in particular to tvago for the amount of time invested in developing this excellent tool!

A quick question for somebody with coding background - my mechanical engineering background does not help me here!

Im trying to write out a 0-5v signal on the UNO pwm pin with the fuel level to go to another ext gauge.

I have tried analogWrite(11, gallons()); after converting to integer ( int val = (int) gallons(); ?) but am not getting anywhere. Understand I need a low pass filter to convert to true analog. Im not really sure what variable i need to call up (which stores the tank remaining value) or where's best to put this line in the program (under mainloop?)

Any help would be appreciated. Thanks alot!
Thanks for the kind words!

My fork of the MPGuino code does not use analogWrite(), since I could not get it to play nicely with the miniature task scheduler routine that I wrote to coordinate all of the background tasks. Plus, I think I shaved off something like 400 bytes or so. Direct pin writes are necessary, and are used for contrast and brightness control on the LED display.

The actual write itself is pretty easy and straightforward, but setting up might take a little effort. I'll look into this and get back to you within a day.

  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 08-05-2015, 08:51 AM   #402 (permalink)
EcoModding Lurker
 
Join Date: May 2010
Location: Sydney, Australia
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Thanks a million! This will help providing an accurate readout since my OEM gauge is highly non-linear!

I have another arduino in my car hooked up to a 128x128Pixel OLED display which ill display the fuel level via a bargraph. This arduino will hopefully read the fuel level out from the mpguino via one of its analog inputs. Im amazed with the mpguino's fuel level accuracy!

What I'm really stuck with is:
1) What/where is the variable that stores the remaining fuel level?
2) Where would i locate a 'write to pin type' function? (I.e. in which block?)
3) What do you mean by write directly to pin?

Much appreciated

Let me know if I can contribute or assist the project in some manner.

Amnon
  Reply With Quote
Old 08-06-2015, 07:20 PM   #403 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,808

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 831
Thanked 709 Times in 457 Posts
Quote:
Originally Posted by amnonholland View Post
Thanks a million! This will help providing an accurate readout since my OEM gauge is highly non-linear!

I have another arduino in my car hooked up to a 128x128Pixel OLED display which ill display the fuel level via a bargraph. This arduino will hopefully read the fuel level out from the mpguino via one of its analog inputs. Im amazed with the mpguino's fuel level accuracy!

What I'm really stuck with is:
1) What/where is the variable that stores the remaining fuel level?
2) Where would i locate a 'write to pin type' function? (I.e. in which block?)
3) What do you mean by write directly to pin?

Much appreciated

Let me know if I can contribute or assist the project in some manner.

Amnon
Initial thoughts -

You can certainly use pin 11, OCR2A, for your analog output. Keep in mind that it will only have a 8-bit resolution, though. Still, considering a 0-5VDC range, that works out to be about a 20 mV resolution.

OCR2A is driven by timer 2 on the Arduino Uno, which is also what I used for my minscheduler module. It runs at about 1024 microseconds, or at about 977 Hz.

To set the desired pulse width, you would write to OCR2A with an 8-bit value. I'd place it in the main loop, where the awake section lies. I'd also have something that wrote a zero to OCR2A when the sleep section is active, probably near the call to set the LCD brightness to zero.

In order to get the remaining fuel, you'll want to load some unsigned long variable with

Code:
value = SWEET64(prgmFindRemainingFuel, tankIdx);
and then do whatever calculations you'll need to convert that into a 8-bit value.

Let me work on it some more. I just got to be able to have a good look at the code again. It's been a while since I last looked at it... heh.
  Reply With Quote
Old 08-07-2015, 11:20 PM   #404 (permalink)
EcoModding Lurker
 
Join Date: May 2010
Location: Sydney, Australia
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Thanks alot.

I inserted the below code to test, however not having much luck. It gave me warnings that "OUTPUT" was not declared. I researched and inserted #include "WProgram.h" which solved the problem.

The serial monitor doesn't look like its printing the remaining fuel value. (its some number with 8-9 digits). Its likely because i have the code in the wrong spot. I cant really trial different locations because it takes >15mins to compile. The PWM output generator works at least when I assign it a constant.

Where should I locate this code? Could you please advise what line it should go after?

Thanks again for the assistance.


pinMode(11, OUTPUT);
unsigned long fuela = SWEET64(prgmFindRemainingFuel, tankIdx);
int fuelout = (fuela/60000)*255;
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
OCR2A = fuelout;
Serial.begin(9600);
Serial.println(fuela);
  Reply With Quote
Old 08-22-2015, 10:11 AM   #405 (permalink)
EcoModding Lurker
 
Join Date: May 2010
Location: Sydney, Australia
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Can anyone suggest a spot to insert the code? I'm a bit lost.

Also do you see any issues with the above lines of code?

Im getting a voltage output that somehow scales with the remaining L value, however is not linear! I have trialled this by for a given consumption (say 1L) changing the tank size parameter. The output voltage does not vary linearly with remaining value or % full.

This would be a great 'option' to be able to provide for people to output to a external gauge since the mpguino is FAR superior in accuracy to a float level assy based level gauge (since the height does not vary linearly with the volume remaining in many tanks due to the way they are constructed!

Thanks.
  Reply With Quote
Old 01-13-2016, 05:07 PM   #406 (permalink)
EcoModding Lurker
 
Join Date: Nov 2015
Location: Athens, Greece
Posts: 7
Thanks: 4
Thanked 3 Times in 3 Posts
Hey guys. I just discovered MPGuino and I want to install one on my '99 Lancia Ypsilon.
I built it and programmed the chip with the latest code (193tav), but I got this problem. The program (or chip or even LCD) seem to be slow. Really slow. When I push the right button to change page, I have to long-press the button and the page changes after like 5 seconds. It's slow.
Does anyone have this problem? I use a ATMega328P and 20MHz crystal.

Thanks
Hector
  Reply With Quote
Old 01-13-2016, 08:06 PM   #407 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,808

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 831
Thanked 709 Times in 457 Posts
Quote:
Originally Posted by Ettore_M View Post
Hey guys. I just discovered MPGuino and I want to install one on my '99 Lancia Ypsilon.
I built it and programmed the chip with the latest code (193tav), but I got this problem. The program (or chip or even LCD) seem to be slow. Really slow. When I push the right button to change page, I have to long-press the button and the page changes after like 5 seconds. It's slow.
Does anyone have this problem? I use a ATMega328P and 20MHz crystal.

Thanks
Hector
Interesting. Can you go to the system time page? Can you see if the time itself updates normally? If so, then the timing itself should be correct, but there might be something wrong with the wiring hookup to your buttons.
  Reply With Quote
Old 01-14-2016, 06:56 PM   #408 (permalink)
EcoModding Lurker
 
Join Date: Nov 2015
Location: Athens, Greece
Posts: 7
Thanks: 4
Thanked 3 Times in 3 Posts
Quote:
Originally Posted by t vago View Post
Interesting. Can you go to the system time page? Can you see if the time itself updates normally? If so, then the timing itself should be correct, but there might be something wrong with the wiring hookup to your buttons.
Yes. I can change the page. The buttons seem to work properly. But in System time page, the time does not update properly. It never seems to get from 00:00 to 00:01. Maybe it takes too long. (I waited for like 15-20 minutes for it)
I built the circuit myself in a protoboard. It's not a kit. But I looked again and again, and I can't seem to find any mistakes.
Also, the startup page takes a minute to complete and change to Instrument page. And CPU reading is at 10-12%. Can't be normal.
Can it be the LCD module?

Thanks a lot.
Hector
  Reply With Quote
Old 01-15-2016, 11:50 AM   #409 (permalink)
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,808

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 831
Thanked 709 Times in 457 Posts
When I get home tonight, I'm going to download this code from the first post, then reflash my MPGuino with this code. It might have gotten corrupted somehow.
  Reply With Quote
The Following User Says Thank You to t vago For This Useful Post:
Ettore_M (01-15-2016)
Old 01-15-2016, 01:51 PM   #410 (permalink)
EcoModding Lurker
 
Join Date: Nov 2015
Location: Athens, Greece
Posts: 7
Thanks: 4
Thanked 3 Times in 3 Posts
Quote:
Originally Posted by t vago View Post
When I get home tonight, I'm going to download this code from the first post, then reflash my MPGuino with this code. It might have gotten corrupted somehow.
Thank you very much t_vago! I'll check again to see if I've done any mistake myself. I'll wait for your results!

Hector

  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