Speed or cruize control

Hi,

First time poster, extreme noob.

I am looking at making a speed or criuze control for a home build woodgas gen-set with a UNO board,

The hardware I have is a metal gear Servo to control the manual throttle body, and a Hall Effect sensor and magnet to count the RPM.

I need the generator to turn at 1500RPM on all load conditions, will this be possible?

Thanks.

Hi Woodgas,

Yes, this should work... Also there are some startup situations with wood-gas that you might be able to handle.

What engine are you using? Does 1500 rpm imply that you are in a 50Hz country? Can you point to your (gas) generator design?

I have heard that some people are controlling the fuel feed and gas-generator with Arduino, but I haven't followed that for a while. When I get back to my 25 acres of Vermont this Summer I will be thinking of all the ways to get energy from wood rather than oil/propane..

Thanks for the reply,

I am using a Toyota 2Y engine driving a Chinese 24KVA single phase 220V generator.

I am from South Africa, we have a small furniture factory that needs to run regardless of the regular power cuts and downtime of electricity we experience.
The gasifier design I used is on a down drought principle, with a automatic circuit on a wiper motor for a shaker to get rid of the ash, and multiple cyclone filters and water coolers for the gas.
My aim is to run it on the offcuts from the factory, (Masonite and Chipboard).

So far the system has been a huge success but it needs constant monitoring and throttle adjustments, that is load dependent.

Start-up happens with 500ml gasoline to get the engine on ideal operating temperature, for shut-down, I use the same amount of gasoline to flush or burn the engine clean just for piece of mind.

I read up on the programming in the evenings, started at basic level, as I have zero background on this sort of thing, but am willing to learn.

Sounds like the PID library would come in handy here. Search the forums for threads on it, also for threads on hall sensor and rpm (together). These are both subjects that come up pretty often and it should yield some useful example code.

Hi,

I tried to teach myself to do things on the Arduino, I got this far:

The hardware I have is a Hobby Servo powered by the engine 12V battery through a 5V regulator to control the manual throttle body, I am using the 220vac output on the new alternator through a 6-0-6V transformer, bridge rectifier, voltage divider and large cap, as a 2.5vdc Input in the PID, I gave up on the latching Hall Effect sensor and two magnets to count the RPM as input as its is a very unreliable source with the coding skills I have obviously.

The code that I did:

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

Servo myservo;  // create servo object to control a servo

int voltpot = 0;  // analog pin used to connect the 0-5v input
int setpot = 1;  // analog pin used to connect the potentiometer


double Setpoint, Input, Output; // define variables we'll be connecting to


double Kp=0.1, Ki=0.2, Kd=0; // Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, REVERSE); // Servo 0=max throttle, 180= min throttle


void setup()
{
  Serial.begin(9600);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  
  Input = analogRead(voltpot);
  Setpoint = 0;
  
  myPID.SetMode(AUTOMATIC); //turn the PID on
}

void loop() 
{
 
 if (Input > 1 )
      {
      Input = analogRead(voltpot); // reads the value of the Input (value between 0 and 1023)
      Setpoint = analogRead(setpot); // reads the value of the Setpoint potentiometer (value between 0 and 1023)
      myPID.Compute();
      myservo.write(Output);                  // sets the servo position according to the scaled value
      digital.write(13, HIGH);
      }
 else
      {
      myservo.write(180); // failsafe
      digital.write(13, LOW);
      }
      
 Serial.print("Volt Value: ");
 Serial.print(Input /204.6, 2); //Converts the input bit value to Volt reading
 Serial.print("\t");
 Serial.print("Set Value: ");
 Serial.print(Setpoint /204.6, 2); //Converts the Setpoint potentiometer bit value to Volt reading
 Serial.print("\t");
 Serial.print("      Angle:");
 Serial.println(Output /1.416, 0); // Converts the PID value (0-255) to servo angle (0-180)
 Serial.print("\t");

}

Problem I have is the PID with the above tuning parameters works when I physically attach a Potentiometer to the movement of the servo with its output to the Input of the PID, it finds the Setpoint value quickly and it is stable.

On the generator it hunts, from almost dying to over revving, I have tried countless other tuning combinations.

Tried setting servo limits, but can never get it to stabilize, even with no load.

What else can I try?

Thanks

Woodgas:
works when I physically attach a Potentiometer to the movement of the servo with its output to the Input of the PID, it finds the Setpoint value quickly and it is stable.

On the generator it hunts, from almost dying to over revving,

