PID controlled throttle

Hi all, very new to programming.
Basically im trying to create something of a cruise control for a simulator. im wanting to write a code to use a PID loop to target a specific rpm (2600) with a servo motor controlling the physical throttle. i want the system to only activate above 2300rpm. i need the ability to not only deactivate it with a switch (easy enough to do with hardware) but also physically overcome the motor to roll off the throttle manually below 2300 to deactivate it. once physically above the cutoff have it re engage and chase the setpoint again. is this a big task? should i use a stepper motor or a regular dc motor instead? appreciate any help or tips at all!
nathan.

How hard is it to turn move the throttle?

A servo sounds more like the right thing.

Say more about all the parts. You leave me wondering what a real simulated throttle is.

I suggest that whatever motor moves whatever throttle, that you let it always do.

Then your logic decides if it is the PID control due to circumstances, or whether to pass along your manual control, or whatever should control the throttle, to the same motor.

But srsly, tell us more about this intriguing project.

a7

I think you'll find that this is more complex than it looks. I'd start off by just getting use to how a PID controller behaves as you change the parameters, since that will help in debugging what comes later.

I've done two projects like this that I can recall that use the "cruise control" behavior where you control something manually up to a point then an automatic controller takes over. That switchover point can get hairy! Best advice I can offer is to google something like "PID control with feedforward" and there should be enough explanation to get you going.

thanks for your reply. i have some knowledge of pid tuning from flying FPV drones. the pid parameters are the least of my concern at this point. i seem to be making some headway with the project. i have some code written that seems to be interacting. im just struggling with setpoint at this point.

throttle is rather easy to turn. it is a flight simulator so its only turning a pot to give throttle input to the simulator. not a whole lot of torque is needed. i have an arduino uno r7 and a 6v 11kg servo motor. i may use a motor with less torque if needed. it is a requirement that the servo torque be weak enough to overcome with force to twist the throttle in either direction.


#include <PID_v1.h>
#include <Servo.h>

Servo myservo;

int rpm = A0;
int val;


//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Specify the links and initial tuning parameters
double Kp=1, Ki=1, Kd=1;
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);

void setup()
{
  //initialize the variables we're linked to

  Input = analogRead(rpm);
  Setpoint = 200;
 
  //turn the PID on
  myPID.SetMode(AUTOMATIC);
 myservo.attach(9);
 }

void loop()
{
  val = analogRead(rpm);
 
  myPID.Compute();
  myservo.write( Output);
 

delay(10);
 }



Servos are not usually happy being driven. The hole idea of the servo is that it stays where you are telling it to be.

You need to think about the mechanical concept that allows a motor to turn something and a human to also turn it.

If you can replace the throttle in the controlled circuit, a motorized potentiometer might be just the thing. They are exactly designed to turn or be turned.

In all cases, something must be able to tell your code where the throttle is set by the control no matter who turns it. I think you will need to be able to grab off the actual throttle setting somehow.

a7

1 Like

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