Throttle body response

Hello,
I am trying to control a throttle body from Citroën with an arduino mega and a L298 (from DF robots). My system is working but the response of the throttle body is kind of random and not efficient.

Every connection are ok, I am delivering the right current and the right voltage to everything but I don't know why the response is not instantaneous. I control everything with a potentiometer and the mapping are working well, it is just the response that is not working. My code looks like this :

int E1 = 6;
int M1 = 7;
int value=5;
int potentio = 0;
float pourcent = 0;

void setup()
{
    pinMode(M1, OUTPUT);
    Serial.begin(9600);
}
void loop()
{
  float TPS1 = analogRead(A3);
  float TPS2 = analogRead(A5);
  potentio = analogRead(A1);

  potentio = map(potentio,0,702,0,255);

  pourcent = map(TPS1,156,964,0,100);
  
  value = potentio;

  digitalWrite(M1,HIGH);
  analogWrite(E1, value);   //PWM Speed Control
  delay(500);  // fréquence à modifier
}

I do:

delay(500);  // fréquence à modifier
1 Like

There is one problem. Your code spends 99% of the time doing absolutely nothing while waiting for the delay to time out. Embrace the blink without delay method of timing. See the blink without delay example in the IDE examples.

More tutorials on millis() timing:

Blink without delay().
Blink without delay detailed explanation
Beginner's guide to millis().
Several things at a time.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.