Not satisfied by the crude operation of my GTI I decided to drive the transformer with a sine wave, like any self-respecting GTI does. What better way to create a sime wave than with a PIC! At first I tried to generate a PWM signal with a PIC12F629 but as this chip doesn't have a PWM module I had to change to a PIC16F628A. I have way too many ports now so I could rewrite my code for a PIC12F617 that does contain a PWM but at the time that was all I had.
But first I needed new hardware. I wanted to keep the existing toriod and the meter circuit. After some headscratching I decided on using an H-bridge and a PWM to voltage converter using a simple form of buck topology. The H-bridge is driven by the PIC as well via opto couplers. Since it only switches during zero crossing the optos are fast enough. The PWM output switches at 20 kHz. The chosen transistor (the one I found in my tray, just like about everything else) has a large C(in) (5.2 nF) so it needs a high current driver (TC4426) to keep losses to a minimum.
During code development I ran into several issues. The first was fatal lockup at startup. The PIC would not run and switch off the optos causing the MOSFETs to go full on. This drained the PIC of power. Eventually this was solved with extra hardware and a PIC output signal (DRIVEON). Then there was the matter of synchronizing the internal clock with the mains phase. The PIC is a bit slower and needs a consistent reference point to properly sync. This is done with a fifth opto. To precisely adjust the phase of the PIC to the mains a lowpass filter/phase shifter is included. So, I now have the PWM drive, HPOS and HNEG for the H-bridge, SYNC to the PIC and DRIVEON for the gate voltage of the MOSFETs of the H-bridge. So yes, it would fit in a 8-pin MCU (PIC12F617) with MCLR available. Too bad the external interrupt pin is the same as the CCP1 (PWM output) pin so I will have to use an IOC interrupt with the additional polarity test. Bummer.
One of the most important features of a GTI is prevention of island operation. When mains power fails the GTI should immediately switch off. That needed quite a few iterations of the code but this was finally solved. Also, proper syncing when connected to the mains and when the external power is supplied now works as required. The whole shebang can be seen in the final code. There are two interrupts, timer0 and RB0. The timer triggers every 0.2 ms and then looks up the next value from the sine table. Which is used four times, for each quadrant of the sine wave. The values are actually the center of each part. Initially I thought that the duty cycle should be far below 100 % but that was just silly and caused me needing more supply voltage than I had available. I finally decided on 99 %. I used a spreadsheet to generate the table.
The second interrupt is driven by opto OC5 and syncs the PWM to mains. There are a few flags used that perform the sanity checks to prevent island operation and syncing when connected to the mains. Because the sequence is complicated and confusing I made a flow chart to figure it out. It works very well and consistently within one single phase. I also pondered on whether to build some hardware panic switch in case of a fault condition like the poweron latchup situation described above but decided to leave that to the mains fuse. My own power source (the homotrainer) doesn't deliver enough power to really damage things so it is not protected.
The electronics was built on a piece of prototyping board that would fit the old GTI.The mains filter was cut off from an old LCD monitor power supply board.
The old controller and MOSFETs were replaced with the new board. The toroidal transformer had the thin wire windings removed. During testing it transpired that my H-bridge transistors wanted to be cooled so I cut off some aluminium L-stock. I then thought it would make an excellent mount point for banana sockets. It does get a bit hot though...
The final test of this contraption was the prevention of island operation and the proper startup when connected to the mains. It took a few attempts to get the shot from the oscilloscope screen right but this shows that it works perfectly. When mains power is lost the circuit tries to synchronize with itself and this causes the criteria for keeping MAINSOK flag set to fail and the H-bridge switches off. PWM remains active, as the little bumps in the second half show.
Reconnecting it to the mains was easier to capture. Top trace shows the SYNC signal, after three periods the circuit is sychronized. This can be clearly seen happening in the timing of the bumps before the H-bridge switches on once FREQVALID flag gets set. The process is shown in the flow chart. Also, the voltage of the power supply can be seen dropping as the load kicks in. The first peak is much higher than the subsequent ones. This was without the big blue capacitor mounted horizontally on the wooden base.
Finally, what bothers me is that the 20 kHz ripple on the PWM output is so high. According to the LTSpice simulation, it should be 1-2 Vpp but it actually is much higher:
I will try to fix this by replacing the two 6.8 µF capacitors with 15 µF units. Should make some difference. Still can't think of the reason, the caps are fine and don't get warm at all during heavy load (110 W feed back power). Could be that the inductive load of the toroid has some influence but could not get this from the simulation. I also observe (no screenshot) that the source current maxes out instead of rising linearly. But as this happens at different levels this can't be core saturation. As this coil is liberated from a fat switch mode power supply this would be unlikely. Maybe the litze wire has something to do with it.
All in all, a nice little project on the side!
Date: 14 August 2018
This software is licensed under the CC-GNU GPL.