Category Archive: Safety transformer V2

Mar 18

Safety transformer V2

I had a external light bulb in series with my previous safety transformer to limit the output/short circuit current. This gave the problem that sometimes a bulb would fall on the ground with changing it. So I decided to make a new version with the light bulbs inside. The previous version had a 140VA transformer and sometimes that was not enough. So I build a new one with a 300VA transformer.

Measuring PCB:

This time I wanted to put a voltage and current meter in it. I could just buy them, but where is the fun in that? So I made them myself. The voltage is lowered by a voltage divider, then rectified with a opamp precision rectifier. Then it is levelled by a RC filter which sends it in a AD converter. The current is measured with a 0,1 Ohm series resistor. Because off the current there is a voltage drop across the resistor that is proportional to the current. That voltage is amplified an rectified and let to the ad converter in the pic.

Scheidingstransformator V2 Schema Scheidingstransformator V2 print



The pic has to drive 6 7-segment displays. To save IO pins to do this I have decided to make a circuit with 2x 74HC595 ic’s. Now it takes only 3 pins per display, so 6 pins in total. 1 of the 2 74HC595 ic’s selects witch 7 segment display is on, the other one drives the digits.

Scheidingstransformator V2 Schema Scheidingstransformator V2 print




Light bulb indicators

To indicate witch lights are burning I made 3 holes in the front and let some optic fiber from there to the light bulbs.


Power supply

To power these 3 pcb’s I made a separate power supply pcb. It delivers +12V, -12V and +5V.

I used a transformer I had lying around, this transformer outputted 2*24V. This has the disadvantage that the 5V regulator gets very hot if I use a linear one. So I decided to use a switching one.

Scheidingstransformator V2 Schema Scheidingstransformator V2 print


Main circuit

As you can read above, the current is limited by setting a light bulbs in series with the load. I have put 3 light bulbs in it, via 3 switches the bulbs can be selected. A forth switch can bypass the bulbs. To limit the output current then and switch the output on/off I used a 2A circuit breaker.

If you put 2 transformers “back to back” then you lose some voltage at the output. Therefore I’ve put a 60VA transformer that can put 15V on or of the output.

For the output I used 2 safety plugs and a wall socket.

Kast schema


Overzicht foto

The front panel:


If I receive my PIC16F676 then I can start programming

May 04

Safety transformer V2 – Update

After finishing the dummyload project, I remembered that this project uses the same display pcb’s. Therefore I could reuse most of the code. So I finished this project as well. The pic in the project is now a PIC16F1825 which operates at 32Mhz.

The code:

'*  Name    : Scheidingstransformator V2                        *
'*  Author  : Stijn Coenen                 *
'*  Notice  : Copyright (c) 2013 Stijn Coenen (Stynus)          *
'*          : All Rights Reserved                               *
'*  Date    : 01/05/2013                                        *
'*  Version : 1.3                                               *
'*  Notes   : This code is provided to you as is, without       *
'*          : warranty of any kind.Use at own risk!!            *
Device = 16F1825
Xtal = 8
'EN: Declarations
'NL: Declaraties
        Symbol  Disp_klok       = LATC.5
        Symbol  Spanning_Data   = LATC.4
        Symbol  Spanning_Latch  = LATC.3
        Symbol  Stroom_Data     = LATC.2
        Symbol  Stroom_Latch    = LATC.1
    'EN: Measurement values
    'NL: Meetwaardes
        Dim     Spanning        As Word
        Dim     Stroom          As Word      
        Symbol  N_Samp_U        = 15          
        Dim     GemU[N_Samp_U]  As Word          
        Symbol  N_Samp_I        = 15         
        Dim     GemI[N_Samp_I]  As Word
    'EN: Display values
    'NL: Display waardes  
        Dim     DispSpanning    As Byte
        Dim     DispStroom      As Byte
        Dim     DispArU[3]      As Byte 
        Dim     DispArI[3]      As Byte              
        Dim     IntCase         As Byte
        Dim     IntX            As Byte
        Dim     IntDisp         As Byte       
        Dim     X               As Byte
        Dim     Temp            As Byte
    'EN: Settings AD converter
    'NL: Instellingen AD converter 
        Declare Adin_Res        10 
        Declare Adin_Tad        FRC  
        Declare Adin_Stime      250         
    'EN: Connections 7 segment displays on the 74HC595 pcb's
    'NL: Aansluitingen 7 segment displays aan de 74HC595 op de printjes    
        Symbol  Nul       = %01001000      '       a        '0         
        Symbol  Een       = %11101011      '     #####      '1
        Symbol  Twee      = %01010010      '     #   #      '2
        Symbol  Drie      = %01100010      '   f # g # b    '3
        Symbol  Vier      = %11100001      '     #####      '4
        Symbol  Vijf      = %01100100      '     #   #      '5
        Symbol  Zes       = %01000100      '   e # d # c    '6
        Symbol  Zeven     = %11101010      '     #####      '7
        Symbol  Acht      = %01000000                       '8
        Symbol  Negen     = %01100000                       '9
        Symbol  Uit       = %11111111                       'Out
        Symbol  Streep    = %11110111                       'Bar
    'EN: Connections of the transistors On the 74HC595 pcb's
    'NL: Aansluitingen Transistoren aan de 74HC595 op de printjes
        Symbol  disp1     = %00001100  
        Symbol  disp2     = %00001010  
        Symbol  disp3     = %00000110             
    'EN: Misc
    'NL: Diverse
        Symbol  TMR0IF    = INTCON.2
        'Tris registers 
        TRISA             = %11111111
        TRISC             = %00000000
        All_Digital       = true        
        On_Hardware_Interrupt GoTo Interrupts
    'EN: Set clock to 64 Mhz
    'NL: klok instellen op 64 Mhz
    OSCCON  = %11110010

    Clear 'ram

    'EN: Timer0 setup to drive the displays
    'NL: Timer0 instellen om de displays aan te sturen
    OPTION_REG  = %00000111
    INTCON      = %10100000
    'EN: Settings AD converter
    'NL: Instellingen AD converter     
    ADCON1  = %10110000
