Electric window controller kit

Wichit Sirichote, wichit.sirichote@gmail.com

Build your own a cheap controller for controlling the electric window with chain actuator.


The kit is for controlling the chain actuator for opening the window. The circuit is timer based device with a programmable opening length. User can set timer 1-9 Hours. The window will open when preset time is reached. The circuit can be adapted to any chain actuators. I got the chain actuator, Windowmaster 804-2 from eBay. The internal control circuit was removed. The motor was powered directly from the DC supply. I used it for my bedroom, when the air conditioner has turned off. The window will be opened for fresh air circulation.
Controller with chain actuator Windowmaster 804-2.

Hardware descriptions:

The circuit is built with Microchip PIC16F684, 14-pin Flash microcontroller. The chip is running with internal 4MHz oscillator. Settings timer is done with BCD switch. The 4-bits BCD are tied to RA0-RA3. SW1 is push button for RESTART/OPEN. SW2 is for manual close connected to RC3. RC3 and RC4 are the output for controlling the H-bridge driver chip. D1 is status LED connected to RC2.
Hardware schematic (click to enlarge)

Firmware:
Main code keeps clearing the WDT timer and test key1. The first power up will enable timer0 interrupt, producing 15Hz tick. Key1 will be tested every 15 ticks. If key1 was pressed, function test will run. The chain actuator will open the window with preset length. The preset range is set in EEPROM byte 0.

When the test function is completed, the chain actuator will stop. Timer interrupt will be disabled, LED status will be turned ON.

To restart the timer function, still press RESTART button, key1 = 0, the internal watch dog timer will reset the microcontroller.

// MCU PIC16F684 internal oscillator 4MHz
// preset length is stored at EEPROM locations 0
// user may modify it for the desired length
// test switch is dual functions: RESTART/OPEN
// Written by W.Sirichote (C) 2018
sbit LED at PORTC.B2;
         sbit OUT1 at PORTC.B3;
         sbit OUT2 at PORTC.B4;
         sbit key1 at PORTA.B4;
char tick, tick_led;
         char sec;
         unsigned int min=0;
         unsigned int set_time;
         unsigned int press=0;
unsigned int preset_length=0, save_preset;
         char run=0;
         char test=0;
         char fire =0;
         char programmed=0;
         char set_hour=0;
unsigned int length;
       
unsigned int adc;
void read_key()
         {
   if(key1 == 0)
   {
   
   switch (press++)
   {
   case 0: OUT1 =1; OUT2 = 1; break;
   case 1: OUT1 =1; OUT2 = 0; run=1; break; // start counting for preset
   case 2: OUT1 =1; OUT2 = 1; run=0; break; // stop counting
   case 3: OUT1 =0; OUT2 = 1; test =1; break; // test reverse with preset
   case 4: OUT1 =1; OUT2= 1; press =0; break;
   }
   }
       
 
 
           
           }
       
 
// 15Hz interrupt
         void interrupt() {
   if (TMR0IF_bit) {
   TMR0IF_bit = 0;
 tick++;
       
 if(run)
   {
   if(--preset_length == 0)
   {
   OUT1 =1; OUT2= 1; press =0;
   preset_length = length;
   run=0;
   LED =0;
   INTCON =0;
   tick_led=0;
 }
           
           
   }
 
   if(tick>15)
   {
   
   tick=0;
   read_key();
   
   if(++sec>60)
   {
   sec=0;
   min++;
   
   if (min>= set_time && fire == 0 )
   {
   OUT1 =1; OUT2 = 0; run=1;
   fire =1;
   }
   
   
   
   }
   }
  
   
   if (++tick_led>15)
   {
   tick_led=0;
   LED = 0;
   delay_ms(5);
   LED = 1;
   
   }
 }
 }
void main() {
   OPTION_REG = 0x07; // Assign prescaler to TMR0
   ANSEL = 0; // Configure PORTA to digital I/O
   CMCON0 = 7; // ANSELH = 0;
   
   WDTCON = 0x16; // WDT clock/65536
   
   WPUA = 0xff;
   
   TRISA = 0xff;
   TRISC = 0; // PORTB is output
   PORTC = 0xFF; // Initialize PORTC
 INTCON = 0xA0; // Enable TMRO interrupt
           
   length = EEPROM_Read(0);
   preset_length = length*2; // double length 0-512
   
   set_hour = PORTA&0x0f; // 0-9
   set_time = set_hour*60; // convert hour to min
   
   // set_time = set_hour*2; // tested by x2
   
   while(1)
   {
   asm CLRWDT;
   while(key1==0)
   ;
   
   }
       
}
Source code listings

The kit under tested. Left-hand is PIC16F684 board, right-hand is L298 H-bridge driver..

Example of using the controller. Closing the window with MANUAL CLOSE. To restart, still press the RESTART button. Test window opening with single press OPEN button again.

 

PARTS LIST
Semiconductors

PVN1 PIC16F684, 14-pin Flash microcontroller
D1 LED
Resistors (all resistors are 1/8W +/-5%)
R1 680
R2,R3 1k
R4 10k
Capacitors

C1 100nF

Additional parts

SW1 RESTART/OPEN
SW2 MANUAL CLOSE
SW3 SW DIP-BCD
L298 H-bridge driver board

DIY Kit is available, please contact Wichit Sirichote

Download Schematic, ROM hex file configuration fuses and EEPROM data
2nd version Firmware with failsafe, source code

DIY kit is available on eBay: Installation example, Schematic, BOM and source code


<

15 December, 2018