Automatic voltage regulator for an alternator/synchronous generator

Hello everybody!

At the moment I'm just starting with Arduino; I have the Uno starter kit and I've been working through the 15 tutorial exercises, with greater and lesser degrees of success.

I'd like some help with a project I've been recently given. I need to design an AVR for an alternator/synchronous generator. Basically this is a device which monitors the output AC voltage of an alternator and either increases the DC current flow to the rotor (to increase the AC output voltage) or decrease it (to decrease the AC output voltage).

Although my current grasp of programming isn't great, I think I need the following to accomplish this:

  1. An A/D converter to convert the AC sine wave into a digital input for the board. A transformer may also be necessary to step down the voltage to prevent damage to the circuits.

  2. A medium-high current switching device such as a power transistor, GTO or IBGT to switch the DC rotor current. I think this will need to be switched very rapidly to regulate the AC voltage in a stable manner.

With these in mind I have some questions:

  1. Has anyone done anything like this before? As I'm new to programming I'd appreciate some guidance with regards to writing the code to govern the switching.

  2. Can the Arduino Uno board handle such a project? For example, is the clock speed sufficient to handle fast switching and accurate monitoring?

  3. If anyone has done this before, can you recommend suitable switching devices, A/D converters and small transformers that will work well with the board?

At the moment I'm envisioning an A/D converter between the alternator output and the board to allow the board to measure the AC voltage. Programming would follow the convention of 'if voltage is low, output voltage from a pin to gate of switching device' to allow the field current to flow and the AC voltage to rise, and 'if voltage is high, turn off pin to close switching device' to stop field current flow. The fast switching would occur because the board would constantly be swapping between these two states. Additionally I need to find a way to measure just the peaks of the AC voltage so that the rises and falls of the AC waveform are not wrongly seen as low or high volts.

Many thanks in advance!

InvCE:
Basically this is a device which monitors the output AC voltage of an alternator and either increases the DC current flow to the rotor (to increase the AC output voltage) or decrease it (to decrease the AC output voltage).

How is this different to what the standard regulator on an automotive alternator does?

I don't suppose there is much difference in concept, but the specification of the alternator would be a much larger AC output voltage and alternator rating.

Additonally I have had an idea for measuring voltage at the peaks of the waveforms. As the alternator will output 50Hz, can I use some kind of zero-cross circuitry and then programme a delay of 5ms after each cross, before measuring the AC output through the A/D converter?

InvCE:
I don't suppose there is much difference in concept, but the specification of the alternator would be a much larger AC output voltage and alternator rating.

A standard automotive alternator regulator pack uses simple analog components to solve this problem. Maybe your alternator is sufficiently different to a standard alternator that you can't just take a standard regulator off the shelf, but you can certainly make your own using the same circuit design. I don't see any reason for pursuing a more complicated microcontroller based approach.

Indeed. However I'm required to use a microcontroller-based system due to the environment of the alternator. Essentially the alternator will feed a dynamic load, which may change in nature from leading to lagging very quickly, as well as in magnitude. So unfortunately it won't feed a battery charger-type load. Additionally I'd like to expand on the project in the future by modifying the programming and circuitry to allow multiple alternators to run and supply such loads in parallel. At the moment I'm aiming for a simple circuit on a standalone generator, but with the provision to expand to something like PID control or PWM with a SEPIC supply. That is a long way off, however it would seem to stipulate a microcontroller-based solution due to future work as opposed to an analogue transistor-based arrangement.

I should add that in additon to the future expansions I'd also like to add additional facilities such as a voltage output display, a frequency monitor (which I can assume will function by monitoring the number of zero-crosses per second and dividing by two), as well as (hopefully) a facility to remotely set and adjust the desired voltage on the fly. I know older systems use a variable resistor for this, but I'd like to use a keypad-type arrangement. I'm dreaming big, but hopefully I can get the basics down first before moving into these areas!

I can't pretend to follow your reasoning, but if you want to introduce a microcontroller into the solution it's certainly possible.

When you mention varying power factor and load, do you mean that you want to be able to shape the output wave form dynamically or just that you want to control the average output voltage, and if so averaged over what period?

By varying power factor and magnitude, I mean that I'm trying to develop an AVR which can appropriately react to changes in load from leading to lagging. For example, if a lagging load is being supplied an additional degree of excitation current would have to be supplied when compared to a unity load of equivalent magnitude to maintain the stator voltage. However if a leading load were to be switched in/on this would cause a voltage rise at the stator terminals, requiring a fast but appropriate reduction in excitation current to prevent damage to the load due to over voltage.

I don't intend to dynamically shape the AC output waveform, I would like to sample the output as rapidly as possible and adjust the rotor current appropriately (also in a rapid fashion). Whether this takes the form of zero-cross with a delay, or utilising some other method, is unknown at the moment.

Looking into car alternator packs and analogue circuits as you suggested, it appears I may be able to utilise the Uno to trigger the gate of a FET-type switching device. However I still need a way for the Uno to read/sample the output voltage and act accordingly.