GoTo Main         
    Context Save
    If TMR0IF = 1 Then
        TMR0IF = 0      'Reset flag
        TMR0   = 230'   'Preloard timer

        'EN: Loading data for the display that is driven this interrupt
        'NL: Data inladen voor het display dat deze interrupt wordt aangestuurd
        DispSpanning    = DispArU[IntCase]
        DispStroom      = DispArI[IntCase]
        'EN: Get the transistor settings and set the decimal point
        'NL: Transistoren info uitlezen en de comma aanzetten
        Select IntCase 
            Case 0
                IntDisp = disp1       
            Case 1          
                IntDisp = disp2 
            Case 2          
                IntDisp = disp3         
                DispStroom.6    = 0 
            Case Else
                IntDisp = 255
                IntCase = 0                
        'EN: Outputting transistors data 
        'NL: Transistor data inklokken
        For IntX  = 0 To 7
            Spanning_Data   = IntDisp.7
            Stroom_Data     = IntDisp.7
            Disp_klok       = 1           
            IntDisp         = IntDisp * 2             
            Disp_klok       = 0
        'EN: Outputting display data 
        'NL: Display data inklokken
        For IntX  = 0 To 7
            Spanning_Data   = DispSpanning.7
            Stroom_Data     = DispStroom.7
            Disp_klok       = 1
            DispSpanning    = DispSpanning << 1
            DispStroom      = DispStroom << 1     
            Disp_klok       = 0
        'EN: Latch data to the outputs of the 74hc595 ic's
        'NL: Data naar de uitgangen van de 74hc595 ic's latchen
        Spanning_Latch  = 1
        Stroom_Latch    = 1     
        'EN: Set counter for next interrupt
        'NL: Teller bijtellen voor volgende interrupt
        Inc IntCase
        If IntCase > 2 Then
            IntCase = 0
        Spanning_Latch  = 0
        Stroom_Latch    = 0 
    Context Restore
    While 1 = 1        
        'EN: Voltage measurement
        'NL: Spannings meting
        For X = (N_Samp_U - 1) To 1 Step -1    
            GemU[X]     = GemU[X-1]      
        Spanning        = ADIn 0
        Spanning        = Spanning /10 
        Spanning        = Spanning - 4.95 
        GemU[0]         = Spanning * 3.25'3.03
        Spanning        = 0
        For X = 0 To (N_Samp_U - 1)    
            Spanning    = Spanning + GemU[X]
        Spanning        = Spanning / N_Samp_U
        'EN: Current measurement
        'NL: Stroom meting    
        For X = (N_Samp_I - 1) To 1 Step -1    
            GemI[X]     = GemI[X-1]      
        Stroom          = ADIn 1   
        Stroom          = Stroom - 55 'Offset
        GemI[0]         = Stroom /4.28
        Stroom          = 0
        For X = 0 To (N_Samp_I - 1)    
            Stroom      = Stroom + GemI[X]
        Stroom          = Stroom / N_Samp_I

        'EN: Calculate value's for on the display
        'NL: Meetwaardes naar display berekenen
        For X = 0 To 2 
            Temp = Dig Spanning, X
            DispArU[X] = LRead Cijfers + Temp       
            Temp = Dig Stroom, X 
            DispArI[X] = LRead Cijfers + Temp
        'EN: Delay for slower display update
        'NL: Wachten om het display niet te snel te updaten
        DelayMS 75
LData Nul, Een, Twee, Drie, Vier, Vijf, Zes, Zeven, Acht, Negen, Uit, Streep     


Code file: Download

Hex file: Download

PCB file meter pcb: Download