Monday 22 July 2019

One Touch Automatic Car Roll Up Window System









If you aware that my previous tutorials, you may already know that I have made an Automatic Car Window Roll Up unit for vehicles. In that project I found some lapses that the







  1. Window always operates when the car lock key is pressed even the door is already locked.

  2. Window operates based on a timer.

  3. Even the door is locked inside. The unit start to work.

  4. No One touch window open/close function.





Therefore, I designed a new unit with premier functions to automatic window system. This unit can identify the window is closed or interrupted to the operation, and one touch window open and close function, only security key can activate the unit etc.





If you want you can do more upgrades with this unit but, I have designed this only for 2 windows.








 Following is given the chart of the project.




The circuit diagram as follows.









The circuit for relays as follows










When you give the power to motor, it must be gone through a current sensor. 


I have use 30A sensor
































The current sensor can detect the current level. Therefore you must do the following.


Use a multimeter and check the current need for the operation of the motor. 







Then once the window is closed/opened fully, again check the current level of the motor. As an example, when the motor is operating it may be consumed less than 6A and when the window is opened/closed the current level may be about 10A.










Connect pin 5 to the + pin of Car security unit's LED bulb





You can use following PCBs for this project












MOTOR UNIT





Car Window Switch Wiring

















Operation of the Unit.





If you want to Auto Roll up the window by Security key,




  1. Engine must be off position

  2. All the doors should be closed.





Then press the lock key.




You will hear car horn one time, then the windows will be roll up.





One touch open/close window








Auto switch in diagram




Auto Switch in practice











  • When the car is in ON mode, Switch on the "Auto" Switch. Then press up window key and drop, the window will be closed.

  • If you press down the window key the window will be opened automatically.




If you interrupted the operation by pressing again, the window will be stopped.











Tuning the Unit.








If you watch carefully, when the car is locked by key, the security led blink in a speed than unlocked. Then count the intervals and you have to change the interval level in the code.





Get the Amperage of the motor when the window is fully opened/closed and put it in to the code.





I have assumed that,



  • Car horn is from Ground on/off

  • Car Door signal is from ground

  • Car security LED power 12V

  • Window operates when car is ON mode.

  • Direct power 12v come though the window switch to Motor









    
/*PROGRAMME : CAR WINDOW AUTO RALL UP
PROGRAMMED BY : SetNfix
WEBSITE : HTTP://WWW.SetNfix.COM
******************************************************************
THIS PROGRAMME IS FOR THE VEHICLES WITH FOLLOWING SETTINGS
1.CAR DOOR LIGHT ON/OFF BY NEGATIVE
2.CAR HORN NEGATIVE
3.POWER WINDOW SYSTEM
AUTO RALL UP WILL WORK WHEN
1.THE CAR IS OFF, THE DOORS ARE CLOSED THEN SECURITY KEY PRESS LOCK, THE FRONT
TWO WINDOWS WILL BE SHUT AUTOMATICALLY.
2.THE CAR IS STARTED AND IF THE AUTO SWITCH ON, IF YOU PRESS WINDOW UP
ONCE THE DRIVER SIDE WINDOW WILL GO UP AUTOMATICALLY*/

int UpSwitch = 0;
int DwnSwitch = 0;
int UpSwitch_Pin = 11;
int DwnSwitch_Pin = 12;

int RMotorUp = 0;
int RMotorDwn = 0;
int LMotorUp = 0;
int RMotorUp_Pin = 10;
int RMotorDwn_Pin = 9;
int LMotorUp_Pin = 8;


int CarDoor =0;
int Sensor = 0;
int Acc = 0;
int Btt = 0;
int CarDoor_Pin =7;
int Acc_Pin = 6;
int Sensor_Pin = 5;

int Btt_Pin = 4;

int CarHorn=0;
int Reset = 0;
int Reset_Pin = 3;
int CarHorn_Pin=A0; // To car horn


int LED = 13;

int DataUpR = 0;
int DataDwnR = 0;
int DataUpL = 0;
int DataUpR_Pin = A1; // To control the unit using external commands
//int DataDwnR_Pin = A1;
//int DataUpL_Pin = A2;

int Active = 0;
int Cancel = 0;
int Window = 0; //
int Interrupt = 0;
float OldMillis;
float NewMillis;
float Balancemillis;
int Timmer = 6000; // Average time to close/Open a window (6s)

int x = 0; //if the door is locked by key, value will be = 1.
int y;

long a = 0;// time push and hold the button.
int aUp = 0;// window up pressed
int aDwn = 0;//window down pressed
int Clicked = 0;// button was pressed when =1

