PWM3




Engelsk version længere nede, English version below

PWM3 er en primært hardware messig løsning til at lave pulsbredemodulation på 230 volt (vil med mindre ændringer også kunne bruges på 110volt).

Diagram, print, firmware, software, links til andre sider og pdf filer findes i bunden.

BEMÆRK, HVIS DU IKKE VED HVAD DU LAVER, SKAL DU IKKE LAVE DETTE PROJEKT, DET ER 230 VOLT DU SKAL RODE MED, DET GØR RIGTIG NAS OG DU KAN OGSÅ VÆRE SÅ UHÆLDIG AT KOMME TIL SKADE ELLER BLIVE SLÅET IHJÆL AF DET, SIGMAHAT ELLER DE ENKELTE HATTE INDIVIDUELT KAN OG VIL IKKE STÅ TIL ANSVAR FOR HVAD UDFALDET AF EN FREMSTILLING AF DETTE PROJEKT FØRER TIL.

DU RICIKERE NEMT AT LAVE RADIOSTØJ MED DETTE PROJEKT, DET ER IKKE VORES SKYLD HVIS DU FORBRYDER DIG MOD REGLER OG LOVE OM UDSPREDELSE AF RADIOSTØJ.

DETTE ER ET GØR DET SELV PROJEKT, DU MÅ PÅREGNE AT SKULLE TILPASSE DET TIL DIT BEHOV!

For at kunne forstå dette projekt, er det godt med lidt baggrundsviden om elektronik, specielt triac og stærkstrøms styring.

Vi vælger at køre vores styredel digitalt, da vi derved kan adskilde svagspændings og stærkspændingsdel med optocoupelere.

Til stærkstrømsstyring bruges triac's, de kan styre vekselstrøm, hvilket er en fordel, da det er det vores lysnet kører på.

Det at vi styre med Triacs har den ulæmpe, at når de er tændt, kan de først slukke igen, når fasen passere nul. Dette sker 100 gange i sekundet ved 50 herts lysnet.

Da vi kun kan slukke når vi er i nul, har vi kun et sted at variere lysstyrken, og det er at forsinke tændingen i forhold til fase start, til dette har vi et lille kredsløb, hvor vi tager en nedtransformeret ac spænding og dæmper en lille smule med modstande, vi måler over en af de modstande med en operationel forstærker, da vi ikke har nogen tilbagekobling, vil dennes udgang være enten 1 eller 0, vi kan derfor lade en pic processor se hvornår en ny halvbølge starter, og den kan derfor vide hvornår den skal starte den løkke der laver forsinkelserne i tændingen der svarer til dæmpningen.

Brættet skal ha 2 spændingsforsyninger, en ac og en dc, dc'en kan være på alt fra 6 volt og op til hvad en 7805'er tillader. Ac trafoen kan være på spænding meget varienrende, da denne reguleres efterfølgende med modstande. For at beregne disse modstandene, skal vi vide hvormeget den ac trafo vi har fået fat på til printet er på i peak to peak spænding, en trafo oplyses som regl i effektiv spænding, for at beregne den om til pp spænding bruges følgen formel Upp=2*Ueff*sqrt(2), altså ca 2,8 gange u effektiv. Vores mål er nu at få lavet en spædningsdeler der sørger for at vi kommer ned på 1-2 volt over modstand B. (vi ved godt at vi kunne ha nøjes med 2 modstande, men da BaeHat (diagram designer) er telefonmand af proffesion, er han vand til at arbejde med balancerede kredsløb), vi vil anbefale at man lægger modstandene i kilo ohms klassen, så hvis vi starter med at sige at modstand b skal være på 1 kohm, kan vi regne ud at ved 1 volt over den, vil der løbe (1volt/1kohm)=1mA gennem den, det vil sige at der også vil løbe 1 mA gennem de andre modstande, således skal der være et spændingsfald over hver af de to andre der svarer til (Upp-1v)/2stk, når vi har fundet det spændingsfald, skal vi bare dividere det med de 1mA der løber gennem dem, og vupti, vi har deres værdi.

