I fail to see the reason for this. Sure, you mention "educational purposes", but I'm not going to make my own transistors from scratch.
The MOC30xx triac driver optocouplers are industry-standard and have been used for decades. Why would they be inferior to "normal optocouplers"?
I mean, I gave it a try myself, years ago (ca. 2010 according to the image dates):
This isn't best because the gate pulses are one and done -- with the transformers I used, it seems they did well enough anyway, but preferably the comparator outputs would gate an oscillator, which continuously buzzes the transformer when so enabled -- ensuring the gate is always driven on when it's supposed to be on. Why this matters, will become apparent in a little bit.
This generally acts like a BJT half-bridge, except you don't need to worry about hFE and base current, SCRs provide that by themselves; the downside is they don't turn off by themselves. So, if you can figure out turn-off, well, at least turn-on is easy enough, just forward-bias the G-C junction and it'll stay on (provided V(A) > V(C) -- it's a good diode in reverse, it stays off for A < C).
So turn-off is the big mystery. An AC phase controller is obvious enough: line flips and the SCR turns off, couldn't be easier*. For an inverter like this, you have to use whiplash to your advantage...
*But do beware inductive loads, for which, your fan speed control idea may have some problems. The best starting point is an R+C across the thyristor, to limit dV/dt and dampen ringing, and perhaps an MOV as well to clamp high voltages. When thyristors breakdown (avalanche), the current flow acts like any other -- it latches on. So, without adequate snubbing on an inductive load, a TRIAC typically just stays latched on, as it constantly retriggers itself from the proceeding half cycle's turn-off spike.
All the junk laid out on the bench. Cool heatsinks and fast SCRs salvaged from a 60s-70s era motor drive. Lots of big iron in that thing...
Switching waveform under load, at highish frequency (a bit over 1kHz):
Top is the output waveform, with respect to ground (note the supplies are bipolar, +/-15V around ground). From the left, there's a bit of a flat spot around zero, then voltage sproings up to a fuzzy output-high level. The "sproing" is the supply inductor (the 2 x 160uH), which is coupled so that the same thing happens on both supplies symmetrically, which saves some energy. A few hundred us later, voltage steps down to a flat spot, then falls again, doing the same 'sproing', and so on. The high pulse is slightly longer than low, showing some PWM; this was variable I think to around 100us minimum pulse width (in either direction). (Filtering the output, you could drive a motor or subwoofer with this, just like any other class D amp or step-down converter would. The carrier frequency is just... a bit sluggish, that's all.
)
The bottom waveform is a current transformer linked to the 0.47uF and inductor...
Zoom on the commutation transient:
Coming from the left, initially the low side is on, then the top side turns on.
This shorts out the supply, pulling output voltage to zero (the midpoint between +V/-V, because the 160uH choke is a 1:1 transformer), and building current through the supply choke (dI/dt = (15V) / (160uH)); the excess inductor current is later burnt off as the ringing transient (well damped by the load resistance, in this case).
The resonant cap (0.47uF PP) was initially at fully supply (30V), but the supply voltage just stepped to zero, so the capacitor discharges through the 9uH inductor.
This discharge must draw full load current plus reverse recovery current, otherwise the inverter stays latched and you're fucked! This is always the difficulty with SCRs in inverter applications, of course; keep talking and no one explodes!
As it happens, the resonant peak is 3A forward, and it swings around and reverses -- I think load current was 1A, so the 2A peak is adequate to turn off both SCRs. Somewhere after the current rises through zero, you see a small step change in the voltage -- probably this is exactly where the SCR(s) turned off, and the resonant current diverts to the MUR2020. Which finally explains the purpose of every component in the inverter.
As resonant current drops below 1A, the MUR2020 is reverse biased and turns off. Leftover charge in the 9uH is shared with the supply inductor, and the capacitor charges back up to full supply voltage (resonating with the supply inductor). At this point, both SCRs are off, the supply stabilizes, and the output is open circuit -- everything is nice and off. (We've done it!) If we turn on an SCR, we can start another cycle, at will. In this case, it's just going full wave, so there's a tiny... chop looking transient there, probably the high side SCR turning back on; and so the output swings up.
So that's a demo of a... okay I'll admit, a more advanced application of SCRs!
For AC phase control, with a TRIAC, as it happens, you can drive the gate either direction. While the SCR is a diode junction from G-K, the TRIAC has an equivalent of two antiparallel diodes, G-MT1 (MT2 is the "switched" end and MT1 is the common terminal). G and MT2 currents can be either direction. When the currents are always in equal directions, it's called I/III quadrant drive -- plot I_MT2 vs. I_G to see this. The other way around is II/IV of course. Typically, all but IV are effective.
So, for example, if you drive a TRIAC from a MCU ground-referenced to MT1, you can simply forward-bias the gate to get quadrant I/II drive. Super simple (safely talking to a MCU flying around at mains voltage, however, is another matter!).
Say you charge a capacitor from line voltage, and discharge it into the gate: I_G and I_MT2 will be in the same direction (quadrant I/III drive). This is your typical lamp-dimmer circuit. To do this, we need one more special component: a DIAC. This is a low voltage rated, gateless TRIAC. So, it turns on when voltage (in either direction) exceeds the rating, and then it snaps on. So you can charge that capacitor to say 20V during part of the mains cycle, and if you use a variable resistor, the charge rate and therefore phase shift is variable. Whenever the capacitor reaches 20V, it gets dumped into the TRIAC gate, turning it on nice and hard and fast. Slick and simple!
Most modern parts work fine in quadrant IV anyway, they just have lower gain -- just sink more current and you're good. There's probably not a lot of places you'd use reverse drive to a TRIAC anyway, but hey, you can if you want to (and if it's rated appropriately).
Tim