//Current sensor Unit
int CrntPin = A2;
float Anval = 0.0;
float Vlt = 0.0;
float Dflt = 66; // Default value of 30A current sensor
float Amps = 0.0;
int Svolt = 2500; // Default voltage of the sensor 2.5v
int Limit = 6; // This is by amps (10 A)
int limiton = 7 ; //limit for normal operation
int Motor = 0;
int ux = 0;
int uy = 0;


//Roll uo timing

int upx = 0;
int upy = 0;



void setup() {
Serial.begin(9600);

pinMode(UpSwitch_Pin,INPUT);
pinMode(DwnSwitch_Pin,INPUT);
pinMode(RMotorUp_Pin,OUTPUT);
pinMode(RMotorDwn_Pin,OUTPUT);
pinMode(LMotorUp_Pin,OUTPUT);
pinMode(CarDoor_Pin,INPUT);
pinMode(Sensor_Pin,INPUT);
pinMode(Acc_Pin,INPUT);
pinMode(Btt_Pin,INPUT);
pinMode(CarHorn_Pin,OUTPUT);
pinMode(Reset_Pin,OUTPUT);
pinMode(DataUpR_Pin,INPUT);
pinMode(CrntPin,INPUT);
pinMode(LED,OUTPUT);
//****************************************************************
CarDoor =digitalRead(CarDoor_Pin);
Sensor=digitalRead(Sensor_Pin);
Acc =digitalRead(Acc_Pin);
Btt =digitalRead(Btt_Pin);



//-------------------------------------------------------------------
//------------CHECK THAT THE CAR LOCKED BY REMOTE KEY OR DOOR--------
//-------------------------------------------------------------------
/* IF THE CAR IS LOCKED BY REMOTE KEY, THEN SECURITY LED START TO BLINK
* BUT IT IS LOCKED BY DOOR LOCK, NOTHING LIGHT
*/

int cnt = 1;

do{
Sensor = digitalRead(Sensor_Pin);
digitalWrite(LED,HIGH);
delay(30);
cnt = cnt +1;
if (Sensor ==1){x = 1;cnt = 120;Serial.print("KEY LOCKED");}
digitalWrite(LED,LOW);
}while (cnt < 100);

//------------------------------------------------------------------
// If the door is locked by door, reset the unit
//------------------------------------------------------------------
if (x == 0){//If the door is locked not by remote key
digitalWrite(Reset_Pin,HIGH); // Activate Reset relay
delay(500);
digitalWrite(Reset_Pin,LOW);
}//-----------------------------------------------------------------


//****************************************************************
//================CAR LOCK Shutter
//****************************************************************
if ((Acc ==0)&&(CarDoor ==1)&&(Btt==1)&&(x==1)){ //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Serial.println("Key lock Shutter 01");
digitalWrite(LED,HIGH);
delay(1000);
carhorn();
delay(2000);
digitalWrite(LED,LOW);

do {
CurrentSensor();
digitalWrite(LED,HIGH);
delay(100);
digitalWrite(RMotorUp_Pin,HIGH); // roll up window
Serial.print("UPR : ");
Serial.println(upx);
Serial.print("MOTOR : ");
Serial.println(Motor);

digitalWrite(LED,LOW);
delay(100);
upx++;
if ((Motor == 0)&&(upy < 35)){ux = 0;} else { ux = 1;}
}while(ux ==0);
digitalWrite(RMotorUp_Pin,LOW); // roll up window STOP!
Serial.println("STEP 1");
delay(500);
CurrentSensor();
delay(50);

do {
CurrentSensor();
digitalWrite(LED,HIGH);
delay(100);
digitalWrite(LMotorUp_Pin,HIGH);
Serial.print("UPY : ");
Serial.println(upy);
Serial.print("MOTOR : ");
Serial.println(Motor);
digitalWrite(LED,LOW);
delay(100);
upy++;

if ((Motor == 0)&&(upy < 35)){uy = 0;} else { uy = 1;}

}while(uy == 0);
digitalWrite(LMotorUp_Pin,LOW);
delay(500);
CurrentSensor();
delay(50);
//----------------------------------------------------------------
digitalWrite(Reset_Pin,HIGH);
delay(500);
digitalWrite(Reset_Pin,LOW);

}//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

digitalWrite(LED,HIGH);
delay(500);
digitalWrite(LED,LOW);
} //************** END VOID SETUP************************