Det er vigtigt hvis man vil vælge en anden optocoupeler, at man vælger en der dels har en triac på ud siden, og dels at den ikke kun kan starte i nul på fasen (som f.eks. moc3041 der bruges til discolitez).

Pic processoren skal indeholde en firmware som får den til at gøre det den skal, denne har vi skrevet i ccs pic c, du kan her på siden (i bunden) downloade enten kildekoden eller hex koden, bemærk hvis du skal køre med en anden frekvens end 50 hertz, skal du downloade kildekoden og ændre den variabel der indeholder frekvensen (tydeligt markeret med kommentare) til 60 hertz og recompile. Hvis du ikke selv har mulighed for det, kan det være du kan lokke os til at gøre det for dig.

Brættet forbindes til computeren via com porten, ud over brættets 3 forbindelser (markeret som pin 2, 3 og 5) skal der i sub-D 9 stikket laves følgende luse: pin 7 og 8 skal forbindes med hinanden, og pin 1,4 og 6 skal klaskes sammen.

Når PWM3 komunikere med pc'en fungere det ved 9600bit pr sekundt, den måde man komunikere med den på er ved at sende først et "k", derefter kanalnummeret, med et ciffer, derefter et "d", og derefter dæmpningen med 2 cifre, (ja, hvis du vil dæmpe til f.eks. 5 er det vigtigt at du sender 05 for at pic'en forstår det.) Derudover kan man sende den et "a" char for at fortælle den at man gerne vil vide hvormeget den dæmper, det resultere i at den tilbage mod computeren smidder alle sine dæmpningsverdier efter samme protocol.

For en nemhedsskyld har vi lavet et par programmer til jer som i kan bruge sammen med pwm3, det første er et der udelukkende, og ganske dumt, kan sende nogle dæmpningsværdier til pwm3, på den ene slider fortæller man hvilken kanal det drejer sig om, og på den anden hvor meget der skal dæmpes, lige så snart der rykkes i den slider der fortæller dæmpningen, sendes den verdi den stilles på til pwm3. Det andet program kan lave levende lys, dog kun på 4 kanaler (du kan selv skrive det om til at tage nogle flere kanaler). Det sidste program er et program til at forbinde discolitez med pwm3, den fungere udelukkende som en bro, den udnytter netværks interfacet i discolitez, derfor skal denne indstilles til at sende dataen til "localhost" (uden gåseøjne), med mindre discolitez kører på en anden maskine.

Vi har lavet 2 videoer til dette projekt, den ene viser så smart hvad du kan med dette projekt, det andet viser de tekniske sider af det.

Vi har under fremstilingen haft forskellige udgaver, pwm1 blev ved tankerne, den var ikke baseret på at kigge efter krydsninger af nul punktet på fasen, og ville derfor ikke ha virket i virkeligheden, pwm2 blev faktisk fremstillet, det var en forsats til discolitz triac printet, men da triac printet brugte moc3041 som kun kan tænde i nul, stod vi overfor enten at skulle skifte alle moc's på printet, eller at vi kunne lave en samlet løsning, med både svagstrøm og stærkstrøm på samme print, vi gik derfor viddere til dette projekt.

I firmwaren har vi et lidt pussigt problem, der er et eller andet sted sket noget pussigt som gør at vi er en faktor 10 ved siden af når det gælder delay i microsekunder, dette er der kompenseret for i udregningen af delayet, du bliver nok nød til selv at rette til i firmwaren.

Vi havde samtidigt et par problemer med det fysiske print, da strømkarekteristikken for led's og optocoupelere er forskellige, resultere det i at lysdioderne ikke vil lyse, ærgeligt, et andet problem er at støjdæmpnings kondensatorene ikke kan være på printet, det har vi løst ved at sætte dem på et eksternt modul print, her skal du nok selv rette print layoutet til, så det passer til netop de kondensatore du får fat på.

