Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Diesel Generator Driver algorithm

I have an old diesel generator, and I am having big problems programing the governor. I need the engine to stay between 2400-2800 RPM

I have strong RC car servo pushing the gas lever of the engine and the servo is moving between 22°(Minimum) and 95°(Maximum) fuel injection

I drive it with an Atmel meg 328 Microcontroller. The speed is measured with a Hal effect sensor and a single magnet on the flywheel. I measure the time it takes to make a full turn and I calculate the RPM based on that (it means if the engine is faster the code reacts to it more often => Faster changes in injection amount)

First I tried the simplest, and dumbest way. If the RPM is bigger than my needed, step servo back => Smaller amount of fuel injection. If the RPM was lower than needed step servo forward. It turn out to be a really bad idea as the engine has a big latency, so My RPM write a perfect sine graph around my Needed RPM, because it has a big inertia. so when the RPM was above the upper limit the engine was still accelerating.

I also tried changing the amount of regulation degree, by multiplying it with the square of the difference (Needed RPM-Current RPM) It turn out to be the best, but it is still running over.

I'd like to be able to predict my curve somehow, and change the fuel injection according to my future curve. And the engine gets a huge RPM drop as the load increases suddenly (I start a compressor from that)

Help me please, I have no Idea. I'll send some picture f the graphs sortly.

like image 439
Roland Jakubik Avatar asked Aug 18 '16 11:08

Roland Jakubik


1 Answers

As Avi Ginsburg mentioned, try using a PID controller:

https://en.wikipedia.org/wiki/PID_controller

Basically it consists of a Proportional, a Integration and Derivation element. This is always used as a looped circuit:

Image from wikipedia

There is also an Arduino library:

http://playground.arduino.cc/Code/PIDLibrary

like image 159
Hafnernuss Avatar answered Nov 05 '22 16:11

Hafnernuss