If you don't need to know the polarity, you could bridge rectify and then use a voltage divider to bring it down to 0-5V levels. (If you do need to know polarity then use two half-wave rectifiers and two separate inputs.) You would need to account for the voltage drop across the rectifier in your code.

Make sure the signal can't ever go negative or exceed 5V or the Arduino may be destroyed.

As far as I remember the ADC tops out at about 10 KHz using the standard analogRead(). You'll need to consider your maximum power frequency and number of samples wanted per cycle to see whether sampling frequency was going to be an issue. If necessary the ADC can work faster if you are willing to sacrifice resolution, but this means bypassing the Arduino runtime and hitting the hardware directly..

Thanks PeterH.

I don't need to know voltage polarity, only voltage magnitude since the positive and negative half-cycles should be the same magnitude anyway. Let me run the following past you, if I may?

Choosing an arbitrary alternator output voltage, say 100VAC, could I use a transformer of 40:1 (resulting in 2.5VAC at the secondary) to feed a bridge rectifier. Assuming a voltage drop of 0.5V per diode in the bridge rectifier, this would result in ((2.51.414)-(0.52))=2.515VDC for a peak voltage to the pin, for voltage sensing. Next, as the output will be fully rectified and not feature a smoothing capacitor across the bridge rectifier, this would mean that the voltage at the pin would go to zero twice per cycle. Therefore a 5ms delay after every occurance of zero volts would be needed before a sample was taken, to ensure the peak of the waveform was being sampled and not a rising or falling edge of the sine wave.

Does that sound correct/feasible?

Additionally, I say I'm using a transformer purely for voltage isolation purposes. Instead of this, could a potential divider resistor circuit of 39k and 1k be used, connected between the phase and the return of the alternator output, to feed 2.5VAC to the bridge rectifier?

for the voltage use a optocoupler and a zener diode
the AC Voltage goes to a bridge and a capacitor with a few resistors in series bring down the current down the zener will act as a simple level shifter.
if the voltage is 100 volt the opto is off with 120 volts it will be 20 mA.
the output can go straight with a pull up to the analog input of uno.
the pwm output goes via optocoupling to transistors and a BUZ11.
pwm is fast enough the rotor has coil enough
second step is current measurement and control.

The fact is, everything you have described so far points away from using a microcontroller.

There are some functions for which a microcontroller is the perfect solution. This simply is not one of them.

You want a prompt response to simple input variables. The major two parts of your task are design the circuits to measure certain parameters and to execute certain control functions. You simply connect the first part to the second part - you have not described any reason to introduce a microcontroller between, except to unnecessarily increase the complexity.

Further than that, if you introduce a microcontroller, you are then responsible for making it "fail-safe", lest it suffer a program "crash" and baulk in such a state that your system "runs wild" to its maximum output with no limit.

I am aware that building an AVR can be accomplished with analogue components much more easily, but I want to proceed in this fashion (using a microcontroller) as a means to start off and get to grips with programming. It's my intention for the development of this to be an educational experience for myself, and as my understanding progresses I would like to be able to add and enhance it as time goes by. As alternators are relatively common (especially automotive ones) I thought it would make an ideal and low-risk first go. That is my primary motivation for using a microcontroller. I don't mind whether it succeeds or not, I just want to learn how to produce something that does a job and understand how it works.

It's entirely up to you and really nobody else's opinion matters, but you're getting them because you asked us for help.

For what it's worth, despite what you say above, the most suitable projects to learn microcontroller and Arduino development are those ones for which the microcontroller/Arduino are a sensible solution. Trying to use a screwdriver to bang a nail in is not a good way to learn how to use a screwdriver.

And yes, if you are not put off by this and are determined to press on with this approach then what you're trying to do seems technically feasible, just not particularly sensible.

I'm back. I appreciate the comments and realise it would be easier and simpler to do this with analogue components, but I really want to give this a go.

I have the beginnings of a sketch here but before I post it, I'll provide some background information.

I have a 1kohm pot connected to A0, this will be my demand.

A voltage divider circuit is as follows: the generator output is full wave (bridge rectified) rectified to produce an equivalent DC voltage. This is then fed into a voltage divider circuit for the Arduino to measure. The nominal output voltage is 100VAC, which would rectify to give approximately 140VDC after diode drops, but I want some upper limit slack. For convenience I want 133.33VAC to equate to 1023 and 0VAC to equate to 0VAC; this means that the nominal 100VAC will read as 767 (three quarters of the range). The voltage divider circuit is thus designed to take:

(133.33VAC * 1.414) - 2 = 186.67VDC (the -2 is the diode drops).

This 186.67VDC is then divided so that at this voltage, 5VDC can be read by the Arduino. The voltage divider circuit therefore consists of a 36kohm, a 330ohm and a 1kohm resistor in series, with the Arduino across the 1kohm. I think this is convenient because a direct comparison can then be made with the voltage across the 1kohm resistor and the 1kohm pot with no need for scaling one to the other. This results in 3.75VDC being read by the Arduino when the generator is at 100VAC. These resistor values can be increased to Mohm if required for additional safety.

A power MOSFET will be acted upon to regulate the generator field strength via PWM to it's gate.

Three LEDs will light up under various conditions, red, green and blue.