Fordelingen blandt hattene har været som følger: BaeHat har lavet diagram, oprindelig firmware source code, den danske dokumentation, vb programmerne og har skudt og redigeret vidoerne. EmHat har lagt det geniale print og bistået BaeHat under udviklingen, BiskHat har rettet stavefejl i den danske dokumentation og oversat den ordret til engelsk (med hjælpe fra BaeHat). KemHat har rettet skønhedsfejl i firmware sourcecoden, rettet i kommentarene for at man bedre kunne læse den og bistået BaeHat under udviklingen. CreamHat har lavet musikken til videoerne og bistået BaeHat under udviklingen.

Resoucrer:
Diagram og board til eagle, med de krævede lib filer pakket i zip
Diagram i PDF, hvis du f.eks. vil ha inspiration til et andet projekt.
PCB i PDF, hvis du bare vil ætse og fremstille. (dette pcb har måske ikke plads til dine komponenter), pakket i zip
Firmware i HEX (50 Hertz, vi garantere ikke at den virker)
Firmware source code, f.eks. hvis du vil køre det på et 60 hertz lysnet.
Windows programmer, sourcecode, skrevet i visual basic 6, pakket i zip.
Discolitez, et program til at styre lys til musik
PWM3 blære demo
PWM3 Teknisk Demo



ENGLISH VERSION:

PWM3 is primary a hardware solution for making a pulsewidthmodulation on a 230V circuit (it can be modified for use on an 110V network if necessary).

Diagrams, PCB, firmware, software, know-how links and PDF files will be available on the bottom of this page.

WARNING! IF YOU DO NOT KNOW WHAT YOU ARE DOING YOU SHOULD REFRAIN FROM MAKING THIS PROJECT, IT'S A 230V CIRCUIT YOU HAVE TO WORK WITH, IF WOU FAIL ANY SAFETY MEASURE IT WILL HURT LIKE HELL, AND IN THE WORST CASE SCENARIO BE FATAL! SIGMAHAT OR ANY OF THE HAT'S CANNOT BE HELD RESPONSIBLE FOR ANY OR ALL DAMAGE CAUSED BY MAKING THIS PROJECT.

THERE IS A HIGH RISK OF MAKING RADIO NOISE, ITS NOT OUR (SIGMAHAT) FAULT IF ANY LAWS ARE BROKEN.

THIS IS A DIY PROJECT, YOU MUST PLAN TO MODIFY IT FOR YOUR CURRENT NEEDS.

To understand this project it’s good to have some prior knowledge about electronics, especially high-voltage controlling and triac circuits.

We have chosen to run our controls digitally, because then we can separate low-voltage and high-voltage with optocouplers.

For the high-voltage controls we will be using triac’s, they can handle AC which is an advantage because it’s what we are using in our house mains.

That we are using triac’s also has a disadvantage that when they are turned on they cannot not go off before the phase has crossed 0 again. This happens 100 times pr second on a 50Hz circuit.

As we can only turn off while we are at zero, we only have one way to controll the dimm, by delaying the turn on compared to phase start, for that we have a little circuit, where we take a downtransformed ac voltage and reduce it further with some resistors, we then use a opamp to measure that ac low voltage, since we do not have a feedback to the opamp, the opamps output will be either 0 or 1, we can therefore let a pic processor se when a new halfwave starts, and it can therefore know when to start the loop that makes the delays in turn on that equals the dimm.

The board needs 2 powersupplies, a ac and a dc, the dc can be anything from 6 volts to what a 7805'er alows. The ac supply can be within a wide range, cause it is regulated with resistors. To calculate the value of these resistors, we first need to know how much the ac supply is in in peak to peak voltage, a ac powersupply is usually mark in rms voltage. To convert rms to pp, we use the following formula: Upp=2*Urms*sqrt(2), which is aproximately 2,8 times U rms. Oure goal is to make a voltage divider that supplies 1-2 volts over resistor B. (we know that we could have maken due with 2 resistors, but because BaeHat (circuit designer) is a tele technician of profession, he is used to working with balanced circuits), we would recommend putting the resistors in the "kilo ohms" range, so if we start by saying that resistor b needs to be at 1 kOhm, then we can calculate that by 1V across it. That means that there will run 1 mA of current through the other resistors as well, so there must be a voltagedrop across each of the 2 remaining resistors equal to (Upp-1V)/2pcs.

