View Single Post
Old 04-30-2017, 08:53 PM   #71 (permalink)
teoman
Master EcoModder
 
teoman's Avatar
 
Join Date: Jan 2017
Location: Istanbul
Posts: 1,245

A3 - '12 Audi A3
Thanks: 65
Thanked 225 Times in 186 Posts
I did a bit more coding, and i have my setup frequency function written.

Some one who knows better, t_vago? Could you double check my frequency code?

I wanted the PWM to be as slow as possible because first, I do not want to wear out the injector, secondly, the slower it moves, the dead-time (time between exciting the coil in the injector and the physical movement of the orifice blocking element, plunger?) becomes less of a concern.

I had previously calculated the max frequencies of my injectors, and at 2000 rpm it was 16Hz.

void setPWMFrequency() {

//SETUP PWM FREQUENCY (or it is too fast for the injector) (DONE)
//https://arduino-info.wikispaces.com/Arduino-PWM-Frequency

// INVESTIGATE IF YOU CAN GET IT EVEN SLOWER (DONE)
//https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM


//PHASE CORRECT PWM
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM20);
//TCCR2B = _BV(CS22);


//SET PWM FREQUENCY TO 30/2 HZ ~ 15HZ
TCCR2B = TCCR2B & B11111000 | B00000111;
// OCR2A = 180;
// OCR2B = 50;
}


Last edited by teoman; 04-30-2017 at 10:13 PM..
  Reply With Quote