Go Back   EcoModder Forum > EcoModding > Off-Topic Tech
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 12-31-2013, 01:37 PM   #11 (permalink)
Master EcoModder
 
P-hack's Avatar
 
Join Date: Oct 2012
Location: USA
Posts: 1,408

awesomer - '04 Toyota prius
Thanks: 102
Thanked 252 Times in 204 Posts
just for fun here is my attempt at a working program, no ownership implied
Code:
int val = 0; 
unsigned long time;
boolean overboost;
void setup(){
  pinMode(0, OUTPUT);//don't need to set pin 3 for analogRead
}
void loop() {
  overboost=false;
  val=analogRead(3);  //
  //val should be between 204 and 716, 1v and 3.5v
  val=val-204;//  val between 0 and 512 
  if(val<0) val=0;
  if(val>510){
    val=510;
    overboost=true;
  }
  val=val/10; //val between 0 and 51, just right for 1v pwm
  if(overboost){
    time=millis()%500;
    if(time<250){
      val=0; //turn off pwm for 250ms out of 500ms 
             //  so the display flashes indicating overboost condition
    }  
  }
  analogWrite(0,val);
}
Binary sketch size: 1,460 bytes


Last edited by P-hack; 12-31-2013 at 07:04 PM..
  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 12-31-2013, 01:58 PM   #12 (permalink)
Master EcoModder
 
P-hack's Avatar
 
Join Date: Oct 2012
Location: USA
Posts: 1,408

awesomer - '04 Toyota prius
Thanks: 102
Thanked 252 Times in 204 Posts
re: calibration table, you want to something larger than an attiny probably, and/or something known as progmem, so you can read into the table directly from flash instead of keeping the whole thing in ram.
  Reply With Quote
Old 12-31-2013, 02:09 PM   #13 (permalink)
Master EcoModder
 
RobertISaar's Avatar
 
Join Date: Jul 2012
Location: camden, MI
Posts: 324

MC SBX - '95 Chevrolet Monte Carlo LS
Last 3: 29.75 mpg (US)
Thanks: 7
Thanked 55 Times in 46 Posts
i could reasonably approximate my curve correction needed with a 16 or 17 variable table with very little error. i did the check against expected vs reality in .25 volt increments over the 0-5V range, so a 21 variable table would allow me to use my findings directly, but interpolating between the values i have wouldn't be that difficult.

....... i should probably quit threadjacking now.
__________________
  Reply With Quote
Old 12-31-2013, 03:42 PM   #14 (permalink)
Master EcoModder
 
P-hack's Avatar
 
Join Date: Oct 2012
Location: USA
Posts: 1,408

awesomer - '04 Toyota prius
Thanks: 102
Thanked 252 Times in 204 Posts
ugh, that arduino-attiny link is giving a cloudflare error (I don't think I will ever recommend cloudflare since they use their front end position to blame you for hogging resources).

Here is the wayback version
https://web.archive.org/web/20131222...as-an-arduino/

Added flashing logic, on for 1/4 second, off for 1/4 sec.
Edit, oops, forgot the meter wants 0-1v not 0-5v... will fix later.

edit, fixed, divided val by 10 instead of 2


Last edited by P-hack; 12-31-2013 at 04:04 PM..
  Reply With Quote
The Following User Says Thank You to P-hack For This Useful Post:
RustyLugNut (12-31-2013)
Reply  Post New Thread






Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com