If you want to choose another optocoupeler it's important to choose one that first of all has a triac on the output and secondly that it allowes you to turn on outside of the zero-crossing (the moc3041 that is used by discolitez has this irritating featur).

The PIC Processor needs a firmware to operate, we have writen our firmware in ccs pic c. On this page (at the buttom) you can download either the sourcecode or the HEX code please note that if you plan to run the PWM3 on a frequency other than 50Hz you need to download the sourcecode and change the variables that contains the frequency (clearly marked with a comment) to wichever frequency you plan to use (e.g. 60Hz) and recompile. If you don't have the possibility to do that you might be able to persuade us to do it for you.

The board connects to the computer via the COM port, besides the three connections (marked as pin 2,3 and 5) there needs to be made the following loops in the sub-d9 connector: pin7 & 8 needs to be connected and pin 1,4 and 6 must be connected with each other.

When the PWM3 communicates with the PC it uses 9600bits per second, the way you communicate to it is by first sending a "k", followed by the channel number, with 1 ciffer followed by a "d" followed by the dimming value expressed in 2 ciffers (yes, if you want to dimm to let's say 5 it's important that you send 05 for the PIC to understand it). other than that you can send a "a" char to tell the PIC that you want to know the dimms, that resolves in the PIC sending back to you all the dimm values via the same protocol.

To make it easy for you we have made a couple of programs to be used togethere with PWM3.
The first is one that, pretty dumb, can tell the dimm values to the PWM3, on the one slider you can tell what channel you want to dimm, on the other you can tell how much you want to dimm, as soon as you move that slider, it sends the dimm values to the PWM3.
The second program is one that makes living lights, though only on 4 channels, (you can DIY it to make use of more channels).
The last program is a program to connect discolitez to PWM3, it is just a bridge, it makes use of the network interface in discolitez, it must therefore be configured to send the data to "localhost" (without quotmarks), unless you run discolitez on another pc.

We have made 2 video recordings for this project. One shows very delicatly what you can use it for. The other one shows the technical aspects of the project.

change log:
PWM1: a project that didn't made to the sketchbook. It wasn't based on looking for phase-shift, and would therefore not have worked IRL.
PWM2: This one was actually made, it was a frontend to the discolitez triac PCB. Sadly because the discolitez circuit used moc3041 which can only turn on in a zero-cross, we were faced with either changing all the moc's on the PCB or we could make a joined solution with both the low-voltage and High-voltage circuits on the same PCB. Therefore we moved forward to this project.

In the firmware we had a funny issue, somewhere something odd happened that made the microsecond delay be a factor 10 off. This was compensated in our formula for calculating the delay, you will probably have to change that back.

We also had a couple of problems with the actual PCB. Because of the difference in current characteristica for the LED's and optocoupeler's the LED's wont light up ...sad. Another problem was with the noise reducing condesators, the ones we got were bigger than the space for them on the PCB. Our solution was to mount them on an external module print, you will therefore probably have to customize the PCB layout to fit the condesators you are going to use.

The workload between the Hats' is as following:
BaeHat has made the diagram, the original firmware sourcecode, the danish documentation, VB programs and the video recordings.
EmHat has made the ingeneous PCB layout and has assisted BaeHat during the development.
BiskHat has run the spell correction (without digital help) and has made a direct translation of the danish documentation with a little help from BaeHat about all the technical terms.
KemHat has corrected some cosmetic bugs in the firmware sourcecode, has made the code comments more comprehensable and assisted BaeHat during the development.
CreamHat made the music featured in the videos and assisted BaeHat during development.

Resources:
Diagram and board for Eagle, with all the neccesary lib files packet into a .zip folder.
Diagram in PDF, if you e.g. want inspiration for another project.
PCB in PDF, if you just wanna etch and produce. (this PCB might not have enough room for your components).
Firmware in HEX (50Hz, we do not guaranty that it works).
Firmware Sourcecode, e.g. if you want to use a 60Hz House mains.
Windows programs source code, written in VB 6.0 and packet in .ZIP.
Discolitez, a program for controlling light to music
PWM3 Showoff demo
PWM3 Tech Demo