Finished Fly by wire throttle control

Showcase your projects! We love to see what people come up with, so please share your creations here.
Post Reply
rameses32
Posts: 18
Joined: Sat Nov 05, 2011 11:49 am

Finished Fly by wire throttle control

Post by rameses32 » Sat Oct 12, 2013 12:11 pm

I finally finished the fly by wire throttle controller I designed for four engines at a TAFE NSW, vocational institute Grafton. Attached is the schematic and link to a video on you-tube. It took me a lot of hours to work the software out to be smooth, consistent, and quick in response. In the end it is very simple, yet performs quite complexly.
http://youtu.be/IJv_XWXhRig
int potpin = A0;
int tps = A1;
int val1;
int val2;
int val3;
int led = 13;

void setup() {

  TCCR2B = TCCR2B & 0b11111000 | 0x01;       //sets PWM to 32 KHz
digitalWrite(led, HIGH); //turns LED in front panel on, letting you know the Arduino is running
}

void loop() {
 
  val1 = analogRead(potpin); //reads POT position
  val2 = analogRead(tps); //reads TPS position
  val1 = map(val1, 1023, 0, 0, 1023); //sets POT Value between 0 and 1023, actually reverses the pot
  val2 = map(val2, 862, 59, 0, 1023); //sets TPS Value between 0 and 1023
  
  while(val2 < val1) { //routine if POT is ahead of TPS
  if (val2 < 340) {
   analogWrite(3, 60); //writes a PWM signal of 60 to pin 3 for first 3rd of throttle opening to smooth out low throttle settings
  }
  if (val2 > 339 && val2 < 680) {
   analogWrite(3, 90); //write a PWM signal of 90 to pin 3 for middle 3rd of throttle positioning, this speeds up throttle response
  }
  if (val2 > 679) {
   analogWrite(3, 120); //write a PWM signal of 120 to pin 3 for remainer of throttle positioning, this speeds up throttle response even faster
  }                                          //by limiting the PWM to an out put of 120, it regulates the output voltage to a maximum of 5 volts from the TIP120 attached
  val1 = analogRead(potpin); //reads inputs for comparison in while loop
  val2 = analogRead(tps);
  val1 = map(val1, 1023, 0, 0, 1023);
  val2 = map(val2, 862, 59, 0, 1023);
   }
   
   while(val2 > val1) { //routine if TPS is ahead of POT
  analogWrite(3, 0); //sends a 0 to Pin 3 to turn off motor
  val1 = analogRead(potpin); //reads inputs for comparison in while loop
  val2 = analogRead(tps);
  val1 = map(val1, 1023, 0, 0, 1023);
  val2 = map(val2, 862, 59, 0, 1023);
  }
}




Attachments
throttle2.jpg

rameses32
Posts: 18
Joined: Sat Nov 05, 2011 11:49 am

Re: Finished Fly by wire throttle control

Post by rameses32 » Sat Oct 12, 2013 12:11 pm

I just realized the diode goes before the Electrolytic cap on the 12v input, the diode is the reverse polarity protection, if it came after the cap, it would protect the Arduino, but the cap would explode,lol. I only drew it this way in the schematic, I built it correctly. Also, do not leave out the diode across the motor terminals, i tried it without it and let the smoke out of a TIP120.
Charle

rameses32
Posts: 18
Joined: Sat Nov 05, 2011 11:49 am

Re: Finished Fly by wire throttle control

Post by rameses32 » Sat Oct 12, 2013 12:19 pm

I just realized by studying my code, that if I would have used a logarithmic potentiometer I could have eliminated even more of the code, oh well, live and learn:)
Charley

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Finished Fly by wire throttle control

Post by andrew » Mon Oct 14, 2013 2:20 am

Well done, it's always interesting to see such things :)

Pogo
Posts: 6
Joined: Thu Dec 19, 2013 6:49 am

Re: Finished Fly by wire throttle control

Post by Pogo » Fri Dec 20, 2013 3:14 am

rameses32 wrote:I just realized by studying my code, that if I would have used a logarithmic potentiometer I could have eliminated even more of the code, oh well, live and learn:)
Charley
Maybe, Charley. Log pots aren't log, they are a few different rate linear segments linked together. The steps might be as much effort to overcome as writing your own linear to log code.

Pogo.

mattechperf
Posts: 2
Joined: Sat Dec 21, 2013 6:40 pm

Re: Finished Fly by wire throttle control

Post by mattechperf » Sun Dec 22, 2013 1:36 am

rameses32 wrote: val2 = map(val2, 862, 59, 0, 1023); //sets TPS Value between 0 and 1023
[/quote]

Great work! I've been curious to see if someone's been working on this.
Does the TPS value of 862-59 come from measurement on that specific throttle body or does it seem be consistent for any using a 5V setup?

mattechperf
Posts: 2
Joined: Sat Dec 21, 2013 6:40 pm

Re: Finished Fly by wire throttle control

Post by mattechperf » Sun Dec 22, 2013 1:36 am

Great work! I've been curious to see if someone's been working on this.
Does the TPS value of 862-59 come from measurement on that specific throttle body or does it seem be consistent for any TB using a 5V setup?

rameses32
Posts: 18
Joined: Sat Nov 05, 2011 11:49 am

Re: Finished Fly by wire throttle control

Post by rameses32 » Mon Apr 14, 2014 9:07 am

It is specific to that model of Throttle Body and would need to be tuned slightly for any other. Actually If I remember correctly, when I designed it I had one model but the ones on the engine were a different model and it took a slight modification, but only minor.

C4Vette
Posts: 1
Joined: Mon Jun 05, 2017 2:09 pm

Re: Finished Fly by wire throttle control

Post by C4Vette » Mon Jun 05, 2017 2:20 pm

Ok, ok, I know: Very OLD topic :lol:
But this sketch helped me to start my own, so thanks for posting!

I tried to make it smoother but did not succeed 100% due to the simplicity of the sketch and electronics. But did succeed partly and brushed up the readability:

Code: Select all

int potpin = A0;
int tpspin = A1;
int POT = 0;
int TPS = 0;
int Start = 200;
int Stop = 950;

void setup() {
  TCCR2B = TCCR2B & 0b11111000 | 0x01;  //sets PWM to 32 KHz
}

void loop() {
  while(TPS <= POT) {                    //routine if POT is ahead of TPS
    analogWrite(3, 185);                 //write a PWM signal to pin 3
    POT = analogRead(potpin);            //reads inputs for comparison in while loop
    TPS = analogRead(tpspin);
    TPS = map(TPS, Start, Stop, 0, 1023);
  }
   
  while(TPS >= POT) {                    //routine if TPS is ahead of POT
    analogWrite(3, 0);                   //sends a 0 to Pin 3 to turn off motor
    POT = analogRead(potpin);            //reads inputs for comparison in while loop
    TPS = analogRead(tpspin);
    TPS = map(TPS, Start, Stop, 0, 1023);
  }
}
My throttle body needed some more power; higher percentage duty-cycle and the mapping needed changing.
https://youtu.be/DqV14BKRVg4

Post Reply