Now that the two inputs are established, I'd like to compare them and act appropriately. Say that the pot is variable one and the output is variable two, if variable 1 is greater than variable two, I want the PWM function to increment, increasing the field strength. Vice versa, if variable two is greater than variable one, I want the PWM to decrement. Whenever the PWM is operating, I want the green LED to flash (it will flash all the time since PWM operations will be constantly running). Additionally I want the red LED to flash if variable 2 is 1VAC (8 samples) above variable one, and go solid if 110VAC or higher is read (>=844). Similarly I want the blue LED to flash if variable 2 is 1VAC (8 samples) below variable one, and go solid if 90VAC or lower is read (<=690).

I also want two switches. One to be pressed to run the programme, and the other to be pressed to stop the programme.

OK, here is what I've done so far on the sketch. It's not a lot, but I'm a rookie so I'd like some help to get the above.

    int const potPin = A0;    //pot to pin A0

    int const sgopPin = A5;    //voltage divider voltage to pin A5

    int const mosfetPin = 9;    //MOSFET gate to pin 9

    int const redLEDPin = 13;    //red led to pin 13

    int const greenLEDPin = 12;    //green led to pin 12

    int const blueLEDPin = 11;    //blue led to pin 11

    int const switchAPIN = 2;    //first switch to pin 2

    int const switchBPIN = 4;    //second switch to pin 4

    int potValue;    //getting this ready for later

    int sgopValue;    //getting this ready for later

    int desiredVoltage;    //getting this ready for later

    int outputVoltage;    //getting this ready for later

    int potValue = 0;    //initial condition for pot voltage. This line might be incorrect?

    int sgopValue = 0;    //initial condition for divider voltage. This line might be incorrect?

    int switchstateA = ;    //Initial condition for switch A. This line might be incorrect?

    int switchstateB = ;    //Initial condition for switch B. This line might be incorrect?

void setup ()

{

    Serial.begin(9600);    //Sets up PC link to serial window in Arduino PC software

    pinMode (redLEDPin, OUTPUT);

    pinMode (greenLEDPin, OUTPUT);

    pinMode (blueLEDPin, OUTPUT);

    pinMode (mosfetPin, OUTPUT);

    pinMode (switchAPin, INPUT);

    pinMode (switchBPin, INPUT);

    pinMode (potPin, INPUT);

    pinMode (sgopPin, INPUT);

void loop ()

{

    potValue = analogRead(potPin);

    Serial.print ("potValue: ");

    Serial.print (potValue);

    sgopValue = analogRead(sgopPin);

    Serial.print (", output: ");

    Serial.println (sgopValue);

}

OK I'm aware I haven't done much as of yet. From looking at the commands I have some theories as how to proceed, but I'd like some input before I do so. I was thinking of assigning the pot to var1 and the output to var2 as previously described by using:

    var1 = analogRead (A0);

    var2 = analogRead (A5);

if (var1 > var2)

    //increment PWM to get MOSFET to increase field

else

    //decrement PWM to get MOSFET to reduce field

Or something similar?

Many thanks in advance!

Please use CODE tags when posting code to stop the forum software from munging your code.

You need to decide what sort of control algorithm you are going to use. One option would be a simple proportional algorithm where the output applied more and more correction, the further the inputs were away from your desired condition. This is easy to implement but has the disadvantage that it will not completely eliminate steady state errors. Another option is to implement a rate-limited integral feedback where the controller will keep nudging the output in the right direction to eliminate the error. This is also easy to implement but has the disadvantage that it does not cope well with big transients. Another option is to implement a PID feedback algorithm. This gives a very powerful solution but has the disadvantage that you need to understand how to use PID and then go through a tuning process to use it in your application.

Turning your LEDs on and off just needs a threshold comparison.

You need to explain more clearly what your 'on'/'off' switches do i.e. are they intended to power down the alternator (does your controller have enough control authority to do that) or just stop trying to control it, or what?

Hi Peter.

I'll talk about the switches first. I'd like two switches, A and B. When the motor powering the generator runs up, I'd like the AVR to be off initially. This is to stop the MOSFET from being permanently closed at standstill and low speeds, to prevent over voltage. I'd like the motor to spin the generator to full speed, then press switch/button A to bring in the regulation (without having to hold it down). I'd also like switch/button B, once pressed (and not having to hold it down either), to stop the regulation before the machine is stopped and allowed to run down. This is to prevent the MOSFET from attempting to increase the field strength to compensate for the machine slowing down.

I'm aware that at the point of A being pressed there will be a massive difference between demand and output, so I'm anticipating a massive rise to get the error reduced ASAP.

For control algorithms, I know a little about PID (but I'm not great at the maths behind it). I wasn't aware that a dedicated control algorithm needed to be used, which is why I mentioned incrementing or decrementing the PWM to the MOSFET gate appropriately. As I've never used P/PI/PD/PID on Arduino before, I wouldn't know how to go about tuning via the Z-N method, beyound altering the sketch every time until the response oscillates, etc.

Thanks a lot for your responses. I'll try to alter my above post with CODE tags and use them in future.

Hi! InvCe
just wanted ask did u manage to perform this project correctly??