Dimmer - Spice Tests
I have been messing around with the Dimmer and Spice recently. After spending countless hours trying stuff out on the bench, I decided to put the design in Spice so I can test things more rapidly. Also, Spice lets me try things that would normally smoke on the bench. :)
Jon wants the current shunt on the high side of the load. He wants this because most household light switch boxes have their neutrals bussed together with the individual hots broken out for each load. In a single switch box, the hot and neutral going to the load are obvious. However, in a multiple switch box (a 'gang' box), the neutrals are connected together at a single wire nut. So, for installation sake, it is better to put the current shunt on the high side.
High side current measurements are difficult because of the high common mode voltages present on the high side. In the US, the peak of this common mode voltage is 170V. However, the voltage drop across the shunt is only a few 10s or 100s of millivolts. The INA148 from TI can actually pick this differential voltage off this high common mode voltage, but it is expensive (>$3 in Q1000).
To solve this, we decided to make a power supply that is referenced to the hot line. Working with this high of a voltage on the bench is a hazzard so I decided to try it in Spice. This worked well as you can see below. It let me try many different combinations/tweeks without the hassle and danger of doing it on the bench.
In the schematic, notice that the high side is my ground reference. Also notice that the current shunt and triac are both on the high side. By referencing the power supply to the high side, I am able to read the differential voltage across the shunt and directly gate the triac without worrying about high common mode voltage. One downside to this technique, however, is that hot power supplies may not pass regulations. That is another research topic.
In the simulation results, notice that the data is pretty messed up the first 300ms. This is because it takes that long to get the power rails up and stable. After about 400ms, the results begin to look pretty good. The 'CurSense' (green) and 'VolSense' (red) signals are supposed to oscillate around the reference (VREF, purple). The yellow signal (hard to see) is my zero crossing detector output. It droops on the top because I am drawing too much current from it for the triac trigger.
In the simulation detail, notice that the CurSense signal if flat/zero for the positive half of the cycle. This is because the zero crossing detector is positive which drives the triac gate off. Also notice that the CurSense signal does not increse until after a short delay past the zero crossing. This is because R23 is chosen to fill C12 slowly, thus creating a delayed trigger. The product of the VoltSense and the CurSense is the power (they need scaling in software).
Also notice that the zero crossing detector 'misses' the actual zero crossing by about 600uS. This is due to the turn on/off of D5. This will have to be corrected in software as well.