Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Planning to use PID to control servo tied to carburetor throttle to manage engine RPM

  1. #1
    Junior Member
    Join Date
    May 2020

    Planning to use PID to control servo tied to carburetor throttle to manage engine RPM

    Current General Plan:
    Utilize Teensy x.x

    Utilize FreqCount or another function as my engine turns 1800 RPM and I believe counting the teeth on the ring gear with a proximity switch will be best for determining the engine's actual RPM.
    At 1800 RPM and 150(ish) teeth on the ring gear, I will see a frequency of 270 Khz. I would also display RPM utilizing LCD after scaling pulses into RPM.

    So setpoint will be 1800 RPM - basically start the engine and have it run at 1800 RPM.

    Input will be a frequency in the range of 250 to 300 Khz if I count teeth. It would be 1800 if I count crankshaft rotations off of the main pulley.
    Output will be a servo (or stepper) that moves the connecting arm to the carburetor - stroke is about 1" from slow to wide open.

    Engine is driving a generator, so load will be varying as "things" randomly turn off and on, requiring more/less power.

    PID will compensate for increasing and decreasing loads by "pressing the gas or letting up on the gas" (servo) at the right time and the right amount.
    PID will need to be fast to prevent low/high voltage conditions for appliances and other "things" connected to the generator.

    This is a marine generator and it currently uses a "mechanical governor" that is belt driven from the crankshaft. As it spins, it "slings" weights away from center and this causes an arm to move, which is connected to the single barrel carburetor. It is kind of like a big lawn mower engine - 4 cylinders. So, there is no emission control, no ECU, etc. The photo below shows the mechanical governor. The spring dampens the the mechanical movement, there are adjustment screws and limit screws, etc. But all the governor is doing is moving that arm connected to the carb. I thought the pictured servo could do that, with PID. Does this info help? My mechanical governor is going out and they want $850 for a new one. I think the Teensy/servo/sensor can be had for $75... so it's worth a go? Or not!

    Click image for larger version. 

Name:	Governor Servo Project.JPG 
Views:	6 
Size:	60.3 KB 
ID:	20314

    Is this pretty straightforward? Got any ideas to get me going?

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Colmar, France
    1800 RPM are only 30 revolutions per second. Thus, you'll get 30Hz from the crankshaft rotations or 30 x 150 teeth = 4500Hz counting teeth.
    That makes things much easier

    Basically, that can be done, many ECUs do it in a similar way (among lots of more sophisticated functions) to stabilize throttling. There are specific hall sensors to detect the teeth without mechanical contact. Their signal needs to be somewhat amplified and cleaned (using a comparator with hysteresis) to get clean and noise free pulses into the Teensy.

    Even the simplest and cheapest Teensy LC can do that, no need for a race horse. I'd suggest to proceed step by step, first build the sensor hardware, then use the FreqMeasure lib to get the pulses per second, multiply these with 60, divide these by the number of teeth to get the RPM info and check if results are coherent. In a second step, add your PID algorithm with appropriate time constants and drive the servo. Make sure to start with a rather big time constant, so that the servo will not nervously oscillate and accept that temporarily, the motor will follow load changes with some delay. Then, if you are sure that the principle works, shorten the time constant step by step until load changes are compensated within acceptable time.

  3. #3
    Senior Member
    Join Date
    Aug 2019
    Melbourne Australia
    Many Crankshaft Angle sensors used in engine management have 3 wires, power, ground and signal so the signal processing is already done.
    Some sense the ring gear, some sense the belt pulley and you have to go digging to find them, some sense the camshaft either directly or inside the ignition distributor if the engine has one. All are designed to withstand the harsh environment you get with electronic bits bolted on to an engine. Heat is one matter but structurally transmitted vibrations are the real killer so it's a good idea to use a ready-made sensor, you just gotta pick one that you can hack into place.

    The toy servos will work but not for long so keep some spares handy.

    For a harsh-environment servo, I've used a diesel engine shutdown servo for this job.
    Its motor looked like a mini windhsield wiper motor attached to a small box with a lever that rotated about 60 degrees and had some electronics in it that needed work to clean up it's resolution - was originally two position only.

    Modern cars have "fly by wire" throttle control, so the accelerator pedal is usually just a pot and the actual throttle valve is driven by some kind of servo. Have looked at a few and observed that:-

    Based on a stepper motor with a solidly built gear train,

    Spring - loaded so throttle is forced closed on powerdown.

    Has a pot for position feedback.

    Come in many shapes and sizes.

    The fun is choosing one, sawing off what you don't need and grafting a linkage onto the throttle shaft, then the all-important bracket.

  4. #4
    Junior Member
    Join Date
    Apr 2020
    Heidelberg, Germany
    If you have an attached generator if it is AC then you can use the o/p voltage signal for the frequency input to the control loop. No need to purchase and mount an extra crank sensor.
    Also please seriously consider the safety aspects of how you implement your servo, it must always fail SAFE. A runaway engine can be very dangerous.
    Does the engine have vacuum available? If so then you could use a PWM controlled pressure switch with a vacuum actuated diaphragm, should be cheaper than an electric servo which usually are specified for finer control.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts