How to synchronize a generator on the electrical grid?
I will preface this answer by saying that, at this time, I have no practical experience with power generation. The following comments are from stories I have listened to and documents I have read. You should not rely on any of this information while doing serious engineering work.
With that disclaimer out of the way...
The answer of "how do you synchronise a unit to another unit, or to the grid" depends on the size and type of the unit.
You didn't specify anything about the type or size of the units you are interested in synchronising. You also didn't mention what aspects you wanted explained (the hardware? the control algorithms? the regulatory requirements?) Therefore I will give a very general high level overview, with some other stuff thrown in for general interest.
The User Guide for the connection of generators of up to 10 MW to the Western Power SWIN distribution system goes through some of the requirements for connecting small generators (up to 10 MW) to the (Australian) South West Interconnected Network. It doesn't talk so much about synchronising, but does talk about the protection and control schemes required.
Small units < 1 MW
For small domestic or commercial type diesel generators, these are usually installed with a transfer switch. The transfer switch is interlocked to ensure the generator cannot parallel with the grid.
For solar inverters, which operate in parallel with the grid, these must be installed with loss-of-mains detection. This prevents the solar inverter from back-feeding power into a dead grid, which would endanger the people trying to fix the grid.
Medium units - 1 MW - 10 MW
Synchronising is done by an auto-synchroniser. This looks at the voltage and phase difference between the unit and the grid. It outputs control signals that vary the unit's speed, phase angle, and voltage until they are synchronised.
Speed and phase angle are varied by controlling the unit's throttle (a.k.a. 'governor', 'automatic generator controller'.) Voltage is adjusted by controlling the unit's automatic voltage regulator (AVR).
Separately, a synchronisation check relay (ANSI 25) is used. The sync check relay inhibits the unit from closing out of sync.
Closing out of sync causes severe electrical and mechanical stress and is to be avoided. The sync check function is therefore engineered to be a "high reliability" protection function with as few "moving parts" as possible.
Medium-size units connected to the grid are also usually equipped with some kind of anti-islanding protection. Again, this is to prevent back-energizing a dead grid. Common protection schemes for this are "rate of change of frequency", and "voltage vector shift".
Large units - power stations - 40 MW+
Large units at power stations have a synchroniser and synchronism-check relay, as above.
Additionally, their frequency may be deliberately adjusted to keep the grid frequency and phase in lock-step with a atomic clock reference.
Anti-islanding where the unit is cut off from the grid is not so much an issue, as the power station is the grid. The main concern is damage to the unit from load transients - either a sudden removal or addition of load. Overfrequency and underfrequency protection is one means of detecting these conditions. Additionally, fail-safe mechanical protections are used (i.e. mechanical overspeed, low/high boiler drum level.)
Finally -
I searched on YouTube for practical tutorials but I did not find useful information. Does anybody have?
You will not find instructions for setting up an auto-synchroniser or a sync-check relay on Youtube.
Such devices are supposed to be designed and installed by qualified electrical engineers, who do not generally look at Youtube videos for professional advice.
The information is far more likely to be found in the technical manuals for each part of the generator-set. I would guess that you would have to read the manuals for the generator, generator controller, automatic voltage regulator, synchroniser, and sync-check relay. After reading each of these documents, you would be in a position to understand the required equipment and configuration.
Pretty much all solar/wind/fuel cell inverters use a software phase-locked loop. I have designed a number of such converters, both single-phase and three-phase.
The PLL determines the grid frequency and angle. Your power converter then utilizes the data to produce the appropriate amount of real and sometimes reactive power.
A good starting point for you is here (Software Phase Locked Loop Design Using C2000™ Microcontrollers for Single Phase Grid Connected Inverter): http://www.ti.com/lit/an/sprabt3/sprabt3.pdf
Please note that all inverters are current sources.
Btw. the grid is a stiff voltage source, so you would not want to connect a generator directly to it. Generators used in houses have a transfer switch, which can be used to hook up critical house loads either to the grid or to the generator.
I have done this with multiple 500KVA truck mounted machines on a festival site back in the day, if goes something like this:
Set the no load voltage of the two machines to be within a volt or so. Set the idle speed of the two machines to be within 1/4Hz or so. Set the droop percentage for full load such that when both machines are at full load the voltage droop is the same (Important for reactive power sharing).
Switch one machine onto the busbars (At this point the bus is still disconnected from the loads).
You have two lightbulbs in series wired between each of the L1,L2 and L3 pairs from the two machines, these will blink as the two machines slide in and out of phase, a syncrometer is better, but light bulbs are more available.
You tweak the throttle on one machine to bring the speeds to very much the same (the lights will blink more slowly as they approach sync speed), then when the lights fade out you throw the switch putting the other machine onto the bus (A clever throttle variant is a water heater that you can use to load one machine down slightly, and a switch, less annoying then a hunk of lumber pressing on the flywheel).
The machines will now both operate at precisely the same speed (Motoring if necessary). Check that the circulating currents are small (If not you have set the no load voltage incorrectly).
Close the load breaker.
If you have the droop set correctly then the two machines will share the load in proportion to their ratings.
It is worth adding a reverse power relay to disconnect a machine that stops generating due to a fuel or mechanical issue, but you may need to bypass this for a second or so when bringing a machine on line as they will hunt until they fully synchronise both speed and phase.
Touring circus in the former soviet block just after the wall came down was memorable for the improvised engineering sometimes involved.
I would not try this with a single phase set, and it is more trouble then it is worth with smaller machines.