You have not explained how things are connected on the generator - what is the difference between that and the system that does work?

Maybe you need different PID settings for the generator because the reaction time is different?

...R

Hi,

I use the exact same code, I just power the transformer setup via mains to get my 2.5vdc at 220vac, to simulate the voltage increase and decrease through the use of a pot connected to the servo.

The Setpoint pot and Input/Servo Pot kind of reacts at the same speed with those tunings, I was hoping this would be fast enough to control the throttle?

I too suspected that reaction time might be the problem, but controlling at faster rates makes the hunting worse, more erratic, controlling at slower rates it hunts the same "distance" just takes longer to get there, kind of like the PID wants to go from 0-255 all the time?

This was my first attempt at controlling the throttle, it worked, but it had to be fine tuned all the time, it did not work for all load conditions.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int voltpot = 0;  // analog pin used to connect the potentiometer
int manualpot = 1;  // analog pin used to connect the potentiometer
int voltval;    // variable to read the value from the analog pin
int manualval;    // variable to read the value from the analog pin

void setup()
{
  Serial.begin(9600);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() 
{ 
  voltval = analogRead(voltpot);            // reads the value of the potentiometer (value between 0 and 1023) 
  manualval = analogRead(manualpot);            // reads the value of the potentiometer (value between 0 and 1023)  
 
 Serial.print("Volt Value: ");
 Serial.print(voltval /204.6, 2);
 Serial.print("\t");
 Serial.print("Manual Value: ");
 Serial.print(manualval /204.6, 2);
 Serial.print("\t");
 
 if (voltval > 1 )
      {
      voltval = map(voltval, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180) 
      myservo.write(voltval);                  // sets the servo position according to the scaled value 
      }
 else
      {
      manualval = map(manualval, 0, 1023, 180, 0);     // scale it to use it with the servo (value between 0 and 180) 
      myservo.write(manualval);                  // sets the servo position according to the scaled value 
      }
 Serial.print("Volt Angle:");
 Serial.print(voltval);
 Serial.print("\t");
 Serial.print("Manual Angle:");
 Serial.println(manualval);  
}

Woodgas:
I use the exact same code, I just power the transformer setup via mains to get my 2.5vdc at 220vac, to simulate the voltage increase and decrease through the use of a pot connected to the servo.

Does this mean that you have some arrangment that you believe produces the same effect as a potentiometer? How does it work?
Make a pencil drawing showing all your circuit connections and post a photo of your drawing.

What tests have you carried out to verify that your "arrangment" appears to the Arduino just like a potentiometer.

...R

Woodgas,

I am not a programmer, but I am a control system designer/tech. A thought I had was to aproach this from a diferent angle. You need to maintain rotational speed under various load conditions. The one thing you have that is absolutely locked to gen speed is the frequency of the output volyage. As your previous posts inply, I assume you are generating 220 Volts at 50 Hz at 1500 rpm rotational speed. If you watch the 50Hz and throttle as needed to maintain you might have a more stable control system. You can watch frequency with timing routines or there are very simple frequency to voltage converter ICs available. As I said, I am not a programmer, but there are many very talanted programmers on this forum. Hey people, what do you think???

Robin

Edit to change sig to avoid confusion with above responder. Also, @Robin2 is one of those talanted programmers I was refering to :).

Thanks for the reply,

Here is the drawing of how the stuff are connected on the Gen itself, note the 220vac will come from the Alternator and the Servo controls the Throttle Body.

Here is the working test bench drawing, note the 220vac comes from the normal electrical mains supply and the servo is physically connected to the pot.

@ rdfeil, I will look into what I can get to make something like that work, programming the interrupt stuff are a bit Greek to me.

I tried using a smaller cap on my DIY power supply, the noise makes the PID hunt, the large cap stabilizes the volts but the time delay it brings makes the PID hunt.

If I go the frequency to voltage route, will there be noise and time delay issues too?

I assume, in the working system the servo arm move the potentiometer which causes a greater or lesser proportion of the 2.6v to appear at pin A0?

I don’t understand why the 2.6v is fed to the wiper of the pot - but that may not matter.

What is the range of voltage at A0 with the working system ?

In the non-working system I don’t see any basis for a varying voltage appearing at pin A0 unless you are hoping that the 220v will vary and cause the 2.65v to vary in proportion. But a 10% variation from, say, 220v to 244v (which may be too much) would only cause a 0.265v variation at A0. For a 5v ADC reference that would be 54 points in the 0-1023 scale. A 1% variation would result in 5 points - which may be within the noise of the system, for example ripple due to the AC.

