Saturday, March 26, 2011
PIC powered filaments - my first PWR / switching project.
I should say that I first tried the Arduino board, but it's C-language front end only allowed a PWM frequency of about 500 Hz. I felt the need for a higher frequency / shorter period. So back to the PIC, and I chose a favorite, the 16F88. It has 18 pins and incorporates ADC, PWM and lots of other good stuff. To make sure I could get the PWM speed I wanted, I used a 20MHz crystal instead of one of the very handy built-in oscillators.
First I worked on learning to get the PIC working in the PWM mode. It didn't take long to be able to produce a "demand" output voltage of good accuracy that I could measure with a DMM and/or see on the scope. I used a simple RC filter on the output pin to convert the pulse train to DC.
PWM is pulse-width modulation. For example, if I set it for 25% output, the output pin will be HIGH for 25% of the selected period and LOW for the remaining 75%, and repeat. Good for power supply voltage regulation. (Similar methods are even used in your digital (CD, MP3) music players to generate audio.)
Now, what about the switching circuit components? I scanned several references (complicated!) and came up with a simple appearing "buck" circuit. The PIC controls a pass transistor that "charges" a series inductor during the ON time, through the load, and when the PIC turns off, the inductor continues to source current through the load with a diode providing the conduction path that opened when the pass transistor turned OFF.
The references indicated that design of PWM circuits is pretty complex and not likely to work with homebrew hacker techniques. I decided to play with my proposed circuit in LTSpice for a while before risking blowing stuff up, since I was pretty clueless. That helped me a lot. I just simulated the PWM pulse drive from the PIC with a square wave source, changing the duty cycle manually until the output voltage was right.
I was using a 20us (microsecond) period, which is the total ON plus OFF time for one cycle. Things were looking good and I was thinking it ought to work, but then I started using LTSpice to look at the dissipation in components such as my transistor. Wow, it was dissipating twice as much as my load. My overall efficiency must have been about 25%. Looking closer, it appeared that the losses occur during switching periods, the rise and fall times. When fully ON or OFF there's no device dissipation, which of course is what makes switching power supplies attractive. Do I somehow have to figure out how to make those rise and fall times smaller? Fortunately, no.
It occurred that my efficiency is related to the number of switching transitions (OFF to ON, ON to OFF) per unit time. So maybe my period is too short. I had just assumed that faster was better. I cranked down the period in my simulation and efficiency improved considerably. I eventually went all the way from 50kHz PWM frequency down to 4.88kHz. So maybe I could have skipped the 20MHz crystal and just used the internal 4MHz oscillator.
One negative is that the peak transistor current gets larger as the ON time stretches out. More inductance can help. My transistor has a rating of 1A continuous and 3A peak and I was trying to hold to that.
Now I'll show the schematic and discuss the component selections-
Next comes the diode, I guess it's a commutating diode. I think it needs to be one of those "fast" diodes used in switching supplies and capable of 2A or more. Junkbox to the rescue again, I have a RHRP860 rated "hyperfast" at 8A and 600V. It's in a TO220 package like my transistor. The cathode of the diode and the collector of the transistor are both on the metal mounting tabs of their packages, so I could bolt both to the same heat sink and board area to make that connection.
Next comes Q2, which switches the main transistor ON and OFF by grounding and opening its base circuit. When this transistor is OFF, it sees the full supply voltage, so I wanted a small transistor that could take fairly high voltage as I look forward to my 170 volt version. The MPSA43 is a small transistor in a TO92 package that can take 300 volts.
Finally the inductor. Books and articles indicate that this can be critical. I picked one from my junk box which seemed to have heavy enough wire and measured 933uH. I have no idea of the intended use although I suspected it was part of a switcher of some kind. I should mention that the inductor should not saturate at maximum current. A recent project of mine was a saturation tester similar to that made by Alan Yates, VK2ZAY.
I may document mine here one of these days. Anyway, I had tested this inductor and it could go several amps without saturating.
That network of three resistors and two capacitors between the output and the PIC's ADC input does two things. First, it's a /2 voltage divider since 6.3 volts would over-range my PIC's 0 to 5 volt ADC input. And second, it's an RC filter to smooth out any ripple on the output so the PIC gets a consistent average reading.
I lashed everything together, including the power supply, PIC board, switching circuit and a 10 ohm load with a 6.3 volt #44 bulb in parallel. (My setpoint in software is 6.3 volts.) Somewhat to my amazement, the lamp came up to normal brilliance and my DMM measured 6.27 volts. And nothing blew up, smoked, or made scary noises. My homemade sheet metal heat sink got to about 125F near the transistor and diode -- not too bad. I added a second 10 ohm load in parallel to get closer to my desired output of a bit over 1.5A and all was good. Regulation with load changes looks good, and as I ran the input voltage from 35V to 65V the output voltage did not waver.
My PIC software changes the output duty cycle in 5% steps until output voltage gets within 10% of setpoint, then slows to the minimum step of about 0.1%. Updates occur about every 5 milliseconds.
It occurs to me that if I power on the PIC before the big supply, the PIC will run up to maximum duty cycle trying to get to setpoint. Then when the main P/S suddenly comes on, output may go high before the PIC is able to sense the overshoot and run the duty cycle back down. Or maybe not. But I may add another input to give a "power supply voltage normal" signal which would be required before the PIC comes off zero.
Let me show you the drive signal from the PIC, as read at the collector of Q2. When the voltage goes low, it allows base current to flow out of PNP transistor Q1, turning it ON. You can click these pictures to make them larger, BTW.
Using such a power supply for filament voltage could have a couple advantages. I recently checked an old tube type power supply and found that my filament voltage which was supposed to be nominally 6.3 volts was actually 6.8 volts. The could be due to having less load on the transformer than it is rated for, but it's partly due to the rise in house line voltage over the years. People still say "one-ten" and "two-twenty", but probably for the last 30 to 40 years, actual house voltages have been 120 and 240 volts. Hard on antique tube gear.
Another value a PIC controlled supply could give would be a "soft start" feature, bringing the filaments up slowly instead of hitting them cold with full voltage.
But if the PIC controlled supply fails, it might destroy some rare tubes it was supposed to protect. In such cases some kind of protection in software or hardware might be advised.