Pages

Wednesday, March 27, 2013

My wife's vent-a-hood

Our stove-top is on an island in the middle of the kitchen.  It has a vent-a-hood, but instead of being over the stove, it pops up out of the island behind the stove.  The circuit board in it went out 6 years or more ago, and I wired a radio shack push-button to the up-down motor and a light switch to the fan motor and just put them in the cabinet space under the counter top.  It works, but it is kinda annoying.

Well, I'm finally getting around to rebuilding the circuit board.  I had a guy at work that knew electronics try to decipher the existing circuit for me.  It seems that I thought he knew more than he did, as all he really did was trace the wires and tell me what some of the components were, not actually how the circuit was working.  Basically, I could run the up-down motor without a problem; simple on-off and there are limit switches at the top and the bottom.  But the fan has multiple speeds but only two wires.  I didn't know how they set the speed on a fan without having a different wire for each speed, and that's what I needed to find out.

Luckily, just knowing the parts put me on the right track.  Apparently, the on-off for both motors is controlled by a triac, one of the components that make up a solid-state relay, instead of using a mechanical relay.  But since the triac isn't mechanical, it can be very quickly turned on and off repeatedly; in fact, turned on and off fast enough to chop a peak of the AC sine wave in half.  This is called "phase control", in that you are controlling the speed of the fan by only allowing a certain percentage of the AC phase to get to the motor.  (Solid-state relays are just as reliable for fast and frequent on-off cycles, but they are more expensive and often have circuitry built in to make sure they only turn on and off when the AC sine wave is crossing the zero line, preventing phase control.)

So that got me started in figuring out how to run the fan, and there are numerous examples out there of phase control.  The other part of the circuit that I couldn't figure out, and that the guy at work had no idea about, was the power supply.  There's no transformer on the old board, but it's powering microcontrollers and such, so I know it has a low-voltage DC side somewhere.  But when you get on the forums and start asking about transformerless power supplies, the typical answer is something along the lines of "those things are inherently unsafe and will kill you, so we don't talk about them here".  Again, I got lucky and ran across an application note put out by MicroChip that is exactly what I needed.  I got that working, powered my circuit and programmed it and everything was going great, but my triacs weren't working on my AC lines.  I could use them to modulate a DC line to flash an LED, but I couldn't get the AC line to go off at all.  At first, I thought it was because I bought the wrong triac (I bought a standard one instead of a "logic sensitive" one) but when the new ones came in, they still didn't work.

And then, luck again.  With all of the examples I had found, I had never come across a true full schematic for doing exactly what I wanted to do.  But I had found a lot of information.  One of the bits was that inductive loads, like fans and such, may require a special circuit to keep the back-flow from turning the triac back on when you try to turn it off.  And another was that with resistive loads like light bulbs (or maybe both types), the phase control produces radio-frequency interference that needs to be filtered out.  So I was doing a search for triacs and resistive loads and found another application note from Microchip, this one about using a triac; AN958: Low-Cost Electric Range Control Using a Triac.  The circuits there use a transformerless power supply and use a triac to phase control a heating element.

Well, by golly, when I used their transistor driving circuit to drive the triac instead of trying to drive it straight off of the microchip, it worked like a charm.  The little ac night-light I am using to test just politely flashes right along with my status LED with no problems.  So now I have to build the zero-cross detection circuit and test it.  That is giving me problems, but they should be coding related, not circuitry related.  Of course, I decided to try and test it with a push button instead of actual AC input first just so I could make sure I had my interrupts right before I started worrying about timing, and that didn't work.  I was thinking about it last night and I think I may have fried the pin on my microchip.  I have the pin wired to ground through a pull-down resistor and then wired to +5 through the button.  So it is truly grounded until you press it, and then pulled to positive when you push the button because the button circuit has less resistance than the ground circuit.  In fact, no resistance.  See, I didn't put a resistor in the positive-flow path at all, so I am wiring my pin straight to positive and giving it, in essence, infinite current.  It is supposed to max at 25 milliamps, so unless it has internal protection, I may have burnt that pin out.

I'm going to move to a different pin and test with a proper current-limiting resistor this time and see if my code works.  If it does, and still fails when I go back to my preferred pin, then it's fried.  Luckilly, the PIC18F4520 that I am using has plenty of input pins I can use as interrupts, so I should still be good if I only fried one pin.  And since it still flashes my LED and accepts programming, I know I didn't fry the entire thing.

No comments:

Post a Comment