Have you studied your alleged DC signal with an oscilloscope?

The usual way to regulate AC systems is by frequency.

Is the motor able to respond fast enough to maintain a steady output in the face of a varying load?

…R

The working system was purely done to test the PID, to try and mimic what the Gen setup will do.

Here is a video of the DC input running of the gen, I operated the throttle body manually, note the reaction time of the sound of the engine revving vs the change in volts.

Here is a video of the DC input not running off the gen but running of the normal mains, I operated a 10k pot in this video.

Reason I use 2.6 volt, actually wanted 2.5, is to be able to read when the alternator goes under or over voltage with a equal distance to the reading limit 0-5v.

Here is a video of the working PID on the test bench, the output follows the setpoint nicely.

Here is a video of how the PID hunts on the Gen setup, it does that at any setpoint, I chose a low setpoint for the video so that the engine would not over rev or die.

If one operate the throttle manually, the engine can be kept at 220-230V with ease, off and on load.

I once got it right to nurse the PID to run well off and on load, but was unable to repeat it again. Here is the video:

I am going to try the frequency to voltage converter thing next.

Woodgas:
The working system was purely done to test the PID, to try and mimic what the Gen setup will do.

You did not answer my questions.

...R

Robin2:
I assume, in the working system the servo arm move the potentiometer which causes a greater or lesser proportion of the 2.6v to appear at pin A0? Yes, the pot has more movement than the servo has, so it can not really go 0-2.6v but its close.

I don’t understand why the 2.6v is fed to the wiper of the pot - but that may not matter. left is (+), middle is output and right is (-) on my pot I might not have put it correct in the drawing because of my little knowledge of circuit drawings and design, sorry about that.

What is the range of voltage at A0 with the working system ? https://youtu.be/sr1vwlN1T8U, the range of the input can be seen in that vid.

In the non-working system I don’t see any basis for a varying voltage appearing at pin A0 unless you are hoping that the 220v will vary and cause the 2.65v to vary in proportion. But a 10% variation from, say, 220v to 244v (which may be too much) would only cause a 0.265v variation at A0. For a 5v ADC reference that would be 54 points in the 0-1023 scale. A 1% variation would result in 5 points - which may be within the noise of the system, for example ripple due to the AC. https://youtu.be/gjk4RNnQeFo, in this video one can see that the output of the alternator is proportional to the input of A0, if it would go to let say 250v it will output something like 2.8v, so the PID will see the lower and upper limit of the alternator range.

Have you studied your alleged DC signal with an oscilloscope? https://youtu.be/G5i7qE5NFbk, only on this Arduino oscilloscope, if I remove the cap it can read the noise.

The usual way to regulate AC systems is by frequency.

Is the motor able to respond fast enough to maintain a steady output in the face of a varying load? If one operate the throttle manually, the engine can be kept at 220-230V with ease, off and on load.

…R

Hi guys,

I came across this frequency library: http://interface.khm.de/index.php/lab/interfaces-advanced/frequency-measurement-library/

I made the the input network, it reads 100%

As soon as I enter myservo.attach(9); or any other pin on the arduino for that matter the frequency readings go haywire, leading me to believe that within the library they used up all the pins?

On to the next.....

Hi, I'm new to this Arduino stuff and forum, just ordered my first one yesterday....
Anyhow, I'm a 57 yr old process engineer, I have worked with PID controllers when most of you were just a thought...
As I read that your system hunts I immediately think: the settings for PID controller are not correct.
You have "Kp=0.1, Ki=0.2, Kd=0"

Kp is a variable from ( I presume in Arduino) 0 - 1 though in the old analogue days it was 0-~500%. A normal setting was then somewhere from 80 - 200%.
If Kp = 0 it acts like a non-proportional controller, not able to establish a stable situation (oscillating fast), if it is to high the controller will be very slow acting (oscillating slow). I would try to set it at .3 and see what happens.

Ki is in normal life set in seconds, I don't know for Arduino but I assume that it is the same. Try 30 seconds and see what happens. The fluctuations should be much smoother. Ki acts like a brake on the output from the Kp action..

Kd is normally also in seconds, set this to 120 seconds. Kd will diminish the difference between set-point and measured value in stable situations in the controller.

Hope this old man helped you a bit.

Regards Frank from The Netherlands.