Spotwelder

I picked up this project from a few years ago again. First I connected the cap pcb on 5V, but it immediately started to pull a lot of current. 1 of the caps was shorted internally. With a lot of effort I found which one it was and replaced it. The I powered the circuit again, did a test weld and did not have a lot of power (almost no current even).

After a few test I had to replace another 2 capacitors that had shorted internally. And a few minutes later the board had a shorted cap again. Now I ran out of spare caps, and I had to decide if I wanted to order new ones. I decided to first calculate the energy that could be stored in the caps and also found out that it was not enough. After some searching on the internet I came across some high capacity capacitors, but they were expensive.

Then I remembered I have a few microwave oven transformers laying around and decided to use one of those. The HV secondary I removed and replaced with some 16mm² wire. The primary I switch with a solid state relay. To control everything I used a small board with a PIC16F1788 microcontroller. On this I put a ULN2803 board to drive the solid-state relays, a buzzer, LCD and a rotary encoder.

Now for detecting when to weld. On the old circuit I just used a pull-up resistor and measured the voltages on the pins. With the new version this can not be done since to 16mm² wire is always low resistance. The way I solved this is by injecting a 50Khz wave onto the wires and measure how much it drops when the pins are shorted. The thick wire on the transformer forms an inductor and is like a open circuit for the 50Khz.
In order to put the signal on to the wire I need more power then the standard pin can deliver, therefore I used a RS485 transceiver as an amplifier. After the RS485 IC is a 1µF capacitor to couple the signal.

I first did a simulation and got this result (left on the plot is output open, right is switch closed to simulate the welding pins to metal).

The out signal of this schematic is connected to an AD converter in the microcontroller. When the signal is below a threshold the welding program starts. The program I made so that it can do 2 pulses. The pulse time of both pulses and the pause time can all be set individually.

 

 

The main part of the program:

 while (1)
    {   
        
        MenuDelay ++;   //For debounce
        if (MenuDelay > 4){
            MenuDelay = 0;
            
            if (WeldState){
                LCD_Print_At(1, 1, "Stat:Weld|T1PaT2"); 
            }else{
                LCD_Print_At(1, 1, "Stat:Open|T1PaT2");                 
            }    
            
            sprintf(GetString,"%4u", WeldTime1 * 20); 
            LCD_Print_At(2, 1, GetString);  
            sprintf(GetString,"%4u", WeldPause * 20); 
            LCD_Print_At(2, 6, GetString);      
            sprintf(GetString,"%4u", WeldTime2 * 20); 
            LCD_Print_At(2, 11, GetString);     
            LCD_Print_At(2, 5,  "|");
            LCD_Print_At(2, 10, "|");    
            LCD_Print_At(2, 15, "mS");  
            
            LCD_Cmd(0xFE);
            LCD_Cmd(0x0E);
            LCD_Cmd(0x0F);
            
            switch (MenuItem){ 
                case 0:     
                    LCD_Goto(4, 2);                      
                    WeldTime1 = RotCountValue;
                    if (!RotaryBtn){
                        DATAEE_WriteByte(1, WeldTime1); 
                        MenuItem ++;
                    }
                    break;  
                case 1:
                    if (RotaryBtn){
                        MenuItem ++;
                        RotCountValue = WeldPause;
                        RotMinValue = 1;
                        RotMaxValue = 100;
                        LCD_Cmd(LCD_CLEAR);   
                    }
                    break; 
                case 2:     
                    LCD_Goto(9, 2);  
                    WeldPause = RotCountValue;    
                    if (!RotaryBtn){
                        DATAEE_WriteByte(2, WeldPause); 
                        MenuItem ++;
                    }
                    break; 
                case 3:
                    if (RotaryBtn){
                        MenuItem ++;
                        RotCountValue = WeldTime2;
                        RotMinValue = 1;
                        RotMaxValue = 100;
                        LCD_Cmd(LCD_CLEAR);   
                    }
                    break;                    
                case 4:     
                    LCD_Goto(14, 2);                     
                    WeldTime2 = RotCountValue;
                    if (!RotaryBtn){
                        DATAEE_WriteByte(3, WeldTime2); 
                        MenuItem ++;
                    }                    
                    break;  
                default:
                    if (RotaryBtn){
                        MenuItem = 0;
                        RotCountValue = WeldTime1;
                        RotMinValue = 1;
                        RotMaxValue = 100;
                    }
                    break;
            }      
        }
        
        SensVoltageBuffer = 0;
        for (uint8_t Counter = 0; Counter < 6; Counter++){ 
            SensVoltage = ADC_GetConversion(0); SensVoltage = SensVoltage >> 6;
            SensVoltageBuffer = SensVoltageBuffer + SensVoltage;      
            __delay_ms(20/6);        
        }
        SensVoltage = SensVoltageBuffer / 6;
        WeldDetect = 200;    
        
        switch (WeldState){
            case 0:
                if (SensVoltage < WeldDetect){
                    WeldState ++;
                }
                break;
            case 1:            
                WeldState ++; 
                WeldTimer = 0;
                break;
            case 2:
                if (SensVoltage < WeldDetect){ 
                    WeldState ++; 
                }else{ 
                    WeldTimer ++; 
                    if (WeldTimer == 250){ 
                       WeldState = 0; 
                    } 
                } 
                break; 
            case 3: 
                LATBbits.LATB4 = 1; //Buzzer 
                WeldState ++; 
                break; 
            case 4: 
                LATBbits.LATB4 = 0; 
                WeldState ++; 
                break; 
            case 5:
                WeldTimer = 0; 
                WeldState ++; 
               break; 
            case 6: 
               LATAbits.LATA3 = 1; 
               LATBbits.LATB5 = 1; 
               if (WeldTimer >= WeldTime1){
                    LATAbits.LATA3 = 0;
                    LATBbits.LATB5 =0;
                    WeldTimer = 0;
                    WeldState ++;
                }else{
                    WeldTimer ++;
                }
                break;
            case 7:
                if (WeldPulses == 1){
                   WeldState = 10; 
                }
                if (WeldTimer >= WeldPause){
                    WeldTimer = 0;
                    WeldState ++;
                }else{
                    WeldTimer ++;
                }
                break;
            case 8:
                LATAbits.LATA3 = 1;
                LATBbits.LATB5 = 1;
                if (WeldTimer >= WeldTime2){
                    LATAbits.LATA3 = 0;
                    LATBbits.LATB5 = 0;
                    WeldTimer = 0;
                    WeldState ++;
                }else{
                    WeldTimer ++;
                }
                break;
            case 9:
                WeldState ++;                
                break;               
            case 10:
                WeldTimer ++;
                if (WeldTimer >= (1000/20)){
                    WeldTimer = 0;
                    WeldState ++;
                }
                break;   
            case 11:     
                 if (SensVoltage > WeldDetect){
                    LATAbits.LATA3 = 0;
                    WeldTimer = 0;
                    WeldState = 0;
                }      
                break;                     
            default:
                WeldState = 0;
                break;                    
        }   
    }

 

Leave a Reply

Your e-mail address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.