void loop() {

UpSwitch = digitalRead(UpSwitch_Pin);
DwnSwitch = digitalRead(DwnSwitch_Pin);
CarDoor =digitalRead(CarDoor_Pin);
Sensor=digitalRead(Sensor_Pin);
Acc =digitalRead(Acc_Pin);
Btt =digitalRead(Btt_Pin);






CurrentSensor(); // GEt current sensor value
delay(50);

//-------------------------------------------------------
//Reset if key lock inside the car when engine is started
//-------------------------------------------------------
if ((Acc==1)&&(Btt==1)){
Serial.println("key lock inside the car when engine is started");
digitalWrite(Reset_Pin,HIGH);
delay(500);
digitalWrite(Reset_Pin,LOW);
}
//-------------------------------------------------------




//Inturrupted to the current process
if ((Active == 1)&&(Interrupt == 0)){
if (digitalRead(UpSwitch_Pin)==1){Window = 1;Interrupt=1;Serial.print("UpSwitch : ");
Serial.println(digitalRead(UpSwitch_Pin));}

if (digitalRead(DwnSwitch_Pin)==1){Window = 2;Interrupt=1;Serial.print("DwnSwitch : ");
Serial.println(digitalRead(DwnSwitch_Pin));}


}
//Stop When Interrupt
if (Interrupt == 1){digitalWrite(RMotorUp_Pin,LOW); digitalWrite(RMotorDwn_Pin,LOW);Serial.println("STEP 05");Window = 0;Active =0; Balancemillis=0; OldMillis = 0;LedBlink();Serial.println("Interrupted");delay(2000);Interrupt =0;}

/*/testing----------------------------
if ((UpSwitch ==1)||(DwnSwitch ==1)){
if (UpSwitch ==1){aUp = 1; aDwn =0;}
if (DwnSwitch ==1){aUp = 0; aDwn =1;}
Clicked = 1; //BUTTON PRESSED
delay(10);
a = a + 1;
}

//FIND THE DURATION TO RELEASE THE BUTTON
if (Clicked ==1){
delay(10);
a = a + 1;

}*/






//-----------------------------------------
//Auto Up the window
if ((UpSwitch ==1)||(DwnSwitch ==1)){
delay(200);
Serial.print("TOUCHED");
if ((Active == 0)&&(Interrupt == 0)){
if ((UpSwitch ==1)&&(digitalRead(UpSwitch_Pin)==0)){Window = 1;Active=1; OldMillis = millis();}
if ((DwnSwitch ==1)&&(digitalRead(DwnSwitch_Pin)==0)){Window = 2;Active=1;OldMillis = millis();}
}
Serial.println(Window);
}

//-----------------------------------------

//***********************************************************
//WINDOW RALL UP
//***********************************************************
if ((Window == 1)&&(Active==1)&&(Interrupt == 0)&&(Balancemillis
Timmer)||(Amps >limiton)){
digitalWrite(RMotorUp_Pin,LOW);
digitalWrite(RMotorDwn_Pin,LOW);
Serial.println("STEP 01");
digitalWrite(LED,LOW);
Active=0; Balancemillis=0; OldMillis = 0;Window = 0;Interrupt =0;Serial.println("WINDOW STOP");delay(500);}
}
//------------------------------------------------------------


//---------------------------------------------------------------
// External Conrol wire
//---------------------------------------------------------------
DataUpR = analogRead(DataUpR_Pin);
Serial.print("DataUpR : ");
Serial.println(DataUpR);
if ((DataUpR>200)&&(DataUpR
<600 ataupr="" if="">400)&&(DataUpR<600 02="" ataupr="" delay="" digitalwrite="" else="" erial.println="" if="" limiton="" mps="" otorup_pin="">300)&&(DataUpR<380 03="" ataupr="" delay="" digitalwrite="" else="" erial.println="" if="" limiton="" mps="" otordwn_pin="">200)&&(DataUpR<280 ---="" -1="" -="" 04="" 0="" amps="" anval="analogRead(CrntPin);" arhorn_pin="" carhorn="" convert="" current="" currentsensor="" delay="" digitalwrite="" else="" erial.println="" et="" flt="" gives="" gnd="" if="" it="" k="" ledblink="" limiton="" loop="" motor---------------------="" motor="" mps="" negative="" of="" otordwn_pin="" otorup_pin="" positive.="" resistors="" svolt="" the="" to="" usage="" vlt="(Anval/1024.0)*5000;" void="" windowdwn="" windowupl="" windowupr=""> Limit){Motor = 1;} else {Motor = 0;} // value "0" is motor is rotating and "1" is blocked.
Serial.print("AMPS : ");
Serial.println(Amps);

//**************************************************************************************
}



If you have any doubt do not forget to put it as a comment.


Stay with SetNfix 
Previous Post
Next Post

post written by:

4 comments:

  1. How to automatically run any sketch as soon as power is supplied to the andruino board??? For eg, as soon as usb is connected to the board, any sketch should automatically run.

    ReplyDelete
  2. Found your post interesting to read. I can't wait to see your post soon. Good Luck with the upcoming update. This article is really very interesting and effective. car locksmith near me

    ReplyDelete
  3. Can you tell why all windows can not roll up together?

    ReplyDelete
  4. Excellent you have provided important data for us. It is essential and informative for everyone. Keep posting always. I am very thankful to you. keyless entry remotes

    ReplyDelete